electric.xml
Class XPath

java.lang.Object
  extended byelectric.xml.XPath
All Implemented Interfaces:
IXPath

public final class XPath
extends java.lang.Object
implements IXPath

XPath provides a set of methods for selecting nodes from an element based on an XPath. The XPath tokens that are currently supported are ".", "..", "...", "/", "*", "@*", "[n]", "name[n]", "[@key='value']", "name[@key='value']", "[text='value']", "name[text='value']" and "@key". To prevent special characters from being treated as XPath directives, enclose the path in single quotes.

Author:
webMethods

Constructor Summary
XPath(java.lang.String xpath)
          Construct an XPath with the specified expression and no namespace context.
XPath(java.lang.String xpath, boolean cache)
          Construct an XPath with the specified expression and no namespace context.
XPath(java.lang.String xpath, INamespaceContext namespaceContext)
          Construct an XPath with the specified expression and namespace context.
XPath(java.lang.String xpath, INamespaceContext namespaceContext, boolean cache)
          Construct an XPath with the specified expression and namespace context.
 
Method Summary
static void addFactory(IXPathFactory factory)
          Add an XPath defaultFactory.
 Attribute getAttribute(Element element)
           
 Attributes getAttributes(Element element)
           
 boolean getBoolean(Node node)
           
static boolean getCacheByDefault()
           
 Element getElement(Parent parent)
           
 Elements getElements(Parent parent)
           
static IXPathFactory getFactory()
          Get the default xpath defaultFactory.
static IXPathFactory getFactory(int implementationLevel)
          Return the first XPath defaultFactory that matches the given implementation level.
 Node getNode(Node node)
           
 Nodes getNodes(Node node)
           
static void setCacheByDefault(boolean flag)
           
static void setFactory(IXPathFactory factory)
          Set the primary default defaultFactory.
 void setNamespace(java.lang.String prefix, java.lang.String namespace)
           
 java.lang.String toString()
          Return the xpath expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPath

public XPath(java.lang.String xpath)
      throws XPathException
Construct an XPath with the specified expression and no namespace context.

Parameters:
xpath - The xpath expression.
Throws:
XPathException - If the path is malformed.

XPath

public XPath(java.lang.String xpath,
             boolean cache)
      throws XPathException
Construct an XPath with the specified expression and no namespace context.

Parameters:
xpath - The xpath expression.
Throws:
XPathException - If the path is malformed.

XPath

public XPath(java.lang.String xpath,
             INamespaceContext namespaceContext)
      throws XPathException
Construct an XPath with the specified expression and namespace context.

Parameters:
xpath - The xpath expression.
namespaceContext - The namespace context.
Throws:
XPathException - If the path is malformed.

XPath

public XPath(java.lang.String xpath,
             INamespaceContext namespaceContext,
             boolean cache)
      throws XPathException
Construct an XPath with the specified expression and namespace context.

Parameters:
xpath - The xpath expression.
namespaceContext - The namespace context.
Throws:
XPathException - If the path is malformed.
Method Detail

toString

public java.lang.String toString()
Return the xpath expression.


getFactory

public static IXPathFactory getFactory()
Get the default xpath defaultFactory.


setFactory

public static void setFactory(IXPathFactory factory)
Set the primary default defaultFactory.

Parameters:
factory -

addFactory

public static void addFactory(IXPathFactory factory)
Add an XPath defaultFactory.

Parameters:
factory -

getFactory

public static IXPathFactory getFactory(int implementationLevel)
Return the first XPath defaultFactory that matches the given implementation level.

Parameters:
implementationLevel - XPATH_FULL or XPATH_PARTIAL
Returns:
an XPath defaultFactory of the appropriate implementation level.

setCacheByDefault

public static void setCacheByDefault(boolean flag)
Parameters:
flag -

getCacheByDefault

public static boolean getCacheByDefault()

getNodes

public Nodes getNodes(Node node)
               throws XPathException
Specified by:
getNodes in interface IXPath
Parameters:
node -
Throws:
XPathException

getNode

public Node getNode(Node node)
             throws XPathException
Specified by:
getNode in interface IXPath
Parameters:
node -
Throws:
XPathException

getAttribute

public Attribute getAttribute(Element element)
                       throws XPathException
Specified by:
getAttribute in interface IXPath
Parameters:
element -
Throws:
XPathException

getAttributes

public Attributes getAttributes(Element element)
                         throws XPathException
Specified by:
getAttributes in interface IXPath
Parameters:
element -
Throws:
XPathException

getElement

public Element getElement(Parent parent)
                   throws XPathException
Specified by:
getElement in interface IXPath
Parameters:
parent -
Throws:
XPathException

getElements

public Elements getElements(Parent parent)
                     throws XPathException
Specified by:
getElements in interface IXPath
Parameters:
parent -
Throws:
XPathException

setNamespace

public void setNamespace(java.lang.String prefix,
                         java.lang.String namespace)
                  throws XPathException
Specified by:
setNamespace in interface IXPath
Parameters:
prefix -
namespace -
Throws:
XPathException

getBoolean

public boolean getBoolean(Node node)
Specified by:
getBoolean in interface IXPath
Parameters:
node -


copyright© 2001-2004 by webMethods All Rights Reserved.