XMLTooling-J 1.3.2-redhat-4

org.opensaml.xml.util
Class XMLObjectHelper

java.lang.Object
  extended by org.opensaml.xml.util.XMLObjectHelper

public final class XMLObjectHelper
extends Object

A helper class for working with XMLObjects.


Method Summary
static
<T extends XMLObject>
T
cloneXMLObject(T originalXMLObject)
          Clone an XMLObject by brute force:
static
<T extends XMLObject>
T
cloneXMLObject(T originalXMLObject, boolean rootInNewDocument)
          Clone an XMLObject by brute force:
static String lookupNamespacePrefix(XMLObject xmlObject, String namespaceURI)
          Get the prefix bound to the specified namespace URI within the scope of the specified XMLObject.
static String lookupNamespaceURI(XMLObject xmlObject, String prefix)
          Get the namespace URI bound to the specified prefix within the scope of the specified XMLObject.
static Element marshall(XMLObject xmlObject)
          Marshall an XMLObject.
static void marshallToOutputStream(XMLObject xmlObject, OutputStream outputStream)
          Marshall an XMLObject to an OutputStream.
static void marshallToWriter(XMLObject xmlObject, Writer writer)
          Marshall an XMLObject to a Writer.
static XMLObject unmarshallFromInputStream(ParserPool parserPool, InputStream inputStream)
          Unmarshall a Document from an InputSteam.
static XMLObject unmarshallFromReader(ParserPool parserPool, Reader reader)
          Unmarshall a Document from a Reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cloneXMLObject

public static <T extends XMLObject> T cloneXMLObject(T originalXMLObject)
                                          throws MarshallingException,
                                                 UnmarshallingException
Clone an XMLObject by brute force:

1) Marshall the original object if necessary 2) Clone the resulting DOM Element 3) Unmarshall a new XMLObject tree around it.

This method variant is equivalent to cloneXMLObject(originalXMLObject, false).

Type Parameters:
T - the type of object being cloned
Parameters:
originalXMLObject - the object to be cloned
Returns:
a clone of the original object
Throws:
MarshallingException - if original object can not be marshalled
UnmarshallingException - if cloned object tree can not be unmarshalled

cloneXMLObject

public static <T extends XMLObject> T cloneXMLObject(T originalXMLObject,
                                                     boolean rootInNewDocument)
                                          throws MarshallingException,
                                                 UnmarshallingException
Clone an XMLObject by brute force:

1) Marshall the original object if necessary 2) Clone the resulting DOM Element 3) Unmarshall a new XMLObject tree around it.

Type Parameters:
T - the type of object being cloned
Parameters:
originalXMLObject - the object to be cloned
rootInNewDocument - if true the cloned object's cached DOM will be rooted in a new Document; if false, the original object's underlying DOM is cloned, but the cloned copy remains unrooted and owned by the original Document
Returns:
a clone of the original object
Throws:
MarshallingException - if original object can not be marshalled
UnmarshallingException - if cloned object tree can not be unmarshalled

unmarshallFromInputStream

public static XMLObject unmarshallFromInputStream(ParserPool parserPool,
                                                  InputStream inputStream)
                                           throws XMLParserException,
                                                  UnmarshallingException
Unmarshall a Document from an InputSteam.

Parameters:
parserPool - the ParserPool instance to use
inputStream - the InputStream to unmarshall
Returns:
the unmarshalled XMLObject
Throws:
XMLParserException - if there is a problem parsing the input data
UnmarshallingException - if there is a problem unmarshalling the parsed DOM

unmarshallFromReader

public static XMLObject unmarshallFromReader(ParserPool parserPool,
                                             Reader reader)
                                      throws XMLParserException,
                                             UnmarshallingException
Unmarshall a Document from a Reader.

Parameters:
parserPool - the ParserPool instance to use
reader - the Reader to unmarshall
Returns:
the unmarshalled XMLObject
Throws:
XMLParserException - if there is a problem parsing the input data
UnmarshallingException - if there is a problem unmarshalling the parsed DOM

marshall

public static Element marshall(XMLObject xmlObject)
                        throws MarshallingException
Marshall an XMLObject. If the XMLObject already has a cached DOM via XMLObject.getDOM(), that Element will be returned. Otherwise the object will be fully marshalled and that Element returned.

Parameters:
xmlObject - the XMLObject to marshall
Returns:
the marshalled Element
Throws:
MarshallingException - if there is a problem marshalling the XMLObject

marshallToOutputStream

public static void marshallToOutputStream(XMLObject xmlObject,
                                          OutputStream outputStream)
                                   throws MarshallingException
Marshall an XMLObject to an OutputStream.

Parameters:
xmlObject - the XMLObject to marshall
outputStream - the OutputStream to which to marshall
Throws:
MarshallingException - if there is a problem marshalling the object

marshallToWriter

public static void marshallToWriter(XMLObject xmlObject,
                                    Writer writer)
                             throws MarshallingException
Marshall an XMLObject to a Writer.

Parameters:
xmlObject - the XMLObject to marshall
writer - the Writer to which to marshall
Throws:
MarshallingException - if there is a problem marshalling the object

lookupNamespaceURI

public static String lookupNamespaceURI(XMLObject xmlObject,
                                        String prefix)
Get the namespace URI bound to the specified prefix within the scope of the specified XMLObject.

Parameters:
xmlObject - the XMLObject from which to search
prefix - the prefix to search
Returns:
the namespace URI bound to the prefix, or none if not found

lookupNamespacePrefix

public static String lookupNamespacePrefix(XMLObject xmlObject,
                                           String namespaceURI)
Get the prefix bound to the specified namespace URI within the scope of the specified XMLObject.

Parameters:
xmlObject - the XMLObject from which to search
namespaceURI - the namespace URI to search
Returns:
the prefix bound to the namespace URI, or none if not found

XMLTooling-J 1.3.2-redhat-4

Copyright © 2006-2013 Internet2. All Rights Reserved.