com.fuckingbrit.q3astats
Class LogOwner

java.lang.Object
  |
  +--com.fuckingbrit.q3astats.LogOwner

public class LogOwner
extends java.lang.Object

The LogOwner encapsulates the person we are parsing the logs for. This class stores all the information we know about the user, and handles the storage and retrieval of this information. This information is stored as an XML File in the current implementation, although I plan to abstract this layer a little further in later releases.

Version:
1.1
Author:
Michael Jervis (mike@fuckingbrit.com)

Constructor Summary
LogOwner(java.io.File playerLog)
          Create a new player, by passing in an XML document that details the logs parsed to date.
LogOwner(java.lang.String name)
          Create a new player by name only
 
Method Summary
 int getDeaths()
          Gets the total number of times this player has been killed.
 java.util.HashMap getHits()
          Get the hits this player has caused.
 int getKills()
          Returns the players total recorded kills
 java.lang.String getName()
          Gets the players name.
 java.util.HashMap getPlayers()
          Gets the players that this player has encountered.
 boolean getRegexMode()
          Gets the regex mode.
 java.lang.String getRegexString()
          Get the current regex of the name matcher
 int getSuicides()
          Gets the number of recorded suicides for this log player.
 boolean isMe(java.lang.String name)
          This method is a critical function of the logowner.
 void logDeath(java.lang.String killer, java.lang.String weapon)
          Log a Death.
 void logHit(java.lang.String where)
          Log a hit.
 void logKill(java.lang.String victim, java.lang.String weapon)
          Log a Kill.
 void setDeaths(int deaths)
          Sets the total number of times player has been killed.
 void setKills(int kills)
          Set the total kills by the player.
 void setName(java.lang.String name)
          Sets the players name.
 void setRegexMode(boolean active)
          Sets the regex mode to active.
 void setRegexString(java.lang.String regex)
          Sets the regular expression string.
 void setSuicides(int suicides)
          Sets the number of suicides found for this log player
 void toXML(java.io.File where)
          Store this player as an XML packet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogOwner

public LogOwner(java.lang.String name)
Create a new player by name only

Parameters:
name - the name of the player.

LogOwner

public LogOwner(java.io.File playerLog)
         throws QuakeParseException
Create a new player, by passing in an XML document that details the logs parsed to date. The XML file will store all stuff we've parsed historicaly.

Throws:
QuakeParseException - If for any reason the XML can not be read.
Method Detail

setSuicides

public void setSuicides(int suicides)
Sets the number of suicides found for this log player

Parameters:
suicides - Number of suicides

getSuicides

public int getSuicides()
Gets the number of recorded suicides for this log player.


getPlayers

public java.util.HashMap getPlayers()
Gets the players that this player has encountered. A set of Player objects

See Also:
Player

getHits

public java.util.HashMap getHits()
Get the hits this player has caused. A set of Hit objects

See Also:
Hit

setName

public void setName(java.lang.String name)
Sets the players name. The player name is used as the name written to the XML file. However, it is not always used as the search value. If regex mode is enabled, then this is NOT used as the match key.

Parameters:
name - The players name.

getName

public java.lang.String getName()
Gets the players name.


setKills

public void setKills(int kills)
Set the total kills by the player. Not advisable. This is auto-incremented when logging a kill.

Parameters:
kills - number of kills.

getKills

public int getKills()
Returns the players total recorded kills


setDeaths

public void setDeaths(int deaths)
Sets the total number of times player has been killed. Not advisable. This is auto-incremented when the death is logged.

Parameters:
deaths - Count of Deaths.

getDeaths

public int getDeaths()
Gets the total number of times this player has been killed.


setRegexMode

public void setRegexMode(boolean active)
                  throws QuakeParseException
Sets the regex mode to active. If we are in regex mode then the regular expression specified is used to match the player name instead of the player name.

Parameters:
active - Sets on or off.
Throws:
QuakeParseException - If there is no regex string set.

getRegexMode

public boolean getRegexMode()
Gets the regex mode.


setRegexString

public void setRegexString(java.lang.String regex)
                    throws QuakeParseException
Sets the regular expression string.

Parameters:
regex - The regular expression to use.
Throws:
QuakeParseException - if the regex string won't compile.

getRegexString

public java.lang.String getRegexString()
Get the current regex of the name matcher


toXML

public void toXML(java.io.File where)
           throws QuakeParseException
Store this player as an XML packet

Parameters:
where - A File to save to.
Throws:
QuakeParseException - if anything causes the save of the XML to fail.

logKill

public void logKill(java.lang.String victim,
                    java.lang.String weapon)
Log a Kill. This will look up the victim in the players hashmap. If the player exists the kill count for that player is incremented. If that player does not exist, that player is added with a single kill.

Parameters:
victim - Who was killed
weapon - What they were killed with

logDeath

public void logDeath(java.lang.String killer,
                     java.lang.String weapon)
Log a Death. This will look up the killer in the players hashmap. If the player exists the death count for that player is incremented. If that player does not exist, that player is added with a single death.

Parameters:
killer - Who killed us?
weapon - What with?

logHit

public void logHit(java.lang.String where)
Log a hit.

Parameters:
where - where we were hit.

isMe

public boolean isMe(java.lang.String name)
This method is a critical function of the logowner. It is used to determine if the name passed in is the user of the log file. This centralises the functionality, and abstracts the matching implementation currently it will automaticaly use the regular expression if there is one, or otherwise fall back to the good old String.equals method.

Parameters:
name - THe name to match against.