com.realtime.crossfire.jxclient.metaserver
Class MetaserverModel

java.lang.Object
  extended by com.realtime.crossfire.jxclient.metaserver.MetaserverModel

public class MetaserverModel
extends java.lang.Object

Maintains the metaserver information.


Field Summary
private  java.util.List<MetaserverEntry> metaList
          The current entries.
private  java.util.Collection<MetaserverEntry> metaListPending
          The pending entries.
private  java.util.Map<java.lang.Integer,java.util.List<MetaserverEntryListener>> metaserverEntryListeners
          All registered metaserver entry listeners.
private  java.util.Collection<MetaserverListener> metaserverListeners
          All registered metaserver listeners.
private  java.lang.Object sync
          Object used for synchronization.
 
Constructor Summary
MetaserverModel()
           
 
Method Summary
 void add(MetaserverEntry metaserverEntry)
          Adds an entry.
 void addMetaserverEntryListener(int index, MetaserverEntryListener listener)
          Adds a metaserver entry listener for one entry.
 void addMetaserverListener(MetaserverListener listener)
          Adds a metaserver listener.
 void begin()
          Starts an update transaction.
 void commit()
          Finishes an update transaction.
 MetaserverEntry getEntry(int index)
          Returns a metaserver entry by index.
private  java.util.Collection<MetaserverEntryListener> getMetaserverEntryListeners(int index)
          Returns the metaserver entry listeners for one entry index.
 int getServerIndex(java.lang.String serverName)
          Returns the index of an entry by server name.
 void removeMetaserverEntryListener(int index, MetaserverEntryListener listener)
          Removes a metaserver entry listener for one entry.
 void removeMetaserverListener(MetaserverListener listener)
          Removes a metaserver listener.
 int size()
          Returns the number of metaserver entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metaList

@NotNull
private final java.util.List<MetaserverEntry> metaList
The current entries.


metaListPending

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


metaserverEntryListeners

@NotNull
private final java.util.Map<java.lang.Integer,java.util.List<MetaserverEntryListener>> metaserverEntryListeners
All registered metaserver entry listeners. Maps entry index to list of listeners.


metaserverListeners

@NotNull
private final java.util.Collection<MetaserverListener> metaserverListeners
All registered metaserver listeners.


sync

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

Constructor Detail

MetaserverModel

public MetaserverModel()
Method Detail

add

public void add(@NotNull
                MetaserverEntry metaserverEntry)
Adds an entry.

Parameters:
metaserverEntry - the entry to add

addMetaserverEntryListener

public void addMetaserverEntryListener(int index,
                                       @NotNull
                                       MetaserverEntryListener listener)
Adds a metaserver entry listener for one entry.

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

addMetaserverListener

public void addMetaserverListener(@NotNull
                                  MetaserverListener listener)
Adds a metaserver listener.

Parameters:
listener - the listener to add

begin

public void begin()
Starts an update transaction.


commit

public void commit()
Finishes an update transaction.


getEntry

@Nullable
public MetaserverEntry getEntry(int index)
Returns a metaserver entry by index.

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

getMetaserverEntryListeners

@NotNull
private java.util.Collection<MetaserverEntryListener> getMetaserverEntryListeners(int index)
Returns the metaserver entry listeners for one entry index.

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

getServerIndex

public int getServerIndex(@NotNull
                          java.lang.String serverName)
Returns the index of an entry by server name.

Parameters:
serverName - the server name
Returns:
the index, or -1 if not found

removeMetaserverEntryListener

public void removeMetaserverEntryListener(int index,
                                          @NotNull
                                          MetaserverEntryListener listener)
Removes a metaserver entry listener for one entry.

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

removeMetaserverListener

public void removeMetaserverListener(@NotNull
                                     MetaserverListener listener)
Removes a metaserver listener.

Parameters:
listener - the listener to remove

size

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

Returns:
the number of metaserver entries