com.realtime.crossfire.jxclient.account
Class CharacterModel

java.lang.Object
  extended by com.realtime.crossfire.jxclient.account.CharacterModel

public class CharacterModel
extends java.lang.Object

Maintains the character list for an account. Only meaningful if the server supports the new "loginmethod".


Field Summary
private  java.util.Map<java.lang.Integer,java.util.List<CharacterInformationListener>> characterInformationListeners
          All registered character entry listeners.
private  java.util.Collection<CharacterListener> characterListeners
          All registered character listeners.
private  java.util.List<CharacterInformation> characters
          The current entries.
private  java.util.Collection<CharacterInformation> charactersPending
          The pending entries.
private  java.lang.Object sync
          Object used for synchronization.
 
Constructor Summary
CharacterModel()
           
 
Method Summary
 void add(CharacterInformation characterInformation)
          Adds an entry.
 void addCharacterInformationListener(int index, CharacterInformationListener listener)
          Adds a character entry listener for one entry.
 void addCharacterListener(CharacterListener listener)
          Adds a character listener.
 void begin()
          Starts an update transaction.
 void commit()
          Finishes an update transaction.
 int getCharacterIndex(java.lang.String characterName)
          Returns the index of an entry by character name.
private  java.util.Collection<CharacterInformationListener> getCharacterInformationListeners(int index)
          Returns the character entry listeners for one entry index.
 CharacterInformation getEntry(int index)
          Returns a character entry by index.
 void removeCharacterInformationListener(int index, CharacterInformationListener listener)
          Removes a character entry listener for one entry.
 void removeCharacterListener(CharacterListener listener)
          Removes a character listener.
 int size()
          Returns the number of character entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

characterInformationListeners

@NotNull
private final java.util.Map<java.lang.Integer,java.util.List<CharacterInformationListener>> characterInformationListeners
All registered character entry listeners. Maps entry index to list of listeners.


characterListeners

@NotNull
private final java.util.Collection<CharacterListener> characterListeners
All registered character listeners.


characters

@NotNull
private final java.util.List<CharacterInformation> characters
The current entries.


charactersPending

@NotNull
private final java.util.Collection<CharacterInformation> charactersPending
The pending entries. Only valid between begin() and commit().


sync

@NotNull
private final java.lang.Object sync
Object used for synchronization.

Constructor Detail

CharacterModel

public CharacterModel()
Method Detail

add

public void add(@NotNull
                CharacterInformation characterInformation)
Adds an entry.

Parameters:
characterInformation - the entry to add

addCharacterInformationListener

public void addCharacterInformationListener(int index,
                                            @NotNull
                                            CharacterInformationListener listener)
Adds a character entry listener for one entry.

Parameters:
index - the entry index to monitor
listener - the listener to add

addCharacterListener

public void addCharacterListener(@NotNull
                                 CharacterListener listener)
Adds a character listener.

Parameters:
listener - the listener to add

begin

public void begin()
Starts an update transaction.


commit

public void commit()
Finishes an update transaction.


getCharacterIndex

public int getCharacterIndex(@NotNull
                             java.lang.String characterName)
Returns the index of an entry by character name.

Parameters:
characterName - the character name
Returns:
the index, or -1 if not found

getCharacterInformationListeners

@NotNull
private java.util.Collection<CharacterInformationListener> getCharacterInformationListeners(int index)
Returns the character entry listeners for one entry index.

Parameters:
index - the entry index
Returns:
the listeners list

getEntry

@Nullable
public CharacterInformation getEntry(int index)
Returns a character entry by index.

Parameters:
index - the index
Returns:
the character entry, or null if the index is invalid

removeCharacterInformationListener

public void removeCharacterInformationListener(int index,
                                               @NotNull
                                               CharacterInformationListener listener)
Removes a character entry listener for one entry.

Parameters:
index - the entry index to monitor
listener - the listener to remove

removeCharacterListener

public void removeCharacterListener(@NotNull
                                    CharacterListener listener)
Removes a character listener.

Parameters:
listener - the listener to remove

size

public int size()
Returns the number of character entries.

Returns:
the number of character entries