|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.pdf.SimpleXMLParser
A simple XML and HTML parser. This parser is, like the SAX parser, an event based parser, but with much less functionality.
The parser can:
<[CDATA[ ... ]]>
construct
\r\n
and \r
to \n
on input, in accordance with the XML Specification, Section 2.11
The code is based on http://www.javaworld.com/javaworld/javatips/javatip128/ with some extra code from XERCES to recognize the encoding.
Field Summary | |
---|---|
private static int |
ATTRIBUTE_EQUAL
|
private static int |
ATTRIBUTE_LVALUE
|
private static int |
ATTRIBUTE_RVALUE
|
private static int |
CDATA
|
private static int |
CLOSE_TAG
|
private static int |
COMMENT
|
private static int |
DOCTYPE
|
private static int |
DONE
|
private static int |
ENTITY
|
private static HashMap |
entityMap
|
private static HashMap |
fIANA2JavaMap
|
private static int |
IN_TAG
|
private static int |
OPEN_TAG
|
private static int |
PRE
|
private static int |
QUOTE
|
private static int |
SINGLE_TAG
|
private static int |
START_TAG
|
private static int |
TEXT
|
Constructor Summary | |
---|---|
private |
SimpleXMLParser()
|
Method Summary | |
---|---|
static char |
decodeEntity(String s)
|
static String |
escapeXML(String s,
boolean onlyASCII)
Escapes a string with the appropriated XML codes. |
private static void |
exc(String s,
int line,
int col)
|
private static String |
getDeclaredEncoding(String decl)
|
private static String |
getEncodingName(byte[] b4)
|
static String |
getJavaEncoding(String iana)
Gets the java encoding from the IANA encoding. |
static void |
parse(SimpleXMLDocHandler doc,
InputStream in)
Parses the XML document firing the events to the handler. |
static void |
parse(SimpleXMLDocHandler doc,
Reader r)
|
static void |
parse(SimpleXMLDocHandler doc,
SimpleXMLDocHandlerComment comment,
Reader r,
boolean html)
Parses the XML document firing the events to the handler. |
private static int |
popMode(Stack st)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final HashMap fIANA2JavaMap
private static final HashMap entityMap
private static final int TEXT
private static final int ENTITY
private static final int OPEN_TAG
private static final int CLOSE_TAG
private static final int START_TAG
private static final int ATTRIBUTE_LVALUE
private static final int ATTRIBUTE_EQUAL
private static final int ATTRIBUTE_RVALUE
private static final int QUOTE
private static final int IN_TAG
private static final int SINGLE_TAG
private static final int COMMENT
private static final int DONE
private static final int DOCTYPE
private static final int PRE
private static final int CDATA
Constructor Detail |
private SimpleXMLParser()
Method Detail |
private static int popMode(Stack st)
public static void parse(SimpleXMLDocHandler doc, InputStream in) throws IOException
doc
- the document handlerin
- the document. The encoding is deduced from the stream. The stream is not closed
IOException
- on errorprivate static String getDeclaredEncoding(String decl)
public static String getJavaEncoding(String iana)
iana
- the IANA encoding
public static void parse(SimpleXMLDocHandler doc, Reader r) throws IOException
IOException
public static void parse(SimpleXMLDocHandler doc, SimpleXMLDocHandlerComment comment, Reader r, boolean html) throws IOException
doc
- the document handlerr
- the document. The encoding is already resolved. The reader is not closed
IOException
- on errorprivate static void exc(String s, int line, int col) throws IOException
IOException
public static String escapeXML(String s, boolean onlyASCII)
s
- the string to be escapedonlyASCII
- codes above 127 will always be escaped with &#nn; if true
public static char decodeEntity(String s)
private static String getEncodingName(byte[] b4)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |