org.inria.ns.reflex.xml.xpath.xpointer
Class ElementScheme

java.lang.Object
  extended by org.inria.ns.reflex.xml.CompiledExpression.Impl
      extended by org.inria.ns.reflex.xml.xpath.xpointer.ElementScheme
All Implemented Interfaces:
CompiledExpression, SchemeBased, XPointer

public class ElementScheme
extends CompiledExpression.Impl
implements XPointer, SchemeBased

The implementation of the XPointer element() scheme.

A valid expression is composed of an optional ID and an optional child sequence. One of them must be present.

Author:
Philippe Poulard

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.xml.CompiledExpression
CompiledExpression.Impl
 
Constructor Summary
ElementScheme(String schemeData, XFactory factory)
          Create a new XPointer expression.
 
Method Summary
 Pattern asPattern()
          Return this expression as a pattern
 Object evaluate(XPathContext context)
          Select the element pointed by this expression.
 int[] getChildSequence()
          Return the child sequence defined by this expression.
 String getId()
          Return the ID part of this expression.
 QName getSchemeName()
          Return the name of this scheme.
 
Methods inherited from class org.inria.ns.reflex.xml.CompiledExpression.Impl
getXFactory
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.inria.ns.reflex.xml.CompiledExpression
getXFactory
 

Constructor Detail

ElementScheme

public ElementScheme(String schemeData,
                     XFactory factory)
              throws XPointerSyntaxException
Create a new XPointer expression.

Parameters:
schemeData - The scheme data is like "id/1/2/3".
factory - The factory that has created this binding.
Throws:
XPointerSyntaxException - When the scheme datas can't be parsed.
Method Detail

getSchemeName

public QName getSchemeName()
Return the name of this scheme.

Specified by:
getSchemeName in interface SchemeBased
Returns:
"element".
See Also:
XMLNames.ELEMENT_XPOINTER_SCHEME, SchemeBased.getSchemeName()

evaluate

public Object evaluate(XPathContext context)
                throws XPathException
Select the element pointed by this expression.

Specified by:
evaluate in interface CompiledExpression
Parameters:
context - The context : a node set with the position of the object where to start evaluating.
Returns:
The non-null element.
Throws:
XPathException
See Also:
CompiledExpression.evaluate(org.inria.ns.reflex.xml.xpath.XPathContext)

getId

public String getId()
Return the ID part of this expression.

Returns:
The ID or null.

getChildSequence

public int[] getChildSequence()
Return the child sequence defined by this expression.

Returns:
An array of child sequences, or null.

asPattern

public Pattern asPattern()
                  throws BadPatternException
Return this expression as a pattern

Specified by:
asPattern in interface CompiledExpression
Returns:
This expression as a pattern.
Throws:
BadPatternException - If this expression can't be converted to a pattern.
See Also:
CompiledExpression.asPattern()