de.fzj.unicore.wsrflite.utils
Class Utilities

java.lang.Object
  extended by de.fzj.unicore.wsrflite.utils.Utilities

public class Utilities
extends Object

tools and utilities, mainly for working with XMLBeans and simplifying handling xsd:any

Author:
schuller, demuth

Method Summary
static void addHeaders(org.w3.x2003.x05.soapEnvelope.Header header, org.apache.xmlbeans.XmlObject[] headers)
           
static void append(org.apache.xmlbeans.XmlObject[] what, org.apache.xmlbeans.XmlObject toWhere)
           
static void append(org.apache.xmlbeans.XmlObject what, org.apache.xmlbeans.XmlObject toWhere)
          appends a XmlObject into another XML document, immediately before the end tag
static org.apache.xmlbeans.XmlObject[] extractAny(org.apache.xmlbeans.XmlObject source, QName q)
          retrieve Xml content by QName (careful, this will not return XML documents, but XML fragments.
static org.apache.xmlbeans.XmlObject[] extractAnyElements(org.apache.xmlbeans.XmlObject source, QName q)
          extract an array of XML elements identified by their qname from an XML source document.
static
<T> List<T>
extractAnyElements(org.apache.xmlbeans.XmlObject source, QName q, Class<? extends org.apache.xmlbeans.XmlObject> asClass)
          extract an array of XML elements identified by their qname from an XML source document.
static String extractElementTextAsString(org.apache.xmlbeans.XmlObject source)
          extract the text content of an XML element
static String extractResourceID(org.w3.x2005.x08.addressing.EndpointReferenceType epr)
           
static String extractResourceID(String id)
           
static org.apache.xmlbeans.XmlObject[] extractResourceProperty(org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument res, QName q)
           
static org.apache.xmlbeans.XmlObject extractResourceProperty(org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyResponseDocument res)
          get the resourceproperty from a GetResourcePropertyResponse
static String extractServiceName(org.w3.x2005.x08.addressing.EndpointReferenceType epr)
           
static String extractServiceName(String url)
           
static QName findAnyElementQName(org.apache.xmlbeans.XmlObject o)
          for an element containing an xsd:any element, find the Qname of the xsd:any
static void insertAny(org.apache.xmlbeans.XmlObject what, org.apache.xmlbeans.XmlObject toWhere)
           
static String makeAddress(String serviceName)
          builds an wsa Address for the given plain web service
static String makeAddress(String serviceName, String resourceID)
          builds an wsa Address for the given service + resourceID
static org.w3.x2005.x08.addressing.EndpointReferenceType makeEPR(String serviceName)
          return the epr of the specified plain ws
static org.w3.x2005.x08.addressing.EndpointReferenceType makeEPR(String serviceName, String resourceID)
          return the epr of the specified ws resource
static String newUniqueID()
          returns a new globally unique identifier
static boolean skipToElement(org.apache.xmlbeans.XmlCursor cursor, QName name)
          fast-forward the cursor up to the element with the given QName
static QName toQName(org.apache.xmlbeans.SchemaType type)
          helper: converts XmlBeans schematype to QName
static boolean validateIntegerRange(String value, int minValue, int maxValue)
          validate that the given String value (interpreted as an Integer) is in the supplied range
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeAddress

public static String makeAddress(String serviceName,
                                 String resourceID)
builds an wsa Address for the given service + resourceID

Parameters:
serviceName -
resourceID -
Returns:

makeAddress

public static String makeAddress(String serviceName)
builds an wsa Address for the given plain web service

Parameters:
serviceName -
resourceID -
Returns:

makeEPR

public static org.w3.x2005.x08.addressing.EndpointReferenceType makeEPR(String serviceName,
                                                                        String resourceID)
return the epr of the specified ws resource

Parameters:
serviceName -
resourceID -
Returns:

makeEPR

public static org.w3.x2005.x08.addressing.EndpointReferenceType makeEPR(String serviceName)
return the epr of the specified plain ws

Parameters:
serviceName -
Returns:

newUniqueID

public static String newUniqueID()
returns a new globally unique identifier

Returns:

toQName

public static QName toQName(org.apache.xmlbeans.SchemaType type)
helper: converts XmlBeans schematype to QName

Parameters:
type -
Returns:
QName

extractResourceProperty

public static org.apache.xmlbeans.XmlObject extractResourceProperty(org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyResponseDocument res)
                                                             throws IOException,
                                                                    org.apache.xmlbeans.XmlException
get the resourceproperty from a GetResourcePropertyResponse

Parameters:
res -
Returns:
Throws:
IOException
org.apache.xmlbeans.XmlException

extractResourceProperty

public static org.apache.xmlbeans.XmlObject[] extractResourceProperty(org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument res,
                                                                      QName q)

append

public static void append(org.apache.xmlbeans.XmlObject what,
                          org.apache.xmlbeans.XmlObject toWhere)
appends a XmlObject into another XML document, immediately before the end tag

Parameters:
what -
toWhere -

append

public static void append(org.apache.xmlbeans.XmlObject[] what,
                          org.apache.xmlbeans.XmlObject toWhere)

insertAny

public static void insertAny(org.apache.xmlbeans.XmlObject what,
                             org.apache.xmlbeans.XmlObject toWhere)

extractAny

public static org.apache.xmlbeans.XmlObject[] extractAny(org.apache.xmlbeans.XmlObject source,
                                                         QName q)
retrieve Xml content by QName (careful, this will not return XML documents, but XML fragments. If you want documents use extractAnyElements() instead)

Parameters:
source - XmlObject
q - QName
Returns:
XmlObject array

extractAnyElements

public static org.apache.xmlbeans.XmlObject[] extractAnyElements(org.apache.xmlbeans.XmlObject source,
                                                                 QName q)
extract an array of XML elements identified by their qname from an XML source document.

Parameters:
source - - the xml fragment
q - - QName of elements to extract
Returns:
XmlObject[]

extractAnyElements

public static <T> List<T> extractAnyElements(org.apache.xmlbeans.XmlObject source,
                                             QName q,
                                             Class<? extends org.apache.xmlbeans.XmlObject> asClass)
extract an array of XML elements identified by their qname from an XML source document.

Parameters:
source - - the xml fragment
q - - QName of elements to extract
asClass - - the XMLbeans class of the elements to extract
Returns:
List - a list of XMLBeans objects with the correct runtime type

findAnyElementQName

public static QName findAnyElementQName(org.apache.xmlbeans.XmlObject o)
for an element containing an xsd:any element, find the Qname of the xsd:any

Parameters:
o -
Returns:

extractElementTextAsString

public static String extractElementTextAsString(org.apache.xmlbeans.XmlObject source)
extract the text content of an XML element

Parameters:
source - the xml element
Returns:
the text content, or "" if element has no content

skipToElement

public static boolean skipToElement(org.apache.xmlbeans.XmlCursor cursor,
                                    QName name)
fast-forward the cursor up to the element with the given QName

Parameters:
cursor -
name -
Returns:
false if element does not exist

addHeaders

public static void addHeaders(org.w3.x2003.x05.soapEnvelope.Header header,
                              org.apache.xmlbeans.XmlObject[] headers)

extractResourceID

public static String extractResourceID(org.w3.x2005.x08.addressing.EndpointReferenceType epr)

extractResourceID

public static String extractResourceID(String id)

extractServiceName

public static String extractServiceName(org.w3.x2005.x08.addressing.EndpointReferenceType epr)

extractServiceName

public static String extractServiceName(String url)

validateIntegerRange

public static boolean validateIntegerRange(String value,
                                           int minValue,
                                           int maxValue)
validate that the given String value (interpreted as an Integer) is in the supplied range

Parameters:
value - - String to be verified
minValue - - minimum
maxValue - - maximum
Returns:
true if the value is within the range, false otherwise


Copyright © 2010. All Rights Reserved.