org.apache.ws.util
Class XmlBeanUtils

java.lang.Object
  extended byorg.apache.ws.util.XmlBeanUtils

public abstract class XmlBeanUtils
extends java.lang.Object

Generic utility methods for working with Apache XMLBeans.

Author:
Ian Springer, Sal Campana

Constructor Summary
XmlBeanUtils()
           
 
Method Summary
static org.apache.xmlbeans.XmlObject addChildElement(org.apache.xmlbeans.XmlObject parent, javax.xml.namespace.QName name)
          Creates a new XmlBean named name and adds it as the last child of the XmlBean parent.
static org.apache.xmlbeans.XmlObject addChildElement(org.apache.xmlbeans.XmlObject parent, org.apache.xmlbeans.XmlObject newChild)
          Adds a copy of the XmlBean newChild as the last child of the XmlBean parent.
static org.apache.xmlbeans.XmlObject copyXmlBean(org.apache.xmlbeans.XmlObject srcXBean)
          Makes and returns a copy of the specified XMLBean.
static org.apache.xmlbeans.XmlObject[] copyXmlBeans(org.apache.xmlbeans.XmlObject[] srcXBeans)
          Makes and returns a copy of the specified XMLBean array.
static org.apache.xmlbeans.XmlObject createElement(javax.xml.namespace.QName elemName)
          DOCUMENT_ME
static java.lang.String getAttributeValue(org.apache.xmlbeans.XmlObject xBean, javax.xml.namespace.QName attribName)
           
static javax.xml.namespace.QName getAttributeValueAsQName(org.apache.xmlbeans.XmlObject xBean, javax.xml.namespace.QName attribName)
           
static org.apache.xmlbeans.XmlObject[] getChildElements(org.apache.xmlbeans.XmlObject xBean)
          Returns an array containing all child elements of the specified XMLBean.
static org.apache.xmlbeans.XmlObject[] getChildElements(org.apache.xmlbeans.XmlObject xBean, javax.xml.namespace.QName name)
          Returns an array containing all child elements, with the specified name, of the specified XMLBean.
static org.apache.xmlbeans.XmlObject getDocument(org.apache.xmlbeans.XmlObject xBean)
          Returns the document XmlBean that is associated with the specified XmlBean.
static javax.xml.namespace.QName getName(org.apache.xmlbeans.XmlCursor xCursor)
          Note.
static javax.xml.namespace.QName getName(org.apache.xmlbeans.XmlObject xBean)
           
static org.apache.xmlbeans.XmlObject getRootElement(org.apache.xmlbeans.XmlObject docXBean)
          Returns the root element of the specified document XMLBean.
static java.lang.String getValue(org.apache.xmlbeans.XmlObject xBean)
           
static javax.xml.namespace.QName getValueAsQName(org.apache.xmlbeans.XmlObject xBean)
           
static java.util.Map getXmlBeanAnyMap(org.apache.xmlbeans.XmlObject xmlObjectToSearch)
          Returns a Map keyed on Element QName to a List containing the "Any" XmlObjects types.
static boolean isDocument(org.apache.xmlbeans.XmlObject xBean)
          Returns true if the specified XMLBean represents an XML document, or false if it does not.
 org.apache.xmlbeans.XmlObject newInstance(javax.xml.namespace.QName elemName)
          Creates a new XMLBean element with the specified name.
static void remove(org.apache.xmlbeans.XmlObject xBean)
          Removes the specifed XMLBean from its parent element.
static boolean removeChildElements(org.apache.xmlbeans.XmlObject xBean)
          Removes all child elements of the specified XMLBean.
static boolean removeChildElements(org.apache.xmlbeans.XmlObject xBean, javax.xml.namespace.QName name)
          Removes all child elements, with the specified name, from the specified XMLBean.
static void setName(org.apache.xmlbeans.XmlCursor xCursor, javax.xml.namespace.QName name)
          Note.
static void setName(org.apache.xmlbeans.XmlObject xBean, javax.xml.namespace.QName name)
           
static void setValue(org.apache.xmlbeans.XmlObject xBean, java.lang.String value)
           
