public class ToHTMLStream extends ToStream
Modifier and Type | Field and Description |
---|---|
static String |
CDATA_CONTINUE
To insert ]]> in a CDATA section by ending the last CDATA section with
]] and starting the next CDATA section with >
|
static String |
CDATA_DELIMITER_CLOSE
The constant "]]>"
|
static String |
CDATA_DELIMITER_OPEN |
static String |
DEFAULT_SAX_SERIALIZER |
static String |
EMPTYSTRING |
static String |
ENTITY_AMP |
static String |
ENTITY_CRLF |
static String |
ENTITY_GT |
static String |
ENTITY_LT |
static String |
ENTITY_QUOT |
protected boolean |
m_inDTD
This flag is set while receiving events from the DTD
|
static String |
XML_PREFIX |
static String |
XMLNS_PREFIX |
static String |
XMLNS_URI |
static String |
XMLVERSION10 |
static String |
XMLVERSION11
Define the XML version.
|
m_cdataStartCalled, m_charInfo, m_disableOutputEscapingStates, m_escaping, m_inDoctype, m_ispreserve, m_isprevtext, m_lineSep, m_lineSepLen, m_lineSepUse, m_preserves, m_spaceBeforeClose
m_attrBuff, m_attributes, m_CdataElems, m_cdataTagOpen, m_charsBuff, m_doctypePublic, m_doctypeSystem, m_doIndent, m_elemContext, m_indentAmount, m_inEntityRef, m_inExternalDTD, m_mediatype, m_needToCallStartDocument, m_prefixMap, m_shouldNotWriteXMLHeader, m_sourceLocator, m_standaloneWasSpecified, m_StringOfCDATASections, m_tracer, m_version, m_writer, PKG_NAME, PKG_PATH
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS
Constructor and Description |
---|
ToHTMLStream()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addUniqueAttribute(String name,
String value,
int flags)
This method is used to add an attribute to the currently open element.
|
void |
attributeDecl(String eName,
String aName,
String type,
String valueDefault,
String value)
This method does nothing.
|
void |
cdata(char[] ch,
int start,
int length)
Receive notification of cdata.
|
void |
characters(char[] chars,
int start,
int length)
Receive notification of character data.
|
protected void |
closeStartTag()
For the enclosing elements starting tag write out out any attributes
followed by ">".
|
void |
comment(char[] ch,
int start,
int length)
Receive notification of an XML comment anywhere in the document.
|
void |
elementDecl(String name,
String model)
This method does nothing.
|
void |
endDocument()
Receive notification of the end of a document.
|
void |
endDTD()
Report the end of DTD declarations.
|
void |
endElement(String elemName)
Receive notification of the end of an element.
|
void |
endElement(String namespaceURI,
String localName,
String name)
Receive notification of the end of an element.
|
void |
entityReference(String name)
Receive notivication of a entityReference.
|
void |
externalEntityDecl(String name,
String publicId,
String systemId)
This method does nothing.
|
static ElemDesc |
getElemDesc(String name)
Get a description of the given element.
|
void |
internalEntityDecl(String name,
String value)
This method does nothing.
|
void |
namespaceAfterStartElement(String prefix,
String uri)
This method is used when a prefix/uri namespace mapping
is indicated after the element was started with a
startElement() and before and endElement().
|
protected void |
processAttribute(Writer writer,
String name,
String value,
ElemDesc elemDesc)
Process an attribute.
|
void |
processAttributes(Writer writer,
int nAttrs)
Process the attributes, which means to write out the currently
collected attributes to the writer.
|
void |
processingInstruction(String target,
String data)
Receive notification of a processing instruction.
|
boolean |
reset()
Try's to reset the super class and reset this class for
re-use, so that you don't need to create a new serializer
(mostly for performance reasons).
|
void |
setOmitMetaTag(boolean bool)
Tells if the formatter should omit the META tag.
|
void |
setOutputFormat(Properties format)
Specifies an output format for this serializer.
|
void |
setSpecialEscapeURLs(boolean bool)
Tells if the formatter should use special URL escaping.
|
protected void |
startDocumentInternal()
Receive notification of the beginning of a document.
|
void |
startDTD(String name,
String publicId,
String systemId)
Report the start of DTD declarations, if any.
|
void |
startElement(String namespaceURI,
String localName,
String name,
Attributes atts)
Receive notification of the beginning of an element.
|
void |
writeAttrString(Writer writer,
String string,
String encoding)
Writes the specified string after substituting specials,
and UTF-16 surrogates for character references
&#xnn . |
void |
writeAttrURI(Writer writer,
String string,
boolean doURLEscaping)
Write the specified string after substituting non ASCII characters,
with
%HH , where HH is the hex of the byte value. |
addAttributeAlways, addCdataSectionElements, characters, charactersRaw, closeCDATA, endCDATA, endNonEscaping, endPrefixMapping, ensureAttributesNamespaceIsDeclared, escapingNotNeeded, firePseudoAttributes, flushPending, flushWriter, getIndentAmount, getOutputFormat, getOutputStream, getWriter, ignorableWhitespace, indent, indent, notationDecl, outputLineSep, serialize, setCdataSectionElements, setContentHandler, setDTDEntityExpansion, setEncoding, setEscaping, setIndentAmount, setLineSepUse, setNewLine, setOutputStream, setTransformer, setWriter, shouldIndent, skippedEntity, startCDATA, startElement, startElement, startEntity, startNonEscaping, startPrefixMapping, startPrefixMapping, unparsedEntityDecl, writeUTF16Surrogate
addAttribute, addAttribute, addAttribute, addAttributes, addXSLAttribute, asContentHandler, asDOM3Serializer, asDOMSerializer, characters, close, comment, documentIsEmpty, endEntity, error, fatalError, fireCDATAEvent, fireCharEvent, fireCommentEvent, fireEndDoc, fireEndElem, fireEndEntity, fireEntityReference, fireEscapingEvent, fireStartDoc, fireStartElem, fireStartEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getLocalName, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputProperty, getOutputPropertyDefault, getOutputPropertyNonDefault, getPrefix, getPrefixPart, getStandalone, getTransformer, getVersion, initCDATA, isCdataSection, patchName, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setIndent, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setStandaloneInternal, setVersion, startDocument, warning
protected boolean m_inDTD
public static final String CDATA_CONTINUE
public static final String CDATA_DELIMITER_CLOSE
public static final String CDATA_DELIMITER_OPEN
public static final String EMPTYSTRING
public static final String ENTITY_AMP
public static final String ENTITY_CRLF
public static final String ENTITY_GT
public static final String ENTITY_LT
public static final String ENTITY_QUOT
public static final String XML_PREFIX
public static final String XMLNS_PREFIX
public static final String XMLNS_URI
public static final String DEFAULT_SAX_SERIALIZER
public static final String XMLVERSION11
public static final String XMLVERSION10
public void setSpecialEscapeURLs(boolean bool)
bool
- True if URLs should be specially escaped with the %xx form.public void setOmitMetaTag(boolean bool)
bool
- True if the META tag should be omitted.public void setOutputFormat(Properties format)
setOutputFormat
in interface Serializer
setOutputFormat
in class ToStream
format
- The output format or serialzation parameters
to use.public static final ElemDesc getElemDesc(String name)
name
- non-null name of element, case insensitive.protected void startDocumentInternal() throws SAXException
startDocumentInternal
in class SerializerBase
SAXException
- Any SAX exception, possibly
wrapping another exception.SAXException
public final void endDocument() throws SAXException
SAXException
- Any SAX exception, possibly
wrapping another exception.SAXException
public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXException
startElement
in interface ContentHandler
startElement
in class ToStream
namespaceURI
- localName
- name
- The element type name.atts
- The attributes attached to the element, if any.SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(java.lang.String, java.lang.String, java.lang.String)
,
AttributeList
public final void endElement(String namespaceURI, String localName, String name) throws SAXException
endElement
in interface ContentHandler
endElement
in class ToStream
namespaceURI
- localName
- name
- The element type nameSAXException
- Any SAX exception, possibly
wrapping another exception.protected void processAttribute(Writer writer, String name, String value, ElemDesc elemDesc) throws IOException
writer
- The writer to write the processed output to.name
- The name of the attribute.value
- The value of the attribute.elemDesc
- The description of the HTML element
that has this attribute.SAXException
IOException
public void writeAttrURI(Writer writer, String string, boolean doURLEscaping) throws IOException
%HH
, where HH is the hex of the byte value.string
- String to convert to XML format.doURLEscaping
- True if we should try to encode as
per http://www.ietf.org/rfc/rfc2396.txt.SAXException
- if a bad surrogate pair is detected.IOException
public void writeAttrString(Writer writer, String string, String encoding) throws IOException
&#xnn
.writeAttrString
in class ToStream
string
- String to convert to XML format.encoding
- CURRENTLY NOT IMPLEMENTED.SAXException
IOException
public final void characters(char[] chars, int start, int length) throws SAXException
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
characters
in interface ContentHandler
characters
in class ToStream
chars
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.SAXException
- Any SAX exception, possibly
wrapping another exception.SAXException
ToStream.ignorableWhitespace(char[], int, int)
,
Locator
public final void cdata(char[] ch, int start, int length) throws SAXException
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
cdata
in class ToStream
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.SAXException
- Any SAX exception, possibly
wrapping another exception.SAXException
ToStream.ignorableWhitespace(char[], int, int)
,
Locator
public void processingInstruction(String target, String data) throws SAXException
target
- The processing instruction target.data
- The processing instruction data, or null if
none was supplied.SAXException
- Any SAX exception, possibly
wrapping another exception.SAXException
public final void entityReference(String name) throws SAXException
entityReference
in interface ExtendedContentHandler
entityReference
in class SerializerBase
name
- non-null reference to entity name string.SAXException
public final void endElement(String elemName) throws SAXException
ToStream
endElement
in interface ExtendedContentHandler
endElement
in class ToStream
elemName
- The element type nameSAXException
ExtendedContentHandler.endElement(String)
public void processAttributes(Writer writer, int nAttrs) throws IOException, SAXException
processAttributes
in class ToStream
writer
- the writer to write processed attributes to.nAttrs
- the number of attributes in m_attributes
to be processedSAXException
IOException
protected void closeStartTag() throws SAXException
closeStartTag
in class ToStream
SAXException
public void namespaceAfterStartElement(String prefix, String uri) throws SAXException
namespaceAfterStartElement
in interface ExtendedContentHandler
namespaceAfterStartElement
in class SerializerBase
uri
- the URI of the namespaceprefix
- the prefix associated with the given URI.SAXException
ExtendedContentHandler.namespaceAfterStartElement(String, String)
public void startDTD(String name, String publicId, String systemId) throws SAXException
ToStream
startDTD
in interface LexicalHandler
startDTD
in class ToStream
name
- The document type name.publicId
- The declared public identifier for the
external DTD subset, or null if none was declared.systemId
- The declared system identifier for the
external DTD subset, or null if none was declared.SAXException
- The application may raise an
exception.ToStream.endDTD()
,
ToStream.startEntity(java.lang.String)
public void endDTD() throws SAXException
endDTD
in interface LexicalHandler
endDTD
in class ToStream
SAXException
- The application may raise an exception.startDTD(java.lang.String, java.lang.String, java.lang.String)
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException
attributeDecl
in interface DeclHandler
attributeDecl
in class ToStream
eName
- The name of the associated element.aName
- The name of the attribute.type
- A string representing the attribute type.valueDefault
- A string representing the attribute default
("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
none of these applies.value
- A string representing the attribute's default value,
or null if there is none.SAXException
- The application may raise an exception.public void elementDecl(String name, String model) throws SAXException
elementDecl
in interface DeclHandler
elementDecl
in class ToStream
name
- The element type name.model
- The content model as a normalized string.SAXException
- The application may raise an exception.public void internalEntityDecl(String name, String value) throws SAXException
internalEntityDecl
in interface DeclHandler
internalEntityDecl
in class ToStream
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.value
- The replacement text of the entity.SAXException
- The application may raise an exception.ToStream.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException
externalEntityDecl
in interface DeclHandler
externalEntityDecl
in class ToStream
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.publicId
- The declared public identifier of the entity, or
null if none was declared.systemId
- The declared system identifier of the entity.SAXException
- The application may raise an exception.ToStream.internalEntityDecl(java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void addUniqueAttribute(String name, String value, int flags) throws SAXException
name
- the qualified name of the attributevalue
- the value of the attribute which can contain only
ASCII printable characters characters in the range 32 to 127 inclusive.flags
- the bit values of this integer give optimization information.SAXException
public void comment(char[] ch, int start, int length) throws SAXException
ToStream
comment
in interface LexicalHandler
comment
in class ToStream
ch
- An array holding the characters in the comment.start
- The starting position in the array.length
- The number of characters to use from the array.SAXException
- The application may raise an exception.public boolean reset()
ToStream
reset
in interface Serializer
reset
in class ToStream
Copyright © 2017 JBoss by Red Hat. All rights reserved.