BEA Systems, Inc.

BEA WebLogic Server 9.0 API Reference


weblogic.apache.xml.serialize
Class DOMWriterImpl

java.lang.Object
  extended byweblogic.apache.xml.serialize.DOMWriterImpl
All Implemented Interfaces:
DOMWriter

public class DOMWriterImpl
extends Object
implements DOMWriter

Implemenatation of DOM Level 3 org.w3c.ls.DOMWriter by delegating serialization calls to XMLSerializer. DOMWriter provides an API for serializing (writing) a DOM document out in an XML document. The XML data is written to an output stream. During serialization of XML data, namespace fixup is done when possible as defined in DOM Level 3 Core, Appendix B.


Constructor Summary
DOMWriterImpl(boolean namespaces)
          Constructs a new DOMWriter.
 
Method Summary
 boolean canSetFeature(String name, boolean state)
          DOM L3-EXPERIMENTAL: Query whether setting a feature to a specific value is supported.
 String getEncoding()
          DOM L3 EXPERIMENTAL: The character encoding in which the output will be written.
 org.apache.xerces.dom3.DOMErrorHandler getErrorHandler()
          The error handler that will receive error notifications during serialization.
 boolean getFeature(String name)
          DOM L3-EXPERIMENTAL: Look up the value of a feature.
 DOMWriterFilter getFilter()
          When the application provides a filter, the serializer will call out to the filter before serializing each Node.
 String getNewLine()
          DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out.
 void setEncoding(String encoding)
          DOM L3 EXPERIMENTAL: The character encoding in which the output will be written.
 void setErrorHandler(org.apache.xerces.dom3.DOMErrorHandler errorHandler)
          DOM L3 EXPERIMENTAL: The error handler that will receive error notifications during serialization.
 void setFeature(String name, boolean state)
          DOM L3-EXPERIMENTAL: Set the state of a feature.
 void setFilter(DOMWriterFilter filter)
          When the application provides a filter, the serializer will call out to the filter before serializing each Node.
 void setNewLine(String newLine)
          DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out.
 boolean writeNode(OutputStream destination, Node wnode)
          DOM L3 EXPERIMENTAL: Write out the specified node as described above in the description of DOMWriter.
 String writeToString(Node wnode)
          DOM L3 EXPERIMENTAL: Serialize the specified node as described above in the description of DOMWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMWriterImpl

public DOMWriterImpl(boolean namespaces)
Constructs a new DOMWriter. The constructor turns on the namespace support in XMLSerializer and initializes the following fields: fNSBinder, fLocalNSBinder, fSymbolTable, fEmptySymbol, fXmlSymbol, fXmlnsSymbol, fNamespaceCounter, fFeatures.

Method Detail

canSetFeature

public boolean canSetFeature(String name,
                             boolean state)
DOM L3-EXPERIMENTAL: Query whether setting a feature to a specific value is supported.
The feature name has the same form as a DOM hasFeature string.

Specified by:
canSetFeature in interface DOMWriter
Parameters:
name - The feature name, which is a DOM has-feature style string.
state - The requested state of the feature (true or false).
Returns:
true if the feature could be successfully set to the specified value, or false if the feature is not recognized or the requested value is not supported. The value of the feature itself is not changed.

getEncoding

public String getEncoding()
DOM L3 EXPERIMENTAL: The character encoding in which the output will be written.
The encoding to use when writing is determined as follows: If the encoding attribute has been set, that value will be used.If the encoding attribute is null or empty, but the item to be written includes an encoding declaration, that value will be used.If neither of the above provides an encoding name, a default encoding of "UTF-8" will be used.
The default value is null.

Specified by:
getEncoding in interface DOMWriter

getErrorHandler

public org.apache.xerces.dom3.DOMErrorHandler getErrorHandler()
The error handler that will receive error notifications during serialization. The node where the error occured is passed to this error handler, any modification to nodes from within an error callback should be avoided since this will result in undefined, implementation dependent behavior.

Specified by:
getErrorHandler in interface DOMWriter

getFeature

public boolean getFeature(String name)
                   throws DOMException
DOM L3-EXPERIMENTAL: Look up the value of a feature.
The feature name has the same form as a DOM hasFeature string

Specified by:
getFeature in interface DOMWriter
Parameters:
name - The feature name, which is a string with DOM has-feature syntax.
Returns:
The current state of the feature (true or false).
Throws:
DOMException - Raise a NOT_FOUND_ERR When the DOMWriter does not recognize the feature name.

getFilter

