public class XmlUtilImpl extends AbstractComponent implements XmlUtil
DomUtilImpl| Modifier and Type | Field and Description |
|---|---|
private static Map<String,Character> |
ENTITY_MAP |
private static XmlUtil |
instance |
NAMESPACE_PREFIX_SCHEMA, NAMESPACE_PREFIX_SCHEMA_INSTANCE, NAMESPACE_PREFIX_SVG, NAMESPACE_PREFIX_XHTML, NAMESPACE_PREFIX_XINCLUDE, NAMESPACE_PREFIX_XLINK, NAMESPACE_PREFIX_XML, NAMESPACE_PREFIX_XML_EVENTS, NAMESPACE_PREFIX_XMLNS, NAMESPACE_PREFIX_XPATH_FUNCTIONS, NAMESPACE_PREFIX_XSLT, NAMESPACE_URI_MATHML, NAMESPACE_URI_RELAXNG_ANNOTATION, NAMESPACE_URI_RELAXNG_STRUCTURE, NAMESPACE_URI_SCHEMA, NAMESPACE_URI_SCHEMA_INSTANCE, NAMESPACE_URI_SVG, NAMESPACE_URI_XHTML, NAMESPACE_URI_XINCLUDE, NAMESPACE_URI_XLINK, NAMESPACE_URI_XML, NAMESPACE_URI_XML_EVENTS, NAMESPACE_URI_XMLNS, NAMESPACE_URI_XPATH_FUNCTIONS, NAMESPACE_URI_XSLT| Constructor and Description |
|---|
XmlUtilImpl()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Reader |
createXmlReader(InputStream inputStream)
This method creates a
Reader from the given inputStream that uses the encoding specified
in the (potential) XML header of the InputStreams content. |
Reader |
createXmlReader(InputStream inputStream,
Charset defaultCharset)
This method creates a
Reader from the given inputStream that uses the encoding specified
in the (potential) XML header of the InputStreams content. |
String |
escapeXml(String string,
boolean escapeQuotations)
This method escapes the given
string for usage in XML (or HTML, etc.). |
void |
escapeXml(String string,
Writer writer,
boolean escapeQuotations)
This method writes the given
string to the writer while escaping special characters for
XML (or HTML, etc.). |
ParserState |
extractPlainText(String htmlFragment,
StringBuilder buffer,
ParserState parserState)
This method extracts the plain text from the given
htmlFragment and appends it to the given
buffer. |
static XmlUtil |
getInstance()
This method gets the singleton instance of this
XmlUtilImpl. |
Character |
resolveEntity(String entityName)
This method resolves an HTML entity given by
entityName. |
doInitialize, doInitialized, getInitializationState, initializeprivate static XmlUtil instance
public static XmlUtil getInstance()
XmlUtilImpl. Cdi.GET_INSTANCE before using.public Reader createXmlReader(InputStream inputStream)
XmlUtilReader from the given inputStream that uses the encoding specified
in the (potential) XML header of the InputStreams content. If no XML header is specified, the
default encoding is used.createXmlReader in interface XmlUtilinputStream - is a fresh input-stream that is supposed to point to the content of an XML document.inputStream that takes respect on the encoding specified in the
(potential) XML header.public Reader createXmlReader(InputStream inputStream, Charset defaultCharset)
XmlUtilReader from the given inputStream that uses the encoding specified
in the (potential) XML header of the InputStreams content. If no XML header is specified, the
default encoding is used.createXmlReader in interface XmlUtilinputStream - is a fresh input-stream that is supposed to point to the content of an XML document.defaultCharset - is the Charset used if NO encoding was specified via an XML header.inputStream that takes respect on the encoding specified in the
(potential) XML header.public String escapeXml(String string, boolean escapeQuotations)
XmlUtilstring for usage in XML (or HTML, etc.).escapeXml in interface XmlUtilstring - is the string to escape.escapeQuotations - if true also the ASCII quotation characters (apos '\'' and quot
'"' ) will be escaped, else if false quotations are untouched. Set this to
true if you are writing the value of an attribute.public void escapeXml(String string, Writer writer, boolean escapeQuotations)
XmlUtilstring to the writer while escaping special characters for
XML (or HTML, etc.).escapeXml in interface XmlUtilstring - is the string to escape.writer - is where to write the string to.escapeQuotations - if true also the ASCII quotation characters (apos '\'' and quot
'"' ) will be escaped, else if false quotations are untouched. Set this to
true if you are writing the value of an attribute.public Character resolveEntity(String entityName)
XmlUtilentityName.resolveEntity in interface XmlUtilentityName - is the bare name of the entity (e.g. "amp" or "uuml"). Please note that entity-names
are case-sensitive.null if no entity exists for the given entityName.public ParserState extractPlainText(String htmlFragment, StringBuilder buffer, ParserState parserState)
XmlUtilhtmlFragment and appends it to the given
buffer. This includes removing tags, un-escaping entities and parsing CDATA sections. Unlike DOM
parsers this method is completely fault tolerant, fast and uses a minimum amount of memory. extractPlainText in interface XmlUtilhtmlFragment - is the HTML fragment to parse.buffer - is the buffer where the plain text will be appended to.parserState - is the state to continue on a subsequent call for multiple htmlFragments of
the same HTML-document or null for a fresh start.htmlFragment. You can pass this as parserState argument
on subsequent call to continue parsing.Copyright © 2001–2016 mmm-Team. All rights reserved.