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

public final Class LSSerializerImpl

extends Object
implements DOMConfiguration, LSSerializer
Class Inheritance
All Implemented Interfaces
org.w3c.dom.ls.LSSerializer, org.w3c.dom.DOMConfiguration
Imports
java.io.File, .FileOutputStream, .OutputStream, .OutputStreamWriter, .StringWriter, .UnsupportedEncodingException, .Writer, java.net.HttpURLConnection, .URL, .URLConnection, java.util.Properties, jdk.xml.internal.SecuritySupport, .JdkConstants, .JdkProperty, .JdkProperty.ImplPropMap, .JdkProperty.State, com.sun.org.apache.xml.internal.serializer.DOM3Serializer, .Encodings, .Serializer, .ToXMLStream, .OutputPropertiesFactory, com.sun.org.apache.xml.internal.serializer.utils.MsgKey, .Utils, .SystemIDResolver, org.w3c.dom.DOMConfiguration, .DOMError, .DOMErrorHandler, .DOMException, .DOMStringList, .Document, .Node, org.w3c.dom.ls.LSException, .LSOutput, .LSSerializer, .LSSerializerFilter

Implemenatation of DOM Level 3 org.w3c.ls.LSSerializer and org.w3c.dom.ls.DOMConfiguration. Serialization is achieved by delegating serialization calls to org.apache.xml.serializer.ToStream or one of its derived classes depending on the serialization method, while walking the DOM in DOM3TreeWalker.
Version
$Id:
See Also
org.w3c.dom.ls.LSSerializer, org.w3c.dom.DOMConfiguration

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private Properties
private DOMErrorHandler
private DOM3Serializer
private String
private String
protected int
private JdkProperty<Boolean>
private String[]
private LSSerializerFilter
private Node
private Serializer
fXMLSerializer

private data members

private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
LSSerializerImpl()

Constructor: Creates a LSSerializerImpl object.

Method Summary

Modifier and TypeMethod and Description
public boolean
canSetParameter(String
A String containing the DOMConfiguration parameter name.
name
,
Object
An Object specifying the value of the corresponding parameter.
value
)

Implements org.w3c.dom.DOMConfiguration.canSetParameter.

Checks if setting a parameter to a specific value is supported.

public DOMConfiguration

Returns:

A DOMConfiguration object.
getDomConfig
()

Implements org.w3c.dom.ls.LSSerializer.getDomConfig.

Returns the DOMConfiguration of the LSSerializer.

public DOMErrorHandler

Returns:

Returns the fDOMErrorHandler.
getErrorHandler
()

This method returns the LSSerializer's error handler.

public LSSerializerFilter

Returns:

A LSSerializerFilter object.
getFilter
()

Implements org.w3c.dom.ls.LSSerializer.getFilter.

Returns the DOMConfiguration of the LSSerializer.

protected String

Returns:

A String containing the input encoding.
getInputEncoding
(Node
The Node to serialize
nodeArg
)

Determines the Input Encoding of the Document Node to serialize.

public String

Returns:

A String containing the end-of-line character sequence used in serialization.
getNewLine
()

Implements org.w3c.dom.ls.LSSerializer.getNewLine.

Returns the End-Of-Line sequence of characters to be used in the XML being serialized.

public Object

Returns:

Object The value of the parameter if known.
getParameter
(String
A String containing the DOMConfiguration parameter name whose value is to be returned.
name
)

Implements org.w3c.dom.DOMConfiguration.getParameter.

This method returns the value of a parameter if known.

public DOMStringList

Returns:

DOMStringList A list of DOMConfiguration parameters recognized by the serializer
getParameterNames
()

Implements org.w3c.dom.DOMConfiguration.getParameterNames.

This method returns a of the parameters supported by this DOMConfiguration object and for which at least one value can be set by the application

protected String

Returns:

A String containing the encoding pseudo-attribute of the XMLDecl.
getXMLEncoding
(Node
The Node to serialize
nodeArg
)

Determines the XML Encoding of the Document Node to serialize.

protected String

Returns:

A String containing the version pseudo-attribute of the XMLDecl.
getXMLVersion
(Node
The Node to serialize
nodeArg
)

Determines the XML Version of the Document Node to serialize.

