- java.lang.Object
-
- com.sun.xml.dtdparser.InputEntity
-
public class InputEntity extends java.lang.ObjectThis is how the parser talks to its input entities, of all kinds. The entities are in a stack.For internal entities, the character arrays are referenced here, and read from as needed (they're read-only). External entities have mutable buffers, that are read into as needed.
Note: This maps CRLF (and CR) to LF without regard for whether it's in an external (parsed) entity or not. The XML 1.0 spec is inconsistent in explaining EOL handling; this is the sensible way.
-
-
Field Summary
Fields Modifier and Type Field Description private char[]bufprivate static intBUFSIZprivate DTDEventListenererrHandlerprivate intfinishprivate org.xml.sax.InputSourceinputprivate booleanisClosedprivate booleanisPEprivate intlineNumberprivate java.util.Localelocaleprivate booleanmaybeInCRLFprivate java.lang.Stringnameprivate static char[]newlineprivate InputEntitynextprivate java.io.Readerreaderprivate java.lang.StringBufferrememberedTextprivate booleanreturnedFirstHalfprivate intstartprivate intstartRemember
-
Constructor Summary
Constructors Modifier Constructor Description privateInputEntity()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckRecursion(InputEntity stack)private booleancheckSurrogatePair(int offset)voidclose()private voidfatal(java.lang.String messageId, java.lang.Object[] params)private voidfillbuf()chargetc()gets the next Java character -- might be part of an XML text character represented by a surrogate pair, or be the end of the entity.intgetColumnNumber()returns -1; maintaining column numbers hurts performancejava.lang.StringgetEncoding()Returns the name of the encoding in use, else null; the name returned is in as standard a form as we can get.static InputEntitygetInputEntity(DTDEventListener h, java.util.Locale l)intgetLineNumber()Returns the current line number in this input sourcejava.lang.StringgetName()chargetNameChar()returns the next name char, or NUL ...java.lang.StringgetPublicId()Returns the public ID of this input source, if knownjava.lang.StringgetSystemId()Returns the system ID of this input source, if knownprivate InputEntitygetTopEntity()booleanignorableWhitespace(DTDEventListener handler)whitespace in markup (flagged to app, discard-able)voidinit(char[] b, java.lang.String name, InputEntity stack, boolean isPE)voidinit(org.xml.sax.InputSource in, java.lang.String name, InputEntity stack, boolean isPE)booleanisDocument()booleanisEOF()returns true iff there's no more data to consume ...booleanisInternal()booleanisParameterEntity()booleanmaybeWhitespace()optional grammatical whitespace (discarded)booleanparsedContent(DTDEventListener docHandler)normal content; whitespace in markup may be handled specially if the parser uses the content model.booleanpeek(java.lang.String next, char[] chars)returns false iff 'next' string isn't as provided, else skips that text and returns true.booleanpeekc(char c)lookahead one characterInputEntitypop()java.lang.StringrememberText()voidstartRemembering()voidungetc()two character pushback is guaranteedbooleanunparsedContent(DTDEventListener docHandler, boolean ignorableWhitespace, java.lang.String whitespaceInvalidMessage)CDATA -- character data, terminated by"]]>"and optionally including unescaped markup delimiters (ampersand and left angle bracket).
-
-
-
Field Detail
-
start
private int start
-
finish
private int finish
-
buf
private char[] buf
-
lineNumber
private int lineNumber
-
returnedFirstHalf
private boolean returnedFirstHalf
-
maybeInCRLF
private boolean maybeInCRLF
-
name
private java.lang.String name
-
next
private InputEntity next
-
input
private org.xml.sax.InputSource input
-
reader
private java.io.Reader reader
-
isClosed
private boolean isClosed
-
errHandler
private DTDEventListener errHandler
-
locale
private java.util.Locale locale
-
rememberedText
private java.lang.StringBuffer rememberedText
-
startRemember
private int startRemember
-
isPE
private boolean isPE
-
BUFSIZ
private static final int BUFSIZ
- See Also:
- Constant Field Values
-
newline
private static final char[] newline
-
-
Method Detail
-
getInputEntity
public static InputEntity getInputEntity(DTDEventListener h, java.util.Locale l)
-
isInternal
public boolean isInternal()
-
isDocument
public boolean isDocument()
-
isParameterEntity
public boolean isParameterEntity()
-
getName
public java.lang.String getName()
-
init
public void init(org.xml.sax.InputSource in, java.lang.String name, InputEntity stack, boolean isPE) throws java.io.IOException, org.xml.sax.SAXException- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
init
public void init(char[] b, java.lang.String name, InputEntity stack, boolean isPE) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
checkRecursion
private void checkRecursion(InputEntity stack) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
pop
public InputEntity pop() throws java.io.IOException
- Throws:
java.io.IOException
-
isEOF
public boolean isEOF() throws java.io.IOException, org.xml.sax.SAXExceptionreturns true iff there's no more data to consume ...- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
getEncoding
public java.lang.String getEncoding()
Returns the name of the encoding in use, else null; the name returned is in as standard a form as we can get.- Returns:
- the name of the encoding in use
-
getNameChar
public char getNameChar() throws java.io.IOException, org.xml.sax.SAXExceptionreturns the next name char, or NUL ... faster than getc(), and the common "name or nmtoken must be next" case won't need ungetc().- Returns:
- the next name char, or NUL
- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
getc
public char getc() throws java.io.IOException, org.xml.sax.SAXExceptiongets the next Java character -- might be part of an XML text character represented by a surrogate pair, or be the end of the entity.- Returns:
- the next Java character
- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
peekc
public boolean peekc(char c) throws java.io.IOException, org.xml.sax.SAXExceptionlookahead one character- Parameters:
c- character to lookahead- Returns:
- true if found
- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
ungetc
public void ungetc()
two character pushback is guaranteed
-
maybeWhitespace
public boolean maybeWhitespace() throws java.io.IOException, org.xml.sax.SAXExceptionoptional grammatical whitespace (discarded)- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
parsedContent
public boolean parsedContent(DTDEventListener docHandler) throws java.io.IOException, org.xml.sax.SAXException
normal content; whitespace in markup may be handled specially if the parser uses the content model.content terminates with markup delimiter characters, namely ampersand (&) and left angle bracket (<).
the document handler's characters() method is called on all the content found
- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
unparsedContent
public boolean unparsedContent(DTDEventListener docHandler, boolean ignorableWhitespace, java.lang.String whitespaceInvalidMessage) throws java.io.IOException, org.xml.sax.SAXException
CDATA -- character data, terminated by"]]>"and optionally including unescaped markup delimiters (ampersand and left angle bracket). This should otherwise be exactly like character data, modulo differences in error report details.The document handler's characters() or ignorableWhitespace() methods are invoked on all the character data found
- Parameters:
docHandler- gets callbacks for character dataignorableWhitespace- if true, whitespace characters will be reported using docHandler.ignorableWhitespace(); implicitly, non-whitespace characters will cause validation errorswhitespaceInvalidMessage- if true, ignorable whitespace causes a validity error report as well as a callback- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
checkSurrogatePair
private boolean checkSurrogatePair(int offset) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public boolean ignorableWhitespace(DTDEventListener handler) throws java.io.IOException, org.xml.sax.SAXException
whitespace in markup (flagged to app, discard-able)the document handler's ignorableWhitespace() method is called on all the whitespace found
- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
peek
public boolean peek(java.lang.String next, char[] chars) throws java.io.IOException, org.xml.sax.SAXExceptionreturns false iff 'next' string isn't as provided, else skips that text and returns true.NOTE: two alternative string representations are both passed in, since one is faster.
- Returns:
- false iff 'next' string isn't as provided
- Throws:
java.io.IOException- for errorsorg.xml.sax.SAXException- for errors
-
startRemembering
public void startRemembering()
-
rememberText
public java.lang.String rememberText()
-
getTopEntity
private InputEntity getTopEntity()
-
getPublicId
public java.lang.String getPublicId()
Returns the public ID of this input source, if known- Returns:
- the public ID of this input source
-
getSystemId
public java.lang.String getSystemId()
Returns the system ID of this input source, if known- Returns:
- the system ID of this input source
-
getLineNumber
public int getLineNumber()
Returns the current line number in this input source- Returns:
- the current line number
-
getColumnNumber
public int getColumnNumber()
returns -1; maintaining column numbers hurts performance- Returns:
- -1
-
fillbuf
private void fillbuf() throws java.io.IOException, org.xml.sax.SAXException- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
close
public void close()
-
fatal
private void fatal(java.lang.String messageId, java.lang.Object[] params) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
-