ca.cbc.sportwire.feed
Class AFPFeed

java.lang.Object
  |
  +--ca.cbc.sportwire.feed.AFPFeed
All Implemented Interfaces:
SportwireFeed, ca.cbc.sportwire.feeder.xmldbms.XmlProperties

public class AFPFeed
extends java.lang.Object
implements SportwireFeed, ca.cbc.sportwire.feeder.xmldbms.XmlProperties

AFPFeed.java Read the AFP system file format into a buffer and provide a string reader over the spooled story. This is a singleton class that reads from stdin. This implementation is not optimal; it parses the input stream, derives a DTD from the filename, inserts that DTD and renders the output as XML so the rest of the Feeder can treat it like ESPN/XMLDBMS input text data. Not great.

Created: Tue Feb 5 12:00:13 EST 2002

Version:
$Id: AFPFeed.java,v 1.8 2002/04/23 04:55:51 garym Exp $
Author:
Gary Lawrence Murphy

Field Summary
(package private) static org.apache.log4j.Category cat
           
private  org.apache.commons.collections.ExtendedProperties config
           
private  org.jdom.Document document
           
private static AFPFeed feeder
          singleton constructor
private  java.lang.String filename
           
private  java.io.BufferedReader in
           
private static java.lang.String PAGEBREAK
           
private  org.apache.oro.text.regex.Perl5Matcher perl
           
private  org.apache.oro.text.regex.Pattern regex
           
 
Fields inherited from interface ca.cbc.sportwire.feeder.xmldbms.XmlProperties
AFP_DTD_PREFIX_PROPERTY, AFP_DTD_REGEX_PROPERTY, DEFAULT_AFP_DTD_PREFIX, DEFAULT_AFP_DTD_REGEX, DEFAULT_MAP_PATH, DEFAULT_SAX_DRIVER_CLASS, MAP_PATH_PROPERTY, SAX_CLASS_PROPERTY
 
Constructor Summary
protected AFPFeed(org.apache.commons.collections.ExtendedProperties sc)
           
 
Method Summary
protected  java.lang.String afpFilenameDTD(java.lang.String filename)
          afpFilenameDTD creates the bogus DTD from the AFP filename by extracting the significant parts of the filename and ignoring the event parts, and prepending the AFP_DTD_PREFIX; note that the prefix is not required to end with a file separator and none will be inserted.
protected  int bufferStory()
          bufferStory for AFP must read in the XML and inject a DOCTYPE derived from the message filename attribute.
protected  org.apache.commons.collections.ExtendedProperties getConfig()
          Get the value of config.
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.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.String getStorybuffer()
           
 void skipToNext()
          Deprecated.  
 java.io.Reader storyReader()
          Method: 'storyReader' provides a StringReader over the internal story buffer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

cat

static org.apache.log4j.Category cat

config

private org.apache.commons.collections.ExtendedProperties config

in

private java.io.BufferedReader in

document

private org.jdom.Document document

perl

private org.apache.oro.text.regex.Perl5Matcher perl

regex

private org.apache.oro.text.regex.Pattern regex

filename

private java.lang.String filename

PAGEBREAK

private static java.lang.String PAGEBREAK

feeder

private static AFPFeed feeder
singleton constructor
Constructor Detail

AFPFeed

protected AFPFeed(org.apache.commons.collections.ExtendedProperties sc)
Method Detail

getConfig

protected org.apache.commons.collections.ExtendedProperties getConfig()
Get the value of config.
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

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.String getStorybuffer()

getInstance

public static SportwireFeed getInstance(org.apache.commons.collections.ExtendedProperties sc)
getInstance returns the Singleton, synchronized to protect against concurrent invocations.
Returns:
a SportwireFeed 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

afpFilenameDTD

protected java.lang.String afpFilenameDTD(java.lang.String filename)
afpFilenameDTD creates the bogus DTD from the AFP filename by extracting the significant parts of the filename and ignoring the event parts, and prepending the AFP_DTD_PREFIX; note that the prefix is not required to end with a file separator and none will be inserted.
Returns:
String value used to identify the DTD/Map file

bufferStory

protected int bufferStory()
                   throws java.io.IOException
bufferStory for AFP must read in the XML and inject a DOCTYPE derived from the message filename attribute.
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