Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess.net.ics.event
Class ICSEventParser

java.lang.Object
  extended byictk.boardgame.chess.net.ics.event.ICSEventParser
Direct Known Subclasses:
FICSBoardUpdateStyle12Parser, FICSChallengeParser, FICSChannelParser, FICSGameCreatedParser, FICSGameNotificationParser, FICSGameResultParser, FICSKibitzParser, FICSMoveListParser, FICSPlayerConnectionParser, FICSPlayerNotificationParser, FICSSeekAdParser, FICSSeekAdReadableParser, FICSSeekClearParser, FICSSeekRemoveParser, FICSShoutParser, FICSTellParser

public abstract class ICSEventParser
extends java.lang.Object

Parses server messages and produces ICSEvent objects. All parsers implement the Singleton design pattern.


Field Summary
static long DEBUG
           
static java.lang.String REGEX_date
           
 
Method Summary
abstract  void assignMatches(java.util.regex.Matcher m, ICSEvent evt)
          Takes the data from the Matcher object and assigns them to the data fields of the ICSEvent object.
 ICSEvent createICSEvent(java.lang.CharSequence s)
          Instantiates a new ICSEvent of the appropriate type for this parser if and only if the CharSequence matches something this parser can understand.
abstract  ICSEvent createICSEvent(java.util.regex.Matcher match)
          Instantiantes a new ICSEvent of the appropriate type for this parser.
 boolean detectFake(java.lang.CharSequence s)
          Is this ICSEvent something faked by a Bot?
 int getEventType()
          returns the event type this parser corrisponds to
 java.util.regex.Pattern getPattern()
          returns the pattern being used for this EventParser
 java.util.regex.Matcher match(java.lang.CharSequence s)
          This method detects if the input CharSequence is a message of the type this parser can handle.
 void setDebug(boolean t)
          turns debugging on for this parser.
abstract  java.lang.String toNative(ICSEvent evt)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final long DEBUG

REGEX_date

public static final java.lang.String REGEX_date
See Also:
Constant Field Values
Method Detail

setDebug

public void setDebug(boolean t)
turns debugging on for this parser. You must also set Log.debug to true and Log.addMask() to see debugging output.


getPattern

public java.util.regex.Pattern getPattern()
returns the pattern being used for this EventParser


getEventType

public int getEventType()
returns the event type this parser corrisponds to


match

public java.util.regex.Matcher match(java.lang.CharSequence s)
This method detects if the input CharSequence is a message of the type this parser can handle. If the return is !null then the Matcher can be passed to createICSEvent(Matcher) to get the ICSEvent objects form of this messasge. You only need use this two step process (instead of just createICSEvent(CharSequence) if you need to know where the match started and ended in the CharSequence.

Parameters:
s - is the CharSequence containing the Event this parser handles
Returns:
null if there is no match

createICSEvent

public ICSEvent createICSEvent(java.lang.CharSequence s)
Instantiates a new ICSEvent of the appropriate type for this parser if and only if the CharSequence matches something this parser can understand.

Returns:
null if this CharSequence is not parsable by this parser

createICSEvent

public abstract ICSEvent createICSEvent(java.util.regex.Matcher match)
Instantiantes a new ICSEvent of the appropriate type for this parser. If the Matcher passed in is not from this parser the results are undefined.


assignMatches

public abstract void assignMatches(java.util.regex.Matcher m,
                                   ICSEvent evt)
Takes the data from the Matcher object and assigns them to the data fields of the ICSEvent object. This will clear all data in the ICSEvent object if there was any to begin with. This function can be used if you wish to recycle ICSEvent objects for some reason.

Throws:
exceptions - if you pass in the wrong type of ICSEvent for this parser, or a bad matcher. This is obviously loose coupling --caveat programmer

detectFake

public boolean detectFake(java.lang.CharSequence s)
Is this ICSEvent something faked by a Bot?


toNative

public abstract java.lang.String toNative(ICSEvent evt)

Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .