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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.apache.xerces.readers.XMLEntityReader
      extended byorg.apache.xerces.readers.AbstractCharReader
          extended byorg.apache.xerces.readers.UTF8CharReader
All Implemented Interfaces:
XMLEntityHandler.EntityReader

final class UTF8CharReader
extends AbstractCharReader

Simple character-based version of a UTF8 reader. This class is not commonly used, but is provided as a much simplified example of the UTF8Reader class that uses the AbstractCharReader to perform all of the reader functions except for filling each buffer of the character data when needed (fillCurrentChunk). We read the input data from an InputStream and perform end-of-line normalization as we process that data.

Version:

Field Summary
protected  int fCarriageReturnCounter
           
protected  int fCharacterCounter
           
protected  XMLEntityHandler.CharDataHandler fCharDataHandler
           
private  boolean fCheckOverflow
           
protected  org.apache.xerces.utils.CharDataChunk fCurrentChunk
           
protected  int fCurrentIndex
           
protected  int fCurrentOffset
           
protected  XMLEntityHandler fEntityHandler
           
protected  org.apache.xerces.framework.XMLErrorReporter fErrorReporter
           
protected  boolean fInCDSect
           
private  java.io.InputStream fInputStream
           
protected  int fLength
           
protected  int fLinefeedCounter
           
protected  int fMostRecentChar
           
protected  char[] fMostRecentData
           
private  int fOutputOffset
           
private  byte[] fOverflow
           
private  int fOverflowEnd
           
private  int fOverflowOffset
           
private  byte[] fPartialMultiByteChar
           
private  int fPartialMultiByteIn
           
private  boolean fPartialMultiByteResult
           
private  int fPartialSurrogatePair
           
protected  boolean fSendCharDataAsCharArray
           
private  boolean fSkipLinefeed
           
 
Constructor Summary
(package private) UTF8CharReader(XMLEntityHandler entityHandler, org.apache.xerces.framework.XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, java.io.InputStream dataStream, 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.
protected  XMLEntityHandler.EntityReader changeReaders()
          Change readers at end of input.
private  boolean copyNormalize(byte[] in, int inOffset, char[] out, int outOffset)
           
 int currentOffset()
          Return the current offset within this reader.
protected  void deferException(int errorCode, java.lang.Object[] args, int offset)
          Delay reporting an error message.
private  boolean exitNormalize(int inOffset, int outOffset, boolean result)
           
protected  int fillCurrentChunk()
          Fill the current chunk the next buffer worth of data.
 int getColumnNumber()
          Return the column number of the current position within the document that we are processing.
 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.
private  boolean handleMultiByteChar(byte b, byte[] in, int inOffset, int inEnd, char[] out, int outOffset, int outEnd)
           
private  boolean handlePartialMultiByteChar(byte b, byte[] in, int inOffset, int inEnd, char[] out, int outOffset, int outEnd)
           
protected  void init(XMLEntityHandler entityHandler, org.apache.xerces.framework.XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, int lineNumber, int columnNumber)
           
 boolean lookingAtChar(char chr, 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  void savePartialMultiByte(int inCount, byte bz)
           
private  void savePartialMultiByte(int inCount, byte bz, byte by)
           
private  void savePartialMultiByte(int inCount, byte bz, byte by, byte bx)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fInputStream

private java.io.InputStream fInputStream

fCheckOverflow

private boolean fCheckOverflow

fOverflow

private byte[] fOverflow

fOverflowOffset

private int fOverflowOffset

fOverflowEnd

private int fOverflowEnd

fOutputOffset

private int fOutputOffset

fSkipLinefeed

private boolean fSkipLinefeed

fPartialMultiByteIn

private int fPartialMultiByteIn

fPartialMultiByteChar

private byte[] fPartialMultiByteChar

fPartialSurrogatePair

private int fPartialSurrogatePair

fPartialMultiByteResult

private boolean fPartialMultiByteResult

fCurrentChunk

protected org.apache.xerces.utils.CharDataChunk fCurrentChunk

fCurrentIndex

protected int fCurrentIndex

fMostRecentData

protected char[] fMostRecentData

fMostRecentChar

protected int fMostRecentChar

fLength

protected int fLength

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

UTF8CharReader

UTF8CharReader(XMLEntityHandler entityHandler,
               org.apache.xerces.framework.XMLErrorReporter errorReporter,
               boolean sendCharDataAsCharArray,
               java.io.InputStream dataStream,
               org.apache.xerces.utils.StringPool stringPool)
         throws java.lang.Exception
Method Detail

fillCurrentChunk

protected int fillCurrentChunk()
                        throws java.lang.Exception
Description copied from class: AbstractCharReader
Fill the current chunk the next buffer worth of data. This method should replace any 0xD,0xA sequence with a single 0xA character, and replace single 0xD characters with a 0xA character. This is described in the spec under section 2.11, "End-of-Line Handling".

Specified by:
fillCurrentChunk in class AbstractCharReader

copyNormalize

private boolean copyNormalize(byte[] in,
                              int inOffset,
                              char[] out,
                              int outOffset)
                       throws java.lang.Exception

exitNormalize

private boolean exitNormalize(int inOffset,
                              int outOffset,
                              boolean result)

savePartialMultiByte

private void savePartialMultiByte(int inCount,
                                  byte bz,
                                  byte by,
                                  byte bx)

savePartialMultiByte

private void savePartialMultiByte(int inCount,
                                  byte bz,
                                  byte by)

savePartialMultiByte

private void savePartialMultiByte(int inCount,
                                  byte bz)

handleMultiByteChar

private boolean handleMultiByteChar(byte b,
                                    byte[] in,
                                    int inOffset,
                                    int inEnd,
                                    char[] out,
                                    int outOffset,
                                    int outEnd)
                             throws java.lang.Exception

handlePartialMultiByteChar

private boolean handlePartialMultiByteChar(byte b,
                                           byte[] in,
                                           int inOffset,
                                           int inEnd,
                                           char[] out,
                                           int outOffset,
                                           int outEnd)
                                    throws java.lang.Exception

deferException

protected void deferException(int errorCode,
                              java.lang.Object[] args,
                              int offset)
Delay reporting an error message. If there is an error detected in the underlying input stream during the fillCurrentChunk method, the error is described here and will be reported when we reach that offset during normal processing. The subclass should place a character with a value of zero at that offset, which will be detected here as an invalid character. When the invalid character is scanned, we will generate the deferred exception.


changeReaders

protected XMLEntityHandler.EntityReader changeReaders()
                                               throws java.lang.Exception
Change readers at end of input. We override our superclass method to release the final chunk of the input data before handing off to the next reader.

Overrides:
changeReaders in class XMLEntityReader

append

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


addString

public 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.


addSymbol

public 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.


lookingAtChar

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


lookingAtValidChar

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


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.


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.


skipPastSpaces

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


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.


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.


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.


scanInvalidChar

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


scanCharRef

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


scanStringLiteral

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


scanAttValue

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


scanEntityValue

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


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.


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.


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.


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.


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