public void
initializeSerializerProps()

Initializes the underlying serializer's configuration depending on the default DOMConfiguration parameters.

public void
setFilter(LSSerializerFilter
A LSSerializerFilter to be applied to the stream to serialize.
filter
)

Implements org.w3c.dom.ls.LSSerializer.setFilter.

Set a LSSerilizerFilter on the LSSerializer.

public void
setNewLine(String
a String that is the end-of-line character sequence to be used in serialization.
newLine
)

Implements org.w3c.dom.ls.LSSerializer.setNewLine.

Sets the End-Of-Line sequence of characters to be used in the XML being serialized.

public void
setParameter(String
A String containing the DOMConfiguration parameter name.
name
,
Object
An Object contaiing the parameters value to set.
value
)

Implements org.w3c.dom.DOMConfiguration.setParameter.

This method sets the value of the named parameter.

public boolean
write(Node
The Node to serialize.
nodeArg
,
LSOutput
The destination for the serialized DOM.
destination
)

Implements org.w3c.dom.ls.LSSerializer.write.

Serializes the specified node to the specified LSOutput and returns true if the Node was successfully serialized.

public String
writeToString(Node
The Node to serialize.
nodeArg
)

Implements org.w3c.dom.ls.LSSerializer.writeToString.

Serializes the specified node and returns a String with the serialized data to the caller.

public boolean
writeToURI(Node
The Node to serialize.
nodeArg
,
String
The URI to write to.
uri
)

Implements org.w3c.dom.ls.LSSerializer.writeToURI.

Serializes the specified node to the specified URI and returns true if the Node was successfully serialized.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANONICALback to summary
private static final int CANONICAL
CDATAback to summary
private static final int CDATA
CHARNORMALIZEback to summary
private static final int CHARNORMALIZE
COMMENTSback to summary
private static final int COMMENTS
DISCARDDEFAULTback to summary
private static final int DISCARDDEFAULT
DTNORMALIZEback to summary
private static final int DTNORMALIZE
ELEM_CONTENT_WHITESPACEback to summary
private static final int ELEM_CONTENT_WHITESPACE
ENTITIESback to summary
private static final int ENTITIES
fDOMConfigPropertiesback to summary
private Properties fDOMConfigProperties
fDOMErrorHandlerback to summary
private DOMErrorHandler fDOMErrorHandler
fDOMSerializerback to summary
private DOM3Serializer fDOMSerializer
fEncodingback to summary
private String fEncoding
fEndOfLineback to summary
private String fEndOfLine
fFeaturesback to summary
protected int fFeatures
fIsStandaloneback to summary
private JdkProperty<Boolean> fIsStandalone
fRecognizedParametersback to summary
private String[] fRecognizedParameters
Annotations
@SuppressWarnings:deprecation
fSerializerFilterback to summary
private LSSerializerFilter fSerializerFilter
fVisitedNodeback to summary
private Node fVisitedNode
fXMLSerializerback to summary
private Serializer fXMLSerializer

private data members

IGNORE_CHAR_DENORMALIZEback to summary
private static final int IGNORE_CHAR_DENORMALIZE
INFOSETback to summary
private static final int INFOSET
IS_STANDALONEback to summary
private static final int IS_STANDALONE
NAMESPACEDECLSback to summary
private static final int NAMESPACEDECLS
NAMESPACESback to summary
private static final int NAMESPACES
NORMALIZECHARSback to summary
private static final int NORMALIZECHARS
PRETTY_PRINTback to summary
private static final int PRETTY_PRINT
SCHEMAVALIDATEback to summary
private static final int SCHEMAVALIDATE
SPLITCDATAback to summary
private static final int SPLITCDATA
VALIDATEback to summary
private static final int VALIDATE
WELLFORMEDback to summary
private static final int WELLFORMED
XMLDECLback to summary
private static final int XMLDECL

Constructor Detail

LSSerializerImplback to summary
public LSSerializerImpl()

Constructor: Creates a LSSerializerImpl object. The underlying XML 1.0 or XML 1.1 org.apache.xml.serializer.Serializer object is created and initialized the first time any of the write methods are invoked to serialize the Node. Subsequent write methods on the same LSSerializerImpl object will use the previously created Serializer object.

