org.globus.ogsa.utils
Class AnyHelper

java.lang.Object
  extended byorg.globus.ogsa.utils.AnyHelper

public class AnyHelper
extends java.lang.Object

The AnyHelper is a utility that simplifies the serialization and deserialization of objects (e.g. Java Beans), strings and DOM Elements inside of types containing the XML Schema any element type, for example ExtensibilityType. This class should only be used in conjunction with sending or receiving a SOAP message. If out-of-band serialization is needed (e.g. in a background thread), then the ObjectSerializer should be used instead. Also note that all the objects used with this API must either be types generated from an XML Schema definition, or have a standard or custom typemapping.


Constructor Summary
AnyHelper()
           
 
Method Summary
static boolean contains(org.apache.axis.encoding.AnyContentType any, java.lang.Class javaClass)
          Checks to see whether type containing any element contains elements of type javaClass.
static org.w3c.dom.Element[] getAsElement(org.apache.axis.encoding.AnyContentType any)
          Converts type containing any element to an array of DOM Elements.
static org.w3c.dom.Element getAsElement(WSDLReferenceType reference)
          Returns a DOM Element representation of a WSDLReferenceType, often contained inside of a LocatorType
static java.lang.Object[] getAsObject(org.apache.axis.encoding.AnyContentType extensibility)
          Converts type containing any element to an array of java objects.
static java.lang.Object[] getAsObject(org.apache.axis.encoding.AnyContentType extensibility, java.lang.Class javaClass)
          Converts type containing any element to an array of java objects.
static org.w3c.dom.Element getAsParentElement(org.apache.axis.encoding.AnyContentType any)
          Converts type containing any element to a single DOM Element, representing the parent MessageElement.
static java.lang.String getAsParentString(org.apache.axis.encoding.AnyContentType any)
          Converts type containing any element to a String, representing the parent MessageElement.
static java.lang.String getAsRawString(org.apache.axis.encoding.AnyContentType extensibility)
          Converts type containing any element to a String (not formatted)
static ServiceDataAttributes[] getAsServiceData(org.apache.axis.encoding.AnyContentType serviceData)
          Converts type containing any element to service data attributes.
static ServiceDataAttributes[] getAsServiceData(org.apache.axis.encoding.AnyContentType serviceData, java.lang.Class javaClass)
          Converts type containing any element to service data attributes.
static ServiceDataValuesType getAsServiceDataValues(org.apache.axis.encoding.AnyContentType extensibility)
          Converts type containing any element to a ServiceDataValuesType.
static org.w3c.dom.Element getAsSingleElement(org.apache.axis.encoding.AnyContentType any)
          Converts type containing any element to a single DOM Element.
static java.lang.Object getAsSingleObject(org.apache.axis.encoding.AnyContentType extensibility)
          Converts type containing any element to a java object.
static java.lang.Object getAsSingleObject(org.apache.axis.encoding.AnyContentType extensibility, java.lang.Class javaClass)
          Converts type containing any element to a java object.
static ServiceDataAttributes getAsSingleServiceData(org.apache.axis.encoding.AnyContentType serviceData)
          Converts type containing any element to service data attributes, wrapping a single element.
static ServiceDataAttributes getAsSingleServiceData(org.apache.axis.encoding.AnyContentType serviceData, java.lang.Class javaClass)
          Converts type containing any element to service data attributes, wrapping a single element.
static java.lang.String getAsString(org.apache.axis.encoding.AnyContentType extensibility)
          Converts type containing any element to a String, formatted pretty for output.
static ExtensibilityType getExtensibility(java.lang.Object obj)
          Converts an arbitrary object to an Extensibility type.
static ExtensibilityType getExtensibility(java.lang.Object obj, javax.xml.namespace.QName qname)
          Converts an arbitrary object to an Extensibility type.
static ExtensibilityType getServiceDataValues(java.lang.Object obj)
          Converts an arbitrary object to an Extensibility type.
static org.apache.axis.message.MessageElement toAny(java.lang.Object obj)
          Populates a SOAP MessageElement with an arbitrary object.
static org.apache.axis.message.MessageElement[] toAny(java.lang.Object[] obj)
          Populates a SOAP MessageElement array with an array of arbitrary objects.
static org.apache.axis.message.MessageElement toAny(java.lang.Object obj, javax.xml.namespace.QName qname)
          Populates a SOAP MessageElement with an arbitrary object.
static org.apache.axis.message.MessageElement toAnyTypeElement(java.lang.Object obj)
          Populates a SOAP MessageElement with an arbitrary object, and wraps it inside of a value element with an xsi:type attribute.
static org.w3c.dom.Element toElement(org.apache.axis.message.MessageElement element)
          Converts a SOAP MessageElement to a DOM Element representation
static org.w3c.dom.Element[] toElement(org.apache.axis.message.MessageElement[] element)
          Array version of toElement
static java.lang.Object toObject(org.apache.axis.message.MessageElement element)
          Converts a SOAP MessageElement to a typed Java object representation.
static java.lang.Object[] toObject(org.apache.axis.message.MessageElement[] element)
          Array version of toObject
static java.lang.Object[] toObject(org.apache.axis.message.MessageElement[] element, java.lang.Class javaClass)
          Array version of toObject
static java.lang.Object toObject(org.apache.axis.message.MessageElement element, java.lang.Class javaClass)
          Converts a SOAP MessageElement to a typed Java object representation.
static ServiceDataAttributes toServiceData(org.apache.axis.message.MessageElement element)
          Converts a SOAP MessageElement to a typed Java object representation, and wraps it inside of a ServiceDataAttribute object holding attributes that the element might have been decorated with.
static ServiceDataAttributes[] toServiceData(org.apache.axis.message.MessageElement[] element)
          Array version of toServiceData
static ServiceDataAttributes[] toServiceData(org.apache.axis.message.MessageElement[] element, java.lang.Class javaClass)
          Array version of toServiceData
static ServiceDataAttributes toServiceData(org.apache.axis.message.MessageElement element, java.lang.Class javaClass)
          Converts a SOAP MessageElement to a typed Java object representation, and wraps it inside of a ServiceDataAttribute object holding attributes that the element might have been decorated with.
static java.lang.String toString(org.apache.axis.message.MessageElement element)
          Converts a SOAP MessageElement to an XML String representation
static java.lang.String[] toString(org.apache.axis.message.MessageElement[] element)
          Array version of toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnyHelper

public AnyHelper()
Method Detail

toAny

public static org.apache.axis.message.MessageElement[] toAny(java.lang.Object[] obj)
                                                      throws GridServiceException
Populates a SOAP MessageElement array with an array of arbitrary objects.

Parameters:
obj - array of objects to be serialized in the any element
Returns:
content of any element as a SOAP MessageElement array
Throws:
GridServiceException - if the object cannot be put in a MessageElement

toAnyTypeElement

public static org.apache.axis.message.MessageElement toAnyTypeElement(java.lang.Object obj)
Populates a SOAP MessageElement with an arbitrary object, and wraps it inside of a value element with an xsi:type attribute. This is similar to using the xsd:any in the same way you would use xsd:anyType objects.

Parameters:
obj - object to be serialized in the any element
Returns:
content of any element as a SOAP MessageElement

toAny

public static org.apache.axis.message.MessageElement toAny(java.lang.Object obj)
                                                    throws GridServiceException
Populates a SOAP MessageElement with an arbitrary object. If obj is not a DOM Element it will get wrapped inside of a value element.

Parameters:
obj - object to be serialized in the any element
Returns:
content of any element as a SOAP MessageElement
Throws:
GridServiceException - if the object cannot be put in a MessageElement

toAny

public static org.apache.axis.message.MessageElement toAny(java.lang.Object obj,
                                                           javax.xml.namespace.QName qname)
                                                    throws GridServiceException
Populates a SOAP MessageElement with an arbitrary object. The object will get wrapped inside of an element named after the qname parameter.

Parameters:
obj - object to be serialized in the any element
qname - name of element the value should be wrapped inside, if null value element wrapping will be used
Returns:
content of any element as a SOAP MessageElement
Throws:
GridServiceException - if the object cannot be put in a MessageElement

toElement

public static org.w3c.dom.Element toElement(org.apache.axis.message.MessageElement element)
                                     throws GridServiceException
Converts a SOAP MessageElement to a DOM Element representation

Parameters:
element - SOAP MessageElement to be converted
Returns:
DOM Element representing the input
Throws:
GridServiceException - if the DOM Element could not be created

toString

public static java.lang.String toString(org.apache.axis.message.MessageElement element)
Converts a SOAP MessageElement to an XML String representation

Parameters:
element - SOAP MessageElement to be converted
Returns:
String in XML format representing the input

toObject

public static java.lang.Object toObject(org.apache.axis.message.MessageElement element)
                                 throws GridServiceException
Converts a SOAP MessageElement to a typed Java object representation. The object must have the appropriate type mappings for this operation to succeed.

Parameters:
element - SOAP MessageElement to be converted
Returns:
Java object that maps to the XML representation of the input
Throws:
GridServiceException - if the input could not be deserialized into a java type, for example because of missing type mappings

