org.apache.axiom.om.util
Class ElementHelper

java.lang.Object
  extended by org.apache.axiom.om.util.ElementHelper

public class ElementHelper
extends java.lang.Object

Helper class to provide extra utility stuff against elements. The code is designed to work with any element implementation.


Constructor Summary
ElementHelper(OMElement element)
          Constructs and binds to an element.
 
Method Summary
static OMElement getChildWithName(OMElement parent, java.lang.String childName)
           
static java.lang.String getContentID(javax.xml.stream.XMLStreamReader parser)
           
static java.lang.String getContentID(javax.xml.stream.XMLStreamReader parser, java.lang.String charsetEncoding)
          Deprecated. use getContentID(XMLStreamReader) instead (see WSCOMMONS-429)
static java.lang.String getContentIDFromHref(java.lang.String href)
          Extract the content ID from a href attribute value, i.e.
static OMElement importOMElement(OMElement omElement, OMFactory omFactory)
          Some times two OMElements needs to be added to the same object tree.
 javax.xml.namespace.QName resolveQName(java.lang.String qname)
          Turns a prefix:local qname string into a proper QName, evaluating it in the OMElement context.
 javax.xml.namespace.QName resolveQName(java.lang.String qname, boolean defaultToParentNameSpace)
          Turns a prefix:local qname string into a proper QName, evaluating it in the OMElement context.
static void setNewElement(OMElement parent, OMElement myElement, OMElement newElement)
           
static SOAPHeaderBlock toSOAPHeaderBlock(OMElement omElement, SOAPFactory factory)
          This is a method to convert regular OMElements to SOAPHeaderBlocks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementHelper

public ElementHelper(OMElement element)
Constructs and binds to an element.

Parameters:
element - element to work with
Method Detail

resolveQName

public javax.xml.namespace.QName resolveQName(java.lang.String qname,
                                              boolean defaultToParentNameSpace)
Turns a prefix:local qname string into a proper QName, evaluating it in the OMElement context.

Parameters:
qname - qname to resolve
defaultToParentNameSpace - flag that controls behaviour when there is no namespace.
Returns:
Returns null for any failure to extract a qname.

resolveQName

public javax.xml.namespace.QName resolveQName(java.lang.String qname)
Turns a prefix:local qname string into a proper QName, evaluating it in the OMElement context. Unprefixed qnames resolve to the local namespace.

Parameters:
qname - prefixed qname string to resolve
Returns:
Returns null for any failure to extract a qname.

setNewElement

public static void setNewElement(OMElement parent,
                                 OMElement myElement,
                                 OMElement newElement)

getChildWithName

public static OMElement getChildWithName(OMElement parent,
                                         java.lang.String childName)
Parameters:
parent -
childName -
Returns:

getContentID

public static java.lang.String getContentID(javax.xml.stream.XMLStreamReader parser,
                                            java.lang.String charsetEncoding)
Deprecated. use getContentID(XMLStreamReader) instead (see WSCOMMONS-429)


getContentID

public static java.lang.String getContentID(javax.xml.stream.XMLStreamReader parser)

getContentIDFromHref

public static java.lang.String getContentIDFromHref(java.lang.String href)
Extract the content ID from a href attribute value, i.e. from a URI following the cid: scheme defined by RFC2392.

Parameters:
href - the value of the href attribute
Returns:
the corresponding content ID

importOMElement

public static OMElement importOMElement(OMElement omElement,
                                        OMFactory omFactory)
Some times two OMElements needs to be added to the same object tree. But in Axiom, a single tree should always contain object created from the same type of factory (eg: LinkedListImplFactory, DOMFactory, etc.,). If one OMElement is created from a different factory than that of the factory which was used to create the object in the existing tree, we need to convert the new OMElement to match to the factory of existing object tree. This method will convert omElement to the given omFactory.

See Also:
to convert instances of OMAttribute

toSOAPHeaderBlock

public static SOAPHeaderBlock toSOAPHeaderBlock(OMElement omElement,
                                                SOAPFactory factory)
                                         throws java.lang.Exception
This is a method to convert regular OMElements to SOAPHeaderBlocks.

Parameters:
omElement -
factory -
Returns:
Throws:
java.lang.Exception


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.