Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xerces.readers
Class UCSReader  view UCSReader download UCSReader.java

java.lang.Object
  extended byorg.apache.xerces.readers.XMLEntityReader
      extended byorg.apache.xerces.readers.UCSReader
All Implemented Interfaces:
org.apache.xerces.utils.StringPool.StringProducer, XMLEntityHandler.EntityReader

final class UCSReader
extends XMLEntityReader
implements org.apache.xerces.utils.StringPool.StringProducer

Reader for UCS-2 and UCS-4 encodings.

This reader is created by the UCSRecognizer class when it decides that the byte stream is encoded in a format supported by this class. This class was intended to be another example of an encoding sensitive reader that could take advantage of the system design to improve performance and reduce resource consumption, but the actual performance tuning remains to be done.

Version:
$Id: UCSReader.java,v 1.3 2000/10/07 18:06:55 markd Exp $

Field Summary
private static char[] cdata_string
           
private static boolean DEBUG_UTF16_BIG
          Set to true to debug UTF-16, big-endian.
(package private) static int E_UCS2B
           
(package private) static int E_UCS2B_NOBOM
           
(package private) static int E_UCS2L
           
(package private) static int E_UCS2L_NOBOM
           
(package private) static int E_UCS4B
           
(package private) static int E_UCS4L
           
private  boolean fBigEndian
           
private  int fBytesPerChar
           
private  boolean fCalledCharPropInit
           
protected  int fCarriageReturnCounter
           
protected  int fCharacterCounter
           
private static char[] fCharacters
           
protected  XMLEntityHandler.CharDataHandler fCharDataHandler
           
private  int fCharDataLength
           
protected  int fCurrentOffset
           
private  org.apache.xerces.utils.ChunkyByteArray fData
           
private  int fEncoding
           
protected  XMLEntityHandler fEntityHandler
           
protected  org.apache.xerces.framework.XMLErrorReporter fErrorReporter
           
protected  boolean fInCDSect
           
protected  int fLinefeedCounter
           
protected  boolean fSendCharDataAsCharArray
           
private  org.apache.xerces.utils.ChunkyCharArray fStringCharArray
           
private  org.apache.xerces.utils.StringPool fStringPool
           
 
Constructor Summary
(package private) UCSReader(XMLEntityHandler entityHandler, org.apache.xerces.framework.XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, org.apache.xerces.utils.ChunkyByteArray data, int encoding, org.apache.xerces.utils.StringPool stringPool)
           
 
Method Summary
 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.
 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.
 void append(XMLEntityHandler.CharBuffer charBuffer, int offset, int length)
          Append the characters processed by this reader associated with offset and length to the CharBuffer.
private  void appendCharData(int ch)
           
 void callCharDataHandler(int offset, int length, boolean isWhitespace)
           
protected  XMLEntityHandler.EntityReader changeReaders()
          This method is called by the reader subclasses at the end of input.
 int currentOffset()
          Return the current offset within this reader.
 boolean equalsString(int offset, int length, char[] strChars, int strOffset, int strLength)
           
private  int getChar(int offset)
           
 int getColumnNumber()
          Return the column number of the current position within the document that we are processing.
private  int getHashcode(int offset, int length)
           
 boolean getInCDSect()
          This method is provided for scanner implementations.
 int getLineNumber()
          Return the line number of the current position within the document that we are processing.
protected  void init(XMLEntityHandler entityHandler, org.apache.xerces.framework.XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, int lineNumber, int columnNumber)
           
 boolean lookingAtChar(char ch, boolean skipPastChar)
          Test that the current character is a ch character.
 boolean lookingAtSpace(boolean skipPastChar)
          Test that the current character is a whitespace character.
 boolean lookingAtValidChar(boolean skipPastChar)
          Test that the current character is valid.
private  int recognizeMarkup()
           
