Top Description Inners Fields Constructors Methods
com.sun.org.apache.xml.internal.serializer

public final Class ToHTMLStream

extends ToStream
Class Inheritance
Imports
java.io.IOException, java.util.Properties, javax.xml.transform.Result, .ErrorListener, org.xml.sax.Attributes, .SAXException, com.sun.org.apache.xml.internal.serializer.utils.MsgKey, .Utils, jdk.xml.internal.JdkXmlUtils

This serializer takes a series of SAX or SAX-like events and writes its output to the given stream. This class is not a public API, it is public because it is used from another package.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final ElemDesc
m_dummy

Dummy element for elements not found.

pack-priv static final ToHTMLStream.Trie
m_elementFlags

A digital search trie for fast, case insensitive lookup of ElemDesc objects.

private static final CharInfo
m_htmlcharInfo

Map that tells which XML characters should have special treatment, and it provides character to entity name lookup.

private ToHTMLStream.Trie
m_htmlInfo

A Trie that is just a copy of the "static" one.

protected boolean
m_inDTD

This flag is set while receiving events from the DTD

private boolean
m_isprevblock

True if the previous element is a block element.

private boolean
m_omitMetaTag

True if the META tag should be omitted.

private boolean
m_specialEscapeURLs

True if URLs should be specially escaped with the %xx form.

Inherited from com.sun.org.apache.xml.internal.serializer.ToStream:
m_canConvertMethm_cdataStartCalledm_charactersBufferm_charInfom_charToByteConverterm_childNodeNumm_childNodeNumStackm_disableOutputEscapingStatesm_encodingInfom_inDoctypem_ispreserveSpacem_isprevtextm_isUTF8m_lineSepm_lineSepLenm_lineSepUsem_maxCharacterm_outputStreamm_preserveSpacesm_shouldFlushm_spaceBeforeClosem_startNewLinem_triedToGetConverter

Constructor Summary

AccessConstructor and Description
public
ToHTMLStream()

Default constructor.

public

Method Summary

Modifier and TypeMethod and Description
public void
addUniqueAttribute(String
the qualified name of the attribute
name
,
String
the value of the attribute which can contain only ASCII printable characters characters in the range 32 to 127 inclusive.
value
,
int
the bit values of this integer give optimization information.
flags
)

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.addUniqueAttribute.

This method is used to add an attribute to the currently open element.

