net.shibboleth.utilities.java.support.xml
Class SerializeSupport

java.lang.Object
  extended by net.shibboleth.utilities.java.support.xml.SerializeSupport

public final class SerializeSupport
extends Object

Set of helper functions for serializing/writing DOM nodes.


Constructor Summary
private SerializeSupport()
          Constructor.
 
Method Summary
static DOMImplementationLS getDomLsImplementation(Node node)
          Gets the DOM, level 3, Load/Store implementation associated with the given node.
static LSSerializer getLsSerializer(DOMImplementationLS domImplLS, Map<String,Object> serializerParams)
          Obtain a the DOM, level 3, Load/Save serializer LSSerializer instance from the given DOMImplementationLS instance.
static String nodeToString(Node node)
          Converts a Node into a String using the DOM, level 3, Load/Save serializer.
static String prettyPrintXML(Node node)
          Pretty prints the XML node.
static void writeNode(Node node, OutputStream output)
          Writes a Node out to a Writer using the DOM, level 3, Load/Save serializer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializeSupport

private SerializeSupport()
Constructor.

Method Detail

nodeToString

@Nonnull
public static String nodeToString(@Nonnull
                                          Node node)
Converts a Node into a String using the DOM, level 3, Load/Save serializer.

Parameters:
node - the node to be written to a string
Returns:
the string representation of the node

prettyPrintXML

@Nonnull
public static String prettyPrintXML(@Nonnull
                                            Node node)
Pretty prints the XML node.

Parameters:
node - xml node to print
Returns:
pretty-printed xml

writeNode

public static void writeNode(@Nonnull
                             Node node,
                             @Nonnull
                             OutputStream output)
Writes a Node out to a Writer using the DOM, level 3, Load/Save serializer. The written content is encoded using the encoding specified in the writer configuration.

Parameters:
node - the node to write out
output - the output stream to write the XML to

getLsSerializer

@Nonnull
public static LSSerializer getLsSerializer(@Nonnull
                                                   DOMImplementationLS domImplLS,
                                                   @Nullable
                                                   Map<String,Object> serializerParams)
Obtain a the DOM, level 3, Load/Save serializer LSSerializer instance from the given DOMImplementationLS instance.

The serializer instance will be configured with the parameters passed as the serializerParams argument. It will also be configured with an LSSerializerFilter that shows all nodes to the filter, and accepts all nodes shown.

Parameters:
domImplLS - the DOM Level 3 Load/Save implementation to use
serializerParams - parameters to pass to the DOMConfiguration of the serializer instance, obtained via LSSerializer.getDomConfig(). May be null.
Returns:
a new LSSerializer instance

getDomLsImplementation

@Nonnull
public static DOMImplementationLS getDomLsImplementation(@Nonnull
                                                                 Node node)
Gets the DOM, level 3, Load/Store implementation associated with the given node.

Parameters:
node - the node, never null
Returns:
the Load/Store implementation, never null


Copyright © 1999-2012. All Rights Reserved.