public class SGMLParser
extends java.lang.Object
implements java.io.Serializable
SGMLParser parses the SGML document according to
the specified DTD and delivers the sgml events to
the listeners (SGMLParserListeners).
For example:
Reader reader = new BufferedReader(new InputStreamReader(System.in));
DTD dtd = new DTD();
// Setups the dtd.
SGMLParser parser = new SGMLParser(dtd);
parser.addSGMLParserListener(new SGMLParserListener(){});
try {
parser.parse(reader);
}
catch (IOException e) {}
Refers to
"ISO 8879 -- Standard Generalized Markup Language (SGML)".DTD,
SGMLEvent,
SGMLParserListener,
直列化された形式| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected java.lang.StringBuffer |
cdata
The buffer for cdata.
|
protected int |
contentModelType
The current parsing content model type.
|
protected static int |
CR |
protected DTD |
dtd
The DTD.
|
protected Element |
element
The current parsing element.
|
protected java.util.Stack |
elementStack
The elements that nests the current element.
|
protected static int |
EOF |
protected Set |
exclusions
The current parsing exclusions.
|
protected Set |
inclusions
The current parsing inclusions.
|
protected int |
lastChar
The last char parsed.
|
protected static int |
LF |
protected java.util.Vector |
listeners
The listeners of the parser.
|
protected java.io.Reader |
reader
The reader to be parsed.
|
protected java.util.Stack |
readerStack
The stack of readers to parse entities.
|
| コンストラクタと説明 |
|---|
SGMLParser(DTD dtd)
Constructs a sgml parser with the specified dtd.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
protected boolean |
acceptElement(Element elem)
Tests if the current element accepts the specified element.
|
protected boolean |
acceptElementInStack(Element elem)
Tests if the current elements on the stack can accept
the specified element.
|
void |
addSGMLParserListener(SGMLParserListener l)
Adds the specified sgml parser listener to receive sgml events
from this parser.
|
protected boolean |
atEnd()
Tests if the end of the stream is reached.
|
protected void |
cdataParsed(SGMLEvent event)
Delivers the specified cdata parsed event to the listeners.
|
protected void |
checkNewElementAcceptable(Element elem)
Checks whether the specified element is acceptable or not as
a new element.
|
protected SGMLEvent |
createCdataEvent(java.lang.String cdata)
Creates an event object for the cdata parsed.
|
protected SGMLEvent |
createEndTagEvent(Element elem)
Creates an event object for the end tag parsed.
|
protected SGMLEvent |
createFinishedEvent()
Creates an event object for the parsing finished.
|
protected SGMLEvent |
createStartTagEvent(Element elem,
java.util.Hashtable attrs)
Creates an event object for the start tag parsed.
|
protected void |
cro()
Perfroms the action for the character reference open.
|
protected void |
endParse()
Ends the parsing and delivers the parsing finished event.
|
protected void |
endTagCloseAction(Element elem)
Perfroms the action for the end tag closing with the specified element.
|
protected void |
endTagParsed(SGMLEvent event)
Delivers the specified end tag parsed event to the listeners.
|
protected void |
ero()
Perfroms the action for the entity reference open.
|
protected void |
etago()
Perfroms the action for the end tag open.
|
protected void |
fatalError(java.lang.String message)
Reports the fatal error that is not able to be recovered.
|
protected boolean |
isFirstTokenish(int c)
Tests if the specified character is valid for the head of the token.
|
protected boolean |
isTokenish(int c)
Tests if the specified character is valid for the token.
|
protected boolean |
isWhitespace(char c)
Tests if the specified character is ISO-LATIN-1 white space.
|
protected void |
mdo()
Perfroms the action for the markup declaration open.
|
void |
parse(java.io.Reader reader)
Parses the sgml document contained in the specified reader.
|
protected void |
parseCdata()
Parses the #CDATA content model.
|
protected void |
parseElementAttributes(Element elem,
java.util.Hashtable attributes)
Parses the attributes with the specified (parsed) element and appends
the parsed results to the specified attributes.
|
protected void |
parseEmpty()
Parses the empty model.
|
protected void |
parseEndTag(Element elem)
Parses the end tag with the specified (parsed) element.
|
protected void |
parseError(java.lang.String message)
Reports the parsing error that is able to be recovered.
|
protected void |
parseRcdata()
Parses the #RCDATA content model.
|
protected void |
parseStartTag(Element elem)
Parses the start tag with the specified (parsed) element.
|
protected void |
parsingFinished(SGMLEvent event)
Delivers the specified parsing finished event to the listeners.
|
protected int |
peekChar()
Peeks the character from the reader.
|
protected boolean |
peekEtago()
Tests if the next character is the end tag close.
|
protected boolean |
peekRe()
Tests if the next character is the record end.
|
protected boolean |
peekRefc()
Tests if the next character is the reference close.
|
protected boolean |
peekTagc()
Tests if the next character is the tag close.
|
protected boolean |
peekTago()
Tests if the next character is the tag open.
|
protected void |
pio()
Perfroms the action for the process instruction open.
|
protected Element |
popElement(SGMLEvent event)
Pops the element and delivers the end tag parsed event.
|
protected void |
popReader()
Pops the reader at the ending of the entity reference.
|
protected void |
pushElement(Element elem,
SGMLEvent event)
Pushs the element and delivers the start tag parsed event.
|
protected void |
pushReader(java.io.Reader r)
Pushs the reader at the beginning of the entity reference.
|
protected void |
re()
Perfroms the action for the record end.
|
protected void |
readAction()
Reads and performs the action.
|
protected boolean |
readActionForCdata()
Reads and performs the action for the #CDATA content model.
|
protected boolean |
readActionForRcdata()
Reads and performs the action for the #RCDATA content model.
|
protected boolean |
readAttributeAssignToken()
Reads the assignment token in the attribute.
|
protected java.lang.String |
readAttributeValueToken()
Reads the value token in the attribute.
|
protected void |
readCdata()
Reads the cdata from the reader.
|
protected int |
readChar()
Reads the character from the reader and sets the lastChar to be the
read character.
|
protected java.lang.String |
readSGMLToken()
Reads the sgml token from the reader.
|
protected void |
readToTagc()
Reads the characters to the occurrence (inclusive) of the tag close.
|
void |
removeSGMLParserListener(SGMLParserListener l)
Removes the specified sgml parser listener so it no longer
receives sgml events from this parser.
|
protected void |
resetCdata()
Resets the buffer for the cdata.
|
protected java.lang.String |
skipAndReadSGMLToken()
Skips the separators and the comments, and reads the sgml token.
|
protected void |
skipComment()
Skip the sgml comment (<!
|
protected void |
skipSeparators()
Skip the separators.
|
protected void |
skipSeparatorsAndComments()
Skip the separators and comments.
|
protected void |
skipToTagc()
Skips to the occurrence (inclusive) of the tag close.
|
protected void |
stago()
Perfroms the action for the start tag open.
|
protected void |
startParse()
Starts the parsing.
|
protected void |
startTagParsed(SGMLEvent event)
Delivers the specified start tag parsed event to the listeners.
|
protected java.lang.String |
trimLastRe(java.lang.String str)
Trims the last record end of the specified string.
|
protected java.lang.String |
upTo(int c)
Reads the characters to the occurrence (exclusive) of the specified
character.
|
protected java.lang.String |
upToSeparators()
Reads the characters to the occurrence (exclusive) of the non
separator character.
|
protected void |
writeCdataAtEnd(boolean atEndTag)
Flushs the buffer for the cdata and delivers the cdata parsed events.
|
protected void |
writeCro() |
protected void |
writeEro() |
protected void |
writeEtago() |
protected void |
writeMdo() |
protected void |
writePio() |
protected void |
writeRe() |
protected void |
writeRefc() |
protected void |
writeStago() |
protected void |
writeTagc() |
protected DTD dtd
protected transient java.util.Vector listeners
protected int lastChar
protected transient java.io.Reader reader
protected transient java.util.Stack readerStack
protected java.lang.StringBuffer cdata
protected int contentModelType
protected Element element
protected java.util.Stack elementStack
protected Set inclusions
protected Set exclusions
protected static final int CR
protected static final int LF
protected static final int EOF
public SGMLParser(DTD dtd)
dtd - the specified dtd.public void addSGMLParserListener(SGMLParserListener l)
l - the sgml parser listenerpublic void removeSGMLParserListener(SGMLParserListener l)
l - the sgml parser listenerprotected void startTagParsed(SGMLEvent event) throws java.io.IOException
java.io.IOExceptionprotected void endTagParsed(SGMLEvent event) throws java.io.IOException
java.io.IOExceptionprotected void cdataParsed(SGMLEvent event) throws java.io.IOException
java.io.IOExceptionprotected void parsingFinished(SGMLEvent event) throws java.io.IOException
java.io.IOExceptionpublic void parse(java.io.Reader reader)
throws java.io.IOException
reader - the reader that contains the sgml document.java.io.IOException - If an I/O error occurs.protected void startParse()
throws java.io.IOException
java.io.IOExceptionprotected void endParse()
throws java.io.IOException
java.io.IOExceptionprotected void parseStartTag(Element elem) throws java.io.IOException
java.io.IOExceptionprotected void parseEndTag(Element elem) throws java.io.IOException
java.io.IOExceptionprotected void parseElementAttributes(Element elem, java.util.Hashtable attributes) throws java.io.IOException
java.io.IOExceptionprotected void endTagCloseAction(Element elem) throws java.io.IOException
java.io.IOExceptionprotected void parseError(java.lang.String message)
protected void fatalError(java.lang.String message)
protected final void cro()
throws java.io.IOException
java.io.IOExceptionprotected void ero()
throws java.io.IOException
java.io.IOExceptionprotected void etago()
throws java.io.IOException
java.io.IOExceptionprotected final void mdo()
throws java.io.IOException
java.io.IOExceptionprotected final void pio()
throws java.io.IOException
java.io.IOExceptionprotected final void re()
throws java.io.IOException
java.io.IOExceptionprotected void stago()
throws java.io.IOException
java.io.IOExceptionprotected final void parseEmpty()
throws java.io.IOException
java.io.IOExceptionprotected final void parseCdata()
throws java.io.IOException
java.io.IOExceptionprotected final void parseRcdata()
throws java.io.IOException
java.io.IOExceptionprotected final boolean atEnd()
protected final boolean isFirstTokenish(int c)
protected final boolean isTokenish(int c)
protected final int readChar()
throws java.io.IOException
java.io.IOExceptionprotected final int peekChar()
throws java.io.IOException
java.io.IOExceptionprotected final void readCdata()
throws java.io.IOException
java.io.IOExceptionprotected final void readToTagc()
throws java.io.IOException
java.io.IOExceptionprotected final java.lang.String readSGMLToken()
throws java.io.IOException
java.io.IOExceptionprotected final java.lang.String skipAndReadSGMLToken()
throws java.io.IOException
java.io.IOExceptionprotected final void readAction()
throws java.io.IOException
java.io.IOExceptionprotected final boolean readActionForCdata()
throws java.io.IOException
java.io.IOExceptionprotected final boolean readActionForRcdata()
throws java.io.IOException
java.io.IOExceptionprotected final boolean readAttributeAssignToken()
throws java.io.IOException
java.io.IOExceptionprotected final java.lang.String readAttributeValueToken()
throws java.io.IOException
java.io.IOExceptionprotected final boolean peekEtago()
throws java.io.IOException
java.io.IOExceptionprotected final boolean peekRe()
throws java.io.IOException
java.io.IOExceptionprotected final boolean peekRefc()
throws java.io.IOException
java.io.IOExceptionprotected final boolean peekTagc()
throws java.io.IOException
java.io.IOExceptionprotected final boolean peekTago()
throws java.io.IOException
java.io.IOExceptionprotected final void skipComment()
throws java.io.IOException
java.io.IOExceptionprotected final void skipSeparators()
throws java.io.IOException
java.io.IOExceptionprotected final void skipSeparatorsAndComments()
throws java.io.IOException
java.io.IOExceptionprotected final void skipToTagc()
throws java.io.IOException
java.io.IOExceptionprotected final java.lang.String upTo(int c)
throws java.io.IOException
java.io.IOExceptionprotected final java.lang.String upToSeparators()
throws java.io.IOException
java.io.IOExceptionprotected final void resetCdata()
protected final java.lang.String trimLastRe(java.lang.String str)
protected void writeCdataAtEnd(boolean atEndTag)
throws java.io.IOException
java.io.IOExceptionprotected final void writeCro()
protected final void writeEro()
protected final void writeEtago()
protected final void writeMdo()
protected final void writePio()
protected final void writeRe()
protected final void writeRefc()
protected final void writeStago()
protected final void writeTagc()
protected SGMLEvent createStartTagEvent(Element elem, java.util.Hashtable attrs)
protected SGMLEvent createEndTagEvent(Element elem)
protected SGMLEvent createCdataEvent(java.lang.String cdata)
protected SGMLEvent createFinishedEvent()
protected final boolean isWhitespace(char c)
protected final boolean acceptElement(Element elem)
protected final boolean acceptElementInStack(Element elem)
protected final void checkNewElementAcceptable(Element elem) throws java.io.IOException
java.io.IOExceptionprotected final void pushReader(java.io.Reader r)
throws java.io.IOException
java.io.IOExceptionprotected final void popReader()
protected final void pushElement(Element elem, SGMLEvent event) throws java.io.IOException
java.io.IOException