org.esau.ptarmigan.impl
Class GeneratorImpl

java.lang.Object
  |
  +--org.xml.sax.helpers.XMLFilterImpl
        |
        +--org.esau.ptarmigan.impl.GeneratorImpl
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, Generator, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

public final class GeneratorImpl
extends org.xml.sax.helpers.XMLFilterImpl
implements Generator

GeneratorImpl

From which the source is identified and which the parsers are launched

Instances of this class parse media files of different formats (mp3, ogg, pls, etc.) and generate SAX events describing the metadata of those files which can then be consumed, such as for data storage.

Those SAX events are typically used to build a Document which in turn is transformed to an object useable by the caller.

IMPLEMENTATION DETAILS

The algorithm used is designed for one-pass usage. It requires the use of a buffered stream where a marker can be set to sniff ahead for tags.

One at a time, give each parser a chance to sniff that buffer. The first one who returns sniff==true will own that position and immediately can parse data from it up to a limit.

NOTES

TODO: remove all references to specific parsers from the GeneratorImpl. Instead refer to them dynamically through StreamParser (ID3v2, Vorbis, etc.) and FileParser (ID3v1) interfaces. Place each parser in a jar and use a resource reference to identify it as a client parser.

Version:
$Revision: 1.7 $ $Date: 2002/09/24 02:51:17 $
Author:
Reed Esau

Fields inherited from interface org.esau.ptarmigan.Generator
DEFAULT_INCLUDE_DIGEST, DEFAULT_INCLUDE_PLAYLIST_ENTRIES, DEFAULT_PROPERTY_READ_LIMIT, FEATURE_INCLUDE_DIGEST, FEATURE_INCLUDE_PLAYLIST_ENTRIES, PROPERTY_READ_LIMIT
 
Constructor Summary
GeneratorImpl()
           
 
Method Summary
 boolean getFeature(java.lang.String name)
          OVERRIDE Look up the value of a feature.
 java.lang.Object getProperty(java.lang.String name)
          OVERRIDE Look up the value of a property.
 void parse(org.xml.sax.InputSource input)
          OVERRIDE SAX-invoked parse If it's a file, attempt to parse the ID3v1 tag at the end of the file.
 void resetData()
          Reset data members for reuse
 void setContentHandler(org.xml.sax.ContentHandler handler)
          OVERRIDE Set the content event handler.
 void setFeature(java.lang.String name, boolean value)
          OVERRIDE Set the value of a feature.
 void setProperty(java.lang.String name, java.lang.Object value)
          OVERRIDE Set the value of a property.
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getParent, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setParent, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.XMLFilter
getParent, setParent
 
Methods inherited from interface org.xml.sax.XMLReader
getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, parse, setDTDHandler, setEntityResolver, setErrorHandler
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 

Constructor Detail

GeneratorImpl

public GeneratorImpl()
Method Detail

parse

public void parse(org.xml.sax.InputSource input)
           throws java.io.IOException,
                  org.xml.sax.SAXException
OVERRIDE SAX-invoked parse If it's a file, attempt to parse the ID3v1 tag at the end of the file.
Specified by:
parse in interface org.xml.sax.XMLReader
Overrides:
parse in class org.xml.sax.helpers.XMLFilterImpl

resetData

public void resetData()
Reset data members for reuse

Note that features and properties are NOT reset to defaults as they are usually set when the generator is created.

Specified by:
resetData in interface Generator

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
OVERRIDE Set the content event handler.
Specified by:
setContentHandler in interface org.xml.sax.XMLReader
Overrides:
setContentHandler in class org.xml.sax.helpers.XMLFilterImpl

getFeature

public boolean getFeature(java.lang.String name)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
OVERRIDE Look up the value of a feature.
Specified by:
getFeature in interface org.xml.sax.XMLReader
Overrides:
getFeature in class org.xml.sax.helpers.XMLFilterImpl

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
OVERRIDE Set the value of a feature.
Specified by:
setFeature in interface org.xml.sax.XMLReader
Overrides:
setFeature in class org.xml.sax.helpers.XMLFilterImpl

getProperty

public java.lang.Object getProperty(java.lang.String name)
                             throws org.xml.sax.SAXNotRecognizedException,
                                    org.xml.sax.SAXNotSupportedException
OVERRIDE Look up the value of a property.
Specified by:
getProperty in interface org.xml.sax.XMLReader
Overrides:
getProperty in class org.xml.sax.helpers.XMLFilterImpl

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws org.xml.sax.SAXNotRecognizedException,
                        org.xml.sax.SAXNotSupportedException
OVERRIDE Set the value of a property.
Specified by:
setProperty in interface org.xml.sax.XMLReader
Overrides:
setProperty in class org.xml.sax.helpers.XMLFilterImpl


Copyright © 2002 Reed Esau, All Rights Reserved.