com.realtime.crossfire.jxclient.metaserver
Class MetaserverEntryParser

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

public class MetaserverEntryParser
extends java.lang.Object

Parser for response lines of metaserver response lines.


Field Summary
private  java.lang.String archBase
          The "archetype base" value for the current server entry.
private  long bytesIn
          The "bytes in" value for the current server entry.
private  long bytesOut
          The "bytes out" value for the current server entry.
private  java.lang.String codeBase
          The "code base" value for the current server entry.
private  java.lang.String comment
          The "comment" value for the current server entry.
private static java.lang.String DEFAULT_BASE
          The default for arch base, map base, and code base if none specified.
private static java.util.regex.Pattern FIELD_SEPARATOR_PATTERN
          The pattern to split a metaserver response line into fields.
private  java.lang.String hostname
          The "hostname" value for the current server entry.
private  boolean inSection
          Whether response parsing is withing a server entry.
private  java.lang.String mapBase
          The "map base" value for the current server entry.
private  int players
          The "players" value for the current server entry.
private static java.lang.String UNKNOWN_VERSION
          The default server version if none specified.
private  int updateSeconds
          The "update seconds" value for the current server entry.
private  int uptimeSeconds
          The "uptime seconds" value for the current server entry.
private  java.lang.String version
          The "server version" value for the current server entry.
 
Constructor Summary
MetaserverEntryParser()
          Creates a new instance.
 
Method Summary
private  void clear()
          Resets values for the current server entry.
static java.lang.String format(MetaserverEntry entry)
          Format a metaserver entry that returns the metaserver entry when parse with parseEntry(CharSequence).
static MetaserverEntry parseEntry(java.lang.CharSequence entry)
          Parses a metaserver response line.
 MetaserverEntry parseLine(java.lang.String line)
          Parses a metaserver response line.
private static java.lang.String replace(java.lang.String str)
          Replace characters with may cause parsing issues.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

archBase

@NotNull
private java.lang.String archBase
The "archetype base" value for the current server entry.


bytesIn

private long bytesIn
The "bytes in" value for the current server entry.


bytesOut

private long bytesOut
The "bytes out" value for the current server entry.


codeBase

@NotNull
private java.lang.String codeBase
The "code base" value for the current server entry.


comment

@NotNull
private java.lang.String comment
The "comment" value for the current server entry. html_command is preferred over text_comment.


DEFAULT_BASE

@NotNull
private static final java.lang.String DEFAULT_BASE
The default for arch base, map base, and code base if none specified.

See Also:
Constant Field Values

FIELD_SEPARATOR_PATTERN

@NotNull
private static final java.util.regex.Pattern FIELD_SEPARATOR_PATTERN
The pattern to split a metaserver response line into fields.


hostname

@Nullable
private java.lang.String hostname
The "hostname" value for the current server entry.


inSection

private boolean inSection
Whether response parsing is withing a server entry.


mapBase

@NotNull
private java.lang.String mapBase
The "map base" value for the current server entry.


players

private int players
The "players" value for the current server entry.


UNKNOWN_VERSION

@NotNull
private static final java.lang.String UNKNOWN_VERSION
The default server version if none specified.

See Also:
Constant Field Values

updateSeconds

private int updateSeconds
The "update seconds" value for the current server entry.


uptimeSeconds

private int uptimeSeconds
The "uptime seconds" value for the current server entry.


version

@NotNull
private java.lang.String version
The "server version" value for the current server entry.

Constructor Detail

MetaserverEntryParser

public MetaserverEntryParser()
Creates a new instance.

Method Detail

clear

private void clear()
Resets values for the current server entry. Will be called whenever parsing of a new entry starts.


format

@NotNull
public static java.lang.String format(@NotNull
                                              MetaserverEntry entry)
Format a metaserver entry that returns the metaserver entry when parse with parseEntry(CharSequence).

Parameters:
entry - The metaserver entry to format.
Returns:
The formatted entry.

parseEntry

@Nullable
public static MetaserverEntry parseEntry(@NotNull
                                                  java.lang.CharSequence entry)
Parses a metaserver response line.

Parameters:
entry - the response line to parse
Returns:
the metaserver entry or null if the line is invalid

parseLine

@Nullable
public MetaserverEntry parseLine(@NotNull
                                          java.lang.String line)
                          throws java.io.IOException
Parses a metaserver response line.

Parameters:
line - the response line to parse
Returns:
the metaserver entry, or null if the line is invalid
Throws:
java.io.IOException - if the response line is invalid

replace

@NotNull
private static java.lang.String replace(@NotNull
                                                java.lang.String str)
Replace characters with may cause parsing issues.

Parameters:
str - The string to replace.
Returns:
The replaced string.