com.ibm.xcap
Class NodeSelector

java.lang.Object
  extended by com.ibm.xcap.NodeSelector

public class NodeSelector
extends java.lang.Object

The NodeSelector class is used to parse and represent the node selector that can be appended to the end of an XCAP URI. The API allows for easy retrieval and generation of the various parts of the node selector.


Nested Class Summary
static class NodeSelector.AttrTest
          The AttrTest is an attribute test condition used to match an element with a specific attribute value.
static class NodeSelector.ElementStep
          Represent element steps of the node selector not including the terminal selector.
 class NodeSelector.NamespaceBindings
          Represents the namespace bindings that are defined in the query portion of the request
static class NodeSelector.TerminalSelector
          The TerminalSelector identifies either an attribute, the namespace, or extension of the last element step of the node selector.
 
Field Summary
protected  java.util.LinkedList<NodeSelector.ElementStep> elementSteps
           
protected  NodeSelector.NamespaceBindings namespaceBindings
           
protected  java.lang.String nodeSelector
           
protected  NodeSelector.TerminalSelector terminalSelector
           
 
Constructor Summary
NodeSelector(java.lang.String nodeSelector)
          Constructs a node selector based on the string representation
NodeSelector(java.lang.String nodeSelector, java.lang.String defaultNamespace)
          Constructs a node selector based on the string representation
 
Method Summary
 java.util.List<NodeSelector.ElementStep> getElementSteps()
          Returns the list of element steps that composes the node selector.
 NodeSelector.ElementStep getLastElementStep()
          Returns the last element step.
 NodeSelector.NamespaceBindings getNamespaceBindings()
          Returns the namespace bindings
 NodeSelector.ElementStep getParentElementStep(NodeSelector.ElementStep childStep)
          Returns the parent element step of a child element step.
 NodeSelector.TerminalSelector getTerminalSelector()
          Returns the terminal selector if it exists.
 boolean parse(org.w3c.dom.Document document)
          Parse the document based on the NodeSelector.
 java.lang.String toString()
           
 java.lang.String toStringWithNsBindings()
          Returns the NodeSelector with the namespace binding declaration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nodeSelector

protected java.lang.String nodeSelector

elementSteps

protected java.util.LinkedList<NodeSelector.ElementStep> elementSteps

terminalSelector

protected NodeSelector.TerminalSelector terminalSelector

namespaceBindings

protected NodeSelector.NamespaceBindings namespaceBindings
Constructor Detail

NodeSelector

public NodeSelector(java.lang.String nodeSelector)
             throws java.net.MalformedURLException
Constructs a node selector based on the string representation

Parameters:
nodeSelector -
Throws:
java.net.MalformedURLException

NodeSelector

public NodeSelector(java.lang.String nodeSelector,
                    java.lang.String defaultNamespace)
             throws java.net.MalformedURLException
Constructs a node selector based on the string representation

Parameters:
nodeSelector -
Throws:
java.net.MalformedURLException
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringWithNsBindings

public java.lang.String toStringWithNsBindings()
Returns the NodeSelector with the namespace binding declaration

Returns:
Returns the NodeSelector with the namespace binding declaration

getElementSteps

public java.util.List<NodeSelector.ElementStep> getElementSteps()
Returns the list of element steps that composes the node selector.

Returns:
Returns the list of element steps that composes the node selector.

getLastElementStep

public NodeSelector.ElementStep getLastElementStep()
Returns the last element step.

Returns:
Returns the last element step.

getParentElementStep

public NodeSelector.ElementStep getParentElementStep(NodeSelector.ElementStep childStep)
Returns the parent element step of a child element step.

Parameters:
childStep - The child element step.
Returns:
Returns the parent element step of a child element step.

getTerminalSelector

public NodeSelector.TerminalSelector getTerminalSelector()
Returns the terminal selector if it exists.

Returns:
Returns the terminal selector if it exists.

getNamespaceBindings

public NodeSelector.NamespaceBindings getNamespaceBindings()
Returns the namespace bindings

Returns:
Returns the namespace bindings

parse

public boolean parse(org.w3c.dom.Document document)
              throws InvalidNodeSelectorException
Parse the document based on the NodeSelector. If the path to an element or attribute exists, then this method returns true otherwise false. Each ElementStep will be populated with the corresponding Element from the document. If the NodeSelector ends in a TerminalSelector, the TerminalSelector will reference the terminal value which in most cases is the target attribute value.

Parameters:
document - The document to parse using the NodeSelector
Returns:
Returns true if the path exists otherwise false.
Throws:
InvalidNodeSelectorException