org.apache.xml.serializer

Class ToUnknownStream

public final class ToUnknownStream extends SerializerBase

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.

UNKNOWN: internal

Constructor Summary
ToUnknownStream()
Default constructor.
Method Summary
voidaddAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute)
Adds an attribute to the currenly open tag
voidaddAttribute(String rawName, String value)
Adds an attribute to the currenly open tag
voidaddAttributes(Attributes atts)
voidaddUniqueAttribute(String rawName, String value, int flags)
Adds a unique attribute to the currenly open tag
ContentHandlerasContentHandler()
DOMSerializerasDOMSerializer()
voidattributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4)
Pass the call on to the underlying handler
voidcharacters(String chars)
Converts the String to a character array and calls the SAX method characters(char[],int,int);
voidcharacters(char[] characters, int offset, int length)
Pass the call on to the underlying handler
voidclose()
voidcomment(String comment)
Pass the call on to the underlying handler
voidcomment(char[] ch, int start, int length)
Pass the call on to the underlying handler
voidelementDecl(String arg0, String arg1)
Pass the call on to the underlying handler
voidendCDATA()
Pass the call on to the underlying handler
voidendDocument()
Pass the call on to the underlying handler
voidendDTD()
Pass the call on to the underlying handler
voidendElement(String elementName)
Pass the call on to the underlying handler
voidendElement(String namespaceURI, String localName, String qName)
Pass the call on to the underlying handler
voidendEntity(String name)
Pass the call on to the underlying handler
voidendPrefixMapping(String prefix)
Pass the call on to the underlying handler
voidentityReference(String entityName)
voidexternalEntityDecl(String name, String publicId, String systemId)
Pass the call on to the underlying handler
voidflushPending()
StringgetDoctypePublic()
Pass the call on to the underlying handler
StringgetDoctypeSystem()
Pass the call on to the underlying handler
StringgetEncoding()
Pass the call on to the underlying handler
booleangetIndent()
Pass the call on to the underlying handler
intgetIndentAmount()
Pass the call on to the underlying handler
StringgetMediaType()
Pass the call on to the underlying handler
NamespaceMappingsgetNamespaceMappings()
Get the current namespace mappings.
StringgetNamespaceURI(String qname, boolean isElement)
StringgetNamespaceURIFromPrefix(String prefix)
booleangetOmitXMLDeclaration()
Pass the call on to the underlying handler
PropertiesgetOutputFormat()
OutputStreamgetOutputStream()
StringgetPrefix(String namespaceURI)
StringgetStandalone()
Pass the call on to the underlying handler
TransformergetTransformer()
StringgetVersion()
Pass the call on to the underlying handler
WritergetWriter()
voidignorableWhitespace(char[] ch, int start, int length)
Pass the call on to the underlying handler
voidinternalEntityDecl(String arg0, String arg1)
Pass the call on to the underlying handler
voidnamespaceAfterStartElement(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(). startPrefixMapping(prefix,uri) would be used before the startElement() call.
voidprocessingInstruction(String target, String data)
Pass the call on to the underlying handler
booleanreset()
passes the call on to the underlying HTML or XML handler
voidserialize(Node node)
Converts the DOM node to output
voidsetCdataSectionElements(Vector URI_and_localNames)
voidsetContentHandler(ContentHandler ch)
voidsetDoctype(String system, String pub)
voidsetDoctypePublic(String doctype)
Set the doctype in the underlying XML handler.
voidsetDoctypeSystem(String doctype)
Set the doctype in the underlying XML handler.
voidsetDocumentLocator(Locator locator)
Pass the call on to the underlying handler
voidsetEncoding(String encoding)
Pass the call on to the underlying handler
booleansetEscaping(boolean escape)
voidsetIndent(boolean indent)
Pass the call on to the underlying handler
voidsetIndentAmount(int value)
Pass the call on to the underlying handler
voidsetMediaType(String mediaType)
voidsetOmitXMLDeclaration(boolean b)
Pass the call on to the underlying handler
voidsetOutputFormat(Properties format)
Set the properties of the handler
voidsetOutputStream(OutputStream output)
Sets the output stream to write to
voidsetSourceLocator(SourceLocator locator)
This method is used to set the source locator, which might be used to generated an error message.
voidsetStandalone(String standalone)
Pass the call on to the underlying handler
voidsetTransformer(Transformer t)
voidsetVersion(String version)
This method cannot be cached because default is different in HTML and XML (we need more than a boolean).
voidsetWriter(Writer writer)
Sets the writer to write to
voidskippedEntity(String name)
Pass the call on to the underlying handler
voidstartCDATA()
Pass the call on to the underlying handler
voidstartDocument()
voidstartDTD(String name, String publicId, String systemId)
Pass the call on to the underlying handler
voidstartElement(String qName)
voidstartElement(String namespaceURI, String localName, String qName)
voidstartElement(String namespaceURI, String localName, String elementName, Attributes atts)
voidstartEntity(String name)
Pass the call on to the underlying handler
voidstartPrefixMapping(String prefix, String uri)
booleanstartPrefixMapping(String prefix, String uri, boolean shouldFlush)

Constructor Detail

ToUnknownStream

public ToUnknownStream()
Default constructor. Initially this object wraps an XML Stream object, so _handler is never null. That may change later to an HTML Stream object.

Method Detail

addAttribute

public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute)
Adds an attribute to the currenly open tag

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