toObject

public static java.lang.Object toObject(org.apache.axis.message.MessageElement element,
                                        java.lang.Class javaClass)
                                 throws GridServiceException
Converts a SOAP MessageElement to a typed Java object representation. The class of the object must have been generated from an XML Schema, and thus contain the appropriate meta data to make deserialization possible.

Parameters:
element - SOAP MessageElement to be converted
javaClass - Class containing meta data about how to deserialize the object.
Returns:
Java object that maps to the XML representation of the input
Throws:
GridServiceException - if the input could not be deserialized into a java type, for example because of missing meta data in the javaClass input type.

toServiceData

public static ServiceDataAttributes toServiceData(org.apache.axis.message.MessageElement element)
                                           throws GridServiceException
Converts a SOAP MessageElement to a typed Java object representation, and wraps it inside of a ServiceDataAttribute object holding attributes that the element might have been decorated with. The object must have the appropriate type mappings for this operation to succeed.

Parameters:
element - SOAP MessageElement to be converted
Returns:
Java object that maps to the XML representation of the input, wrapped inside of a ServiceDataAttributes object
Throws:
GridServiceException - if the input could not be deserialized into a java type, for example because of missing type mappings

toServiceData

public static ServiceDataAttributes toServiceData(org.apache.axis.message.MessageElement element,
                                                  java.lang.Class javaClass)
                                           throws GridServiceException
Converts a SOAP MessageElement to a typed Java object representation, and wraps it inside of a ServiceDataAttribute object holding attributes that the element might have been decorated with. The class of the object must have been generated from an XML Schema, and thus contain the appropriate meta data to make deserialization possible.

Parameters:
element - SOAP MessageElement to be converted
javaClass - Class containing meta data about how to deserialize the object.
Returns:
Java object that maps to the XML representation of the input, wrapped inside of a ServiceDataAttributes object
Throws:
GridServiceException - if the input could not be deserialized into a java type, for example because of missing meta data in the javaClass input type.

toString

public static java.lang.String[] toString(org.apache.axis.message.MessageElement[] element)
Array version of toString


toElement

public static org.w3c.dom.Element[] toElement(org.apache.axis.message.MessageElement[] element)
                                       throws GridServiceException
Array version of toElement

Throws:
GridServiceException

toObject

public static java.lang.Object[] toObject(org.apache.axis.message.MessageElement[] element)
                                   throws GridServiceException
Array version of toObject

Throws:
GridServiceException

toObject

public static java.lang.Object[] toObject(org.apache.axis.message.MessageElement[] element,
                                          java.lang.Class javaClass)
                                   throws GridServiceException
Array version of toObject

Throws:
GridServiceException

toServiceData

public static ServiceDataAttributes[] toServiceData(org.apache.axis.message.MessageElement[] element)
                                             throws GridServiceException
Array version of toServiceData

Throws:
GridServiceException

toServiceData

public static ServiceDataAttributes[] toServiceData(org.apache.axis.message.MessageElement[] element,
                                                    java.lang.Class javaClass)
                                             throws GridServiceException
Array version of toServiceData

Throws:
GridServiceException

getAsServiceData

public static ServiceDataAttributes[] getAsServiceData(org.apache.axis.encoding.AnyContentType serviceData)
                                                throws GridServiceException
Converts type containing any element to service data attributes.

Throws:
GridServiceException
See Also:
toServiceData(MessageElement element)

getAsServiceData

public static ServiceDataAttributes[] getAsServiceData(org.apache.axis.encoding.AnyContentType serviceData,
                                                       java.lang.Class javaClass)
                                                throws GridServiceException
Converts type containing any element to service data attributes.

Throws:
GridServiceException
See Also:
toServiceData(MessageElement element, Class javaClass)

getAsSingleServiceData

public static ServiceDataAttributes getAsSingleServiceData(org.apache.axis.encoding.AnyContentType serviceData)
                                                    throws GridServiceException
Converts type containing any element to service data attributes, wrapping a single element.

Throws:
GridServiceException
See Also:
toServiceData(MessageElement element)

getAsSingleServiceData

public static ServiceDataAttributes getAsSingleServiceData(org.apache.axis.encoding.AnyContentType serviceData,
                                                           java.lang.Class javaClass)
                                                    throws GridServiceException
Converts type containing any element to service data attributes, wrapping a single element.

Throws:
GridServiceException
See Also:
toServiceData(MessageElement element, Class javaClass)

getAsObject

