com.ibm.websphere.fabric.da.util
Class SdoXPathUtil

java.lang.Object
  extended by com.ibm.websphere.fabric.da.util.SdoXPathUtil

public final class SdoXPathUtil
extends java.lang.Object

Version:
$Id: $
Author:
babka@us.ibm.com

Field Summary
static org.apache.commons.jxpath.JXPathContextFactory FACTORY
           
 
Method Summary
static java.lang.String getFullXpath(commonj.sdo.DataObject dobj, java.lang.String xpath)
          Given an SDO and an XPath expression, returns the fully-specified XPath expression that would find the same item.
static java.util.List<XPathSearchResult> getListViaXpath(commonj.sdo.DataObject dobj, java.lang.String xpath)
          Retrieves zero or more values from an SDO object by searching through the object web as though it is an XML document.
static XPathSearchResult getViaXpath(commonj.sdo.DataObject dobj, java.lang.String xpath)
          Retrieves a value from an SDO object by searching through the object web as though it is an XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY

public static final org.apache.commons.jxpath.JXPathContextFactory FACTORY
Method Detail

getViaXpath

public static XPathSearchResult getViaXpath(commonj.sdo.DataObject dobj,
                                            java.lang.String xpath)
Retrieves a value from an SDO object by searching through the object web as though it is an XML document. The location (or locations) of the value are specified using an XPath expression. If the value can be coerced to a String, that String value is returned in the XPathSearchResult. If the XPath expression results in multiple possible values, only one is returned.

Parameters:
dobj - The SDO DataObject to be searched.
xpath - An XPath expression that identifies where the value is located.
Returns:
An XPathSearchResult that contains the name of the element that contains the value referred to by the XPath expression, plus one of the following:
  • the String value of a leaf object
  • the DataObject representing the subtree when the XPath expression indicated a complex subtree of the DataObject
  • null if the XPath expression was not found in the DataObject at all.

getListViaXpath

public static java.util.List<XPathSearchResult> getListViaXpath(commonj.sdo.DataObject dobj,
                                                                java.lang.String xpath)
Retrieves zero or more values from an SDO object by searching through the object web as though it is an XML document. The location (or locations) of the value are specified using an XPath expression. If any value can be coerced to a String, that String value is returned in the XPathSearchResult. If the XPath expression results in multiple possible values, all are returned.

Parameters:
dobj - The SDO DataObject to be searched.
xpath - An XPath expression that identifies where the value(s) is(are) located.
Returns:
A list of XPathSearchResult objects that contain the name of the element that contains the value referred to by the XPath expression, plus one of the following:
  • the String value of a leaf object.
  • the DataObject representing the subtree when the item found is a complex subtree of the DataObject.
  • an empty list if the XPath expression was not found in the DataObject at all

getFullXpath

public static java.lang.String getFullXpath(commonj.sdo.DataObject dobj,
                                            java.lang.String xpath)
Given an SDO and an XPath expression, returns the fully-specified XPath expression that would find the same item. If the XPath would return multiple items, this returns the XPath to just the first one. The advantage of fully-specified XPath expressions is that the search for them is faster than generic XPath expressions.

Parameters:
dobj - The SDO DataObject to be searched.
xpath - An XPath expression that identifies where the value is located.
Returns:
A String containing a fully-qualified XPath expression that would return the same result as com.ibm.websphere.fabric.da.util.SdoXPathUtil.getViaXpath(). If the XPath expression is not found at all in the SDO object, this method returns null.


Copyright © 2002-2009 IBM. All Rights Reserved.