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
- charset
public XMLParser(XMLParserListener listener, Charset charset)
listener
- the listener
charset
- the Charset
public 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 listener
charset
- the Charset to use
public XMLParser(boolean b, XMLParserListener listener)
b
- true if HTML is being parsed
listener
- the XMLParserListener
public XMLParser(XMLParserListener listener)
listener
- the XMLParserListener
public 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 remove
public void parse(InputStream in) throws IOException
in
- the InputStream to parse
IOException
- if IO went wrong
public void parse(InputStream in, boolean detectEncoding) throws IOException
in
- the InputStream to parse
detectEncoding
- true if encoding should be detected from the stream
IOException
- if IO went wrong
public void parse(InputStream in, Charset charSet) throws IOException
in
- the stream to read
charSet
- to use for the constructed reader.
IOException
- if reading fails
public void parse(Reader reader) throws IOException
reader
- the reader
IOException
- if IO went wrong
public InputStreamReader detectEncoding(InputStream in) throws IOException, UnsupportedEncodingException
in
- the stream
IOException
- if IO went wrong
UnsupportedEncodingException
- if unsupported encoding was detected
protected void setState(State state)
state
- the current state
public XMLParser append(char character)
character
- the character to append
public 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 content
public void comment()
public char currentLastChar()
public String currentTag()
public TagState currentTagState()
public void setMonitor(ParserMonitor monitor)
monitor
- the monitor to set
public void setDecodeSpecialChars(boolean decodeSpecialChars)
decodeSpecialChars
- true to decode, false to not decode
public boolean isDecodeSpecialChars()
public String bufferToString()
public XMLParser append(char[] bytes)
bytes
- the byte array to append
public int bufferSize()
public XMLParser append(String string)
string
- the String to append
public Charset getCharset()
Copyright © 1998–2018. All rights reserved.