|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.apache.xerces.readers.XMLEntityReader | +--org.enhydra.apache.xerces.readers.UTF8Reader
This is the primary reader used for UTF-8 encoded byte streams.
This reader processes requests from the scanners against the underlying UTF-8 byte stream, avoiding when possible any up-front transcoding. When the StringPool handle interfaces are used, the information in the data stream will be added to the string pool and lazy-evaluated until asked for.
We use the SymbolCache to match expected names (element types in end tags) and walk the data structures of that class directly.
There is a significant amount of hand-inlining and some blatant voilation of good object oriented programming rules, ignoring boundaries of modularity, etc., in the name of good performance.
There are also some places where the code here frequently crashes the SUN java runtime compiler (JIT) and the code here has been carefully "crafted" to avoid those problems.
Field Summary | |
static byte[] |
fgAsciiAttValueChar
|
static byte[] |
fgAsciiEntityValueChar
|
Fields inherited from class org.enhydra.apache.xerces.readers.XMLEntityReader |
fCarriageReturnCounter, fCharacterCounter, fCharDataHandler, fCurrentOffset, fEntityHandler, fErrorReporter, fInCDSect, fLinefeedCounter, fSendCharDataAsCharArray |
Constructor Summary | |
UTF8Reader(XMLEntityHandler entityHandler,
XMLErrorReporter errorReporter,
boolean sendCharDataAsCharArray,
InputStream dataStream,
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 . |
XMLEntityHandler.EntityReader |
changeReaders()
This method is called by the reader subclasses at the end of input. |
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. |
int |
scanAttValue(char qchar,
boolean asSymbol)
Scan an attribute value. |
int |
scanCharRef(boolean hex)
Scan a character reference. |
int |
scanContent(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,
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,
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 |
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. |
protected boolean |
skippedMultiByteCharWithFlag(int b0,
int flag)
|
boolean |
skippedString(char[] s)
Skip past a sequence of characters that matches the specified character array. |
void |
skipToChar(char ch)
Advance through the input data up to the next ch character. |
Methods inherited from class org.enhydra.apache.xerces.readers.XMLEntityReader |
currentOffset, getColumnNumber, getInCDSect, getLineNumber, init, setInCDSect |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final byte[] fgAsciiAttValueChar
public static final byte[] fgAsciiEntityValueChar
Constructor Detail |
public UTF8Reader(XMLEntityHandler entityHandler, XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, InputStream dataStream, StringPool stringPool) throws Exception
Method Detail |
public int addString(int offset, int length)
XMLEntityHandler.EntityReader
StringPool
from the characters scanned using this
reader as described by offset
and length
.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
offset
- The offset within this reader where the characters start.length
- The length within this reader where the characters end.StringPool
handle for the string.public int addSymbol(int offset, int length)
XMLEntityHandler.EntityReader
StringPool
from the characters scanned using this
reader as described by offset
and length
.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
offset
- The offset within this reader where the characters start.length
- The length within this reader where the characters end.StringPool
handle for the symbol.public void append(XMLEntityHandler.CharBuffer charBuffer, int offset, int length)
XMLEntityHandler.EntityReader
offset
and
length
to the CharBuffer
.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
charBuffer
- The CharBuffer
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.public XMLEntityHandler.EntityReader changeReaders() throws Exception
XMLEntityReader
changeReaders
in class XMLEntityReader
public boolean lookingAtChar(char ch, boolean skipPastChar) throws Exception
XMLEntityHandler.EntityReader
ch
character.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
ch
- The character to match against.skipPastChar
- If true
, we advance past the matched character.true
if the current character is a ch
character;
false
otherwise.Exception
- public boolean lookingAtValidChar(boolean skipPastChar) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
skipPastChar
- If true
, we advance past the valid character.true
if the current character is valid;
false
otherwise.Exception
- public boolean lookingAtSpace(boolean skipPastChar) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
skipPastChar
- If true
, we advance past the whitespace character.true
if the current character is whitespace;
false
otherwise.Exception
- public void skipToChar(char ch) throws Exception
XMLEntityHandler.EntityReader
ch
character.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
ch
- The character to search for.Exception
- public void skipPastSpaces() throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
Exception
- protected boolean skippedMultiByteCharWithFlag(int b0, int flag) throws Exception
public void skipPastName(char fastcheck) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
Exception
- public void skipPastNmtoken(char fastcheck) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
Exception
- public boolean skippedString(char[] s) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
s
- The characters to match.true
if the current character is valid;
false
otherwise.Exception
- public int scanInvalidChar() throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
Exception
- public int scanCharRef(boolean hex) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
Exception
- public int scanStringLiteral() throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
StringPool
handle for the string that
was scanned, or one of the following error codes:
STRINGLIT_RESULT_QUOTE_REQUIRED
STRINGLIT_RESULT_INVALID_CHARException
- public int scanAttValue(char qchar, boolean asSymbol) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
qchar
- The initial quote character, either a single or double quote.StringPool
handle for the string that
was scanned, or one of the following error codes:
ATTVALUE_RESULT_COMPLEX
ATTVALUE_RESULT_LESSTHAN
ATTVALUE_RESULT_INVALID_CHARException
- public int scanEntityValue(int qchar, boolean createString) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
qchar
- The initial quote character, either a single or double quote.StringPool
handle for the string that
was scanned, or one of the following error codes:
ENTITYVALUE_RESULT_FINISHED
ENTITYVALUE_RESULT_REFERENCE
ENTITYVALUE_RESULT_PEREF
ENTITYVALUE_RESULT_INVALID_CHAR
ENTITYVALUE_RESULT_END_OF_INPUTException
- public boolean scanExpectedName(char fastcheck, StringPool.CharArrayRange expectedName) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
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 characters of the name we expect.true
if we scanned the name we expected to find; otherwise
false
if we did not.Exception
- public void scanQName(char fastcheck, QName qname) throws Exception
XMLEntityHandler.EntityReader
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.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
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.
Exception
- public int scanName(char fastcheck) throws Exception
XMLEntityHandler.EntityReader
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.org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
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.StringPool
handle for the name that was scanned,
or -1 if a name was not found at the current position within the input data.Exception
- public int scanContent(QName element) throws Exception
XMLEntityHandler.EntityReader
org.enhydra.apache.xerces.readers.XMLEntityHandler.EntityReader
elementType
- The element type handle in the StringPool.Exception
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |