org.apache.jackrabbit.name
Class Path.PathElement

java.lang.Object
  extended byorg.apache.jackrabbit.name.Path.PathElement
Direct Known Subclasses:
Path.CurrentElement, Path.ParentElement, Path.RootElement
Enclosing class:
Path

public static class Path.PathElement
extends Object

Object representation of a single JCR path element. A PathElement object contains the qualified name and optional index of a single JCR path element.

Once created, a PathElement object is immutable.


Method Summary
 boolean denotesCurrent()
          Returns true if this element denotes the current ('.') element, otherwise returns false.
 boolean denotesName()
          Returns true if this element represents a regular name (i.e.
 boolean denotesParent()
          Returns true if this element denotes the parent ('..') element, otherwise returns false.
 boolean denotesRoot()
          Returns true if this element denotes the root element, otherwise returns false.
 boolean equals(Object obj)
          Check for path element equality.
static Path.PathElement fromString(String s)
          Parses the given path element string into a path element object.
 int getIndex()
          Returns the 1-based index or 0 if no index was specified (which is equivalent to specifying 1).
 QName getName()
          Returns the qualified name of this path element.
 int hashCode()
          Computes a hash code for this path element.
 String toJCRName(NamespaceResolver resolver)
          Returns the JCR name representation of this path element.
 void toJCRName(NamespaceResolver resolver, StringBuffer buf)
          Appends the JCR name representation of this path element to the given string buffer.
 String toString()
          Returns a string representation of this path element.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public QName getName()
Returns the qualified name of this path element.

Returns:
qualified name

getIndex

public int getIndex()
Returns the 1-based index or 0 if no index was specified (which is equivalent to specifying 1).

Returns:
Returns the 1-based index or 0 if no index was specified.

denotesRoot

public boolean denotesRoot()
Returns true if this element denotes the root element, otherwise returns false.

Returns:
true if this element denotes the root element; otherwise false

denotesParent

public boolean denotesParent()
Returns true if this element denotes the parent ('..') element, otherwise returns false.

Returns:
true if this element denotes the parent element; otherwise false

denotesCurrent

public boolean denotesCurrent()
Returns true if this element denotes the current ('.') element, otherwise returns false.

Returns:
true if this element denotes the current element; otherwise false

denotesName

public boolean denotesName()
Returns true if this element represents a regular name (i.e. neither root, '.' nor '..'), otherwise returns false.

Returns:
true if this element represents a regular name; otherwise false

toJCRName

public String toJCRName(NamespaceResolver resolver)
                 throws NoPrefixDeclaredException
Returns the JCR name representation of this path element. Note that strictly speaking the returned value is in fact a JCR relative path instead of a JCR name, as it contains the index value if the index is greater than one.

Parameters:
resolver - namespace resolver
Returns:
JCR name representation of the path element
Throws:
NoPrefixDeclaredException - if the namespace of the path element name can not be resolved

toJCRName

public void toJCRName(NamespaceResolver resolver,
                      StringBuffer buf)
               throws NoPrefixDeclaredException
Appends the JCR name representation of this path element to the given string buffer.

Parameters:
resolver - namespace resolver
buf - string buffer where the JCR name representation should be appended to
Throws:
NoPrefixDeclaredException - if the namespace of the path element name can not be resolved
See Also:
toJCRName(NamespaceResolver)

toString

public String toString()
Returns a string representation of this path element. Note that the path element name is expressed using the {uri}name syntax. Use the toJCRName method to get the prefixed string representation of the path element.

Returns:
string representation of the path element

fromString

public static Path.PathElement fromString(String s)
                                   throws IllegalArgumentException
Parses the given path element string into a path element object.

Parameters:
s - path element string
Returns:
path element object
Throws:
IllegalArgumentException - if the given path element string is null or if its format is invalid

hashCode

public int hashCode()
Computes a hash code for this path element.

Returns:
hash code

equals

public boolean equals(Object obj)
Check for path element equality. Returns true if the given object is a PathElement and contains the same name and index as this one.

Parameters:
obj - the object to compare with
Returns:
true if the path elements are equal


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.