vSphere Client SDK API Documentation : version 5.5.0.1300321

com.vmware.vise.search
Class JaxbPropertyUnmarshaller

java.lang.Object
  extended by com.vmware.vise.search.JaxbPropertyUnmarshaller
All Implemented Interfaces:
PropertyUnmarshaller

public final class JaxbPropertyUnmarshaller
extends Object
implements PropertyUnmarshaller

JAXB-based unmarshaller for object model data.

By default supports unmarshalling of primitive and redirect types. To support unmarshalling of complex or custom types, additional JAXB bindings can be registered as a package or at the individual class level.

If a default unmarshaller is not specified, returns raw xml for any non-primitive, non-reference types that do not have registered JAXB bindings.

Implementation is safe to be shared by multiple threads.


Constructor Summary
JaxbPropertyUnmarshaller(PropertyUnmarshaller defaultUnmarshaller, Collection<String> bindingPackages, ClassLoader classLoader, boolean loadPrimitiveBindings)
          Create a new instance.
 
Method Summary
 ValueEx<Object> getValue(PropertyInfo propertyInfo, XMLStreamReader reader)
          Unmarshal and return the value of the property described by propertyInfo from the reader.
static JaxbPropertyUnmarshaller newInstance(Collection<String> bindingPackages, ClassLoader classLoader)
          Create a new instance with bindings for primitive and reference types in addition to the bindings specified in bindingPackages.
static JaxbPropertyUnmarshaller newPrimitiveInstance()
          Create a new instance with bindings for primitive and reference types.
 void registerJaxbBindingClass(String xmlType, Class<?> javaType)
          Register a JAXB binding class for an xml object type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxbPropertyUnmarshaller

public JaxbPropertyUnmarshaller(@optional
                                PropertyUnmarshaller defaultUnmarshaller,
                                @optional
                                Collection<String> bindingPackages,
                                @optional
                                ClassLoader classLoader,
                                boolean loadPrimitiveBindings)
Create a new instance.

Parameters:
defaultUnmarshaller - Unmarshaller that handles properties that do not have registered JAXB bindings. If null, a pass-through unmarshaller will return raw xml for any response elements without their own bindings.
bindingPackages - Packages containing binding classes:
  • Only top-level classes from these packages will be registered, i.e. sub-packages containing binding classes must be explicitly specified.
  • Assumes that each binding class maps to the object type with that exact class name (case-sensitive).
classLoader - ClassLoader for classes within the binding packages. Can be null if bindingPackages is null or empty.
loadPrimitiveBindings - If true, then initialize bindings for primitive types (byte, short, int, long, float, double, boolean, string and date).
Throws:
IllegalArgumentException - if classLoader is null and bindingPackages is not empty.
Method Detail

newInstance

public static JaxbPropertyUnmarshaller newInstance(Collection<String> bindingPackages,
                                                   ClassLoader classLoader)
Create a new instance with bindings for primitive and reference types in addition to the bindings specified in bindingPackages. The property values of any types without a JAXB binding class will be returned as raw xml.

Parameters:
bindingPackages - Packages containing binding classes:
  • Only top-level classes from these packages will be registered, i.e. sub-packages containing binding classes must be explicitly specified.
  • Assumes that each binding class maps to the object type with that exact class name (case-sensitive).
classLoader - ClassLoader for classes within the binding packages.
Returns:
A new JaxbPropertyUnmarshaller.
Throws:
IllegalArgumentException - If any parameters are null.

newPrimitiveInstance

public static JaxbPropertyUnmarshaller newPrimitiveInstance()
Create a new instance with bindings for primitive and reference types. The property values of any types without a JAXB binding class will be returned as raw xml.

Returns:
A new JaxbPropertyUnmarshaller.

registerJaxbBindingClass

public void registerJaxbBindingClass(String xmlType,
                                     Class<?> javaType)
Register a JAXB binding class for an xml object type.

Parameters:
xmlType - An xml object type.
javaType - A JAXB binding class.
Throws:
IllegalArgumentException - if any parameters are null.

getValue

public ValueEx<Object> getValue(PropertyInfo propertyInfo,
                                XMLStreamReader reader)
                         throws XMLStreamException
Description copied from interface: PropertyUnmarshaller
Unmarshal and return the value of the property described by propertyInfo from the reader.

Specified by:
getValue in interface PropertyUnmarshaller
Parameters:
propertyInfo - Metadata on the property to be unmarshalled from the reader.
reader - An xml stream reader.
Returns:
A ValueEx instance containing the value of the property as well as any non-fatal exceptions (that may have occurred while getting the value) which the unmarshaller chose not to propagate but to swallow for whatever reason. By using the ValueEx instance, the unmarshaller can still report the exception(s) that occurred, thus indicating to the caller that something went wrong but not fatally. The caller is free to decide what to do with the information, e.g. it may log it. This value should never be null.
Throws:
XMLStreamException - if any XML stream specific issues are encountered while deserializing.

vSphere Client SDK API Documentation : version 5.5.0.1300321

Copyright @ 2012 VMware, Inc. All rights reserved.