Steppublic class Step extends Object Represents a 'step' in an SPath expression. |
Fields Summary |
---|
private boolean | depthUnlimited | private String | name | private List | predicates | private String | uri | private String | localPart |
Constructors Summary |
---|
public Step(boolean depthUnlimited, String name, List predicates)Constructs a new Step object, given a name and a (possibly null)
list of predicates. A boolean is also passed, indicating
whether this particular Step is relative to the 'descendent-or-self'
axis of the node courrently under consideration. If true, it is;
if false, then this Step is rooted as a direct child of the node
under consideration.
if (name == null)
throw new IllegalArgumentException("non-null name required");
this.depthUnlimited = depthUnlimited;
this.name = name;
this.predicates = predicates;
|
Methods Summary |
---|
public java.lang.String | getName()Returns the Step's node name.
return name;
| public java.util.List | getPredicates()Returns a list of this Step object's predicates.
return predicates;
| public boolean | isDepthUnlimited()Returns true if the Step's depth is unlimited, false otherwise.
return depthUnlimited;
| public boolean | isMatchingName(java.lang.String uri, java.lang.String localPart)Returns true if the given name matches the Step object's
name, taking into account the Step object's wildcards; returns
false otherwise.
// check and normalize arguments
if (localPart == null)
throw new IllegalArgumentException("need non-null localPart");
if (uri != null && uri.equals(""))
uri = null;
// split name into uri/localPart if we haven't done so already
if (this.localPart == null && this.uri == null)
parseStepName();
// generic wildcard
if (this.uri == null && this.localPart.equals("*"))
return true;
// match will null namespace
if (uri == null && this.uri == null
&& localPart.equals(this.localPart))
return true;
if (uri != null && this.uri != null && uri.equals(this.uri)) {
// exact match
if (localPart.equals(this.localPart))
return true;
// namespace-specific wildcard
if (this.localPart.equals("*"))
return true;
}
// no match
return false;
| private java.lang.String | mapPrefix(java.lang.String prefix)Returns a URI for the given prefix, given our mappings.
// ability to specify a mapping is, as of yet, unimplemented
if (prefix == null)
return null;
else
throw new IllegalArgumentException(
"unknown prefix '" + prefix + "'");
| private void | parseStepName()Lazily computes some information about our name.
String prefix;
int colonIndex = name.indexOf(":");
if (colonIndex == -1) {
// no colon, so localpart is simply name (even if it's "*")
prefix = null;
localPart = name;
} else {
prefix = name.substring(0, colonIndex);
localPart = name.substring(colonIndex + 1);
}
uri = mapPrefix(prefix);
|
|