org.apache.woden.xpointer
Class XPointer

java.lang.Object
  extended by org.apache.woden.xpointer.XPointer

public class XPointer
extends java.lang.Object

XPointer is a class which represents an XPointer defined in the XPointer Framework. This is specified at http://www.w3.org/TR/xptr-framework/

Author:
Dan Harvey (danharvey42@gmail.com)

Constructor Summary
XPointer()
          Constructs a new XPointer.
XPointer(java.lang.String xpointerString)
          Constructs a new XPointer from the serialised string.
 
Method Summary
 void addPointerPart(int index, PointerPart pointerPart)
          Inserts a pointer part at index of this XPointer.
 void addPointerPart(PointerPart pointerPart)
          Appends a pointer part to the end of this XPointer.
 void addPrefixNamespaceBinding(NCName prefix, java.lang.String namespace)
          Adds a Prefix/Namespace binding to this XPointers contex.
 NCName getNamespaceBinding(java.lang.String namespace)
          Gets Prefix the Namespace is bound to if the binding exists, otherwise it will return null.
 java.lang.Object[] getPointerParts()
          Returns the pointer parts in this XPointer.
 java.lang.String getPrefixBinding(NCName prefix)
          Gets the Namespace the Prefix is bound to if the binding exists, otherwise it will return null.
 NCName getShorthandPointer()
          Returns the shorthandPointer in this XPointer.
 boolean hasNamespaceBinding(java.lang.String namespace)
          Checks whether a namespace is bound or not.
 boolean hasPointerParts()
          Tests whether this XPointer has scheme based pointers or not.
 boolean hasPrefixBinding(NCName prefix)
          Checks whether a prefix is bound or not.
 boolean hasShorthandPointer()
          Tests whether this XPointer has a shorthand pointer or not.
 void setShorthandPointer(NCName shorthandPointer)
          Sets the Shorthand Pointer of this XPointer to the NCName given as an argument.
 java.lang.String toString()
          Returns a String serialisation of this XPointer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPointer

public XPointer()
Constructs a new XPointer.


XPointer

public XPointer(java.lang.String xpointerString)
         throws InvalidXPointerException
Constructs a new XPointer from the serialised string.

Parameters:
xpointerString - a String form of the XPointer to deserialise.
Throws:
InvalidXPointerException
Method Detail

addPointerPart

public void addPointerPart(PointerPart pointerPart)
Appends a pointer part to the end of this XPointer.

Parameters:
pointerPart - the Pointer Part to append.
Throws:
UnsupportedOperationException() - if a Shorthand Pointer is already set.

addPointerPart

public void addPointerPart(int index,
                           PointerPart pointerPart)
Inserts a pointer part at index of this XPointer.

Parameters:
pointerPart - the Pointer Part to inserted.
index - an integer specifying the point to insert the pointer part.
Throws:
UnsupportedOperationException() - if a Shorthand Pointer is already set.

getPointerParts

public java.lang.Object[] getPointerParts()
Returns the pointer parts in this XPointer.

Returns:
a PointerPart[] of type Object[] containing the pointer parts in this XPointer.
Throws:
java.lang.IllegalStateException - if this XPointer has a shorthand pointer.

setShorthandPointer

public void setShorthandPointer(NCName shorthandPointer)
Sets the Shorthand Pointer of this XPointer to the NCName given as an argument.

Parameters:
shorthandPointer - an NCName of the Shorthand Pointer to set.
Throws:
UnsupportedOperationException() - is a PointerPart Pointer is already set.

getShorthandPointer

public NCName getShorthandPointer()
Returns the shorthandPointer in this XPointer.

Returns:
an NCName containing the shorthand pointer for this XPointer.
Throws:
java.lang.IllegalStateException - if this XPointer has a shorthand pointer.

addPrefixNamespaceBinding

public void addPrefixNamespaceBinding(NCName prefix,
                                      java.lang.String namespace)
Adds a Prefix/Namespace binding to this XPointers contex.

Parameters:
prefix - a NCName of the prefix too bind to the namespace.
namespace - a String of the namespace to bind to the prefix.
Throws:
java.lang.NullPointerException - if the prefix or namespace arguments are null.
java.lang.IllegalArgumentException - if the prefix or namespace are invalid as specified at http://www.w3.org/TR/xptr-framework/#nsContext

getPrefixBinding

public java.lang.String getPrefixBinding(NCName prefix)
Gets the Namespace the Prefix is bound to if the binding exists, otherwise it will return null.

Parameters:
prefix - a NCName of the prefix bound to the namespace.
Returns:
A String of the namespace bound to this prefix or null if none exists.

getNamespaceBinding

public NCName getNamespaceBinding(java.lang.String namespace)
Gets Prefix the Namespace is bound to if the binding exists, otherwise it will return null.

Parameters:
namespace - a String of the prefix bound to the prefix.
Returns:
A NCName of the prefix bound to this namespace or null if none exists.

hasPrefixBinding

public boolean hasPrefixBinding(NCName prefix)
Checks whether a prefix is bound or not.

Parameters:
prefix - A NCName of the prefix to check.
Returns:
a boolean value that is true if the binding exists, or false otherwise.

hasNamespaceBinding

public boolean hasNamespaceBinding(java.lang.String namespace)
Checks whether a namespace is bound or not.

Parameters:
namespace - A String of the namespace to check.
Returns:
a boolean value that is true if the binding exists, or false otherwise.

hasShorthandPointer

public boolean hasShorthandPointer()
Tests whether this XPointer has a shorthand pointer or not.

Returns:
a boolean which is true if this XPointer contains an shorthand pointer, false otherwise.

hasPointerParts

public boolean hasPointerParts()
Tests whether this XPointer has scheme based pointers or not.

Returns:
a boolean which is true if this XPointer contains scheme based pointers, false otherwise.

toString

public java.lang.String toString()
Returns a String serialisation of this XPointer.

Overrides:
toString in class java.lang.Object
Returns:
a String containing the serialisation of this XPointer


Copyright © 2005-2010 Apache Software Foundation. All Rights Reserved.