APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.serializer

public final Class ToUnknownStream

extends SerializerBase
Class Inheritance
Imports
java.io.IOException, .OutputStream, .Writer, java.util.ArrayList, .List, .Properties, javax.xml.transform.ErrorListener, .SourceLocator, .Transformer, org.w3c.dom.Node, org.xml.sax.Attributes, .ContentHandler, .Locator, .SAXException

This class wraps another SerializationHandler. The wrapped object will either handler XML or HTML, which is not known until a little later when the first XML tag is seen. If the first tag is then the wrapped object is an HTML handler, otherwise it is an XML handler. This class effectively caches the first few calls to it then passes them on to the wrapped handler (once it exists). After that subsequent calls a simply passed directly to the wrapped handler. The user of this class doesn't know if the output is ultimatley XML or HTML. This class is not a public API, it is public because it is used within Xalan.

Field Summary

Modifier and TypeField and Description
private static final String
private String
m_firstElementLocalName

the local name (no prefix) associated with the first element

private String
m_firstElementName

the element name (including any prefix) of the very first tag in the document

private String
m_firstElementPrefix

the prefix of the very first tag in the document

private String
m_firstElementURI

the namespace URI associated with the first element

private boolean
m_firstTagNotEmitted

true if the first tag has been emitted to the wrapped handler

private SerializationHandler
m_handler

The wrapped handler, initially XML but possibly switched to HTML

private List<String>
m_namespacePrefix

A collection of namespace Prefix (only for first element) _namespaceURI has the matching URIs for these prefix'

private List<String>
m_namespaceURI

A collection of namespace URI's (only for first element).

private boolean
m_needToCallStartDocument

Hides com.sun.org.apache.xml.internal.serializer.SerializerBase.m_needToCallStartDocument.

true if startDocument() was called before the underlying handler was initialized
private boolean
m_wrapped_handler_not_initialized

true if the underlying handler (XML or HTML) is fully initialized

Inherited from com.sun.org.apache.xml.internal.serializer.SerializerBase:
m_attrBuffm_attributesm_CdataElemsm_cdataTagOpenm_charsBuffm_docIsEmptym_doctypePublicm_doctypeSystemm_doIndentm_elemContextm_errListenerm_indentAmountm_inEntityRefm_inExternalDTDm_isStandalonem_mediatypem_needToCallSetDocumentInfom_needToOutputDocTypeDeclm_prefixMapm_shouldNotWriteXMLHeaderm_sourceLocatorm_standaloneWasSpecifiedm_StringOfCDATASectionsm_tracerm_versionm_writer

Constructor Summary

AccessConstructor and Description
public
ToUnknownStream()

Default constructor.

public

Method Summary

Modifier and TypeMethod and Description
public void
addAttribute(String
the URI of a namespace
uri
,
String
the attribute name, without prefix
localName
,
String
the attribute name, with prefix (if any)
rawName
,
String
the type of the attribute, typically "CDATA"
type
,
String
the value of the parameter
value
)

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

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

Adds an attribute to the currenly open tag

public void
addAttribute(String
the URI of a namespace
uri
,
String
the attribute name, without prefix
localName
,
String
the attribute name, with prefix (if any)
rawName
,
String
the type of the attribute, typically "CDATA"
type
,
String
the value of the parameter
value
,
boolean
true if this attribute is coming from an xsl:attribute element
XSLAttribute
)

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

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

Adds an attribute to the currenly open tag

public void
addAttribute(String
the attribute name, with prefix (if any)
rawName
,
String
the value of the parameter
value
)

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

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

Adds an attribute to the currenly open tag

public void
public void
addUniqueAttribute(String rawName, String value, int flags)

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

Adds a unique attribute to the currenly open tag

public ContentHandler
public Object
public DOMSerializer
public void
attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4)

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

Pass the call on to the underlying handler

public void
characters(String
The string of characters to process.
chars
)

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

Converts the String to a character array and calls the SAX method characters(char[],int,int);

public void
characters(char[] characters, int offset, int length)

Implements org.xml.sax.ContentHandler.characters.

Pass the call on to the underlying handler

public void
public void
public void
comment(char[] ch, int start, int length)

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

Pass the call on to the underlying handler

public void
elementDecl(String arg0, String arg1)

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

Pass the call on to the underlying handler

private void
public void
endCDATA()

Implements org.xml.sax.ext.LexicalHandler.endCDATA.

Pass the call on to the underlying handler

public void
endDocument()

Implements org.xml.sax.ContentHandler.endDocument.

Pass the call on to the underlying handler

public void
endDTD()

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

Pass the call on to the underlying handler

public void
endElement(String elementName)

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

Pass the call on to the underlying handler

public void
endElement(String namespaceURI, String localName, String qName)

Implements org.xml.sax.ContentHandler.endElement.

Pass the call on to the underlying handler

public void
public void
endPrefixMapping(String prefix)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Pass the call on to the underlying handler

public void
public void
externalEntityDecl(String name, String publicId, String systemId)

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

Pass the call on to the underlying handler

protected void
private void
public void
flushPending()

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.flushPending.

A SerializationHandler accepts SAX-like events, so it can accumulate attributes or namespace nodes after a startElement().

public String
public String
public String
public boolean
public int
private String
getLocalNameUnknown(String value)