static void setValueAsQName(org.apache.xmlbeans.XmlObject xBean, javax.xml.namespace.QName qName)
           
static javax.xml.soap.SOAPElement toSOAPElement(org.apache.xmlbeans.XmlObject xBean)
           
static javax.xml.soap.SOAPElement[] toSOAPElementArray(org.apache.xmlbeans.XmlObject[] elems)
          DOCUMENT_ME
static org.apache.xmlbeans.XmlObject toXmlObject(java.lang.Object obj)
          If possible, converts the specified object to an XMLBean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlBeanUtils

public XmlBeanUtils()
Method Detail

getAttributeValue

public static java.lang.String getAttributeValue(org.apache.xmlbeans.XmlObject xBean,
                                                 javax.xml.namespace.QName attribName)
Parameters:
xBean -
attribName -
Returns:

getAttributeValueAsQName

public static javax.xml.namespace.QName getAttributeValueAsQName(org.apache.xmlbeans.XmlObject xBean,
                                                                 javax.xml.namespace.QName attribName)
Parameters:
xBean -
Returns:

getChildElements

public static org.apache.xmlbeans.XmlObject[] getChildElements(org.apache.xmlbeans.XmlObject xBean,
                                                               javax.xml.namespace.QName name)
Returns an array containing all child elements, with the specified name, of the specified XMLBean.

Parameters:
xBean - an XMLBean that represents an XML element
name - the name to look for, or null to return all child elements
Returns:
an array containing all child elements, with the specified name, of the specified XMLBean

getChildElements

public static org.apache.xmlbeans.XmlObject[] getChildElements(org.apache.xmlbeans.XmlObject xBean)
Returns an array containing all child elements of the specified XMLBean.

Parameters:
xBean - an XMLBean that represents an XML element
Returns:
an array containing all child elements of the specified XMLBean

getDocument

public static org.apache.xmlbeans.XmlObject getDocument(org.apache.xmlbeans.XmlObject xBean)
Returns the document XmlBean that is associated with the specified XmlBean.

Parameters:
xBean - an XmlBean
Returns:
the document XmlBean that is associated with the specified XmlBean

isDocument

public static boolean isDocument(org.apache.xmlbeans.XmlObject xBean)
Returns true if the specified XMLBean represents an XML document, or false if it does not.

Parameters:
xBean - an XMLBean
Returns:
true if the specified XMLBean represents an XML document, or false if it does not

setName

public static void setName(org.apache.xmlbeans.XmlObject xBean,
                           javax.xml.namespace.QName name)
Parameters:
xBean -

setName

public static void setName(org.apache.xmlbeans.XmlCursor xCursor,
                           javax.xml.namespace.QName name)
Note. this method does not dispose of the cursor

Parameters:
xCursor -

getName

public static javax.xml.namespace.QName getName(org.apache.xmlbeans.XmlObject xBean)
Parameters:
xBean -
Returns:

getName

public static javax.xml.namespace.QName getName(org.apache.xmlbeans.XmlCursor xCursor)
Note. this method does not dispose of the cursor

Parameters:
xCursor -
Returns:

getRootElement

public static org.apache.xmlbeans.XmlObject getRootElement(org.apache.xmlbeans.XmlObject docXBean)
Returns the root element of the specified document XMLBean. If the specified XMLBean is not a document, the XMLBean itself is returned.

Parameters:
docXBean - a document XMLBean
Returns:
the root element of the specified document XMLBean, or, if the specified XMLBean is not a document, the XMLBean itself

setValue

public static void setValue(org.apache.xmlbeans.XmlObject xBean,
                            java.lang.String value)
Parameters:
xBean -
value -

getValue

public static java.lang.String getValue(org.apache.xmlbeans.XmlObject xBean)
Parameters:
xBean -
Returns:

setValueAsQName

public static void setValueAsQName(org.apache.xmlbeans.XmlObject xBean,
                                   javax.xml.namespace.QName qName)
Parameters:
xBean -
qName -

getValueAsQName

public static javax.xml.namespace.QName getValueAsQName(org.apache.xmlbeans.XmlObject xBean)
Parameters:
xBean -
Returns:

getXmlBeanAnyMap

