public class ObjectUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends SAMLObject> |
createSamlObject(Class<T> clazz)
Utility method for creating an OpenSAML
SAMLObject using the default element name of the class. |
static <T extends SAMLObject> |
createSamlObject(Class<T> clazz,
QName elementName)
Utility method for creating an OpenSAML
SAMLObject given its element name. |
static <T extends XMLObject> |
createXMLObject(Class<T> clazz,
QName elementName)
Utility method for creating an
XMLObject given its element name. |
static <T extends XMLObject> |
createXMLObject(Class<T> clazz,
QName registeredElementName,
QName elementNameToAssign)
Utility method for creating an
XMLObject given its registered element name but where the
elementNameToAssign is assigned to the object created. |
static <T extends SAMLObject> |
getBuilder(Class<T> clazz)
Returns the builder object that can be used to create objects of the supplied class type.
|
static <T extends XMLObject> |
getBuilder(QName elementName)
Returns the builder object that can be used to build object for the given element name.
|
static <T extends SAMLObject> |
getDefaultElementName(Class<T> clazz)
Returns the default element name for the supplied class
|
static <T extends XMLObject> |
marshall(T object)
Marshalls the supplied
XMLObject into an Element . |
static <T extends SAMLObject> |
toString(T object)
Returns the given SAML object in its "pretty print" XML string form.
|
static <T extends SAMLObject> |
toStringSafe(T object)
The same as
Object.toString() but the method never throws (returns the empty string instead). |
static <T extends XMLObject> |
unmarshall(Element xml,
Class<T> targetClass)
Unmarshalls the supplied element into the given type.
|
static <T extends XMLObject> |
unmarshall(InputStream inputStream,
Class<T> targetClass)
Unmarshalls the supplied input stream into the given type.
|
public static <T extends SAMLObject> T createSamlObject(Class<T> clazz)
SAMLObject
using the default element name of the class.
Note: The field DEFAULT_ELEMENT_NAME of the given class will be used as the object's element name.
T
- the type of the class to createclazz
- the class to createcreateSamlObject(Class, QName)
public static <T extends SAMLObject> T createSamlObject(Class<T> clazz, QName elementName)
SAMLObject
given its element name.T
- the typeclazz
- the class to createelementName
- the element name to assign the object that is created.public static <T extends XMLObject> T createXMLObject(Class<T> clazz, QName elementName)
XMLObject
given its element name.T
- the typeclazz
- the class to createelementName
- the element name for the XML object to createpublic static <T extends XMLObject> T createXMLObject(Class<T> clazz, QName registeredElementName, QName elementNameToAssign)
XMLObject
given its registered element name but where the
elementNameToAssign
is assigned to the object created.T
- the typeclazz
- the class to createregisteredElementName
- the element name that the object is registered underelementNameToAssign
- the element to assign to the object that is createdpublic static <T extends SAMLObject> QName getDefaultElementName(Class<T> clazz)
T
- the typeclazz
- class to checkpublic static <T extends SAMLObject> XMLObjectBuilder<T> getBuilder(Class<T> clazz)
Note: The field DEFAULT_ELEMENT_NAME of the given class will be used as the object's element name.
T
- the typeclazz
- the class which we want a builder forgetBuilder(QName)
public static <T extends XMLObject> XMLObjectBuilder<T> getBuilder(QName elementName)
T
- the typeelementName
- the element name for the XML object that the builder should returnpublic static <T extends XMLObject> Element marshall(T object) throws MarshallingException
XMLObject
into an Element
.T
- the typeobject
- the object to marshallMarshallingException
- for marshalling errorspublic static <T extends XMLObject> T unmarshall(Element xml, Class<T> targetClass) throws UnmarshallingException
T
- the typexml
- the DOM (XML) to unmarshalltargetClass
- the required classXMLObject
of the given typeUnmarshallingException
- for unmarshalling errorspublic static <T extends XMLObject> T unmarshall(InputStream inputStream, Class<T> targetClass) throws XMLParserException, UnmarshallingException
T
- the typeinputStream
- the input stream of the XML resourcetargetClass
- the required classXMLObject
of the given typeXMLParserException
- for XML parsing errorsUnmarshallingException
- for unmarshalling errorspublic static <T extends SAMLObject> String toString(T object) throws MarshallingException
T
- the type of object to "print"object
- the object to display as a stringMarshallingException
- for marshalling errorspublic static <T extends SAMLObject> String toStringSafe(T object)
Object.toString()
but the method never throws (returns the empty string instead). Useful for logging
statements.T
- the type of object to "print"object
- the object to display as a stringCopyright © 2018 Litsec AB. All rights reserved.