com.flexive.shared
Class XPathElement

java.lang.Object
  extended by com.flexive.shared.XPathElement
All Implemented Interfaces:
java.io.Serializable

public class XPathElement
extends java.lang.Object
implements java.io.Serializable

A single XPath element (alias and multiplicity)

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Constructor Summary
XPathElement(java.lang.String alias, int index, boolean indexDefined)
          Ctor
 
Method Summary
static java.lang.String buildXPath(boolean leadingSlash, java.lang.String... elements)
          Build an XPath from the given elements
 boolean equals(java.lang.Object obj)
          
 java.lang.String getAlias()
          Getter for the alias
 int getIndex()
          Getter for the multiplicity
static int[] getIndices(java.lang.String XPath)
          Get the FQ indices of an XPath as an int array
static FxPK getPK(java.lang.String xPath)
          Extract the primary key stored in the given XPath.
 int hashCode()
          
 boolean isIndexDefined()
          Was the multiplicity explicitly defined?
static boolean isValidXPath(java.lang.String XPath)
          Check if this XPath is valid
static XPathElement lastElement(java.lang.String XPath)
          Get the last (rightmost) element of an XPath
 void setIndex(int index)
          Setter for the multiplicity
static java.util.List<XPathElement> split(java.lang.String XPath)
          Split an XPath into its elements
static java.lang.String stripType(java.lang.String XPath)
          Strip leading types from an XPath if present
static XPathElement toElement(java.lang.String XPath, java.lang.String alias)
          Convert an alias of an XPath to an element
 java.lang.String toString()
          get FQN of the alias
static java.lang.String toXPath(java.util.List<XPathElement> xpe)
          Get the XPath of an array of XPathElements with multiplicities
static java.lang.String toXPathMult(java.lang.String XPath)
          Get the given XPath with full multiplicity information
static java.lang.String toXPathNoMult(java.util.List<XPathElement> xpe)
          Get the XPath of an array of XPathElements without multiplicities
static java.lang.String toXPathNoMult(java.lang.String XPath)
          Get the given XPath with no indices
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPathElement

public XPathElement(java.lang.String alias,
                    int index,
                    boolean indexDefined)
Ctor

Parameters:
alias - alias to use
index - multiplicity to apply
indexDefined - was the multiplicity explicitly defined?
Method Detail

getAlias

public java.lang.String getAlias()
Getter for the alias

Returns:
alias

getIndex

public int getIndex()
Getter for the multiplicity

Returns:
multiplicity

setIndex

public void setIndex(int index)
Setter for the multiplicity

Parameters:
index - the multiplicity to apply

isIndexDefined

public boolean isIndexDefined()
Was the multiplicity explicitly defined?

Returns:
multiplicity explicitly defined

toString

public java.lang.String toString()
get FQN of the alias

Overrides:
toString in class java.lang.Object
Returns:
FQ alias

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

split

public static java.util.List<XPathElement> split(java.lang.String XPath)
                                          throws FxInvalidParameterException
Split an XPath into its elements

Parameters:
XPath -
Returns:
XPathElement array
Throws:
FxInvalidParameterException - for invalid elements

lastElement

public static XPathElement lastElement(java.lang.String XPath)
                                throws FxInvalidParameterException
Get the last (rightmost) element of an XPath

Parameters:
XPath -
Returns:
last (rightmost) element of an XPath
Throws:
FxInvalidParameterException

toElement

public static XPathElement toElement(java.lang.String XPath,
                                     java.lang.String alias)
                              throws FxInvalidParameterException
Convert an alias of an XPath to an element

Parameters:
XPath - full XPath, only used if exception is thrown
alias - alias to convert to an XPathElement
Returns:
XPathElement
Throws:
FxInvalidParameterException

isValidXPath

public static boolean isValidXPath(java.lang.String XPath)
Check if this XPath is valid

Parameters:
XPath -
Returns:
valid or not

toXPath

public static java.lang.String toXPath(java.util.List<XPathElement> xpe)
Get the XPath of an array of XPathElements with multiplicities

Parameters:
xpe - list containing XPathElement
Returns:
XPath

toXPathNoMult

public static java.lang.String toXPathNoMult(java.util.List<XPathElement> xpe)
Get the XPath of an array of XPathElements without multiplicities

Parameters:
xpe - list containing XPathElement
Returns:
XPath

toXPathMult

public static java.lang.String toXPathMult(java.lang.String XPath)
                                    throws FxInvalidParameterException
Get the given XPath with full multiplicity information

Parameters:
XPath - XPath
Returns:
XPath with full multiplicity information
Throws:
FxInvalidParameterException - for invalid XPath

toXPathNoMult

public static java.lang.String toXPathNoMult(java.lang.String XPath)
                                      throws FxInvalidParameterException
Get the given XPath with no indices

Parameters:
XPath - XPath with indices
Returns:
XPath with indices stripped
Throws:
FxInvalidParameterException - for invalid XPath

getIndices

public static int[] getIndices(java.lang.String XPath)
                        throws FxInvalidParameterException
Get the FQ indices of an XPath as an int array

Parameters:
XPath - the xpath to examine
Returns:
FQ indices of an XPath as an int array
Throws:
FxInvalidParameterException - on errors

buildXPath

public static java.lang.String buildXPath(boolean leadingSlash,
                                          java.lang.String... elements)
Build an XPath from the given elements

Parameters:
leadingSlash - prepend a leading slash character?
elements - elements that build the XPath
Returns:
XPath

stripType

public static java.lang.String stripType(java.lang.String XPath)
Strip leading types from an XPath if present

Parameters:
XPath - the XPath
Returns:
XPath without leading type

getPK

public static FxPK getPK(java.lang.String xPath)
Extract the primary key stored in the given XPath. If no PK is contained in the XPath, a FxRuntimeException is thrown.

Parameters:
xPath - the xpath
Returns:
the primary key stored in the given XPath
Throws:
FxRuntimeException - if the given xpath is invalid or contains no PK