Class SerializeSupport
- java.lang.Object
-
- net.shibboleth.utilities.java.support.xml.SerializeSupport
-
public final class SerializeSupport extends Object
Set of helper functions for serializing/writing DOM nodes.
-
-
Field Summary
Fields Modifier and Type Field Description private static Map<String,Object>prettyPrintParamsDOM configuration parameters used by LSSerializer in pretty print format output.
-
Constructor Summary
Constructors Modifier Constructor Description privateSerializeSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DOMImplementationLSgetDOMImplementationLS(Node node)Gets the DOM, level 3, Load/Store implementation associated with the given node.static LSSerializergetLSSerializer(DOMImplementationLS domImplLS, Map<String,Object> serializerParams)Obtain a the DOM, level 3, Load/Save serializerLSSerializerinstance from the givenDOMImplementationLSinstance.static StringnodeToString(Node node)Converts a Node into a String using the DOM, level 3, Load/Save serializer.static StringnodeToString(Node node, Map<String,Object> serializerParams)Converts a Node into a String using the DOM, level 3, Load/Save serializer.static StringprettyPrintXML(Node node)Converts a Node into a String, using the DOM, level 3, Load/Save serializer.static voidwriteNode(Node node, OutputStream output)Writes a Node out to a Writer using the DOM, level 3, Load/Save serializer.static voidwriteNode(Node node, OutputStream output, Map<String,Object> serializerParams)Writes a Node out to a Writer using the DOM, level 3, Load/Save serializer.
-
-
-
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
-
nodeToString
@Nonnull public static String nodeToString(@Nonnull Node node, @Nullable Map<String,Object> serializerParams)
Converts a Node into a String using the DOM, level 3, Load/Save serializer.- Parameters:
node- the node to be written to a stringserializerParams- parameters to pass to theDOMConfigurationof the serializer instance, obtained viaLSSerializer.getDomConfig(). May be null.- Returns:
- the string representation of the node
-
prettyPrintXML
@Nonnull public static String prettyPrintXML(@Nonnull Node node)
Converts a Node into a String, using the DOM, level 3, Load/Save serializer. A serializer option of 'format-pretty-print=true' is used to produce the pretty-print formatting.- 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 outoutput- the output stream to write the XML to
-
writeNode
public static void writeNode(@Nonnull Node node, @Nonnull OutputStream output, @Nullable Map<String,Object> serializerParams)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 outoutput- the output stream to write the XML toserializerParams- parameters to pass to theDOMConfigurationof the serializer instance, obtained viaLSSerializer.getDomConfig(). May be null.
-
getLSSerializer
@Nonnull public static LSSerializer getLSSerializer(@Nonnull DOMImplementationLS domImplLS, @Nullable Map<String,Object> serializerParams)
Obtain a the DOM, level 3, Load/Save serializerLSSerializerinstance from the givenDOMImplementationLSinstance.The serializer instance will be configured with the parameters passed as the
serializerParamsargument. It will also be configured with anLSSerializerFilterthat shows all nodes to the filter, and accepts all nodes shown.- Parameters:
domImplLS- the DOM Level 3 Load/Save implementation to useserializerParams- parameters to pass to theDOMConfigurationof the serializer instance, obtained viaLSSerializer.getDomConfig(). May be null.- Returns:
- a new LSSerializer instance
-
getDOMImplementationLS
@Nonnull public static DOMImplementationLS getDOMImplementationLS(@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
-
-