public class MetaserverEntryParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
MetaserverEntryParser()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
clear()
Resets values for the current server entry.
|
static java.lang.String |
format(MetaserverEntry entry)
Formats 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)
Replaces characters with may cause parsing issues.
|
@NotNull private java.lang.String archBase
private long bytesIn
private long bytesOut
@NotNull private java.lang.String codeBase
@NotNull private java.lang.String comment
@NotNull private static final java.lang.String DEFAULT_BASE
@NotNull private static final java.util.regex.Pattern FIELD_SEPARATOR_PATTERN
@Nullable private java.lang.String hostname
private boolean inSection
@NotNull private java.lang.String mapBase
private int players
@NotNull private static final java.lang.String UNKNOWN_VERSION
private int updateSeconds
private int uptimeSeconds
@NotNull private java.lang.String version
private void clear()
@NotNull public static java.lang.String format(@NotNull MetaserverEntry entry)
parseEntry(CharSequence)
.entry
- the metaserver entry to format@Nullable public static MetaserverEntry parseEntry(@NotNull java.lang.CharSequence entry)
entry
- the response line to parsenull
if the line is invalid@Nullable public MetaserverEntry parseLine(@NotNull java.lang.String line) throws java.io.IOException
line
- the response line to parsenull
if the line is invalidjava.io.IOException
- if the response line is invalid@NotNull private static java.lang.String replace(@NotNull java.lang.String str)
str
- the string to replace