public static java.lang.Object[] getAsObject(org.apache.axis.encoding.AnyContentType extensibility)
                                      throws GridServiceException
Converts type containing any element to an array of java objects.

Throws:
GridServiceException
See Also:
toObject(MessageElement element)

getAsObject

public static java.lang.Object[] getAsObject(org.apache.axis.encoding.AnyContentType extensibility,
                                             java.lang.Class javaClass)
                                      throws GridServiceException
Converts type containing any element to an array of java objects.

Throws:
GridServiceException
See Also:
toObject(MessageElement element, Class javaClass)

getAsSingleObject

public static java.lang.Object getAsSingleObject(org.apache.axis.encoding.AnyContentType extensibility)
                                          throws GridServiceException
Converts type containing any element to a java object.

Throws:
GridServiceException
See Also:
toObject(MessageElement element)

getAsServiceDataValues

public static ServiceDataValuesType getAsServiceDataValues(org.apache.axis.encoding.AnyContentType extensibility)
                                                    throws GridServiceException
Converts type containing any element to a ServiceDataValuesType. This type is for example returned by queryByName queries on ServiceData

Throws:
GridServiceException
See Also:
toObject(MessageElement element)

getAsSingleObject

public static java.lang.Object getAsSingleObject(org.apache.axis.encoding.AnyContentType extensibility,
                                                 java.lang.Class javaClass)
                                          throws GridServiceException
Converts type containing any element to a java object.

Throws:
GridServiceException
See Also:
toObject(MessageElement element, Class javaClass)

getAsElement

public static org.w3c.dom.Element getAsElement(WSDLReferenceType reference)
                                        throws GridServiceException
Returns a DOM Element representation of a WSDLReferenceType, often contained inside of a LocatorType

Throws:
GridServiceException

getAsSingleElement

public static org.w3c.dom.Element getAsSingleElement(org.apache.axis.encoding.AnyContentType any)
                                              throws GridServiceException
Converts type containing any element to a single DOM Element.

Throws:
GridServiceException
See Also:
toElement(MessageElement element)

getAsElement

public static org.w3c.dom.Element[] getAsElement(org.apache.axis.encoding.AnyContentType any)
                                          throws GridServiceException
Converts type containing any element to an array of DOM Elements.

Throws:
GridServiceException
See Also:
toElement(MessageElement element)

getAsParentElement

public static org.w3c.dom.Element getAsParentElement(org.apache.axis.encoding.AnyContentType any)
                                              throws GridServiceException
Converts type containing any element to a single DOM Element, representing the parent MessageElement.

Throws:
GridServiceException
See Also:
toElement(MessageElement element)

contains

public static boolean contains(org.apache.axis.encoding.AnyContentType any,
                               java.lang.Class javaClass)
Checks to see whether type containing any element contains elements of type javaClass. The javaClass must be generated from an XML Schema representation. This operation could be seen as the instanceof equivalent for xsd:any types


getAsParentString

public static java.lang.String getAsParentString(org.apache.axis.encoding.AnyContentType any)
                                          throws GridServiceException
Converts type containing any element to a String, representing the parent MessageElement.

Throws:
GridServiceException
See Also:
toString(MessageElement element)

getAsString

public static java.lang.String getAsString(org.apache.axis.encoding.AnyContentType extensibility)
                                    throws GridServiceException
Converts type containing any element to a String, formatted pretty for output.
This is a time consuming operation. For faster conversion (unformatted) see getAsRawString().

Throws:
GridServiceException
See Also:
toString(MessageElement element)

getAsRawString

public static java.lang.String getAsRawString(org.apache.axis.encoding.AnyContentType extensibility)
Converts type containing any element to a String (not formatted)

See Also:
toString(MessageElement element)

getExtensibility

public static ExtensibilityType getExtensibility(java.lang.Object obj)
                                          throws GridServiceException
Converts an arbitrary object to an Extensibility type. The object will be wrapped according to the rules of toAny

Throws:
GridServiceException

getExtensibility

public static ExtensibilityType getExtensibility(java.lang.Object obj,
                                                 javax.xml.namespace.QName qname)
                                          throws GridServiceException
Converts an arbitrary object to an Extensibility type. The object will be wrapped according to the rules of toAny

Throws:
GridServiceException

getServiceDataValues

public static ExtensibilityType getServiceDataValues(java.lang.Object obj)
                                              throws GridServiceException
Converts an arbitrary object to an Extensibility type. The object will be wrapped inside of a standard OGSI serviceDataValues element

Throws:
GridServiceException


Copyright ? 1999 University of Chicago and The University of Southern California. All Rights Reserved.