|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sap.tc.mobile.cfs.xml.api.MIXMLParser
public class MIXMLParser
MI-private non-checking fast XML parser.
| Nested Class Summary | |
|---|---|
static class |
MIXMLParser.CopyToWriterContentHandler
This class wrapps any MIContentHandler and copies
the xml into a writer (if set) after calling the wrapper. |
| Field Summary | |
|---|---|
protected MIContentHandler |
contentHandler
The ContentHandler that will receive the events |
protected static Location |
logger
Logger for messages. |
| Constructor Summary | |
|---|---|
MIXMLParser()
Constructor. |
|
| Method Summary | |
|---|---|
protected void |
checkNameChar(char c,
boolean isFirst)
Check if character is name character. |
protected static char[] |
doubleLength(char[] characterArray)
Creates a new char array with the same entries as the original one but the double length. |
MIContentHandler |
getContentHandler()
Get content handler of this parser. |
protected char |
nextChar()
Get next character from input buffer. |
void |
parse(java.io.InputStream inputStream)
Parse data from input stream (utf-8 encoding). |
void |
parse(java.io.Reader reader)
Parse data from reader (encoding given by reader). |
void |
setContentHandler(MIContentHandler contentHandler)
Set content handler for this parser. |
void |
setWriter(java.io.Writer writer)
Set a writer to copy the xml into. |
protected char |
skipWS(char readCharacter)
Skip whitespace. |
void |
stopParsing()
Stops parsing after current element is finished. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Location logger
protected MIContentHandler contentHandler
| Constructor Detail |
|---|
public MIXMLParser()
| Method Detail |
|---|
public void setContentHandler(MIContentHandler contentHandler)
contentHandler - new content handler.public MIContentHandler getContentHandler()
public void stopParsing()
public void parse(java.io.InputStream inputStream)
inputStream - stream to parse.public void parse(java.io.Reader reader)
reader - reader to parse.public void setWriter(java.io.Writer writer)
MIContentHandler
is called. To unset the writer you need to pass null
as agrument to this method.
final MIContentHandler contentHandler = new MIContentHandler(){
private boolean startWriter = false;
public void endAttributes() {
if(this.startWriter){
parser.setWriter(writer);
this.startWriter = false;
}
}
public void startElement(char[] localName, int start, int length) {
if(MIXMLTools.equals(localName, start, length, "writerTest")){
this.startWriter = true;
}
}
public void endElement(char[] localName, int start, int length) {
if(MIXMLTools.equals(localName, start, length, "writerTest")){
parser.setWriter(null);
}
}
public void endDocument() {
writer.flush();
}
public void characters(char[] ch, int start, int length) {}
public void attribute(char[] name, int startName, int lengthName, char[] value, int startValue, int lengthValue) {}
public void startDocument() {}
}
If there are any IO Exception while writing to the writer
the parser will throw a RuntimeException.
writer - the Writer to copy the xml into or null
to end the copying process and unset the writer.protected final char skipWS(char readCharacter)
readCharacter - read character that might be whitespace.
protected final char nextChar()
protected static char[] doubleLength(char[] characterArray)
characterArray -
protected void checkNameChar(char c,
boolean isFirst)
c - character to check.isFirst - if true, check for first name character.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||