Artix User APIs

com.iona.jbus.util
Class XMLUtils

java.lang.Object
  extended bycom.iona.jbus.util.XMLUtils

public final class XMLUtils
extends Object

The XMLUtils class is a utility class that is used to convert a Java Object into XML and XML into a Java Object. To carry out these conversions, the XMLUtils class must have a knowledge of the object's members, which it obtains from a type definition in a WSDL file. Consequently, a schema describing the object must be included in the types section of a WSDL file, and the location of the WSDL file is passed as a parameter to each of this class' public methods.


Method Summary
static Object eprFromXML(String xml)
          Converts XML into a WS-Addressing epr reference object.
static String eprToXML(Object epr)
          Converts a WS-Addressing epr reference object into XML.
static Object fromXML(String xml, QName qname, Class cls, String schemaPath)
          Converts XML into an object.
static Object fromXML(String xml, QName elementQName, QName typeQName, Class cls, com.iona.webservices.wsdl.model.Model wsdlModel, com.iona.webservices.reflect.wsdl.SchemaTypeFactory factory)
          Converts XML into an object.
static Object fromXML(String xml, QName elementQName, QName typeQName, Class cls, String schemaPath)
          Converts XML into an object.
static QName getObjectQName(Object obj)
          Obtains the typeQName from an artix type.
static Object referenceFromXML(String xml)
          Converts XML into a reference object.
static String referenceToXML(Object ref)
          Converts a reference object into XML.
static String toXML(Object obj, String schemaPath)
          Converts an object into XML.
static String toXML(QName qname, Object obj, com.iona.webservices.wsdl.model.Model wsdlModel, com.iona.webservices.reflect.wsdl.SchemaTypeFactory factory)
          Converts an object into XML.
static String toXML(QName qname, Object obj, String schemaPath)
          Converts an object into XML.
static String toXML(QName elementQName, QName typeQName, Object obj, com.iona.webservices.wsdl.model.Model wsdlModel, com.iona.webservices.reflect.wsdl.SchemaTypeFactory factory)
          Converts an object into XML.
static String toXML(QName elementQName, QName typeQName, Object obj, String schemaPath)
          Converts an object into XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toXML

public static String toXML(Object obj,
                           String schemaPath)
                    throws WriteException
Converts an object into XML. Application code should use this version of the toXML method if the object to be converted represents a type. This version of the toXML method requires that the object implement the _getQName method, which returns the qname of the type this object represents. The _getQName method is defined for an object when wsdltojava is used to generate code from a WSDL. or schema file If the object does not implement the _getQName method, application code must use one of the other versions of the toXML method.

Parameters:
obj - the object to be converted into XML.
schemaPath - the url to the location of the WSDL/Schema file.
Returns:
String the XML string representing the object.
Throws:
WriteException - If there is an error in the conversion.

toXML

public static String toXML(QName qname,
                           Object obj,
                           String schemaPath)
                    throws WriteException
Converts an object into XML. Application code should use this version of the toXML method if the object to be converted represents a type but does not implement the _getQName method. To use this version of the toXML method, the application code must provide the qname of the type this object represents.

Parameters:
qname - the qname of the schema type respresenting the object.
obj - the object to be converted into XML.
schemaPath - the url to the location of the WSDL/Schema.
Returns:
String the XML string representing the object.
Throws:
WriteException - If there is an error in the conversion.

toXML

public static String toXML(QName qname,
                           Object obj,
                           com.iona.webservices.wsdl.model.Model wsdlModel,
                           com.iona.webservices.reflect.wsdl.SchemaTypeFactory factory)
                    throws WriteException
Converts an object into XML. Application code should use this version of the toXML method if the object to be converted represents a type but does not implement the _getQName method. To use this version of the toXML method, the application code must provide the qname of the type this object represents.

Parameters:
qname - the qname of the schema type respresenting the object.
obj - the object to be converted into XML.
wsdlModel - the model of the WSDL/Schema.
factory - the SchemaTypeFactory of the WSDL/Schema.
Returns:
String the XML string representing the object.
Throws:
WriteException - If there is an error in the conversion.

toXML

public static String toXML(QName elementQName,
                           QName typeQName,
                           Object obj,
                           com.iona.webservices.wsdl.model.Model wsdlModel,
                           com.iona.webservices.reflect.wsdl.SchemaTypeFactory factory)
                    throws WriteException
Converts an object into XML. Application code should use this version of the toXML method if the object to be converted represents a type but does not implement the _getQName method. To use this version of the toXML method, the application code must provide the qname of the type this object represents.

Parameters:
elementQName - the qname of the element representing the object.
typeQName - the qname of the schema type respresenting the object.
obj - the object to be converted into XML.
wsdlModel - the model of the WSDL/Schema.
factory - the SchemaTypeFactory of the WSDL/Schema.
Returns:
String the XML string representing the object.
Throws:
WriteException - If there is an error in the conversion.

toXML

public static String toXML(QName elementQName,
                           QName typeQName,
                           Object obj,
                           String schemaPath)
                    throws WriteException