public DOMWriterFilter getFilter()
When the application provides a filter, the serializer will call out to the filter before serializing each Node. Attribute nodes are never passed to the filter. The filter implementation can choose to remove the node from the stream or to terminate the serialization early.

Specified by:
getFilter in interface DOMWriter

getNewLine

public String getNewLine()
DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out. The only permitted values are these:
null
Use a default end-of-line sequence. DOM implementations should choose the default to match the usual convention for text files in the environment being used. Implementations must choose a default sequence that matches one of those allowed by 2.11 "End-of-Line Handling".
CR
The carriage-return character (#xD).
CR-LF
The carriage-return and line-feed characters (#xD #xA).
LF
The line-feed character (#xA).

The default value for this attribute is null.

Specified by:
getNewLine in interface DOMWriter

setEncoding

public void setEncoding(String encoding)
DOM L3 EXPERIMENTAL: The character encoding in which the output will be written.
The encoding to use when writing is determined as follows: If the encoding attribute has been set, that value will be used.If the encoding attribute is null or empty, but the item to be written includes an encoding declaration, that value will be used.If neither of the above provides an encoding name, a default encoding of "UTF-8" will be used.
The default value is null.

Specified by:
setEncoding in interface DOMWriter

setErrorHandler

public void setErrorHandler(org.apache.xerces.dom3.DOMErrorHandler errorHandler)
DOM L3 EXPERIMENTAL: The error handler that will receive error notifications during serialization. The node where the error occured is passed to this error handler, any modification to nodes from within an error callback should be avoided since this will result in undefined, implementation dependent behavior.

Specified by:
setErrorHandler in interface DOMWriter

setFeature

public void setFeature(String name,
                       boolean state)
                throws DOMException
DOM L3-EXPERIMENTAL: Set the state of a feature.
The feature name has the same form as a DOM hasFeature string.
It is possible for a DOMWriter to recognize a feature name but to be unable to set its value.

Specified by:
setFeature in interface DOMWriter
Parameters:
name - The feature name.
state - The requested state of the feature (true or false).
Throws:
DOMException - Raise a NOT_SUPPORTED_ERR exception when the DOMWriter recognizes the feature name but cannot set the requested value.
Raise a NOT_FOUND_ERR When the DOMWriter does not recognize the feature name.

setFilter

public void setFilter(DOMWriterFilter filter)
When the application provides a filter, the serializer will call out to the filter before serializing each Node. Attribute nodes are never passed to the filter. The filter implementation can choose to remove the node from the stream or to terminate the serialization early.

Specified by:
setFilter in interface DOMWriter

setNewLine

public void setNewLine(String newLine)
DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out. The only permitted values are these:
null
Use a default end-of-line sequence. DOM implementations should choose the default to match the usual convention for text files in the environment being used. Implementations must choose a default sequence that matches one of those allowed by 2.11 "End-of-Line Handling".
CR
The carriage-return character (#xD).
CR-LF
The carriage-return and line-feed characters (#xD #xA).
LF
The line-feed character (#xA).

The default value for this attribute is null.

Specified by:
setNewLine in interface DOMWriter

writeNode

public boolean writeNode(OutputStream destination,
                         Node wnode)
DOM L3 EXPERIMENTAL: Write out the specified node as described above in the description of DOMWriter. Writing a Document or Entity node produces a serialized form that is well formed XML. Writing other node types produces a fragment of text in a form that is not fully defined by this document, but that should be useful to a human for debugging or diagnostic purposes.

Specified by:
writeNode in interface DOMWriter
Parameters:
destination - The destination for the data to be written.
wnode - The Document or Entity node to be written. For other node types, something sensible should be written, but the exact serialized form is not specified.
Returns:
Returns true if node was successfully serialized and false in case a failure occured and the failure wasn't canceled by the error handler.
Throws:
none

writeToString

public String writeToString(Node wnode)
                     throws DOMException
DOM L3 EXPERIMENTAL: Serialize the specified node as described above in the description of DOMWriter. The result of serializing the node is returned as a string. Writing a Document or Entity node produces a serialized form that is well formed XML. Writing other node types produces a fragment of text in a form that is not fully defined by this document, but that should be useful to a human for debugging or diagnostic purposes.

Specified by:
writeToString in interface DOMWriter
Parameters:
wnode - The node to be written.
Returns:
Returns the serialized data, or null in case a failure occured and the failure wasn't canceled by the error handler.
Throws:
DOMException - DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a DOMString.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs90
Copyright 2005 BEA Systems Inc.