Method Detail

canSetParameterback to summary
public boolean canSetParameter(String name, Object value)

Implements org.w3c.dom.DOMConfiguration.canSetParameter.

Checks if setting a parameter to a specific value is supported.

Parameters
name:String

A String containing the DOMConfiguration parameter name.

value:Object

An Object specifying the value of the corresponding parameter.

Returns:boolean

Doc from org.w3c.dom.DOMConfiguration.canSetParameter.

true if the parameter could be successfully set to the specified value, or false if the parameter is not recognized or the requested value is not supported. This does not change the current value of the parameter itself.

Annotations
@SuppressWarnings:deprecation
Since
DOM Level 3
See Also
org.w3c.dom.DOMConfiguration#canSetParameter(java.lang.String, java.lang.Object)
getDomConfigback to summary
public DOMConfiguration getDomConfig()

Implements org.w3c.dom.ls.LSSerializer.getDomConfig.

Returns the DOMConfiguration of the LSSerializer.

Returns:DOMConfiguration

A DOMConfiguration object.

Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#getDomConfig()
getErrorHandlerback to summary
public DOMErrorHandler getErrorHandler()

This method returns the LSSerializer's error handler.

Returns:DOMErrorHandler

Returns the fDOMErrorHandler.

getFilterback to summary
public LSSerializerFilter getFilter()

Implements org.w3c.dom.ls.LSSerializer.getFilter.

Returns the DOMConfiguration of the LSSerializer.

Returns:LSSerializerFilter

A LSSerializerFilter object.

Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#getFilter()
getInputEncodingback to summary
protected String getInputEncoding(Node nodeArg)

Determines the Input Encoding of the Document Node to serialize. If the Document Node is not a DOM Level 3 Node, then null is returned.

Parameters
nodeArg:Node

The Node to serialize

Returns:String

A String containing the input encoding.

getNewLineback to summary
public String getNewLine()

Implements org.w3c.dom.ls.LSSerializer.getNewLine.

Returns the End-Of-Line sequence of characters to be used in the XML being serialized. If none is set a default "\n" is returned.

Returns:String

A String containing the end-of-line character sequence used in serialization.

Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#getNewLine()
getParameterback to summary
public Object getParameter(String name) throws DOMException

Implements org.w3c.dom.DOMConfiguration.getParameter.

This method returns the value of a parameter if known.

Parameters
name:String

A String containing the DOMConfiguration parameter name whose value is to be returned.

Returns:Object

Object The value of the parameter if known.

Exceptions
DOMException:

Doc from org.w3c.dom.DOMConfiguration.getParameter.

NOT_FOUND_ERR: Raised when the parameter name is not recognized.

See Also
org.w3c.dom.DOMConfiguration#getParameter(java.lang.String)
getParameterNamesback to summary
public DOMStringList getParameterNames()

Implements org.w3c.dom.DOMConfiguration.getParameterNames.

This method returns a of the parameters supported by this DOMConfiguration object and for which at least one value can be set by the application

Returns:DOMStringList

DOMStringList A list of DOMConfiguration parameters recognized by the serializer

See Also
org.w3c.dom.DOMConfiguration#getParameterNames()
getXMLEncodingback to summary
protected String getXMLEncoding(Node nodeArg)

Determines the XML Encoding of the Document Node to serialize. If the Document Node is not a DOM Level 3 Node, then the default encoding "UTF-8" is returned.

Parameters
nodeArg:Node

The Node to serialize

Returns:String

A String containing the encoding pseudo-attribute of the XMLDecl.

Exceptions
Throwable:
if the DOM implementation does not implement Document.getXmlEncoding()
getXMLVersionback to summary
protected String getXMLVersion(Node nodeArg)

Determines the XML Version of the Document Node to serialize. If the Document Node is not a DOM Level 3 Node, then the default version returned is 1.0.

Parameters
nodeArg:Node

The Node to serialize

Returns:String

A String containing the version pseudo-attribute of the XMLDecl.

Exceptions
Throwable:
if the DOM implementation does not implement Document.getXmlVersion()
initializeSerializerPropsback to summary
public void initializeSerializerProps()