public static java.util.Map getXmlBeanAnyMap(org.apache.xmlbeans.XmlObject xmlObjectToSearch)
Returns a Map keyed on Element QName to a List containing the "Any" XmlObjects types.

The way we determine that an element is an Any is by asking for the element property of the schemaType for the element by the element's QName.

Parameters:
xmlObjectToSearch - The XmlObject to find the Any elements in.
Returns:
Map keyed on Element QName to a List containing the "Any" XmlObjects

addChildElement

public static org.apache.xmlbeans.XmlObject addChildElement(org.apache.xmlbeans.XmlObject parent,
                                                            org.apache.xmlbeans.XmlObject newChild)
Adds a copy of the XmlBean newChild as the last child of the XmlBean parent.

Parameters:
parent - the XmlBean to be added to; must represent an element or a document
newChild - the XmlBean to be added; must represent an element or a document

addChildElement

public static org.apache.xmlbeans.XmlObject addChildElement(org.apache.xmlbeans.XmlObject parent,
                                                            javax.xml.namespace.QName name)
Creates a new XmlBean named name and adds it as the last child of the XmlBean parent.

Parameters:
parent - the XmlBean to be added to; must represent an element or a document
name - the name of the new XmlBean to be added

copyXmlBean

public static org.apache.xmlbeans.XmlObject copyXmlBean(org.apache.xmlbeans.XmlObject srcXBean)
Makes and returns a copy of the specified XMLBean.

Parameters:
srcXBean - the XMLBean to be copied
Returns:
a copy of the specified XMLBean

copyXmlBeans

public static org.apache.xmlbeans.XmlObject[] copyXmlBeans(org.apache.xmlbeans.XmlObject[] srcXBeans)
Makes and returns a copy of the specified XMLBean array.

Parameters:
srcXBeans - the array of XMLBeans to be copied
Returns:
a copy of the specified XMLBean array

createElement

public static org.apache.xmlbeans.XmlObject createElement(javax.xml.namespace.QName elemName)
DOCUMENT_ME

Parameters:
elemName - DOCUMENT_ME
Returns:
DOCUMENT_ME

remove

public static void remove(org.apache.xmlbeans.XmlObject xBean)
Removes the specifed XMLBean from its parent element.

Parameters:
xBean - an XMLBean

removeChildElements

public static boolean removeChildElements(org.apache.xmlbeans.XmlObject xBean,
                                          javax.xml.namespace.QName name)
Removes all child elements, with the specified name, from the specified XMLBean.

Parameters:
xBean - an XMLBean
Returns:
true if all child elements, with the specified name, were successfully removed

removeChildElements

public static boolean removeChildElements(org.apache.xmlbeans.XmlObject xBean)
Removes all child elements of the specified XMLBean.

Parameters:
xBean - an XMLBean
Returns:
true if all child elements were successfully removed

toSOAPElement

public static javax.xml.soap.SOAPElement toSOAPElement(org.apache.xmlbeans.XmlObject xBean)
                                                throws java.lang.Exception
Parameters:
xBean -
Returns:
Throws:
java.lang.Exception

toSOAPElementArray

public static javax.xml.soap.SOAPElement[] toSOAPElementArray(org.apache.xmlbeans.XmlObject[] elems)
                                                       throws java.lang.Exception
DOCUMENT_ME

Parameters:
elems - DOCUMENT_ME
Returns:
DOCUMENT_ME
Throws:
java.lang.Exception - DOCUMENT_ME

toXmlObject

public static org.apache.xmlbeans.XmlObject toXmlObject(java.lang.Object obj)
                                                 throws java.lang.Exception
If possible, converts the specified object to an XMLBean.

Parameters:
obj - an object
Returns:
an XMLBean, or null if the parameter is null
Throws:
java.lang.Exception - if the object cannot be converted to an XMLBean

newInstance

public org.apache.xmlbeans.XmlObject newInstance(javax.xml.namespace.QName elemName)
Creates a new XMLBean element with the specified name.

Parameters:
elemName - the element name
Returns:
a new XMLBean element with the specified name


Copyright © 2004-2005 Apache Software Foundation. All Rights Reserved.