org.primordion.xholon.base
Class XPath

java.lang.Object
  extended byorg.primordion.xholon.base.XPath
All Implemented Interfaces:
IXPath

public class XPath
extends java.lang.Object
implements IXPath

Simple XPath implementation. This is NOT a complete implementation of XPath 1.0.

Since:
0.1 (Created on Sep 8, 2005)
Author:
Ken Webb

Field Summary
 
Fields inherited from interface org.primordion.xholon.base.IXPath
AXIS_ANCESTOR, AXIS_ANCESTORORSELF, AXIS_ATTRIBUTE, AXIS_CHILD, AXIS_DEFAULT, AXIS_DESCENDANT, AXIS_DESCENDANTORSELF, AXIS_FOLLOWING, AXIS_FOLLOWINGSIBLING, AXIS_NAMESPACE, AXIS_PARENT, AXIS_PRECEDING, AXIS_PRECEDINGSIBLING, AXIS_SELF, XPATH_OP_EQ, XPATH_OP_GE, XPATH_OP_GT, XPATH_OP_LE, XPATH_OP_LT, XPATH_OP_NE, XPATH_OP_NOP
 
Constructor Summary
XPath()
           
 
Method Summary
 IXholon evaluate(java.lang.String expression, IXholon item)
          Evaluate an XPath expression in the specified context and return the result as a IXholon.
 java.lang.String evaluate(java.lang.String expression, java.lang.Object item)
          Evaluate an XPath expression in the specified context and return the result as a String.
 java.lang.Object evaluate(java.lang.String expression, java.lang.Object item, int returnType)
          Evaluate an XPath expression in the specified context and return the result as the specified type.
 java.util.Vector searchForClosestNeighbors(int distance, int include, java.lang.String excludeBecName, java.lang.String xhcName, int maxQuantity, boolean matchSuperClasses, IXholon xhNode)
          Search for closest neighbors whose XholonClass names are xhcName.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPath

public XPath()
Method Detail

evaluate

public java.lang.String evaluate(java.lang.String expression,
                                 java.lang.Object item)
Description copied from interface: IXPath
Evaluate an XPath expression in the specified context and return the result as a String.

Specified by:
evaluate in interface IXPath
Parameters:
expression - The XPath expression.
item - The starting context (node or node list, for example).
Returns:
The string that is the result of evaluating the expression and converting the result to a String.
See Also:
1.3

evaluate

public java.lang.Object evaluate(java.lang.String expression,
                                 java.lang.Object item,
                                 int returnType)
Description copied from interface: IXPath
Evaluate an XPath expression in the specified context and return the result as the specified type.

Specified by:
evaluate in interface IXPath
Parameters:
expression - The XPath expression.
item - The starting context (node or node list, for example).
returnType - The desired return type.
Returns:
Result of evaluating an XPath expression as an Object of returnType.
See Also:
1.3

evaluate

public IXholon evaluate(java.lang.String expression,
                        IXholon item)
Description copied from interface: IXPath
Evaluate an XPath expression in the specified context and return the result as a IXholon.

Specified by:
evaluate in interface IXPath
Parameters:
expression - The XPath expression.
item - The starting context, a IXholon.
Returns:
The IXholon that is the result of evaluating the expression.

Examples of expressions (location paths):

ancestor::AnElevatorSystem/Floor[1]/CallButton[1]

ancestor::Cytoplasm/Cytosol/Pyruvate

ancestor::ExtraCellularSolution/child::Glucose

./DescendantName

./child::DescendantName/TargetDescendantName


searchForClosestNeighbors

public java.util.Vector searchForClosestNeighbors(int distance,
                                                  int include,
                                                  java.lang.String excludeBecName,
                                                  java.lang.String xhcName,
                                                  int maxQuantity,
                                                  boolean matchSuperClasses,
                                                  IXholon xhNode)
Search for closest neighbors whose XholonClass names are xhcName.

Specified by:
searchForClosestNeighbors in interface IXPath
Parameters:
distance - How far within the tree to search for neighbors.
include - Whether to include (P)arent and/or (S)iblings and/or (C)hildren.
excludeBecName - Name of a XholonClass, used to limit the scope of the returned Vector.
xhcName - Name of a XholonClass.
maxQuantity - Maximum quantity of closest neighbors to return (may return fewer)
matchSuperClasses - Whether or not to match superclasses.
xhNode - A xholon node.
Returns:
Vector containing instances of IXholon, or null. TODO Make this fully a part of XPath, once Xpath supports returning a NodeSet and not just a single node. TODO Make it protected; but for now XhLife needs to use it directly to get a Vector.