XML for Java 2.0.0

com.ibm.xml.framework
Class XMLReader

java.lang.Object
  |
  +--com.ibm.xml.framework.XMLReader

public abstract class XMLReader
extends java.lang.Object
implements Locator

This is the class used by the scanner to process the XML data. This class provides the scanner with location information through the Locator interface.

Version:
Revision: 59 1.6 src/com/ibm/xml/framework/XMLReader.java, parser, xml4j2, xml4j2_0_0
See Also:
XMLParser, Locator

Field Summary
static int CHARDATA_RESULT_ALL_SPACE
           
static int CHARDATA_RESULT_CDEND
           
static int CHARDATA_RESULT_CHARDATA
           
static int CHARDATA_RESULT_INVALID_CHAR
           
static int CHARDATA_RESULT_MARKUP
           
static int CHARDATA_RESULT_REFERENCE
           
static int CHARDATA_RESULT_STATE_MASK
           
protected static byte E_CharDataFlag
           
protected static byte E_EncNameFlag
           
protected static byte E_InitialNameCharFlag
           
protected static byte E_NameCharFlag
           
protected static byte E_PubidCharFlag
           
protected static byte E_VersionNumFlag
           
protected  int fCarriageReturnCounter
           
protected  int fCharacterCounter
           
protected  int fCurrentOffset
           
protected static byte[] fgAsciiAlphaChar
           
protected static byte[] fgAsciiCharData
           
protected static byte[] fgAsciiInitialNameChar
           
protected static byte[] fgAsciiNameChar
           
protected static byte[] fgAsciiWSCharData
           
protected static byte[] fgAsciiXDigitChar
           
protected static byte[] fgCharFlags
           
protected  int fLinefeedCounter
           
protected  ParserState fParserState
           
protected  java.lang.String fPublicId
           
protected  java.lang.String fSystemId
           
 
Constructor Summary
protected XMLReader(ParserState parserState, java.lang.String publicId, java.lang.String systemId)
          Default constructor
 
Method Summary
abstract  int addString(int offset, int length)
          Add a string to the StringPool from the characters scanned using this reader as described by offset and length.
abstract  int addSymbol(int offset, int length)
          Add a symbol to the StringPool from the characters scanned using this reader as described by offset and length.
abstract  void append(ChunkyCharArray charArray, int offset, int length)
          Append the characters processed by this reader associated with offset and length to the ChunkyCharArray.
 int currentOffset()
          Return the current offset within this reader.
 int getColumnNumber()
          Return the column number of the current position within the document that we are processing.
 int getLineNumber()
          Return the line number of the current position within the document that we are processing.
 java.lang.String getPublicId()
          Return the public identifier of the InputSource that we are processing.
 java.lang.String getSystemId()
          Return the system identifier of the InputSource that we are processing.
abstract  boolean lookingAtChar(char ch)
          Test that the current character is a ch character.
abstract  boolean lookingAtSpace()
          Test that the current character is a whitespace character.
abstract  boolean lookingAtValidChar()
          Test that the current character is valid.
abstract  int scanContent(ScanContentState scanState)
          Skip through the input data while we are looking at character data.
abstract  int scanName(char fastcheck, int expectedName)
          Add a sequence of characters that match the XML definition of a Name to the StringPool.
abstract  int skipAsciiChar()
          Skip one ascii character.
abstract  int skipDecimalDigit()
          Skip a single decimal digit character.
abstract  int skipHexDigit()
          Skip a single hexadecimal digit character.
abstract  int skipInvalidChar(int errorCode)
          Advance past an invalid character, reporting it as an errorCode error.
abstract  int skipOneChar()
          Skip one character.
abstract  int skipPastChar(char ch)
          Advance through the input data beyond the next ch character.
abstract  int skipPastName(char fastcheck)
          Skip past a sequence of characters that match the XML definition of a Name.
abstract  int skipPastNmtoken(char fastcheck)
          Skip past a sequence of characters that match the XML definition of an Nmtoken.
abstract  int skipPastSpaces()
          Skip past whitespace characters starting at the current position.
abstract  boolean skippedAlpha()
          Skip a single ascii alpha character.
abstract  boolean skippedChar(char ch)
          Advance past a ch character.
abstract  boolean skippedEncName()
          Skip a single character defined by XML as a EncName character.
abstract  boolean skippedPubidChar()
          Skip a single character defined by XML as a PubidChar character.
abstract  boolean skippedSpace()
          Advance past one whitespace character.
abstract  boolean skippedString(char[] s)
          Skip past a sequence of characters that matches the specified character array.
abstract  boolean skippedValidChar()
          Advance past one valid character.
abstract  boolean skippedVersionNum()
          Skip a single character defined by XML as a VersionNum character.
abstract  int skipToChar(char ch)
          Advance through the input data up to the next ch character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARDATA_RESULT_MARKUP

public static final int CHARDATA_RESULT_MARKUP

CHARDATA_RESULT_REFERENCE

public static final int CHARDATA_RESULT_REFERENCE

