net.sourceforge.stripes.util.bean
Class PropertyExpression

java.lang.Object
  extended by net.sourceforge.stripes.util.bean.PropertyExpression

public class PropertyExpression
extends Object

An expression representing a property, nested property or indexed property of a JavaBean, or a combination of all three. Capable of parsing String property expressions into a series of Nodes representing each sub-property or indexed property. Expression nodes can be separated with periods, or square-bracket indexing. Items inside square brackets can be single or double quoted, or bare int/long/float/double/boolean literals in the same manner they appear in Java source code (e.g. 123.6F for a float).

Since:
Stripes 1.4
Author:
Tim Fennell

Method Summary
static PropertyExpression getExpression(String expression)
          Factory method for retrieving PropertyExpression objects for expression strings.
 Node getRootNode()
          Fetches the root or first node in this expression.
 String getSource()
          Fetches the original 'source' of the expression - the String value that was parsed to create the PropertyExpression object.
protected  void parse(String expression)
          Performs the internal parsing of the expression and stores the results in a chain of nodes internally.
 String toString()
          Returns the String expression that was parsed to create this PropertyExpression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getRootNode

public Node getRootNode()
Fetches the root or first node in this expression. In an expression like 'foo.bar' this would return the node that contains 'foo'.

Returns:
the first node in the expression

getSource

public String getSource()
Fetches the original 'source' of the expression - the String value that was parsed to create the PropertyExpression object.

Returns:
the String form of the expression that was parsed

getExpression

public static PropertyExpression getExpression(String expression)
                                        throws ParseException
Factory method for retrieving PropertyExpression objects for expression strings.

Parameters:
expression - the expression to fetch a PropertyExpression for
Returns:
PropertyExpression the parsed form of the expression passed in
Throws:
ParseException

parse

protected void parse(String expression)
              throws ParseException
Performs the internal parsing of the expression and stores the results in a chain of nodes internally. Passes through the String a character at a time looking for transitions between nodes and invalid states.

Parameters:
expression - the String expression to be parsed
Throws:
ParseException

toString

public String toString()
Returns the String expression that was parsed to create this PropertyExpression.

Overrides:
toString in class Object


? Copyright 2005-2006, Stripes Development Team.