org.apache.xml.resolver.readers
Class TextCatalogReader

java.lang.Object
  |
  +--org.apache.xml.resolver.readers.TextCatalogReader
All Implemented Interfaces:
CatalogReader
Direct Known Subclasses:
TR9401CatalogReader

public class TextCatalogReader
extends java.lang.Object
implements CatalogReader

Parses plain text Catalog files.

This class reads plain text Open Catalog files.

Version:
1.0
Author:
Norman Walsh Norman.Walsh@Sun.COM
See Also:
Catalog

Field Summary
protected  boolean caseSensitive
          Are keywords in the catalog case sensitive?
protected  java.io.InputStream catfile
          The input stream used to read the catalog
protected  int[] stack
          Character lookahead stack.
protected  java.util.Stack tokenStack
          Token stack.
protected  int top
          The current position on the lookahead stack
 
Constructor Summary
TextCatalogReader()
          Construct a CatalogReader object.
 
Method Summary
protected  void finalize()
          The destructor.
 boolean getCaseSensitive()
           
protected  int nextChar()
          Return the next logical character from the input stream.
protected  java.lang.String nextToken()
          Return the next token in the catalog file.
 void readCatalog(Catalog catalog, java.io.InputStream is)
          Read a catalog from an input stream.
 void readCatalog(Catalog catalog, java.lang.String fileUrl)
          Start parsing a text catalog file.
 void setCaseSensitive(boolean isCaseSensitive)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

catfile

protected java.io.InputStream catfile
The input stream used to read the catalog

stack

protected int[] stack
Character lookahead stack. Reading a catalog sometimes requires up to two characters of lookahead.

tokenStack

protected java.util.Stack tokenStack
Token stack. Recognizing an unexpected catalog entry requires the ability to "push back" a token.

top

protected int top
The current position on the lookahead stack

caseSensitive

protected boolean caseSensitive
Are keywords in the catalog case sensitive?
Constructor Detail

TextCatalogReader

public TextCatalogReader()
Construct a CatalogReader object.
Method Detail

setCaseSensitive

public void setCaseSensitive(boolean isCaseSensitive)

getCaseSensitive

public boolean getCaseSensitive()

readCatalog

public void readCatalog(Catalog catalog,
                        java.lang.String fileUrl)
                 throws java.net.MalformedURLException,
                        java.io.IOException
Start parsing a text catalog file. The file is actually read and parsed as needed by nextEntry.

Specified by:
readCatalog in interface CatalogReader
Parameters:
fileUrl - The URL or filename of the catalog file to process
Throws:
java.net.MalformedURLException - Improper fileUrl
java.io.IOException - Error reading catalog file

readCatalog

public void readCatalog(Catalog catalog,
                        java.io.InputStream is)
                 throws java.net.MalformedURLException,
                        java.io.IOException
Description copied from interface: CatalogReader
Read a catalog from an input stream.

This class reads a catalog from an input stream.

Specified by:
readCatalog in interface CatalogReader
Following copied from interface: org.apache.xml.resolver.readers.CatalogReader
Parameters:
catalog - The catalog for which this reader is called.
is - The input stream that is to be read.
Throws:
java.io.IOException - if the URL cannot be read.
UnknownCatalogFormatException - if the catalog format is not recognized.
UnparseableCatalogException - if the catalog cannot be parsed. (For example, if it is supposed to be XML and isn't well-formed.)

finalize

protected void finalize()
The destructor.

Makes sure the catalog file is closed.

Overrides:
finalize in class java.lang.Object

nextToken

protected java.lang.String nextToken()
                              throws java.io.IOException,
                                     CatalogException
Return the next token in the catalog file.

FYI: This code does not throw any sort of exception for a file that contains an n

Returns:
The Catalog file token from the input stream.
Throws:
java.io.IOException - If an error occurs reading from the stream.

nextChar

protected int nextChar()
                throws java.io.IOException
Return the next logical character from the input stream.
Returns:
The next (logical) character from the input stream. The character may be buffered from a previous lookahead.
Throws:
java.io.IOException - If an error occurs reading from the stream.


Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.