private  int recognizeReference()
           
 void releaseString(int offset, int length)
           
 int scanAttValue(char qchar, boolean asSymbol)
          Scan an attribute value.
 int scanCharRef(boolean hex)
          Scan a character reference.
 int scanContent(org.apache.xerces.utils.QName element)
          Skip through the input while we are looking at character data.
 int scanEntityValue(int qchar, boolean createString)
          Scan an entity value.
 boolean scanExpectedName(char fastcheck, org.apache.xerces.utils.StringPool.CharArrayRange expectedName)
          Scan the name that is expected at the current position in the document.
 int scanInvalidChar()
          Scan an invalid character.
 int scanName(char fastcheck)
          Add a sequence of characters that match the XML definition of a Name to the StringPool.
 void scanQName(char fastcheck, org.apache.xerces.utils.QName qname)
          Add a sequence of characters that match the XML Namespaces definition of a QName to the StringPool.
 int scanStringLiteral()
          Scan a string literal.
 void setInCDSect(boolean inCDSect)
          This method is provided for scanner implementations.
 void skipPastName(char fastcheck)
          Skip past a sequence of characters that match the XML definition of a Name.
 void skipPastNmtoken(char fastcheck)
          Skip past a sequence of characters that match the XML definition of an Nmtoken.
 void skipPastSpaces()
          Skip past whitespace characters starting at the current position.
 boolean skippedString(char[] s)
          Skip past a sequence of characters that matches the specified character array.
 void skipToChar(char chr)
          Advance through the input data up to the next ch character.
 java.lang.String toString(int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_UTF16_BIG

private static final boolean DEBUG_UTF16_BIG
Set to true to debug UTF-16, big-endian.

See Also:
Constant Field Values

E_UCS4B

static final int E_UCS4B
See Also:
Constant Field Values

E_UCS4L

static final int E_UCS4L
See Also:
Constant Field Values

E_UCS2B

static final int E_UCS2B
See Also:
Constant Field Values

E_UCS2L

static final int E_UCS2L
See Also:
Constant Field Values

E_UCS2B_NOBOM

static final int E_UCS2B_NOBOM
See Also:
Constant Field Values

E_UCS2L_NOBOM

static final int E_UCS2L_NOBOM
See Also:
Constant Field Values

fData

private org.apache.xerces.utils.ChunkyByteArray fData

fEncoding

private int fEncoding

fStringPool

private org.apache.xerces.utils.StringPool fStringPool

fBytesPerChar

private int fBytesPerChar

fBigEndian

private boolean fBigEndian

fStringCharArray

private org.apache.xerces.utils.ChunkyCharArray fStringCharArray

fCalledCharPropInit

private boolean fCalledCharPropInit

fCharacters

private static char[] fCharacters

fCharDataLength

private int fCharDataLength

cdata_string

private static final char[] cdata_string

fEntityHandler

protected XMLEntityHandler fEntityHandler

fErrorReporter

protected org.apache.xerces.framework.XMLErrorReporter fErrorReporter

fSendCharDataAsCharArray

protected boolean fSendCharDataAsCharArray

fCharDataHandler

protected XMLEntityHandler.CharDataHandler fCharDataHandler

fInCDSect

protected boolean fInCDSect

fCarriageReturnCounter

protected int fCarriageReturnCounter

fLinefeedCounter

protected int fLinefeedCounter

fCharacterCounter

protected int fCharacterCounter

fCurrentOffset

protected int fCurrentOffset
Constructor Detail

UCSReader

UCSReader(XMLEntityHandler entityHandler,
          org.apache.xerces.framework.XMLErrorReporter errorReporter,
          boolean sendCharDataAsCharArray,
          org.apache.xerces.utils.ChunkyByteArray data,
          int encoding,
          org.apache.xerces.utils.StringPool stringPool)
    throws java.lang.Exception
Method Detail

getChar

private int getChar(int offset)
             throws java.io.IOException

addString

public int addString(int offset,
                     int length)
Description copied from interface: XMLEntityHandler.EntityReader
Add a string to the StringPool from the characters scanned using this reader as described by offset and length.

Specified by:
addString in interface XMLEntityHandler.EntityReader

addSymbol

public int addSymbol(int offset,
                     int length)
Description copied from interface: XMLEntityHandler.EntityReader
Add a symbol to the StringPool from the characters scanned using this reader as described by offset and length.

Specified by:
addSymbol in interface XMLEntityHandler.EntityReader

append

public void append(XMLEntityHandler.CharBuffer charBuffer,
                   int offset,
                   int length)
Description copied from interface: XMLEntityHandler.EntityReader
Append the characters processed by this reader associated with offset and length to the CharBuffer.

Specified by:
append in interface XMLEntityHandler.EntityReader

releaseString

public void releaseString(int offset,
                          int length)
Specified by:
releaseString in interface org.apache.xerces.utils.StringPool.StringProducer

toString

public java.lang.String toString(int offset,
                                 int length)
Specified by:
toString in interface org.apache.xerces.utils.StringPool.StringProducer

getHashcode

private int getHashcode(int offset,
                        int length)

equalsString

public boolean equalsString(int offset,
                            int length,
                            char[] strChars,
                            int strOffset,
                            int strLength)
Specified by:
equalsString in interface org.apache.xerces.utils.StringPool.StringProducer

appendCharData

private void appendCharData(int ch)

callCharDataHandler

public void callCharDataHandler(int offset,
                                int length,
                                boolean isWhitespace)
                         throws java.lang.Exception

lookingAtChar

public boolean lookingAtChar(char ch,
                             boolean skipPastChar)
                      throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Test that the current character is a ch character.

Specified by:
lookingAtChar in interface XMLEntityHandler.EntityReader

lookingAtValidChar

public boolean lookingAtValidChar(boolean skipPastChar)
                           throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Test that the current character is valid.

Specified by:
lookingAtValidChar in interface XMLEntityHandler.EntityReader

lookingAtSpace

public boolean lookingAtSpace(boolean skipPastChar)
                       throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Test that the current character is a whitespace character.

Specified by:
lookingAtSpace in interface XMLEntityHandler.EntityReader

skipToChar

public void skipToChar(char chr)
                throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Advance through the input data up to the next ch character.

Specified by:
skipToChar in interface XMLEntityHandler.EntityReader

skipPastSpaces

public void skipPastSpaces()
                    throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Skip past whitespace characters starting at the current position.

Specified by:
skipPastSpaces in interface XMLEntityHandler.EntityReader

skipPastName

public void skipPastName(char fastcheck)
                  throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Skip past a sequence of characters that match the XML definition of a Name.

Specified by:
skipPastName in interface XMLEntityHandler.EntityReader

skipPastNmtoken

public void skipPastNmtoken(char fastcheck)
                     throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Skip past a sequence of characters that match the XML definition of an Nmtoken.

Specified by:
skipPastNmtoken in interface XMLEntityHandler.EntityReader

skippedString

public boolean skippedString(char[] s)
                      throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Skip past a sequence of characters that matches the specified character array.

Specified by:
skippedString in interface XMLEntityHandler.EntityReader

scanInvalidChar

public int scanInvalidChar()
                    throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Scan an invalid character.

Specified by:
scanInvalidChar in interface XMLEntityHandler.EntityReader

scanCharRef

public int scanCharRef(boolean hex)
                throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Scan a character reference.

Specified by:
scanCharRef in interface XMLEntityHandler.EntityReader

scanStringLiteral

public int scanStringLiteral()
                      throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Scan a string literal.

Specified by:
scanStringLiteral in interface XMLEntityHandler.EntityReader

scanAttValue

public int scanAttValue(char qchar,
                        boolean asSymbol)
                 throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Scan an attribute value.

Specified by:
scanAttValue in interface XMLEntityHandler.EntityReader

scanEntityValue

public int scanEntityValue(int qchar,
                           boolean createString)
                    throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Scan an entity value.

Specified by:
scanEntityValue in interface XMLEntityHandler.EntityReader

scanExpectedName

public boolean scanExpectedName(char fastcheck,
                                org.apache.xerces.utils.StringPool.CharArrayRange expectedName)
                         throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Scan the name that is expected at the current position in the document. This method is invoked when we are scanning the element type in an end tag that must match the element type in the corresponding start tag.

Specified by:
scanExpectedName in interface XMLEntityHandler.EntityReader

scanQName

public void scanQName(char fastcheck,
                      org.apache.xerces.utils.QName qname)
               throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Add a sequence of characters that match the XML Namespaces definition of a QName to the StringPool. If we find a QName at the current position we will add it to the StringPool and will return the string pool handle of that QName to the caller.

Specified by:
scanQName in interface XMLEntityHandler.EntityReader

scanName

public int scanName(char fastcheck)
             throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
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 string pool handle for that symbol to the caller.

Specified by:
scanName in interface XMLEntityHandler.EntityReader

recognizeMarkup

private int recognizeMarkup()
                     throws java.lang.Exception

recognizeReference

private int recognizeReference()
                        throws java.lang.Exception

scanContent

public int scanContent(org.apache.xerces.utils.QName element)
                throws java.lang.Exception
Description copied from interface: XMLEntityHandler.EntityReader
Skip through the input while we are looking at character data.

Specified by:
scanContent in interface XMLEntityHandler.EntityReader

init

protected void init(XMLEntityHandler entityHandler,
                    org.apache.xerces.framework.XMLErrorReporter errorReporter,
                    boolean sendCharDataAsCharArray,
                    int lineNumber,
                    int columnNumber)

currentOffset

public int currentOffset()
Return the current offset within this reader.

Specified by:
currentOffset in interface XMLEntityHandler.EntityReader

getLineNumber

public int getLineNumber()
Return the line number of the current position within the document that we are processing.

Specified by:
getLineNumber in interface XMLEntityHandler.EntityReader

getColumnNumber

public int getColumnNumber()
Return the column number of the current position within the document that we are processing.

Specified by:
getColumnNumber in interface XMLEntityHandler.EntityReader

setInCDSect

public void setInCDSect(boolean inCDSect)
This method is provided for scanner implementations.

Specified by:
setInCDSect in interface XMLEntityHandler.EntityReader

getInCDSect

public boolean getInCDSect()
This method is provided for scanner implementations.

Specified by:
getInCDSect in interface XMLEntityHandler.EntityReader

changeReaders

protected XMLEntityHandler.EntityReader changeReaders()
                                               throws java.lang.Exception
This method is called by the reader subclasses at the end of input.