Converts an object into XML. Application code can use this version of the toXML method if the object to be converted represents either a type or an element. To use this version of the toXML method to convert an element object into XML, the application code must provide the qname of the element this object represents. The element qname is provided as the first parameter. To use this version of the toXML method to convert a type object into XML, the application code must provide the qname of the type this object represents. The type qname is provided as the second parameter. If an element is being converted, pass null as the type qname. If a type is being converted, pass null as the element qname. If both element & type qnames are specified, then the element qname will hold precedence over the type qname. If the element is not found in the wsdl, then the type qname is used.

Parameters:
elementQName - the qname of the element representing the object.
typeQName - the qname of the schema type respresenting the object.
obj - the object to be converted into XML.
schemaPath - the url to the location of the WSDL/Schema file.
Returns:
String the XML string representing the object.
Throws:
WriteException - If there is an error in the conversion.

referenceToXML

public static String referenceToXML(Object ref)
                             throws WriteException
Converts a reference object into XML.

Parameters:
ref - the reference object to be converted into XML.
Returns:
String the XML string representing the reference object.
Throws:
WriteException - If there is an error in the conversion.

eprToXML

public static String eprToXML(Object epr)
                       throws WriteException
Converts a WS-Addressing epr reference object into XML.

Parameters:
epr - the reference object to be converted into XML.
Returns:
String the XML string representing the WS-Addressing epr object.
Throws:
WriteException - If there is an error in the conversion.

eprFromXML

public static Object eprFromXML(String xml)
                         throws ReadException
Converts XML into a WS-Addressing epr reference object.

Parameters:
xml - the xml string representation of the reference object.
Returns:
Object the converted WS-Addressing epr reference object from xml.
Throws:
ReadException - If there is an error in the conversion.

fromXML

public static Object fromXML(String xml,
                             QName qname,
                             Class cls,
                             String schemaPath)
                      throws ReadException
Converts XML into an object. Application code should use this version of the fromXML method if the XML to be converted represents a type.

Parameters:
xml - the xml string representation of the object.
qname - the qname of the schema type respresenting the object.
cls - the class of the object.
schemaPath - the url to the location of the WSDL/Schema file.
Returns:
Object the converted object from xml.
Throws:
ReadException - If there is an error in the conversion.

fromXML

public static Object fromXML(String xml,
                             QName elementQName,
                             QName typeQName,
                             Class cls,
                             com.iona.webservices.wsdl.model.Model wsdlModel,
                             com.iona.webservices.reflect.wsdl.SchemaTypeFactory factory)
                      throws ReadException
Converts XML into an object. Application code can use this version of thefromXML fromXML method if the XML to be converted represents either a type or an element. To use this version of the fromXML method to convert XML into an element, the application code must provide the qname of the element this object represents. The element qname is provided as the second parameter. To use this version of the fromXML method to convert XML into a type, the application code must provide the qname of the type this object represents. The type qname is provided as the third parameter. If XML is being converted into an element, pass null as the type qname. If XML is being converted into a type, pass null as the element qname. If both element & type qnames are specified, then the element qname will hold precedence over the type qname. If the element is not found in the wsdl, then the type qname is used.

Parameters:
xml - the xml string representation of the object.
elementQName - the qname of the element respresenting the object.
typeQName - the qname of the schema type respresenting the object.
cls - the class of the object.
wsdlModel - the model of the WSDL/Schema.
factory - the SchemaTypeFactory of the WSDL/Schema.
Returns:
Object the converted object from xml.
Throws:
ReadException - If there is an error in the conversion.

fromXML

public static Object fromXML(String xml,
                             QName elementQName,
                             QName typeQName,
                             Class cls,
                             String schemaPath)
                      throws ReadException
Converts XML into an object. Application code can use this version of thefromXML fromXML method if the XML to be converted represents either a type or an element. To use this version of the fromXML method to convert XML into an element, the application code must provide the qname of the element this object represents. The element qname is provided as the second parameter. To use this version of the fromXML method to convert XML into a type, the application code must provide the qname of the type this object represents. The type qname is provided as the third parameter. If XML is being converted into an element, pass null as the type qname. If XML is being converted into a type, pass null as the element qname. If both element & type qnames are specified, then the element qname will hold precedence over the type qname. If the element is not found in the wsdl, then the type qname is used.

Parameters:
xml - the xml string representation of the object.
elementQName - the qname of the element respresenting the object.
typeQName - the qname of the schema type respresenting the object.
cls - the class of the object.
schemaPath - the url to the location of the WSDL/Schema file.
Returns:
Object the converted object from xml.
Throws:
ReadException - If there is an error in the conversion.

referenceFromXML

public static Object referenceFromXML(String xml)
                               throws ReadException
Converts XML into a reference object.

Parameters:
xml - the xml string representation of the reference object.
Returns:
Object the converted reference object from xml.
Throws:
ReadException - If there is an error in the conversion.

getObjectQName

public static QName getObjectQName(Object obj)
Obtains the typeQName from an artix type.

Parameters:
obj - the artix type
Returns:
type qname of the object

Artix User APIs

Copyright � 2004 IONA Technologies PLC. All rights reserved.