public class XMLParser extends Object
XMLParserListener
for receiving events.Constructor and Description |
---|
XMLParser()
Constructs a default XMLParser ready for HTML/XHTML processing.
|
XMLParser(boolean isHtml,
Charset charset)
Constructs a XMLParser.
|
XMLParser(boolean b,
XMLParserListener listener)
Constructs a new Parser with the default jvm charset.
|
XMLParser(boolean isHtml,
XMLParserListener listener,
Charset charset)
Construct a XMLParser with the given XMLParserConfig.
|
XMLParser(XMLParserListener listener)
Constructs a new Parser with HTML parsing set to true and the default jvm charset.
|
XMLParser(XMLParserListener listener,
Charset charset)
Construct an XMLParser with the given XMLParserConfig ready for
HTML/XHTML processing..
|
Modifier and Type | Method and Description |
---|---|
XMLParser |
addListener(XMLParserListener pl)
If no
ParserListener is added, parsing with the parser seems
useless no? |
XMLParser |
append(char character) |
XMLParser |
append(char[] bytes) |
XMLParser |
append(String string)
Appends the given string to the buffer.
|
int |
bufferSize() |
String |
bufferToString() |
void |
comment()
Triggered for comments.
|
String |
current()
Returns the current content of the text buffer.
|
char |
currentLastChar() |
String |
currentTag()
Get the current tag
|
TagState |
currentTagState()
Get the state of the current tag
|
InputStreamReader |
detectEncoding(InputStream in)
Detects encoding from a stream.
|
void |
endElement()
Triggered when a closing tag has been encountered.
|
void |
flush()
Flushes the currently stored data in the buffer.
|
Charset |
getCharset()
Returns the current used character set.
|
boolean |
isDecodeSpecialChars() |
XMLParserMemory |
memory()
Returns the XMLParserMemory.
|
void |
parse(InputStream in)
Parse an InputStream with default encoding set
|
void |
parse(InputStream in,
boolean detectEncoding)
Parse an InputStream that optionally detects encoding from the stream
|
void |
parse(InputStream in,
Charset charSet)
Parses an InputStream using the given encoding
|
void |
parse(Reader reader)
Parse an Reader
|
XMLParser |
removeListener(XMLParserListener pl)
Removes a Listener from the list of listeners.
|
StateController |
selectState()
The state controller of the parser
|
void |
setDecodeSpecialChars(boolean decodeSpecialChars)
Determines whether special chars like > will be decoded
|
void |
setMonitor(ParserMonitor monitor) |
protected void |
setState(State state)
Set the current state.
|
void |
startElement()
Triggered when an opening tag has been encountered.
|
void |
text(String bs)
Triggered when content has been encountered.
|
void |
unknownData()
Triggered when the UnknownState encountered anything before encountering
a tag.
|
public XMLParser()
public XMLParser(boolean isHtml, Charset charset)
isHtml
- false if this parser is not going to parse HTML and
whitespace should be submitted as text too.charset
- charsetpublic XMLParser(XMLParserListener listener, Charset charset)
listener
- the listenercharset
- the Charsetpublic XMLParser(boolean isHtml, XMLParserListener listener, Charset charset)
isHtml
- false if this parser is not going to parse HTML and
whitespace should be submitted as text too.listener
- the listenercharset
- the Charset to usepublic XMLParser(boolean b, XMLParserListener listener)
b
- true if HTML is being parsedlistener
- the XMLParserListenerpublic XMLParser(XMLParserListener listener)
listener
- the XMLParserListenerpublic XMLParser addListener(XMLParserListener pl)
ParserListener
is added, parsing with the parser seems
useless no?pl
- the XMLParserListener
public XMLParser removeListener(XMLParserListener pl)
pl
- the XMLParserListener
to removepublic void parse(InputStream in) throws IOException
in
- the InputStream to parseIOException
- if IO went wrongpublic void parse(InputStream in, boolean detectEncoding) throws IOException
in
- the InputStream to parsedetectEncoding
- true if encoding should be detected from the streamIOException
- if IO went wrongpublic void parse(InputStream in, Charset charSet) throws IOException
in
- the stream to readcharSet
- to use for the constructed reader.IOException
- if reading failspublic void parse(Reader reader) throws IOException
reader
- the readerIOException
- if IO went wrongpublic InputStreamReader detectEncoding(InputStream in) throws IOException, UnsupportedEncodingException
in
- the streamIOException
- if IO went wrongUnsupportedEncodingException
- if unsupported encoding was detectedprotected void setState(State state)
state
- the current statepublic XMLParser append(char character)
character
- the character to appendpublic StateController selectState()
StateController
public void unknownData()
public void flush()
public String current()
public XMLParserMemory memory()
public void startElement()
public void endElement()
public void text(String bs)
bs
- the contentpublic void comment()
public char currentLastChar()
public String currentTag()
public TagState currentTagState()
public void setMonitor(ParserMonitor monitor)
monitor
- the monitor to setpublic void setDecodeSpecialChars(boolean decodeSpecialChars)
decodeSpecialChars
- true to decode, false to not decodepublic boolean isDecodeSpecialChars()
public String bufferToString()
public XMLParser append(char[] bytes)
bytes
- the byte array to appendpublic int bufferSize()
public XMLParser append(String string)
string
- the String to appendpublic Charset getCharset()
Copyright © 2017. All rights reserved.