ca.cbc.sportwire.feed
Class ESPNXMLFeed
java.lang.Object
|
+--com.sportsticker.internetclient.InternetClient
|
+--ca.cbc.sportwire.feed.ESPNXMLFeed
- All Implemented Interfaces:
- ESPNFeedProperties, java.lang.Runnable, SportwireFeed
- public class ESPNXMLFeed
- extends com.sportsticker.internetclient.InternetClient
- implements SportwireFeed, ESPNFeedProperties
ESPNXMLFeed.java
Read the ESPN XML stream socket into a buffer and provide a string
reader over the spooled story breaking the input at ^V^V^A
sequences. Without the ESPN libraries, you cannot compile the
Feeder without removing this class.
Created: Mon Nov 12 16:14:22 2001
- Version:
- $Id: ESPNXMLFeed.java,v 1.14 2002/04/19 20:38:04 garym Exp $
- Author:
- Gary Lawrence Murphy
Inner classes inherited from class com.sportsticker.internetclient.InternetClient |
com.sportsticker.internetclient.InternetClient.SocketReader |
Field Summary |
(package private) static org.apache.log4j.Category |
cat
|
private org.apache.commons.collections.ExtendedProperties |
config
|
private static ESPNXMLFeed |
feeder
singleton constructor |
private java.io.BufferedReader |
in
|
private boolean |
isrunning
|
private java.lang.String |
lastTag
|
private java.io.PrintWriter |
log
|
private java.io.PipedOutputStream |
out
|
(package private) static java.util.Map |
pattern
|
private java.lang.StringBuffer |
storybuffer
|
Fields inherited from class com.sportsticker.internetclient.InternetClient |
authHost, authPort, buffer, clientSocket, EOT, exit, host, idleTimeout, inputCiphers, key, keyFile, os, outputCiphers, reader, STX, US, username |
Fields inherited from interface ca.cbc.sportwire.feed.ESPNFeedProperties |
CTRLA, CTRLB, CTRLD, CTRLH, CTRLK, CTRLL, ESPN_AUTHHOST_PROPERTY, ESPN_AUTHKEY_PROPERTY, ESPN_AUTHPORT_PROPERTY, ESPN_AUTHUSER_PROPERTY, ESPN_HOST_PROPERTY, ESPN_IDLE_DEFAULT, ESPN_IDLE_PROPERTY, ESPN_SOURCE_DEFAULT, ESPN_SOURCE_PROPERTY, ESPN_SPOOL_PROPERTY, PAGEBREAK |
Constructor Summary |
protected |
ESPNXMLFeed(org.apache.commons.collections.ExtendedProperties sc)
ESPNXMLFeed constructor |
Method Summary |
protected int |
bufferStory()
bufferStory spools one document at a time for the
SportWire system to load into the doc queue for later
parsing/archiving or whatever else gets done to it. |
protected boolean |
espnConnect()
|
protected java.lang.String |
fixupXml(java.lang.String line)
fixupXml : Sportsticker XML contains errors that
will not parse with standard XML tools like Xerces. |
protected org.apache.commons.collections.ExtendedProperties |
getConfig()
Get the global configuration properties |
java.io.BufferedReader |
getIn()
Get the value of in. |
static SportwireFeed |
getInstance(org.apache.commons.collections.ExtendedProperties sc)
getInstance returns the Singleton, synchronized to
protect against concurrent invocations. |
java.lang.String |
getLastTag()
getLastTag returns a meaningful name of the last
story read through the Reader |
java.io.PipedOutputStream |
getOut()
Get the value of out. |
java.lang.String |
getStatus()
getStatus : return a status string reporting on the
state of the feed parser; used by the XMLRPC status monitor |
private java.lang.StringBuffer |
getStorybuffer()
|
protected boolean |
openPipes()
|
void |
run()
run : when running in socket mode, this will ensure
the connection stays alive and has workers reading it. |
boolean |
running()
|
protected void |
runstate(boolean r)
|
void |
setIn(java.io.BufferedReader v)
Set the value of in. |
void |
setOut(java.io.PipedOutputStream v)
Set the value of out. |
void |
skipToNext()
Deprecated. |
protected void |
startLog(org.apache.commons.collections.ExtendedProperties sc)
startLog : if espn.log appears in the config file,
it defines a filename that will receive everything the wire
receives (after the cleanup of bad XML). |
void |
stop()
stop : override ESPN method to avoid system exit |
java.io.Reader |
storyReader()
Method: 'storyReader' provides a StringReader over the internal
story buffer. |
Methods inherited from class com.sportsticker.internetclient.InternetClient |
, cleanUp, connect, finalize |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
cat
static org.apache.log4j.Category cat
config
private org.apache.commons.collections.ExtendedProperties config
in
private java.io.BufferedReader in
log
private java.io.PrintWriter log
out
private java.io.PipedOutputStream out
lastTag
private java.lang.String lastTag
storybuffer
private java.lang.StringBuffer storybuffer
isrunning
private boolean isrunning
feeder
private static ESPNXMLFeed feeder
- singleton constructor
pattern
static java.util.Map pattern
ESPNXMLFeed
protected ESPNXMLFeed(org.apache.commons.collections.ExtendedProperties sc)
ESPNXMLFeed
constructor
- Parameters:
sc
- an ExtendedProperties
value
getConfig
protected org.apache.commons.collections.ExtendedProperties getConfig()
- Get the global configuration properties
- Returns:
- ExtendedProperties value of config.
getStatus
public java.lang.String getStatus()
- Description copied from interface:
SportwireFeed
getStatus
: return a status string reporting on the
state of the feed parser; used by the XMLRPC status monitor
- Specified by:
getStatus
in interface SportwireFeed
- Following copied from interface:
ca.cbc.sportwire.feed.SportwireFeed
- Returns:
- a
String
value
getIn
public java.io.BufferedReader getIn()
- Get the value of in.
- Returns:
- BufferedReader value of in.
setIn
public void setIn(java.io.BufferedReader v)
- Set the value of in.
- Parameters:
v
- Value to assign to in.
getOut
public java.io.PipedOutputStream getOut()
- Get the value of out.
- Returns:
- PipedOutputStream value of out.
setOut
public void setOut(java.io.PipedOutputStream v)
- Set the value of out.
- Parameters:
v
- Value to assign to out.
getLastTag
public java.lang.String getLastTag()
- Description copied from interface:
SportwireFeed
getLastTag
returns a meaningful name of the last
story read through the Reader
- Specified by:
getLastTag
in interface SportwireFeed
- Following copied from interface:
ca.cbc.sportwire.feed.SportwireFeed
- Returns:
- a
String
value
getStorybuffer
private java.lang.StringBuffer getStorybuffer()
running
public boolean running()
runstate
protected void runstate(boolean r)
startLog
protected void startLog(org.apache.commons.collections.ExtendedProperties sc)
startLog
: if espn.log appears in the config file,
it defines a filename that will receive everything the wire
receives (after the cleanup of bad XML). This is useful for
creating test data that you can then pipe into the program
after disabling the socket reader.
- Parameters:
sc
- an ExtendedProperties
value
openPipes
protected boolean openPipes()
espnConnect
protected boolean espnConnect()
getInstance
public static SportwireFeed getInstance(org.apache.commons.collections.ExtendedProperties sc)
getInstance
returns the Singleton, synchronized to
protect against concurrent invocations.
- Parameters:
sc
- an ExtendedProperties
value- Returns:
- a
SportwireFeed
value
run
public void run()
run
: when running in socket mode, this will ensure
the connection stays alive and has workers reading it. the
worker thread will take read the sportsticker socket and write
to the internal PipeOutputStream that is connected to the
PipeInputStream used by the story reader.
- Overrides:
run
in class com.sportsticker.internetclient.InternetClient
stop
public void stop()
stop
: override ESPN method to avoid system exit
- Overrides:
stop
in class com.sportsticker.internetclient.InternetClient
fixupXml
protected java.lang.String fixupXml(java.lang.String line)
fixupXml
: Sportsticker XML contains errors that
will not parse with standard XML tools like Xerces. As each
line is read, it passes through this method where ampersands
and other illegal chars are replaced and the strange ESPN date
format is re-arranged into something more friendly to Java and
RDBMS. As time goes on, there are likely to be more patches
tucked into this method. This method also picks out the lastTag.
This should be updated to use the util.RegexMap class
- Parameters:
line
- a String
value- Returns:
- a
String
value
skipToNext
public void skipToNext()
throws java.io.IOException
- Deprecated.
- Method: 'skipToNext' syncs the ticker to the next complete
story; if it was already at the top of a story, this scraps
that one and moves on to the next.
- Specified by:
skipToNext
in interface SportwireFeed
- Throws:
java.io.IOException
- if a read error occurs
bufferStory
protected int bufferStory()
throws java.io.IOException
bufferStory
spools one document at a time for the
SportWire system to load into the doc queue for later
parsing/archiving or whatever else gets done to it. Keep in
mind that ESPN XML is not legal XML, so this method will
correct certain patterns on the fly.
- Returns:
- int count of lines in this story
- Throws:
java.io.IOException
- if an error occurs
storyReader
public java.io.Reader storyReader()
throws java.io.IOException
- Method: 'storyReader' provides a StringReader over the internal
story buffer. The storybuffer is replaced with each call to
skipToNext.
- Specified by:
storyReader
in interface SportwireFeed
- Returns:
- 'Reader' value
- Throws:
java.io.IOException
- if an error occurs