Class CharacterDAO

java.lang.Object
marauroa.server.game.db.CharacterDAO
Direct Known Subclasses:
StendhalCharacterDAO

public class CharacterDAO extends Object
data access object for characters
Author:
miguel, hendrik
  • Constructor Details

    • CharacterDAO

      protected CharacterDAO()
      Creates a new CharacterDAO
  • Method Details

    • addCharacter

      @Deprecated public void addCharacter(DBTransaction transaction, String username, String character, RPObject player) throws SQLException, IOException
      Deprecated.
      creates a new character
      Parameters:
      transaction - DBTransaction
      username - username
      character - name of character
      player - RPObject of the player
      Throws:
      IOException - in case of an input/output error
      SQLException - in case of an database error
    • addCharacter

      public void addCharacter(DBTransaction transaction, String username, String character, RPObject player, Timestamp timestamp) throws SQLException, IOException
      creates a new character
      Parameters:
      transaction - DBTransaction
      username - username
      character - name of character
      player - RPObject of the player
      timestamp - timestamp
      Throws:
      IOException - in case of an input/output error
      SQLException - in case of an database error
    • removeCharacter

      public boolean removeCharacter(DBTransaction transaction, String username, String character) throws SQLException
      deletes a character
      Parameters:
      transaction - DBTransaction
      username - username
      character - name of character
      Returns:
      true, if the character was deleted, false if it did not exist
      Throws:
      SQLException - in case of an database error
    • hasCharacter

      public boolean hasCharacter(DBTransaction transaction, String character) throws SQLException
      checks whether the specified character exists
      Parameters:
      transaction - DBTransaction
      character - name of character
      Returns:
      true, if the character exists and belongs to the account; false otherwise
      Throws:
      SQLException - in case of an database error
    • hasCharacter

      public boolean hasCharacter(DBTransaction transaction, String username, String character) throws SQLException
      checks whether the specified account owns the specified character
      Parameters:
      transaction - DBTransaction
      username - username
      character - name of character
      Returns:
      true, if the character exists and belongs to the account; false otherwise
      Throws:
      SQLException - in case of an database error
    • hasActiveCharacter

      public boolean hasActiveCharacter(DBTransaction transaction, String username, String character) throws SQLException
      checks whether the specified account owns the specified character and it is active
      Parameters:
      transaction - DBTransaction
      username - username
      character - name of character
      Returns:
      true, if the character exists and belongs to the account; false otherwise
      Throws:
      SQLException - in case of an database error
    • getCharacters

      public List<String> getCharacters(DBTransaction transaction, String username) throws SQLException
      gets a list of characters for this account
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      list of characters
      Throws:
      SQLException - in case of an database error
    • storeCharacter

      @Deprecated public void storeCharacter(DBTransaction transaction, String username, String character, RPObject player) throws SQLException, IOException
      Deprecated.
      This method stores a character's avatar in the database and updates the link with the Character table.
      Parameters:
      transaction - the database transaction
      username - the player's username
      character - the player's character name
      player - the RPObject itself.
      Throws:
      SQLException - if there is any problem at database.
      IOException
    • storeCharacter

      public void storeCharacter(DBTransaction transaction, String username, String character, RPObject player, Timestamp timestamp) throws SQLException, IOException
      This method stores a character's avatar in the database and updates the link with the Character table.
      Parameters:
      transaction - the database transaction
      username - the player's username
      character - the player's character name
      player - the RPObject itself.
      timestamp - timestamp
      Throws:
      SQLException - if there is any problem at database.
      IOException
    • loadCharacter

      public RPObject loadCharacter(DBTransaction transaction, String username, String character) throws SQLException, IOException
      This method loads the character's avatar associated with this character from the database.
      Parameters:
      transaction - the database transaction
      username - the player's username
      character - the player's character name
      Returns:
      The loaded RPObject
      Throws:
      SQLException - if there is any problem at database
      IOException
    • loadAllCharacters

      public Map<String,​RPObject> loadAllCharacters(DBTransaction transaction, String username) throws SQLException, IOException
      This method loads all the characters associated with this username from the database.
      Parameters:
      transaction - the database transaction
      username - the player's username
      Returns:
      The loaded RPObject
      Throws:
      SQLException - if there is any problem at database
      IOException - if there is a problem reading the blob
    • loadAllActiveCharacters

      public Map<String,​RPObject> loadAllActiveCharacters(DBTransaction transaction, String username) throws SQLException, IOException
      This method loads all active the characters associated with this username from the database.
      Parameters:
      transaction - the database transaction
      username - the player's username
      Returns:
      The loaded RPObject
      Throws:
      SQLException - if there is any problem at database
      IOException - if there is a problem reading the blob
    • getAccountName

      public String getAccountName(DBTransaction transaction, String character) throws SQLException
      gets the name of the account to which the specified character belongs.
      Parameters:
      transaction - the database transaction
      character - name of character
      Returns:
      name of account, or null in case the character does not exist
      Throws:
      SQLException - if there is any problem at database
    • getCanonicalName

      public String getCanonicalName(DBTransaction transaction, String character) throws SQLException
      gets the canonical spelling of the character name
      Parameters:
      transaction - the database transaction
      character - name of character
      Returns:
      name of character, or null in case the character does not exist
      Throws:
      SQLException - if there is any problem at database
    • isCharacterCreationLimitReached

      public boolean isCharacterCreationLimitReached(DBTransaction transaction, String username, String address) throws IOException, SQLException
      is the character creation limit reached?
      Parameters:
      transaction - the database transaction
      username - username of account
      address - ip-address of client
      Returns:
      true if too many characters have been created
      Throws:
      IOException - in case of an input output error
      SQLException - if there is any problem at database
    • getCreationDate

      public Date getCreationDate(DBTransaction transaction, String character) throws SQLException
      Gets the date the character was registered
      Parameters:
      transaction - DBTransaction
      character - name of character
      Returns:
      date of character creation or null if no character with that name exists
      Throws:
      SQLException - in case of an database error
    • setCharacterStatus

      public void setCharacterStatus(DBTransaction transaction, String username, String character, String status) throws SQLException, IOException
      Modifies a character status.
      Parameters:
      transaction - DBTransaction
      username - username
      character - name of character
      status - status to set
      Throws:
      IOException - in case of an input/output error
      SQLException - in case of an database error
    • addCharacter

      @Deprecated public void addCharacter(String username, String character, RPObject player) throws SQLException, IOException
      Deprecated.
      creates a new character
      Parameters:
      username - username
      character - name of character
      player - RPObject of the player
      Throws:
      IOException - in case of an input/output error
      SQLException - in case of an database error
    • removeCharacter

      @Deprecated public boolean removeCharacter(String username, String character) throws SQLException
      Deprecated.
      deletes a character
      Parameters:
      username - username
      character - name of character
      Returns:
      true, if the character was deleted, false if it did not exist
      Throws:
      SQLException - in case of an database error
    • hasCharacter

      @Deprecated public boolean hasCharacter(String character) throws SQLException
      Deprecated.
      checks whether the specified character exists
      Parameters:
      character - name of character
      Returns:
      true, if the character exists and belongs to the account; false otherwise
      Throws:
      SQLException - in case of an database error
    • hasCharacter

      @Deprecated public boolean hasCharacter(String username, String character) throws SQLException
      Deprecated.
      checks whether the specified account owns the specified character
      Parameters:
      username - username
      character - name of character
      Returns:
      true, if the character exists and belongs to the account; false otherwise
      Throws:
      SQLException - in case of an database error
    • hasActiveCharacter

      @Deprecated public boolean hasActiveCharacter(String username, String character) throws SQLException
      Deprecated.
      checks whether the specified account owns the specified character and it is active
      Parameters:
      username - username
      character - name of character
      Returns:
      true, if the character exists and belongs to the account; false otherwise
      Throws:
      SQLException - in case of an database error
    • getCharacters

      @Deprecated public List<String> getCharacters(String username) throws SQLException
      Deprecated.
      gets a list of characters for this account
      Parameters:
      username - username
      Returns:
      list of characters
      Throws:
      SQLException - in case of an database error
    • storeCharacter

      @Deprecated public void storeCharacter(String username, String character, RPObject player) throws SQLException, IOException
      Deprecated.
      This method stores a character's avatar in the database and updates the link with the Character table.
      Parameters:
      username - the player's username
      character - the player's character name
      player - the RPObject itself.
      Throws:
      SQLException - if there is any problem at database.
      IOException
    • loadCharacter

      @Deprecated public RPObject loadCharacter(String username, String character) throws SQLException, IOException
      Deprecated.
      This method loads the character's avatar associated with this character from the database.
      Parameters:
      username - the player's username
      character - the player's character name
      Returns:
      The loaded RPObject
      Throws:
      SQLException - if there is any problem at database
      IOException
    • loadAllCharacters

      @Deprecated public Map<String,​RPObject> loadAllCharacters(String username) throws SQLException, IOException
      Deprecated.
      This method loads all the characters associated with this username from the database.
      Parameters:
      username - the player's username
      Returns:
      The loaded RPObject
      Throws:
      SQLException - if there is any problem at database
      IOException - if there is a problem reading the blob
    • loadAllActiveCharacters

      @Deprecated public Map<String,​RPObject> loadAllActiveCharacters(String username) throws SQLException, IOException
      Deprecated.
      This method loads all active the characters associated with this username from the database.
      Parameters:
      username - the player's username
      Returns:
      The loaded RPObject
      Throws:
      SQLException - if there is any problem at database
      IOException - if there is a problem reading the blob
    • getAccountName

      @Deprecated public String getAccountName(String character) throws SQLException
      Deprecated.
      gets the name of the account to which the specified character belongs.
      Parameters:
      character - name of character
      Returns:
      name of account, or null in case the character does not exist
      Throws:
      SQLException - if there is any problem at database
    • getCanonicalName

      @Deprecated public String getCanonicalName(String character) throws SQLException
      Deprecated.
      gets the canonical spelling of the character name
      Parameters:
      character - name of character
      Returns:
      name of character, or null in case the character does not exist
      Throws:
      SQLException - if there is any problem at database
    • isCharacterCreationLimitReached

      @Deprecated public boolean isCharacterCreationLimitReached(String username, String address) throws IOException, SQLException
      Deprecated.
      is the character creation limit reached?
      Parameters:
      username - username of account
      address - ip-address of client
      Returns:
      true if too many characters have been created
      Throws:
      IOException - in case of an input output error
      SQLException - if there is any problem at database
    • getCreationDate

      @Deprecated public Date getCreationDate(String character) throws SQLException
      Deprecated.
      Gets the date the character was registered
      Parameters:
      character - name of character
      Returns:
      date of character creation or null if no character with that name exists
      Throws:
      SQLException - in case of an database error
    • setCharacterStatus

      @Deprecated public void setCharacterStatus(String username, String character, String status) throws SQLException, IOException
      Deprecated.
      Modifies a character status.
      Parameters:
      username - username
      character - name of character
      status - status to set
      Throws:
      IOException - in case of an input/output error
      SQLException - in case of an database error