See Also: ExtendedContentHandler

addAttribute

public void addAttribute(String rawName, String value)
Adds an attribute to the currenly open tag

Parameters: rawName the attribute name, with prefix (if any) value the value of the parameter

See Also: ExtendedContentHandler

addAttributes

public void addAttributes(Attributes atts)

See Also: addAttributes

addUniqueAttribute

public void addUniqueAttribute(String rawName, String value, int flags)
Adds a unique attribute to the currenly open tag

asContentHandler

public ContentHandler asContentHandler()

Returns: the wrapped XML or HTML handler

See Also: asContentHandler

asDOMSerializer

public DOMSerializer asDOMSerializer()

See Also: asDOMSerializer

attributeDecl

public void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)

characters

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

See Also: characters

characters

public void characters(char[] characters, int offset, int length)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#characters(char[], int, int)

close

public void close()

See Also: close

comment

public void comment(String comment)
Pass the call on to the underlying handler

See Also: comment

comment

public void comment(char[] ch, int start, int length)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#comment(char[], int, int)

elementDecl

public void elementDecl(String arg0, String arg1)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.DeclHandler#elementDecl(String, String)

endCDATA

public void endCDATA()
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#endCDATA()

endDocument

public void endDocument()
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#endDocument()

endDTD

public void endDTD()
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#endDTD()

endElement

public void endElement(String elementName)
Pass the call on to the underlying handler

See Also: endElement

endElement

public void endElement(String namespaceURI, String localName, String qName)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#endElement(String, String, String)

endEntity

public void endEntity(String name)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#endEntity(String)

endPrefixMapping

public void endPrefixMapping(String prefix)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#endPrefixMapping(String)

entityReference

public void entityReference(String entityName)

See Also: ExtendedContentHandler

externalEntityDecl

public void externalEntityDecl(String name, String publicId, String systemId)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)

flushPending

public void flushPending()

See Also: flushPending

getDoctypePublic

public String getDoctypePublic()
Pass the call on to the underlying handler

See Also: getDoctypePublic

getDoctypeSystem

public String getDoctypeSystem()
Pass the call on to the underlying handler

See Also: getDoctypeSystem

getEncoding

public String getEncoding()
Pass the call on to the underlying handler

See Also: getEncoding

getIndent

public boolean getIndent()
Pass the call on to the underlying handler

See Also: getIndent

getIndentAmount

public int getIndentAmount()
Pass the call on to the underlying handler

See Also: getIndentAmount

getMediaType

public String getMediaType()
Pass the call on to the underlying handler

See Also: getMediaType

getNamespaceMappings

public NamespaceMappings getNamespaceMappings()
Get the current namespace mappings. Simply returns the mappings of the wrapped handler.

See Also: getNamespaceMappings

getNamespaceURI

public String getNamespaceURI(String qname, boolean isElement)

See Also: ExtendedContentHandler

getNamespaceURIFromPrefix

public String getNamespaceURIFromPrefix(String prefix)

getOmitXMLDeclaration

public boolean getOmitXMLDeclaration()
Pass the call on to the underlying handler

See Also: getOmitXMLDeclaration

getOutputFormat

public Properties getOutputFormat()

Returns: the properties of the underlying handler

See Also: getOutputFormat

getOutputStream

public OutputStream getOutputStream()

Returns: the OutputStream of the underlying XML or HTML handler

