org.apache.avalon.excalibur.catalog
Class XMLCatalogReader

java.lang.Object
  |
  +--org.apache.avalon.excalibur.catalog.XMLCatalogReader
All Implemented Interfaces:
org.xml.sax.DocumentHandler

public class XMLCatalogReader
extends java.lang.Object
implements org.xml.sax.DocumentHandler

Parses XML Catalog files.

This class reads XML Catalog files, returning a stream of tokens. At present, it recognizes John Cowan's XML Catalogs (formerly XCatalogs). In the future, additional XML Catalog formats may be supported.

This code interrogates the following non-standard system properties:

xml.catalog.debug

Sets the debug level. A value of 0 is assumed if the property is not set or is not a number.

Version:
1.0
Author:
Arbortext, Inc., Norman Walsh
See Also:
Catalog

Field Summary
 int debug
           The debug level
 
Constructor Summary
XMLCatalogReader()
           Construct an XMLCatalogReader object.
 
Method Summary
 void characters(char[] ch, int start, int length)
           The SAX characters method.
 void endDocument()
           The SAX endDocument method.
 void endElement(java.lang.String name)
           The SAX endElement method.
 void ignorableWhitespace(char[] ch, int start, int length)
           The SAX ignorableWhitespace method.
 CatalogEntry nextEntry()
           Get the next entry from the file
 void parseCatalog(java.lang.String fileUrl)
           Attempt to parse an XML Catalog file.
 void processingInstruction(java.lang.String target, java.lang.String data)
           The SAX processingInstruction method.
 void setDocumentLocator(org.xml.sax.Locator locator)
           The SAX setDocumentLocator method.
 void setParserClass(java.lang.String parser)
           Sets the parser class, enabling XML Catalog parsing.
 void startDocument()
           The SAX startDocument method.
 void startElement(java.lang.String name, org.xml.sax.AttributeList atts)
           The SAX startElement method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public int debug

The debug level

In general, higher numbers produce more information:

Constructor Detail

XMLCatalogReader

public XMLCatalogReader()

Construct an XMLCatalogReader object.

Method Detail

parseCatalog

public void parseCatalog(java.lang.String fileUrl)
                  throws org.xml.sax.SAXException,
                         java.io.IOException,
                         NotXMLCatalogException,
                         NoXMLParserException,
                         UnknownCatalogFormatException,
                         java.lang.ClassNotFoundException,
                         java.lang.InstantiationException,
                         java.lang.IllegalAccessException,
                         java.lang.ClassCastException

Attempt to parse an XML Catalog file.

Parameters:
fileUrl - The URL or filename of the catalog file to process
Throws:
org.xml.sax.SAXException - Error parsing catalog file.
java.io.IOException - Error reading catalog file.
NoXMLParserException - No Parser class provided.
NotXMLCatalogException - The Catalog appears not to be XML.
UnknownCatalogFormatException - Unexpected XML catalog type.
java.lang.ClassNotFoundException - Parser class can't be found.
java.lang.InstantiationException - Parser class can't be instantiated.
java.lang.IllegalAccessException - Error instantiating parser class.
java.lang.ClassCastException - Parser class isn't a SAX Parser.

nextEntry

public CatalogEntry nextEntry()
                       throws java.io.IOException

Get the next entry from the file

Returns:
A CatalogEntry object for the next entry in the catalog
Throws:
java.io.IOException - Error reading catalog file

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException

The SAX startDocument method. Does nothing.

Specified by:
startDocument in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException

The SAX endDocument method. Does nothing.

Specified by:
endDocument in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

startElement

public void startElement(java.lang.String name,
                         org.xml.sax.AttributeList atts)
                  throws org.xml.sax.SAXException

The SAX startElement method.

This element attempts to identify the type of catalog by looking at the name of the first element encountered. If it recognizes the element, it sets the catalogType appropriately.

After the catalog type has been identified, the appropriate entry parser is called for each subsequent element in the catalog.

Specified by:
startElement in interface org.xml.sax.DocumentHandler
Parameters:
name - The name of the element.
atts - The list of attributes on the element.
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

endElement

public void endElement(java.lang.String name)
                throws org.xml.sax.SAXException

The SAX endElement method. Does nothing.

Specified by:
endElement in interface org.xml.sax.DocumentHandler
Parameters:
name - DOC: Insert Description of Parameter
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException

The SAX characters method. Does nothing.

Specified by:
characters in interface org.xml.sax.DocumentHandler
Parameters:
ch - DOC: Insert Description of Parameter
start - DOC: Insert Description of Parameter
length - DOC: Insert Description of Parameter
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException

The SAX ignorableWhitespace method. Does nothing.

Specified by:
ignorableWhitespace in interface org.xml.sax.DocumentHandler
Parameters:
ch - DOC: Insert Description of Parameter
start - DOC: Insert Description of Parameter
length - DOC: Insert Description of Parameter
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException

The SAX processingInstruction method. Does nothing.

Specified by:
processingInstruction in interface org.xml.sax.DocumentHandler
Parameters:
target - DOC: Insert Description of Parameter
data - DOC: Insert Description of Parameter
Throws:
org.xml.sax.SAXException - DOC: Insert Description of Exception

setParserClass

public void setParserClass(java.lang.String parser)

Sets the parser class, enabling XML Catalog parsing.

Sets the parser class that will be used for loading XML Catalogs. If this method is not called, all attempts to use the XMLCatalogParser will fail, throwing a NoXMLParserException .

Parameters:
parser - The name of a class implementing the SAX Parser interface to be used for subsequent XML Catalog parsing.
See Also:
com.arbortext.catalog.NoXMLParserException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)

The SAX setDocumentLocator method. Does nothing.

Specified by:
setDocumentLocator in interface org.xml.sax.DocumentHandler
Parameters:
locator - The new DocumentLocator value


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.