public void
attributeDecl(String
The name of the associated element.
eName
,
String
The name of the attribute.
aName
,
String
A string representing the attribute type.
type
,
String
A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
valueDefault
,
String
A string representing the attribute's default value, or null if there is none.
value
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

Implements org.xml.sax.ext.DeclHandler.attributeDecl.

This method does nothing.

public final void
cdata(char[]
The characters from the XML document.
ch
,
int
The start position in the array.
start
,
int
The number of characters to read from the array.
length
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.cdata.

Receive notification of cdata.

public final void
characters(char[]
The characters from the XML document.
chars
,
int
The start position in the array.
start
,
int
The number of characters to read from the array.
length
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.characters.

Implements org.xml.sax.ContentHandler.characters.

Receive notification of character data.

protected void
closeStartTag()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.closeStartTag.

For the enclosing elements starting tag write out out any attributes followed by ">"

public void
comment(char[]
An array holding the characters in the comment.
ch
,
int
The starting position in the array.
start
,
int
The number of characters to use from the array.
length
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.comment.

Implements org.xml.sax.ext.LexicalHandler.comment.

Receive notification of an XML comment anywhere in the document.

public void
elementDecl(String
The element type name.
name
,
String
The content model as a normalized string.
model
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.elementDecl.

Implements org.xml.sax.ext.DeclHandler.elementDecl.

This method does nothing.

public final void
endDocument()

Implements org.xml.sax.ContentHandler.endDocument.

Receive notification of the end of a document.

public void
public final void
endElement(final String namespaceURI, final String localName, final String
The element type name
name
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.

public final void
endElement(String
The element type name
elemName
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.endElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.endElement.

Receive notification of the end of an element.

public final void
public void
externalEntityDecl(String
The name of the entity. If it is a parameter entity, the name will begin with '%'.
name
,
String
The declared public identifier of the entity, or null if none was declared.
publicId
,
String
The declared system identifier of the entity.
systemId
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.externalEntityDecl.

Implements org.xml.sax.ext.DeclHandler.externalEntityDecl.

This method does nothing.

public static final ElemDesc

Returns:

non-null reference to ElemDesc, which may be m_dummy if no element description matches the given name.
getElemDesc
(String
non-null name of element, case insensitive.
name
)

Get a description of the given element.

private ElemDesc
getElemDesc2(String name)

Calls to this method could be replaced with calls to getElemDesc(name), but this one should be faster.

private final boolean

Returns:

True if the META tag should be omitted.
getOmitMetaTag
()

Tells if the formatter should omit the META tag.

private final boolean

Returns:

True if URLs should be specially escaped with the %xx form.
getSpecialEscapeURLs
()

Tells if the formatter should use special URL escaping.

pack-priv static void
private void
public void
internalEntityDecl(String
The name of the entity. If it is a parameter entity, the name will begin with '%'.
name
,
String
The replacement text of the entity.
value
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.internalEntityDecl.

Implements org.xml.sax.ext.DeclHandler.internalEntityDecl.

This method does nothing.

private boolean
isASCIIDigit(char c)

Tell if a character is an ASCII digit.

private boolean

Returns:

true or false
isHHSign
(String
must be 2 characters long
str
)

Dmitri Ilyin: Makes sure if the String is HH encoded sign.

private static String

Returns:

should be a two character string.
makeHHString
(int
must be a value less than 255.
i
)

Make an integer into an HH hex value.

public void
namespaceAfterStartElement(String
the prefix associated with the given URI.
prefix
,
String
the URI of the namespace
uri
)

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.namespaceAfterStartElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.namespaceAfterStartElement.

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
The writer to write the processed output to.
writer
,
String
The name of the attribute.
name
,
String
The value of the attribute.
value
,
ElemDesc
The description of the HTML element that has this attribute.
elemDesc
)

Process an attribute.

public void
processAttributes(Writer
the writer to write processed attributes to.
writer
,
int
the number of attributes in m_attributes to be processed
nAttrs
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.processAttributes.

Process the attributes, which means to write out the currently collected attributes to the writer.

public void
processingInstruction(String
The processing instruction target.
target
,
String
The processing instruction data, or null if none was supplied.
data
)

Implements org.xml.sax.ContentHandler.processingInstruction.

Receive notification of a processing instruction.

public boolean
reset()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.reset.

Implements com.sun.org.apache.xml.internal.serializer.Serializer.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).

public void
setOmitMetaTag(boolean
True if the META tag should be omitted.
bool
)

Tells if the formatter should omit the META tag.

public void
setOutputFormat(Properties
The output format or serialzation parameters to use.
format
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.setOutputFormat.

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setOutputFormat.

Specifies an output format for this serializer.

public void
setSpecialEscapeURLs(boolean
True if URLs should be specially escaped with the %xx form.
bool
)

Tells if the formatter should use special URL escaping.

protected boolean

Returns:

True if the content should be formatted.
shouldFormatOutput
()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.shouldFormatOutput.

Only check m_doIndent, disregard m_ispreserveSpace.

protected boolean
shouldIndentForText()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.shouldIndentForText.

If the previous is an inline element, won't insert a new line before the text.

protected void
startDocumentInternal()

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.startDocumentInternal.

Receive notification of the beginning of a document.

public void
startDTD(String
The document type name.
name
,
String
The declared public identifier for the external DTD subset, or null if none was declared.
publicId
,
String
The declared system identifier for the external DTD subset, or null if none was declared.
systemId
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.startDTD.

Implements org.xml.sax.ext.LexicalHandler.startDTD.

Report the start of DTD declarations, if any.

public void
startElement(String namespaceURI, String localName, String
The element type name.
name
,
Attributes
The attributes attached to the element, if any.
atts
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element.

public void
writeAttrString(final Writer writer, String
String to convert to XML format.
string
,
String
CURRENTLY NOT IMPLEMENTED.
encoding
)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.writeAttrString.

Writes the specified string after substituting specials, and UTF-16 surrogates for character references &#xnn.

public void
writeAttrURI(final Writer writer, String
String to convert to XML format.
string
,
boolean
True if we should try to encode as per http://www.ietf.org/rfc/rfc2396.txt.
doURLEscaping
)

Write the specified string after substituting non ASCII characters, with %HH, where HH is the hex of the byte value.

Inherited from com.sun.org.apache.xml.internal.serializer.ToStream:
accumDefaultEntityaccumDefaultEscapeaddAttributeAlwaysaddCdataSectionElementscharacterscharactersRawcloseCDATAendCDATAendNonEscapingendPrefixMappingensureAttributesNamespaceIsDeclaredensurePrefixIsDeclaredescapingNotNeededfirePseudoAttributesflushCharactersBufferflushPendingflushWritergetIndentgetIndentAmountgetOutputFormatgetOutputStreamgetWriterignorableWhitespaceindentindentisUTF16SurrogatenotationDecloutputDocTypeDecloutputEntityDecloutputLineSepserializesetCdataSectionElementssetContentHandlersetDTDEntityExpansionsetEncodingsetEscapingsetIndentAmountsetLineSepUsesetOutputStreamsetPropsetTransformersetWritershouldIndentskippedEntitystartCDATAstartElementstartElementstartEntitystartNonEscapingstartPrefixMappingstartPrefixMappingunparsedEntityDeclwriteNormalizedCharswriteUTF16Surrogate

Field Detail

m_dummyback to summary
private static final ElemDesc m_dummy

Dummy element for elements not found.

m_elementFlagsback to summary
pack-priv static final ToHTMLStream.Trie m_elementFlags

A digital search trie for fast, case insensitive lookup of ElemDesc objects.

m_htmlcharInfoback to summary
private static final CharInfo m_htmlcharInfo

Map that tells which XML characters should have special treatment, and it provides character to entity name lookup.

m_htmlInfoback to summary
private ToHTMLStream.Trie m_htmlInfo

A Trie that is just a copy of the "static" one. We need this one to be able to use the faster, but not thread-safe method Trie.get2(name)

m_inDTDback to summary
protected boolean m_inDTD

This flag is set while receiving events from the DTD

m_isprevblockback to summary
private boolean m_isprevblock

True if the previous element is a block element.

m_omitMetaTagback to summary
private boolean m_omitMetaTag

True if the META tag should be omitted.

m_specialEscapeURLsback to summary
private boolean m_specialEscapeURLs

True if URLs should be specially escaped with the %xx form.

Constructor Detail

ToHTMLStreamback to summary
public ToHTMLStream()

Default constructor.

ToHTMLStreamback to summary
public ToHTMLStream(ErrorListener l)

Method Detail

addUniqueAttributeback to summary
public void addUniqueAttribute(String name, String value, int flags) throws SAXException

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.addUniqueAttribute.

This method is used to add an attribute to the currently open element. The caller has guaranted that this attribute is unique, which means that it not been seen before and will not be seen again.

Parameters
name:String

the qualified name of the attribute

value:String

the value of the attribute which can contain only ASCII printable characters characters in the range 32 to 127 inclusive.

flags:int

the bit values of this integer give optimization information.

attributeDeclback to summary
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

Implements org.xml.sax.ext.DeclHandler.attributeDecl.

This method does nothing.

Parameters
eName:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

The name of the associated element.

aName:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

The name of the attribute.

type:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

A string representing the attribute type.

valueDefault:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.

value:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

A string representing the attribute's default value, or null if there is none.

Exceptions
SAXException:

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.attributeDecl.

The application may raise an exception.

cdataback to summary
public final void cdata(char[] ch, int start, int length) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.cdata.

Receive notification of cdata.

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).

Parameters
ch:char[]

The characters from the XML document.

start:int

The start position in the array.

length:int

The number of characters to read from the array.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
ignorableWhitespace, org.xml.sax.Locator
charactersback to summary
public final void characters(char[] chars, int start, int length) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.characters.

Implements org.xml.sax.ContentHandler.characters.

Receive notification of character data.

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).

Parameters
chars:char[]

The characters from the XML document.

start:int

The start position in the array.

length:int

The number of characters to read from the array.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
ignorableWhitespace, org.xml.sax.Locator
closeStartTagback to summary
protected void closeStartTag() throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.closeStartTag.

For the enclosing elements starting tag write out out any attributes followed by ">"

commentback to summary
public void comment(char[] ch, int start, int length) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.comment.

Implements org.xml.sax.ext.LexicalHandler.comment.

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.comment.

Receive notification of an XML comment anywhere in the document. This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read).

Parameters
ch:char[]

An array holding the characters in the comment.

start:int

The starting position in the array.

length:int

The number of characters to use from the array.

Exceptions
SAXException:
The application may raise an exception.
elementDeclback to summary
public void elementDecl(String name, String model) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.elementDecl.

Implements org.xml.sax.ext.DeclHandler.elementDecl.

This method does nothing.

Parameters
name:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.elementDecl.

The element type name.

model:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.elementDecl.

The content model as a normalized string.

Exceptions
SAXException:

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.elementDecl.

The application may raise an exception.

endDocumentback to summary
public final void endDocument() throws SAXException

Implements org.xml.sax.ContentHandler.endDocument.

Receive notification of the end of a document.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
endDTDback to summary
public void endDTD() throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.endDTD.

Implements org.xml.sax.ext.LexicalHandler.endDTD.

Report the end of DTD declarations.

Exceptions
SAXException:
The application may raise an exception.
See Also
startDTD
endElementback to summary
public final void endElement(final String namespaceURI, final String localName, final String name) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.

Parameters
name:String

The element type name

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
endElementback to summary
public final void endElement(String elemName) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.endElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.endElement.

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.endElement.

Receive notification of the end of an element.

Parameters
elemName:String

The element type name

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
ExtendedContentHandler#endElement(String)
entityReferenceback to summary
public final void entityReference(String name) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.entityReference.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.entityReference.

Receive notivication of a entityReference.

Parameters
name:String

non-null reference to entity name string.

externalEntityDeclback to summary
public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.externalEntityDecl.

Implements org.xml.sax.ext.DeclHandler.externalEntityDecl.

This method does nothing.

Parameters
name:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.externalEntityDecl.

The name of the entity. If it is a parameter entity, the name will begin with '%'.

publicId:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.externalEntityDecl.

The declared public identifier of the entity, or null if none was declared.

systemId:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.externalEntityDecl.

The declared system identifier of the entity.

Exceptions
SAXException:

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.externalEntityDecl.

The application may raise an exception.

getElemDescback to summary
public static final ElemDesc getElemDesc(String name)

Get a description of the given element.

Parameters
name:String

non-null name of element, case insensitive.

Returns:ElemDesc

non-null reference to ElemDesc, which may be m_dummy if no element description matches the given name.

getElemDesc2back to summary
private ElemDesc getElemDesc2(String name)

Calls to this method could be replaced with calls to getElemDesc(name), but this one should be faster.

getOmitMetaTagback to summary
private final boolean getOmitMetaTag()

Tells if the formatter should omit the META tag.

Returns:boolean

True if the META tag should be omitted.

getSpecialEscapeURLsback to summary
private final boolean getSpecialEscapeURLs()

Tells if the formatter should use special URL escaping.

Returns:boolean

True if URLs should be specially escaped with the %xx form.

initTagReferenceback to summary
pack-priv static void initTagReference(ToHTMLStream.Trie m_elementFlags)
initToHTMLStreamback to summary
private void initToHTMLStream()
internalEntityDeclback to summary
public void internalEntityDecl(String name, String value) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.internalEntityDecl.

Implements org.xml.sax.ext.DeclHandler.internalEntityDecl.

This method does nothing.

Parameters
name:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.internalEntityDecl.

The name of the entity. If it is a parameter entity, the name will begin with '%'.

value:String

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.internalEntityDecl.

The replacement text of the entity.

Exceptions
SAXException:

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.internalEntityDecl.

The application may raise an exception.

isASCIIDigitback to summary
private boolean isASCIIDigit(char c)

Tell if a character is an ASCII digit.

isHHSignback to summary
private boolean isHHSign(String str)

Dmitri Ilyin: Makes sure if the String is HH encoded sign.

Parameters
str:String

must be 2 characters long

Returns:boolean

true or false

makeHHStringback to summary
private static String makeHHString(int i)

Make an integer into an HH hex value. Does no checking on the size of the input, since this is only meant to be used locally by writeAttrURI.

Parameters
i:int

must be a value less than 255.

Returns:String

should be a two character string.

namespaceAfterStartElementback to summary
public void namespaceAfterStartElement(String prefix, String uri) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.namespaceAfterStartElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.namespaceAfterStartElement.

This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). startPrefixMapping(prefix,uri) would be used before the startElement() call.

Parameters
prefix:String

the prefix associated with the given URI.

uri:String

the URI of the namespace

See Also
ExtendedContentHandler#namespaceAfterStartElement(String, String)
processAttributeback to summary
protected void processAttribute(Writer writer, String name, String value, ElemDesc elemDesc) throws IOException, SAXException

Process an attribute.

Parameters
writer:Writer

The writer to write the processed output to.

name:String

The name of the attribute.

value:String

The value of the attribute.

elemDesc:ElemDesc

The description of the HTML element that has this attribute.

processAttributesback to summary
public void processAttributes(Writer writer, int nAttrs) throws IOException, SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.processAttributes.

Process the attributes, which means to write out the currently collected attributes to the writer. The attributes are not cleared by this method

Parameters
writer:Writer

the writer to write processed attributes to.

nAttrs:int

the number of attributes in m_attributes to be processed

processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Implements org.xml.sax.ContentHandler.processingInstruction.

Receive notification of a processing instruction.

Parameters
target:String

The processing instruction target.

data:String

The processing instruction data, or null if none was supplied.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
resetback to summary
public boolean reset()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.reset.

Implements com.sun.org.apache.xml.internal.serializer.Serializer.reset.

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.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).

Returns:boolean

true if the class was successfuly reset.

setOmitMetaTagback to summary
public void setOmitMetaTag(boolean bool)

Tells if the formatter should omit the META tag.

Parameters
bool:boolean

True if the META tag should be omitted.

setOutputFormatback to summary
public void setOutputFormat(Properties format)

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.setOutputFormat.

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setOutputFormat.

Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document. This method can be called multiple times before starting the serialization of a particular result-tree. In principle all serialization parameters can be changed, with the exception of method="html" (it must be method="html" otherwise we shouldn't even have a ToHTMLStream object here!)

Parameters
format:Properties

The output format or serialzation parameters to use.

setSpecialEscapeURLsback to summary
public void setSpecialEscapeURLs(boolean bool)

Tells if the formatter should use special URL escaping.

Parameters
bool:boolean

True if URLs should be specially escaped with the %xx form.

shouldFormatOutputback to summary
protected boolean shouldFormatOutput()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.shouldFormatOutput.

Only check m_doIndent, disregard m_ispreserveSpace.

Returns:boolean

True if the content should be formatted.

shouldIndentForTextback to summary
protected boolean shouldIndentForText()

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.shouldIndentForText.

If the previous is an inline element, won't insert a new line before the text.

startDocumentInternalback to summary
protected void startDocumentInternal() throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.startDocumentInternal.

Receive notification of the beginning of a document.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
startDTDback to summary
public void startDTD(String name, String publicId, String systemId) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.startDTD.

Implements org.xml.sax.ext.LexicalHandler.startDTD.

Doc from com.sun.org.apache.xml.internal.serializer.ToStream.startDTD.

Report the start of DTD declarations, if any. Any declarations are assumed to be in the internal subset unless otherwise indicated.

Parameters
name:String

The document type name.

publicId:String

The declared public identifier for the external DTD subset, or null if none was declared.

systemId:String

The declared system identifier for the external DTD subset, or null if none was declared.

Exceptions
SAXException:
The application may raise an exception.
startElementback to summary
public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element.

Parameters
name:String

The element type name.

atts:Attributes

The attributes attached to the element, if any.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
endElement, org.xml.sax.AttributeList
writeAttrStringback to summary
public void writeAttrString(final Writer writer, String string, String encoding) throws IOException, SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToStream.writeAttrString.

Writes the specified string after substituting specials, and UTF-16 surrogates for character references &#xnn.

Parameters
string:String

String to convert to XML format.

encoding:String

CURRENTLY NOT IMPLEMENTED.

writeAttrURIback to summary
public void writeAttrURI(final Writer writer, String string, boolean doURLEscaping) throws IOException

Write the specified string after substituting non ASCII characters, with %HH, where HH is the hex of the byte value.

Parameters
string:String

String to convert to XML format.

doURLEscaping:boolean

True if we should try to encode as per http://www.ietf.org/rfc/rfc2396.txt.

Exceptions
SAXException:
if a bad surrogate pair is detected.
com.sun.org.apache.xml.internal.serializer back to summary

pack-priv Class ToHTMLStream.Trie

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ToHTMLStream.Trie.Node

The node representation for the trie.

Field Summary

Modifier and TypeField and Description
public static final int
ALPHA_SIZE

Size of the m_nextChar array.

private char[]
m_charBuffer

helper buffer to convert Strings to char arrays

private final boolean
m_lowerCaseOnly

true if the search for an object is lower case only with the key

pack-priv final ToHTMLStream.Trie.Node
m_Root

The root node of the tree.

Constructor Summary

AccessConstructor and Description
public
Trie()

Construct the trie that has a case insensitive search.

public
Trie(boolean
true if the search keys are to be loser case only, not case insensitive.
lowerCaseOnly
)

Construct the trie given the desired case sensitivity with the key.

public
Trie(ToHTMLStream.Trie
the Trie that this one is a copy of.
existingTrie
)

Construct the trie from another Trie.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

The object that matches the key, or null.
get
(final String
must be a 7-bit ASCII string
key
)

Get an object that matches the key.

public Object

Returns:

The object that matches the key, or null.
get2
(final String
must be a 7-bit ASCII string
key
)

Get an object that matches the key.

public int
getLongestKeyLength()

Get the length of the longest key used in the table.

public Object

Returns:

The old object that matched key, or null.
put
(String
must be a 7-bit ASCII string
key
,
Object
any java object.
value
)

Put an object into the trie for lookup.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALPHA_SIZEback to summary
public static final int ALPHA_SIZE

Size of the m_nextChar array.

m_charBufferback to summary
private char[] m_charBuffer

helper buffer to convert Strings to char arrays

m_lowerCaseOnlyback to summary
private final boolean m_lowerCaseOnly

true if the search for an object is lower case only with the key

m_Rootback to summary
pack-priv final ToHTMLStream.Trie.Node m_Root

The root node of the tree.

Constructor Detail

Trieback to summary
public Trie()

Construct the trie that has a case insensitive search.

Trieback to summary
public Trie(boolean lowerCaseOnly)

Construct the trie given the desired case sensitivity with the key.

Parameters
lowerCaseOnly:boolean

true if the search keys are to be loser case only, not case insensitive.

Trieback to summary
public Trie(ToHTMLStream.Trie existingTrie)

Construct the trie from another Trie. Both the existing Trie and this new one share the same table for lookup, and it is assumed that the table is fully populated and not changing anymore.

Parameters
existingTrie:ToHTMLStream.Trie

the Trie that this one is a copy of.

Method Detail

getback to summary
public Object get(final String key)

Get an object that matches the key.

Parameters
key:String

must be a 7-bit ASCII string

Returns:Object

The object that matches the key, or null.

get2back to summary
public Object get2(final String key)

Get an object that matches the key. This method is faster than get(), but is not thread-safe.

Parameters
key:String

must be a 7-bit ASCII string

Returns:Object

The object that matches the key, or null.

getLongestKeyLengthback to summary
public int getLongestKeyLength()

Get the length of the longest key used in the table.

putback to summary
public Object put(String key, Object value)

Put an object into the trie for lookup.

Parameters
key:String

must be a 7-bit ASCII string

value:Object

any java object.

Returns:Object

The old object that matched key, or null.

com.sun.org.apache.xml.internal.serializer back to summary

private Class ToHTMLStream.Trie.Node

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.org.apache.xml.internal.serializer.ToHTMLStream.Trie.Node

The node representation for the trie.

Field Summary

Modifier and TypeField and Description
pack-priv final ToHTMLStream.Trie.Node[]
m_nextChar

The next nodes.

pack-priv Object
m_Value

The value.

Constructor Summary

AccessConstructor and Description
pack-priv
Node()

Constructor, creates a Node[ALPHA_SIZE].

Field Detail

m_nextCharback to summary
pack-priv final ToHTMLStream.Trie.Node[] m_nextChar

The next nodes.

m_Valueback to summary
pack-priv Object m_Value

The value.

Constructor Detail

Nodeback to summary
pack-priv Node()

Constructor, creates a Node[ALPHA_SIZE].