FantasySportsModule 0.0.2-dev

org.fanfoot.scoring
Class EventParser

java.lang.Object
  |
  +--org.fanfoot.scoring.EventParser

public class EventParser
extends java.lang.Object

Parsers a file looking for events that may be important in a fantasy game. Creates a set of Event objects from a given commentary/statistics file.

Author:
rgardler

Constructor Summary
EventParser()
          Creates a new instance of EventParser
EventParser(java.lang.String strURL)
          Creates a new instance of EventParser
 
Method Summary
 void addListener(EventParserListener epl)
          Add a listener to this parser
 java.lang.String getCommentarySource()
          Return the source code of the currently loaded commentary.
 EventParserConfiguration getConfiguration()
          Getter for property conf.
 void loadConfiguration(java.lang.String strConf)
          Load the configuration file indicated.
protected  void notifyRetrievedCommentary()
          Notify all listeners when the commentary has been retrieved
 Events parse(java.io.File file, java.lang.String strType)
          Parse the supplied file
 Events parse(java.lang.String strURL, java.lang.String strType)
          Parse the supplied resource
 Events parse(java.net.URL url, java.lang.String strType)
          Parse the supplied resource
 java.lang.String parseEventsUID(java.lang.String strData, java.lang.String strType)
          Create a Unique Identifier for a set of Events held in the supplied game data string.
 void removeListener(EventParserListener epl)
          Remove a listener to this parser
 void setConfiguration(EventParserConfiguration conf)
          Setter for property conf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventParser

public EventParser()
Creates a new instance of EventParser


EventParser

public EventParser(java.lang.String strURL)
            throws EventParserConfigurationException
Creates a new instance of EventParser

Parameters:
strURL - the url of the configuration file for this parser
Throws:
EventParserConfigurationException - Description of the Exception
EventParserConfigurationException
Method Detail

parse

public Events parse(java.lang.String strURL,
                    java.lang.String strType)
             throws java.net.MalformedURLException,
                    java.io.IOException,
                    EventParserConfigurationException
Parse the supplied resource

Parameters:
strURL - the URL of the resource to parse
strType - the type of resource this is (this corresponds to the sourceType element of the matcher element in the config file
Returns:
Events found in the resource
Throws:
java.net.MalformedURLException - Description of the Exception
java.io.IOException - Description of the Exception
EventParserConfigurationException - Description of the Exception

parse

public Events parse(java.io.File file,
                    java.lang.String strType)
             throws java.io.IOException,
                    EventParserConfigurationException
Parse the supplied file

Parameters:
file - the file to parse
strType - the type of resource this is (this corresponds to the sourceType element of the matcher element in the config file
Returns:
Events found in the resource
Throws:
java.io.IOException - Description of the Exception
EventParserConfigurationException - Description of the Exception

parse

public Events parse(java.net.URL url,
                    java.lang.String strType)
             throws java.net.MalformedURLException,
                    java.io.IOException,
                    EventParserConfigurationException
Parse the supplied resource

Parameters:
url - the URL of the resource to parse
strType - the type of resource this is (this corresponds to the sourceType element of the matcher element in the config file
Returns:
Events found in the resource
Throws:
java.net.MalformedURLException - Description of the Exception
java.io.IOException - Description of the Exception
EventParserConfigurationException - Description of the Exception

parseEventsUID

public java.lang.String parseEventsUID(java.lang.String strData,
                                       java.lang.String strType)
                                throws EventParserConfigurationException
Create a Unique Identifier for a set of Events held in the supplied game data string. This is done by matching the Regular Expression in the UID child element of the events root element in the parser configuration file.

Parameters:
strData - the game data
strType - the type of data supplied
Returns:
String UID for this set of events
Throws:
EventParserConfigurationException - when the event UDI cannot be generated

getConfiguration

public EventParserConfiguration getConfiguration()
Getter for property conf.

Returns:
Value of property conf.

setConfiguration

public void setConfiguration(EventParserConfiguration conf)
Setter for property conf.

Parameters:
conf - New value of property conf.

loadConfiguration

public void loadConfiguration(java.lang.String strConf)
                       throws EventParserConfigurationException
Load the configuration file indicated.

Parameters:
strConf - URL from which to load configuration file
Throws:
EventParserConfigurationException - Description of the Exception

addListener

public void addListener(EventParserListener epl)
Add a listener to this parser

Parameters:
epl - the listener to add

removeListener

public void removeListener(EventParserListener epl)
Remove a listener to this parser

Parameters:
epl - the listener to remove

notifyRetrievedCommentary

protected void notifyRetrievedCommentary()
Notify all listeners when the commentary has been retrieved


getCommentarySource

public java.lang.String getCommentarySource()
Return the source code of the currently loaded commentary.

Returns:
string containing the source code for the current commentary

FantasySportsModule 0.0.2-dev

Copyright © 2003 We know What you Want.net. All Rights Reserved.