See Also: getOutputStream

getPrefix

public String getPrefix(String namespaceURI)

See Also: ExtendedContentHandler

getStandalone

public String getStandalone()
Pass the call on to the underlying handler

See Also: getStandalone

getTransformer

public Transformer getTransformer()

getVersion

public String getVersion()
Pass the call on to the underlying handler

See Also: getVersion

getWriter

public Writer getWriter()

Returns: the Writer of the underlying XML or HTML handler

See Also: getWriter

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)

internalEntityDecl

public void internalEntityDecl(String arg0, String arg1)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)

namespaceAfterStartElement

public 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(). startPrefixMapping(prefix,uri) would be used before the startElement() call.

Parameters: uri the URI of the namespace prefix the prefix associated with the given URI.

See Also: ExtendedContentHandler

processingInstruction

public void processingInstruction(String target, String data)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#processingInstruction(String, String)

reset

public boolean reset()
passes the call on to the underlying HTML or XML handler

Returns: ???

See Also: reset

serialize

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

Parameters: node the DOM node to transform to output

See Also:

setCdataSectionElements

public void setCdataSectionElements(Vector URI_and_localNames)

Parameters: URI_and_localNames Vector a list of pairs of URI/localName specified in the cdata-section-elements attribute.

See Also: SerializationHandler

setContentHandler

public void setContentHandler(ContentHandler ch)

See Also: setContentHandler

setDoctype

public void setDoctype(String system, String pub)

See Also: XSLOutputAttributes

setDoctypePublic

public void setDoctypePublic(String doctype)
Set the doctype in the underlying XML handler. Remember that this method was called, just in case we need to transfer this doctype to an HTML handler

Parameters: doctype the public doctype to set

See Also: setDoctypePublic

setDoctypeSystem

public void setDoctypeSystem(String doctype)
Set the doctype in the underlying XML handler. Remember that this method was called, just in case we need to transfer this doctype to an HTML handler

Parameters: doctype the system doctype to set

See Also: setDoctypeSystem

setDocumentLocator

public void setDocumentLocator(Locator locator)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#setDocumentLocator(Locator)

setEncoding

public void setEncoding(String encoding)
Pass the call on to the underlying handler

See Also: setEncoding

setEscaping

public boolean setEscaping(boolean escape)

See Also: SerializationHandler

setIndent

public void setIndent(boolean indent)
Pass the call on to the underlying handler

See Also: XSLOutputAttributes

setIndentAmount

public void setIndentAmount(int value)
Pass the call on to the underlying handler

setMediaType

public void setMediaType(String mediaType)

See Also: setMediaType

setOmitXMLDeclaration

public void setOmitXMLDeclaration(boolean b)
Pass the call on to the underlying handler

See Also: XSLOutputAttributes

setOutputFormat

public void setOutputFormat(Properties format)
Set the properties of the handler

Parameters: format the output properties to set

See Also: setOutputFormat

setOutputStream

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

Parameters: output the OutputStream to write to

See Also: setOutputStream

setSourceLocator

public void setSourceLocator(SourceLocator locator)
This method is used to set the source locator, which might be used to generated an error message.

Parameters: locator the source locator

See Also: setSourceLocator

setStandalone

public void setStandalone(String standalone)
Pass the call on to the underlying handler

See Also: setStandalone

setTransformer

public void setTransformer(Transformer t)

setVersion

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

setWriter

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

Parameters: writer the writer to write to

See Also: setWriter

skippedEntity

public void skippedEntity(String name)
Pass the call on to the underlying handler

See Also: org.xml.sax.ContentHandler#skippedEntity(String)

startCDATA

public void startCDATA()
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#startCDATA()

startDocument

public void startDocument()

See Also: org.xml.sax.ContentHandler#startDocument()

startDTD

public void startDTD(String name, String publicId, String systemId)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)

startElement

public void startElement(String qName)

startElement

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

startElement

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

startEntity

public void startEntity(String name)
Pass the call on to the underlying handler

See Also: org.xml.sax.ext.LexicalHandler#startEntity(String)

startPrefixMapping

public void startPrefixMapping(String prefix, String uri)

Parameters: prefix The prefix that maps to the URI uri The URI for the namespace

See Also: org.xml.sax.ContentHandler#startPrefixMapping(String, String)

startPrefixMapping

public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush)
Copyright B) 2005 Apache XML Project. All Rights Reserved.