CHARDATA_RESULT_CDEND

public static final int CHARDATA_RESULT_CDEND

CHARDATA_RESULT_INVALID_CHAR

public static final int CHARDATA_RESULT_INVALID_CHAR

CHARDATA_RESULT_STATE_MASK

public static final int CHARDATA_RESULT_STATE_MASK

CHARDATA_RESULT_CHARDATA

public static final int CHARDATA_RESULT_CHARDATA

CHARDATA_RESULT_ALL_SPACE

public static final int CHARDATA_RESULT_ALL_SPACE

fParserState

protected ParserState fParserState

fPublicId

protected java.lang.String fPublicId

fSystemId

protected java.lang.String fSystemId

fCarriageReturnCounter

protected int fCarriageReturnCounter

fLinefeedCounter

protected int fLinefeedCounter

fCharacterCounter

protected int fCharacterCounter

fCurrentOffset

protected int fCurrentOffset

fgAsciiXDigitChar

protected static final byte[] fgAsciiXDigitChar

fgAsciiAlphaChar

protected static final byte[] fgAsciiAlphaChar

fgAsciiInitialNameChar

protected static final byte[] fgAsciiInitialNameChar

fgAsciiNameChar

protected static final byte[] fgAsciiNameChar

fgAsciiCharData

protected static final byte[] fgAsciiCharData

fgAsciiWSCharData

protected static final byte[] fgAsciiWSCharData

E_VersionNumFlag

protected static final byte E_VersionNumFlag

E_EncNameFlag

protected static final byte E_EncNameFlag

E_PubidCharFlag

protected static final byte E_PubidCharFlag

E_CharDataFlag

protected static final byte E_CharDataFlag

E_InitialNameCharFlag

protected static final byte E_InitialNameCharFlag

E_NameCharFlag

protected static final byte E_NameCharFlag

fgCharFlags

protected static byte[] fgCharFlags
Constructor Detail

XMLReader

protected XMLReader(ParserState parserState,
                    java.lang.String publicId,
                    java.lang.String systemId)
Default constructor
Parameters:
parser - The parser that we are working for.
publicID - The public identifier of the InputSource that we are processing, or null if not provided.
systemID - The system identifier of the InputSource that we are processing, or null if not provided.
Method Detail

getPublicId

public java.lang.String getPublicId()
Return the public identifier of the InputSource that we are processing.
Specified by:
getPublicId in interface Locator
Returns:
The public identifier, or null if not provided.
See Also:
Locator

getSystemId

public java.lang.String getSystemId()
Return the system identifier of the InputSource that we are processing.
Specified by:
getSystemId in interface Locator
Returns:
The system identifier, or null if not provided.
See Also:
Locator

getLineNumber

public int getLineNumber()
Return the line number of the current position within the document that we are processing.
Specified by:
getLineNumber in interface Locator
Returns:
The current line number.
See Also:
Locator

getColumnNumber

public int getColumnNumber()
Return the column number of the current position within the document that we are processing.
Specified by:
getColumnNumber in interface Locator
Returns:
The current column number.
See Also:
Locator

addString

public abstract int addString(int offset,
                              int length)
Add a string to the StringPool from the characters scanned using this reader as described by offset and length.
Parameters:
offset - The offset within this reader where the characters start.
length - The length within this reader where the characters end.
Returns:
The index within the StringPool of the resulting string.

addSymbol

public abstract int addSymbol(int offset,
                              int length)
Add a symbol to the StringPool from the characters scanned using this reader as described by offset and length.
Parameters:
offset - The offset within this reader where the characters start.
length - The length within this reader where the characters end.
Returns:
The index within the StringPool of the resulting symbol.

append

public abstract void append(ChunkyCharArray charArray,
                            int offset,
                            int length)
Append the characters processed by this reader associated with offset and length to the ChunkyCharArray.
Parameters:
charArray - The ChunkyCharArray to append the characters to.
offset - The offset within this reader where the copy should start.
length - The length within this reader where the copy should stop.

skipOneChar

public abstract int skipOneChar()
                         throws java.lang.Exception
Skip one character.
Returns:
The offset within this reader where we will look next.

skipAsciiChar

public abstract int skipAsciiChar()
                           throws java.lang.Exception
Skip one ascii character. The caller will call this method after determining that the current character is an ascii character. This is useful if the reader can advance through the input data more efficiently if it knows that the character is ascii.
Returns:
The offset within this reader where we will look next.

skipToChar

public abstract int skipToChar(char ch)
                        throws java.lang.Exception
Advance through the input data up to the next ch character.
Returns:
The offset within this reader where we will look next.

skipPastChar

public abstract int skipPastChar(char ch)
                          throws java.lang.Exception
Advance through the input data beyond the next ch character.
Returns:
The offset within this reader where we will look next.

skippedValidChar

public abstract boolean skippedValidChar()
                                  throws java.lang.Exception
Advance past one valid character.
Returns:
true if the current character was valid and skipped; false otherwise.

lookingAtValidChar

