|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.inria.ns.reflex.xml.CanonicalPath
public class CanonicalPath
Represent the canonical path of a node.
This path only stores the name and the position of each step + the node type of the last step.
The canReach(...) methods are convenient methods that check if a node (eventually represented by its canonical path) is contained or equal to another node.
The normalize(...) methods allow to disambiguish the prefixes used in this path ; one of these methods should be called before using the string form of this path, otherwise the string representation of this path could be displayed with a prefix mapped to several namespace URIs (can occur if this path is built from a node for which itself or one of its ancestor has renamed a prefix).
| Constructor Summary | |
|---|---|
CanonicalPath(Object node)
Compute the canonical path of a node. |
|
| Method Summary | |
|---|---|
boolean |
canReach(CanonicalPath canonicalPath)
Check if a path can be reached by this path, that is to say that the subtree selected by the candidate path would be part of the subtree selected by this path. |
boolean |
canReach(Object node)
Check if a node can be reached by this path, that is to say that the candidate node would be part of the subtree selected by this path. |
boolean |
equals(Object o)
Compares the steps of 2 paths. |
NamespaceContext.Mutable |
getNamespaces()
Return the set of namespace mappings defined by the normal form of this canonical path. |
void |
normalize()
Normalize this path. |
void |
normalize(NamespaceContext.Mutable namespaces)
Normalize this path regarding the given mutable namespace context. |
StringBuffer |
toPrettyString()
Return a pretty string representation of this. |
StringBuffer |
toPrettyString(StringBuffer buf)
Append a pretty string representation of this to the given buffer. |
String |
toString()
Return the string representation of this path, that is to say the canonical XPath expression that allows to reach the node that was used to build this path. |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CanonicalPath(Object node)
node - The node.
Node,
SAXNode,
XOperable| Method Detail |
|---|
public boolean canReach(Object node)
| this path | can reach ? | node's path |
|---|---|---|
| /a/b/c | /a/b/c | |
| /a/b/c | /a/b/c/d/e | |
| /a/b/c | /d/e/f | |
| /acme:foo[1]/bar[2] | /acme:foo[1]/bar[2]/acme[3] | |
| /a/a/a | /a/a/a/a | |
| /a/a/a/a | /a/a/a |
node - The candidate node.
true if this node contains the candidate node,
false otherwise.canReach(CanonicalPath)public boolean canReach(CanonicalPath canonicalPath)
A path tested upon itself return true.
2 paths p1 and p2 that are equals return true
with p1.canReach(p2) and p2.canReach(p1).
canonicalPath - The path to test.
true if the given canonical path is a subpath
of this path or is equal to this path, false otherwise.canReach(Object)public boolean equals(Object o)
equals in class Objecto - The object to compare.
true if the object to compare is a
canonical path that have the same steps of this path.public void normalize()
An unprefixed name bound to a namespace URI is changed to a prefixed name. The prefix endorses the form "ns[A-Z][n]".
When needed, prefixes that are bound to several namespace URIs (in the case where they had been redefined) are changed (a number is appended to such prefixes).
In any case, before generating a new prefix, a lookup for an existing prefix already bound to the expected namespace URI is performed.
The first call to this method cause the normalization, next calls are ignored.
normalize in interface QNameSetnormalize(NamespaceContext.Mutable),
QNameSet.normalize()public NamespaceContext.Mutable getNamespaces()
normalize(org.inria.ns.reflex.xml.NamespaceContext.Mutable),
QNameSet.normalize()public void normalize(NamespaceContext.Mutable namespaces)
Unlike the other normalize() method, this one perform the normalization each time it is invoked, as a normalized path may be incoherent regarding a given namespace context.
The operations performed are the same of the other method but the existing mappings found in the namespace context are preserved ; new definitions are added if necessary.
To populate an empty namespace context, use preferably
getNamespaces().
normalize in interface QNameSetnamespaces - The mutable namespace context that
might be augmented with new definition if this
path contains prefixed names.normalize(),
QNameSet.normalize(NamespaceContext.Mutable),
getNamespaces()public String toString()
*** The returned string is not normalized automatically. The relevant method must be invoked before. ***
toString in class Objectnormalize(),
Object.toString()public StringBuffer toPrettyString()
toPrettyString in interface PresentabletoPrettyString(StringBuffer)public StringBuffer toPrettyString(StringBuffer buf)
After the normalization, the string value of this path is followed with all mappings used in this path (a single mapping per line).
toPrettyString in interface Presentablebuf - The buffer to append to.
toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||