org.jaxen.expr

Class DefaultNameStep

Implemented Interfaces:
NameStep, Predicated, Serializable, Step

public class DefaultNameStep
extends DefaultStep
implements NameStep

Expression object that represents any flavor of name-test steps within an XPath.

This includes simple steps, such as "foo", non-default-axis steps, such as "following-sibling::foo" or "@foo", and namespace-aware steps, such as "foo:bar".

Authors:
bob mcwhirter (bob@werken.com)
Stephen Colebourne

Field Summary

private boolean
hasPrefix
Quick flag denoting if we have a namespace prefix *
private String
localName
Our local-name.
private boolean
matchesAnyName
Quick flag denoting if the local name was '*'
private String
prefix
Our prefix, bound through the current Context.
private static long
serialVersionUID

Fields inherited from class org.jaxen.expr.DefaultStep

axis, predicates

Constructor Summary

DefaultNameStep(IterableAxis axis, String prefix, String localName, PredicateSet predicateSet)
Constructor.

Method Summary

List
evaluate(Context context)
Evaluate the context node set to find the new node set.
String
getLocalName()
Gets the local name.
String
getPrefix()
Gets the namespace prefix.
String
getText()
Gets the step as a fully defined XPath.
private boolean
hasNamespace(String uri)
Checks whether the URI represents a namespace.
boolean
isMatchesAnyName()
Does this step match any name? (i.e.
boolean
matches(Object node, ContextSupport contextSupport)
Checks whether the node matches this step.
protected boolean
matchesNamespaceURIs(String uri1, String uri2)
Compares two namespace URIs, handling null.
String
toString()
Returns a full information debugging string.

Methods inherited from class org.jaxen.expr.DefaultStep

addPredicate, axisIterator, evaluate, getAxis, getAxisName, getIterableAxis, getPredicateSet, getPredicates, getText, simplify, toString

Field Details

hasPrefix

private boolean hasPrefix
Quick flag denoting if we have a namespace prefix *

localName

private String localName
Our local-name. This is the 'bar' in 'foo:bar'.

matchesAnyName

private boolean matchesAnyName
Quick flag denoting if the local name was '*'

prefix

private String prefix
Our prefix, bound through the current Context. The empty-string ("") if no prefix was specified. Decidedly NOT-NULL, due to SAXPath constraints. This is the 'foo' in 'foo:bar'.

serialVersionUID

private static final long serialVersionUID
Field Value:
428414912247718390L

Constructor Details

DefaultNameStep

public DefaultNameStep(IterableAxis axis,
                       String prefix,
                       String localName,
                       PredicateSet predicateSet)
Constructor.
Parameters:
axis - the axis to work through
prefix - the name prefix
localName - the local name
predicateSet - the set of predicates

Method Details

evaluate

public List evaluate(Context context)
            throws JaxenException
Evaluate the context node set to find the new node set.

This method overrides the version in DefaultStep for performance.

Specified by:
evaluate in interface Step
Overrides:
evaluate in interface DefaultStep

getLocalName

public String getLocalName()
Gets the local name.
Specified by:
getLocalName in interface NameStep
Returns:
the local name

getPrefix

public String getPrefix()
Gets the namespace prefix.
Specified by:
getPrefix in interface NameStep
Returns:
the prefix

getText

public String getText()
Gets the step as a fully defined XPath.
Specified by:
getText in interface Step
Overrides:
getText in interface DefaultStep
Returns:
the full XPath for this step

hasNamespace

private boolean hasNamespace(String uri)
Checks whether the URI represents a namespace.
Parameters:
uri - the URI to check
Returns:
true if non-null and non-empty

isMatchesAnyName

public boolean isMatchesAnyName()
Does this step match any name? (i.e. Is it '*'?)
Returns:
true if it matches any name

matches

public boolean matches(Object node,
                       ContextSupport contextSupport)
            throws JaxenException
Checks whether the node matches this step.
Specified by:
matches in interface Step
Parameters:
node - the node to check
contextSupport - the context support
Returns:
true if matches
Throws:
JaxenException -

matchesNamespaceURIs

protected boolean matchesNamespaceURIs(String uri1,
                                       String uri2)
Compares two namespace URIs, handling null.
Parameters:
uri1 - the first URI
uri2 - the second URI
Returns:
true if equal, where null==""

toString

public String toString()
Returns a full information debugging string.
Overrides:
toString in interface DefaultStep
Returns:
a debugging string