Crossfire JXClient, Trunk
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.metaserver.ServerCache Class Reference
Collaboration diagram for com.realtime.crossfire.jxclient.metaserver.ServerCache:
Collaboration graph

Public Member Functions

void expire (final long timestamp)
 
Map< String, MetaserverEntrygetAll ()
 
void put (@NotNull final MetaserverEntry metaserverEntry)
 
void save ()
 
 ServerCache (@Nullable final Path file)
 

Static Public Attributes

static final CharSequence DEFAULT_ENTRY_LOCALHOST = "0|localhost|0|--|Local server. Start server before you try to connect.|0|0|0|||"
 

Private Member Functions

boolean addEntry (@NotNull final CharSequence metaserverEntryLine, final long timestamp)
 
void load ()
 
void saveInternal (@NotNull final Path file) throws IOException
 

Private Attributes

final Map< String, Infoentries = new HashMap<>()
 
final Path file
 

Detailed Description

Maintains a set of known servers backed up in a file.

Author
Andreas Kirschbaum

Definition at line 43 of file ServerCache.java.

Constructor & Destructor Documentation

◆ ServerCache()

com.realtime.crossfire.jxclient.metaserver.ServerCache.ServerCache ( @Nullable final Path  file)

Creates a new instance.

Parameters
filethe backing file or
null
to not cache on disk

Definition at line 68 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.file, and com.realtime.crossfire.jxclient.metaserver.ServerCache.load().

Here is the call graph for this function:

Member Function Documentation

◆ addEntry()

boolean com.realtime.crossfire.jxclient.metaserver.ServerCache.addEntry ( @NotNull final CharSequence  metaserverEntryLine,
final long  timestamp 
)
private

Parses a metaserver entry line and adds the result to entries.

Parameters
metaserverEntryLinethe metaserver entry line to parse
timestampthe query timestamp
Returns
whether the line was parsed correctly

Definition at line 161 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.entries, com.realtime.crossfire.jxclient.metaserver.MetaserverEntry.getKey(), and com.realtime.crossfire.jxclient.metaserver.MetaserverEntryParser.parseEntry().

Referenced by com.realtime.crossfire.jxclient.metaserver.ServerCache.load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expire()

void com.realtime.crossfire.jxclient.metaserver.ServerCache.expire ( final long  timestamp)

Expires entries older than a given timestamp from the cache.

Parameters
timestampthe timestamp

Definition at line 87 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.entries.

Referenced by com.realtime.crossfire.jxclient.metaserver.MetaserverProcessor.updateMetaList().

Here is the caller graph for this function:

◆ getAll()

Map<String, MetaserverEntry> com.realtime.crossfire.jxclient.metaserver.ServerCache.getAll ( )

Returns all cached entries. The returned set may be modified by the caller.

Returns
the cached entries; maps key to metaserver entry

Definition at line 98 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.entries.

Referenced by com.realtime.crossfire.jxclient.metaserver.MetaserverProcessor.MetaserverProcessor(), and com.realtime.crossfire.jxclient.metaserver.MetaserverProcessor.updateMetaList().

Here is the caller graph for this function:

◆ load()

void com.realtime.crossfire.jxclient.metaserver.ServerCache.load ( )
private

Loads the entries from the backing file.

Definition at line 109 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.addEntry(), com.realtime.crossfire.jxclient.metaserver.ServerCache.DEFAULT_ENTRY_LOCALHOST, and com.realtime.crossfire.jxclient.metaserver.ServerCache.file.

Referenced by com.realtime.crossfire.jxclient.metaserver.ServerCache.ServerCache().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ put()

void com.realtime.crossfire.jxclient.metaserver.ServerCache.put ( @NotNull final MetaserverEntry  metaserverEntry)

Adds an entry to the cache. Overwrites old entries for the same hostname.

Parameters
metaserverEntrythe entry to add

Definition at line 79 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.entries.

Referenced by com.realtime.crossfire.jxclient.metaserver.MetaserverProcessor.updateMetaList().

Here is the caller graph for this function:

◆ save()

void com.realtime.crossfire.jxclient.metaserver.ServerCache.save ( )

Saves all entries to the backing file.

Definition at line 174 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.file, and com.realtime.crossfire.jxclient.metaserver.ServerCache.saveInternal().

Referenced by com.realtime.crossfire.jxclient.metaserver.MetaserverProcessor.updateMetaList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveInternal()

void com.realtime.crossfire.jxclient.metaserver.ServerCache.saveInternal ( @NotNull final Path  file) throws IOException
private

Saves all entries to the backing file.

Parameters
filethe file to write
Exceptions
IOExceptionif an I/O error occurs

Definition at line 191 of file ServerCache.java.

References com.realtime.crossfire.jxclient.metaserver.ServerCache.entries, com.realtime.crossfire.jxclient.metaserver.ServerCache.file, and com.realtime.crossfire.jxclient.metaserver.MetaserverEntryParser.format().

Referenced by com.realtime.crossfire.jxclient.metaserver.ServerCache.save().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ DEFAULT_ENTRY_LOCALHOST

final CharSequence com.realtime.crossfire.jxclient.metaserver.ServerCache.DEFAULT_ENTRY_LOCALHOST = "0|localhost|0|--|Local server. Start server before you try to connect.|0|0|0|||"
static

◆ entries

final Map<String, Info> com.realtime.crossfire.jxclient.metaserver.ServerCache.entries = new HashMap<>()
private

◆ file

final Path com.realtime.crossfire.jxclient.metaserver.ServerCache.file
private

The documentation for this class was generated from the following file: