java.lang.Object com.realtime.crossfire.jxclient.gui.log.Parser
public class Parser
Parser for parsing drawextinfo messages received from a Crossfire server to
update a Buffer
instance.
Field Summary | |
---|---|
private boolean |
bold
Whether bold face is enabled. |
private java.awt.Color |
color
The color to use. |
private static java.util.Map<java.lang.String,java.awt.Color> |
COLORS
Maps color tag name to color instance. |
private static java.util.regex.Pattern |
END_OF_LINE_PATTERN
Pattern to match line breaks. |
private FontID |
font
The font to use. |
private static java.util.Map<java.lang.String,FontID> |
FONTS
Maps font tag name to font instance. |
private boolean |
italic
Whether italic face is enabled. |
private boolean |
underline
Whether underlining is enabled. |
private static java.util.regex.Pattern |
WORD_SEPARATOR_PATTERN
The pattern to split a string into words. |
Constructor Summary | |
---|---|
Parser()
|
Method Summary | |
---|---|
void |
parse(java.lang.CharSequence text,
java.awt.Color defaultColor,
Buffer buffer)
Parses a text message. |
private Line |
parseLine(java.lang.String text,
java.awt.Color defaultColor)
Parses one text line. |
private void |
parseLine(java.lang.String text,
java.awt.Color defaultColor,
Buffer buffer)
Parses one text line. |
private void |
parseLineWithoutMediaTags(java.lang.String text,
Buffer buffer)
Parses one text line of a plain text message without media tags. |
void |
parseWithoutMediaTags(java.lang.CharSequence text,
java.awt.Color color,
Buffer buffer)
Parses a plain text message without media tags. |
private void |
processTag(java.lang.String tag,
java.awt.Color defaultColor)
Processes a tag. |
private void |
processText(java.lang.String text,
Line line)
Processes one text segment. |
private void |
resetAttributes(java.awt.Color defaultColor)
Resets all attributes to default values. |
static java.lang.String |
toString(java.awt.Color color)
Returns the string representation for a color. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean bold
@Nullable private java.awt.Color color
null
means default color.
@NotNull private static final java.util.Map<java.lang.String,java.awt.Color> COLORS
@NotNull private static final java.util.regex.Pattern END_OF_LINE_PATTERN
private FontID font
@NotNull private static final java.util.Map<java.lang.String,FontID> FONTS
private boolean italic
private boolean underline
@NotNull private static final java.util.regex.Pattern WORD_SEPARATOR_PATTERN
Constructor Detail |
---|
public Parser()
Method Detail |
---|
public void parse(@NotNull java.lang.CharSequence text, @Nullable java.awt.Color defaultColor, @NotNull Buffer buffer)
text
- the text message to parsedefaultColor
- the default color to usebuffer
- the buffer to update@NotNull private Line parseLine(@NotNull java.lang.String text, @Nullable java.awt.Color defaultColor)
text
- the text to processdefaultColor
- the default color to use
Line
instanceprivate void parseLine(@NotNull java.lang.String text, @Nullable java.awt.Color defaultColor, @NotNull Buffer buffer)
text
- the text to processdefaultColor
- the default color to usebuffer
- the buffer instance to add toprivate void parseLineWithoutMediaTags(@NotNull java.lang.String text, @NotNull Buffer buffer)
text
- the text to processbuffer
- the buffer instance to add topublic void parseWithoutMediaTags(@NotNull java.lang.CharSequence text, @NotNull java.awt.Color color, @NotNull Buffer buffer)
text
- the text message to parsecolor
- the color to usebuffer
- the buffer to updateprivate void processTag(@NotNull java.lang.String tag, @Nullable java.awt.Color defaultColor)
tag
- the tag name to process. Leading and trailing brackets have
been removeddefaultColor
- the default color to useprivate void processText(@NotNull java.lang.String text, @NotNull Line line)
text
- the text segment to processline
- the line to add toprivate void resetAttributes(@Nullable java.awt.Color defaultColor)
defaultColor
- the default color to use@NotNull public static java.lang.String toString(@NotNull java.awt.Color color)
color
- the color to convert