Initializes the underlying serializer's configuration depending on the default DOMConfiguration parameters. This method must be called before a node is to be serialized.

setFilterback to summary
public void setFilter(LSSerializerFilter filter)

Implements org.w3c.dom.ls.LSSerializer.setFilter.

Set a LSSerilizerFilter on the LSSerializer. When set, the filter is called before each node is serialized which depending on its implemention determines if the node is to be serialized or not.

Parameters
filter:LSSerializerFilter

A LSSerializerFilter to be applied to the stream to serialize.

Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#setFilter
setNewLineback to summary
public void setNewLine(String newLine)

Implements org.w3c.dom.ls.LSSerializer.setNewLine.

Sets the End-Of-Line sequence of characters to be used in the XML being serialized. Setting this attribute to null will reset its value to the default value i.e. "\n".

Parameters
newLine:String

a String that is the end-of-line character sequence to be used in serialization.

Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#setNewLine
setParameterback to summary
public void setParameter(String name, Object value) throws DOMException

Implements org.w3c.dom.DOMConfiguration.setParameter.

This method sets the value of the named parameter.

Parameters
name:String

A String containing the DOMConfiguration parameter name.

value:Object

An Object contaiing the parameters value to set.

Exceptions
DOMException:

Doc from org.w3c.dom.DOMConfiguration.setParameter.

NOT_FOUND_ERR: Raised when the parameter name is not recognized.
NOT_SUPPORTED_ERR: Raised when the parameter name is recognized but the requested value cannot be set.
TYPE_MISMATCH_ERR: Raised if the value type for this parameter name is incompatible with the expected value type.

See Also
org.w3c.dom.DOMConfiguration#setParameter(java.lang.String, java.lang.Object)
writeback to summary
public boolean write(Node nodeArg, LSOutput destination) throws LSException

Implements org.w3c.dom.ls.LSSerializer.write.

Serializes the specified node to the specified LSOutput and returns true if the Node was successfully serialized.

Parameters
nodeArg:Node

The Node to serialize.

destination:LSOutput

Doc from org.w3c.dom.ls.LSSerializer.write.

The destination for the serialized DOM.

Returns:boolean

Doc from org.w3c.dom.ls.LSSerializer.write.

Returns true if node was successfully serialized. Return false in case the normal processing stopped but the implementation kept serializing the document; the result of the serialization being implementation dependent then.

Exceptions
LSException:
SERIALIZE_ERR: Raised if the LSSerializer was unable to serialize the node.
Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#write(org.w3c.dom.Node, org.w3c.dom.ls.LSOutput)
writeToStringback to summary
public String writeToString(Node nodeArg) throws DOMException, LSException

Implements org.w3c.dom.ls.LSSerializer.writeToString.

Serializes the specified node and returns a String with the serialized data to the caller.

Parameters
nodeArg:Node

The Node to serialize.

Returns:String

Doc from org.w3c.dom.ls.LSSerializer.writeToString.

Returns the serialized data.

Exceptions
DOMException:

Doc from org.w3c.dom.ls.LSSerializer.writeToString.

DOMSTRING_SIZE_ERR: Raised if the resulting string is too long to fit in a DOMString.

LSException:
SERIALIZE_ERR: Raised if the LSSerializer was unable to serialize the node.
Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#writeToString(org.w3c.dom.Node)
writeToURIback to summary
public boolean writeToURI(Node nodeArg, String uri) throws LSException

Implements org.w3c.dom.ls.LSSerializer.writeToURI.

Serializes the specified node to the specified URI and returns true if the Node was successfully serialized.

Parameters
nodeArg:Node

The Node to serialize.

uri:String

Doc from org.w3c.dom.ls.LSSerializer.writeToURI.

The URI to write to.

Returns:boolean

Doc from org.w3c.dom.ls.LSSerializer.writeToURI.

Returns true if node was successfully serialized. Return false in case the normal processing stopped but the implementation kept serializing the document; the result of the serialization being implementation dependent then.

Exceptions
LSException:
SERIALIZE_ERR: Raised if the LSSerializer was unable to serialize the node.
Since
DOM Level 3
See Also
org.w3c.dom.ls.LSSerializer#writeToURI(org.w3c.dom.Node, String)