adapforms.form
Class FormPath

java.lang.Object
  extended by adapforms.form.FormPath

public class FormPath
extends java.lang.Object

Represents a form path, pointing to a single specific form element within an adaptive form.

Upon instantiation, the given path will be trimmed, have leading and trailing slashed removed, and checked for malformed path structure.
If given a static path as input, the returned runtime path will equal the static path.

The path will be made available in two forms:
- Runtime: The full path, as given - points to a specific instantiated element.
- Static: The path with repeat entry IDs removed - points to the "prototype" element.

equals(Object), hashCode(), toString() etc, work on the runtime path.

Author:
Henrik Gammelmark, geemark@cs.au.dk

Nested Class Summary
 class FormPath.Part
          Single part of a form path.
 
Field Summary
static FormPath root
          The path representing the root.
 
Constructor Summary
FormPath(java.lang.String path)
          Create a new path instance.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 FormPath.Part getLastPart()
          Return the last part of the path (rightmost part in string form).
 java.util.List<FormPath.Part> getParts()
          Enumerate all parts of the runtime version of the path.
 FormPath getRuntimeParent()
          Get the parent path of this path in a runtime context.
 java.lang.String getRuntimePath()
          Get the runtime version of the path
 FormPath getStaticParent()
          Get the parent path of this path in a static context, that is the path pointing to the container of this element.
 java.lang.String getStaticPath()
          Get the static version of the path
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

root

public static final FormPath root
The path representing the root.

Constructor Detail

FormPath

public FormPath(java.lang.String path)
         throws InvalidPathException
Create a new path instance.

Throws:
InvalidPathException - If the path is invalid or malformed
Method Detail

getRuntimePath

public java.lang.String getRuntimePath()
Get the runtime version of the path


getStaticPath

public java.lang.String getStaticPath()
Get the static version of the path


getParts

public java.util.List<FormPath.Part> getParts()
Enumerate all parts of the runtime version of the path.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getRuntimeParent

public FormPath getRuntimeParent()
Get the parent path of this path in a runtime context. The parent is determined in the obvious way, with the twist that the parent of a repeat entry is the repeat element (i.e. the repeat entry ID is merely stripped).
The parent of the root is the root itself.


getStaticParent

public FormPath getStaticParent()
Get the parent path of this path in a static context, that is the path pointing to the container of this element.
The parent of the root is the root itself.


getLastPart

public FormPath.Part getLastPart()
Return the last part of the path (rightmost part in string form).