com.realtime.crossfire.jxclient.gui.log
Class Parser

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.log.Parser

public class Parser
extends java.lang.Object

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

bold

private boolean bold
Whether bold face is enabled.


color

@Nullable
private java.awt.Color color
The color to use. null means default color.


COLORS

@NotNull
private static final java.util.Map<java.lang.String,java.awt.Color> COLORS
Maps color tag name to color instance. The keys must be lower case.


END_OF_LINE_PATTERN

@NotNull
private static final java.util.regex.Pattern END_OF_LINE_PATTERN
Pattern to match line breaks.


font

private FontID font
The font to use.


FONTS

@NotNull
private static final java.util.Map<java.lang.String,FontID> FONTS
Maps font tag name to font instance.


italic

private boolean italic
Whether italic face is enabled.


underline

private boolean underline
Whether underlining is enabled.


WORD_SEPARATOR_PATTERN

@NotNull
private static final java.util.regex.Pattern WORD_SEPARATOR_PATTERN
The pattern to split a string into words.

Constructor Detail

Parser

public Parser()
Method Detail

parse

public void parse(@NotNull
                  java.lang.CharSequence text,
                  @Nullable
                  java.awt.Color defaultColor,
                  @NotNull
                  Buffer buffer)
Parses a text message.

Parameters:
text - the text message to parse
defaultColor - the default color to use
buffer - the buffer to update

parseLine

@NotNull
private Line parseLine(@NotNull
                               java.lang.String text,
                               @Nullable
                               java.awt.Color defaultColor)
Parses one text line.

Parameters:
text - the text to process
defaultColor - the default color to use
Returns:
the Line instance

parseLine

private void parseLine(@NotNull
                       java.lang.String text,
                       @Nullable
                       java.awt.Color defaultColor,
                       @NotNull
                       Buffer buffer)
Parses one text line.

Parameters:
text - the text to process
defaultColor - the default color to use
buffer - the buffer instance to add to

parseLineWithoutMediaTags

private void parseLineWithoutMediaTags(@NotNull
                                       java.lang.String text,
                                       @NotNull
                                       Buffer buffer)
Parses one text line of a plain text message without media tags.

Parameters:
text - the text to process
buffer - the buffer instance to add to

parseWithoutMediaTags

public void parseWithoutMediaTags(@NotNull
                                  java.lang.CharSequence text,
                                  @NotNull
                                  java.awt.Color color,
                                  @NotNull
                                  Buffer buffer)
Parses a plain text message without media tags.

Parameters:
text - the text message to parse
color - the color to use
buffer - the buffer to update

processTag

private void processTag(@NotNull
                        java.lang.String tag,
                        @Nullable
                        java.awt.Color defaultColor)
Processes a tag.

Parameters:
tag - the tag name to process. Leading and trailing brackets have been removed
defaultColor - the default color to use

processText

private void processText(@NotNull
                         java.lang.String text,
                         @NotNull
                         Line line)
Processes one text segment.

Parameters:
text - the text segment to process
line - the line to add to

resetAttributes

private void resetAttributes(@Nullable
                             java.awt.Color defaultColor)
Resets all attributes to default values.

Parameters:
defaultColor - the default color to use

toString

@NotNull
public static java.lang.String toString(@NotNull
                                                java.awt.Color color)
Returns the string representation for a color.

Parameters:
color - the color to convert
Returns:
the string representation