public abstract boolean lookingAtValidChar()
                                    throws java.lang.Exception
Test that the current character is valid.
Returns:
true if the current character is valid; false otherwise.

skipInvalidChar

public abstract int skipInvalidChar(int errorCode)
                             throws java.lang.Exception
Advance past an invalid character, reporting it as an errorCode error.
Returns:
The offset within this reader where we will look next.

skippedChar

public abstract boolean skippedChar(char ch)
                             throws java.lang.Exception
Advance past a ch character.
Parameters:
ch - The character to match against.
Returns:
true if the current character was a ch character and skipped; false otherwise.

lookingAtChar

public abstract boolean lookingAtChar(char ch)
                               throws java.lang.Exception
Test that the current character is a ch character.
Parameters:
ch - The character to match against.
Returns:
true if the current character is a ch character; false otherwise.

skippedSpace

public abstract boolean skippedSpace()
                              throws java.lang.Exception
Advance past one whitespace character.
Returns:
true if the current character was whitespace and skipped; false otherwise.

lookingAtSpace

public abstract boolean lookingAtSpace()
                                throws java.lang.Exception
Test that the current character is a whitespace character.
Returns:
true if the current character is whitespace; false otherwise.

skipPastSpaces

public abstract int skipPastSpaces()
                            throws java.lang.Exception
Skip past whitespace characters starting at the current position.
Returns:
The offset within this reader where we will look next.

skipDecimalDigit

public abstract int skipDecimalDigit()
                              throws java.lang.Exception
Skip a single decimal digit character.
Returns:
The value of the skipped character, if it was a decimal digit, as an integer between 0 and 9, or -1 if the current character is not a decimal digit.

skipHexDigit

public abstract int skipHexDigit()
                          throws java.lang.Exception
Skip a single hexadecimal digit character.
Returns:
The value of the skipped character, if it was a hexadecimal digit, as an integer between 0 and 15, or -1 if the current character is not a hexadecimal digit.

skippedAlpha

public abstract boolean skippedAlpha()
                              throws java.lang.Exception
Skip a single ascii alpha character. An ascii alpha character is either in the ascii range 'a' through 'z' or in the range 'A' through 'Z'.
Returns:
true if the current character was alpha and skipped; false otherwise.

skippedVersionNum

public abstract boolean skippedVersionNum()
                                   throws java.lang.Exception
Skip a single character defined by XML as a VersionNum character.
Returns:
true if the current character is a VersionNum character and skipped; false otherwise.

skippedEncName

public abstract boolean skippedEncName()
                                throws java.lang.Exception
Skip a single character defined by XML as a EncName character.
Returns:
true if the current character is a EncName character and skipped; false otherwise.

skippedPubidChar

public abstract boolean skippedPubidChar()
                                  throws java.lang.Exception
Skip a single character defined by XML as a PubidChar character.
Returns:
true if the current character is a PubidChar character and skipped; false otherwise.

skippedString

public abstract boolean skippedString(char[] s)
                               throws java.lang.Exception
Skip past a sequence of characters that matches the specified character array.
Parameters:
s - The characters to match.
Returns:
true if the current character is valid; false otherwise.

scanName

public abstract int scanName(char fastcheck,
                             int expectedName)
                      throws java.lang.Exception
Add a sequence of characters that match the XML definition of a Name to the StringPool. If we find a name at the current position we will add it to the StringPool as a symbol and will return the index within the string pool to the caller.
Parameters:
fastcheck - A character that is not a legal name character that is provided as a hint to the reader of a character likely to terminate the Name.
expectedName - The index within the StringPool of the name that must match the name at the current position, or -1 if there is no specific name expected.
Returns:
The index within the StringPool of the name that was scanned, or -1 if a name was not found at the current position within the input data.
See Also:
StringPool

skipPastName

public abstract int skipPastName(char fastcheck)
                          throws java.lang.Exception
Skip past a sequence of characters that match the XML definition of a Name.
Returns:
The offset within this reader where we will look next.

skipPastNmtoken

public abstract int skipPastNmtoken(char fastcheck)
                             throws java.lang.Exception
Skip past a sequence of characters that match the XML definition of an Nmtoken.
Returns:
The offset within this reader where we will look next.

scanContent

public abstract int scanContent(ScanContentState scanState)
                         throws java.lang.Exception
Skip through the input data while we are looking at character data. The result codes are: CHARDATA_RESULT_MARKUP // stopped at markup, i.e. '<' CHARDATA_RESULT_REFERENCE // stopped at reference, i.e. '&' CHARDATA_RESULT_CDEND // stopped at CDEnd, i.e. ']]>' CHARDATA_RESULT_INVALID_CHAR // stopped at invalid character CHARDATA_RESULT_CHARDATA // a flag indicating we found some CharData CHARDATA_RESULT_ALL_SPACE // a flag indicating the CharData was all whitespace
Returns:
The result code.
See Also:
ScanContentState

currentOffset

public final int currentOffset()
Return the current offset within this reader.
Returns:
The offset.

XML for Java 2.0.0