Utility function for calls to local-name().

public String
public NamespaceMappings
public String
public String
public boolean
public Properties

Returns:

the properties of the underlying handler
getOutputFormat
()

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

Returns the output format properties for this serializer.

public OutputStream

Returns:

the OutputStream of the underlying XML or HTML handler
getOutputStream
()

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

Get the output stream where the events will be serialized to.

public String
getPrefix(String namespaceURI)

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

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

Returns the prefix currently pointing to the given URI (if any).

private String
getPrefixPartUnknown(String qname)

Utility function to return prefix Don't want to override static function on SerializerBase So added Unknown suffix to method name.

public String
public Transformer
public String
public Writer

Returns:

the Writer of the underlying XML or HTML handler
getWriter
()

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

Get the character stream where the events will be serialized to.

public void
ignorableWhitespace(char[] ch, int start, int length)

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Pass the call on to the underlying handler

private void
initStreamOutput()

Initialize the wrapped output stream (XML or HTML).

public void
internalEntityDecl(String arg0, String arg1)

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

Pass the call on to the underlying handler

private boolean

Returns:

true if the first element is an opening tag
isFirstElemHTML
()

Determine if the firts element in the document is or This uses the cached first element name, first element prefix and the cached namespaces from previous method calls

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

public void
processingInstruction(String target, String data)

Implements org.xml.sax.ContentHandler.processingInstruction.

Pass the call on to the underlying handler

public boolean

Returns:

???
reset
()

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

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

passes the call on to the underlying HTML or XML handler

public void
serialize(Node
the DOM node to transform to output
node
)

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.serialize.

Converts the DOM node to output

public void
setCdataSectionElements(List<String>
a list of pairs of URI/localName specified in the cdata-section-elements attribute.
URI_and_localNames
)

Implements com.sun.org.apache.xml.internal.serializer.XSLOutputAttributes.setCdataSectionElements.

Sets the value coming from the xsl:output cdata-section-elements stylesheet property.

public void
setContentHandler(ContentHandler ch)

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.setContentHandler.

Set the SAX Content handler that the serializer sends its output to.

public void
setDoctype(String system, String pub)

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

Implements com.sun.org.apache.xml.internal.serializer.XSLOutputAttributes.setDoctype.

Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties

public void
public void
public void
public void
public boolean
setEscaping(boolean escape)

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.setEscaping.

Turns special character escaping on/off.

public void
public void
public void
public void
setMediaType(String mediaType)

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

Implements com.sun.org.apache.xml.internal.serializer.XSLOutputAttributes.setMediaType.

Sets the value coming from the xsl:output media-type stylesheet attribute.

public void
public void
setOutputFormat(Properties
the output properties to set
format
)

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

Set the properties of the handler

public void
setOutputStream(OutputStream
the OutputStream to write to
output
)

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

Sets the output stream to write to

public void
setSourceLocator(SourceLocator
the source locator
locator
)

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

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

This method is used to set the source locator, which might be used to generated an error message.

public void
public void
public void
setVersion(String version)

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

Implements com.sun.org.apache.xml.internal.serializer.XSLOutputAttributes.setVersion.

This method cannot be cached because default is different in HTML and XML (we need more than a boolean).

public void
setWriter(Writer
the writer to write to
writer
)

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

Sets the writer to write to

public void
skippedEntity(String name)

Implements org.xml.sax.ContentHandler.skippedEntity.

Pass the call on to the underlying handler

public void
startCDATA()

Implements org.xml.sax.ext.LexicalHandler.startCDATA.

Pass the call on to the underlying handler

public void
public void
startDTD(String name, String publicId, String systemId)

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

Pass the call on to the underlying handler

public void
startElement(String qName)

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

This method is used to notify of the start of an element

public void
startElement(String namespaceURI, String localName, String qName)

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

This method is used to notify that an element is starting.

public void
startElement(String namespaceURI, String localName, String elementName, Attributes atts)

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element.

public void
startEntity(String name)

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Pass the call on to the underlying handler

public void
startPrefixMapping(String
The prefix that maps to the URI
prefix
,
String
The URI for the namespace
uri
)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Begin the scope of a prefix-URI Namespace mapping.

public boolean
startPrefixMapping(String prefix, String uri, boolean shouldFlush)

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

This method is used to notify that a prefix maping is to start, which can be for the current element, or for the one to come.

Inherited from com.sun.org.apache.xml.internal.serializer.SerializerBase:
addAttributeAlwaysaddXSLAttributecharactersdocumentIsEmptyerrorfatalErrorfireCDATAEventfireCharEventfireCommentEventfireEndDocfireEndElemfireEndEntityfireEntityReferencefireEscapingEventfireStartDocfireStartElemfireStartEntitygetFirstCharLocNamegetLocalNamegetOutputPropDefaultKeysgetOutputPropertygetOutputPropertyDefaultgetOutputPropertyNonDefaultgetOutputPropKeysgetPrefixPartinitCDATAinitCdataElemsinTemporaryOutputStateisCdataSectionisInEntityRefnotationDeclpatchNamesetDocumentInfosetDTDEntityExpansionsetNamespaceMappingssetOutputPropertysetOutputPropertyDefaultsetPropsetStandaloneInternalstartDocumentInternalunparsedEntityDeclwarning