org.teatrove.tea.parsetree
Class ArrayLookup

java.lang.Object
  extended by org.teatrove.tea.parsetree.Node
      extended by org.teatrove.tea.parsetree.Expression
          extended by org.teatrove.tea.parsetree.ArrayLookup
All Implemented Interfaces:
Serializable, Cloneable, NullSafe

public class ArrayLookup
extends Expression
implements NullSafe

An ArrayLookup can access indexed properties on objects. A Bean Introspector can be used to get the available indexed properties from an object, however, the only ones supported by Tea are unnamed. For this reason, the Introspector is not used. Any class with methods named "get" that return something and have a single parameter (the type of which is not limited to ints) will support an array lookup.

Arrays, Collections and Strings are treated specially, and they all support array lookup on an int typed index.

Author:
Brian S O'Neill
See Also:
BeanAnalyzer, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.teatrove.tea.parsetree.Expression
Expression.Conversion
 
Constructor Summary
ArrayLookup(SourceInfo info, Expression expr, Token lookupToken, Expression lookupIndex)
           
 
Method Summary
 Object accept(NodeVisitor visitor)
          Every subclass of Node must override this method with the following: return visitor.visit(this).
 Object clone()
          Returns a clone of this Node and all its children.
 Expression getExpression()
           
 Expression getLookupIndex()
           
 Token getLookupToken()
           
 Method getReadMethod()
          Returns the method to invoke in order to perform the lookup.
 boolean isExceptionPossible()
          Returns true if an exception can be thrown while executing this Expression.
 boolean isNullSafe()
           
 void setExpression(Expression expr)
           
 void setLookupIndex(Expression lookupIndex)
           
 void setNullSafe(boolean nullSafe)
           
 void setReadMethod(Method m)
           
 
Methods inherited from class org.teatrove.tea.parsetree.Expression
convertTo, convertTo, forceConversion, getConversionChain, getInitialType, getType, getValue, isValueKnown, setInitialType, setType
 
Methods inherited from class org.teatrove.tea.parsetree.Node
getSourceInfo, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayLookup

public ArrayLookup(SourceInfo info,
                   Expression expr,
                   Token lookupToken,
                   Expression lookupIndex)
Method Detail

accept

public Object accept(NodeVisitor visitor)
Description copied from class: Node
Every subclass of Node must override this method with the following: return visitor.visit(this).

Overrides:
accept in class Expression
Parameters:
visitor - A visitor of this Node
Returns:
Node The Node returned by the visitor
See Also:
NodeVisitor

clone

public Object clone()
Description copied from class: Node
Returns a clone of this Node and all its children. Immutable child objects are not necessarily cloned

Overrides:
clone in class Expression

isExceptionPossible

public boolean isExceptionPossible()
Description copied from class: Expression
Returns true if an exception can be thrown while executing this Expression. By default, returns true only if a type conversion could cause an exception.

Overrides:
isExceptionPossible in class Expression

getExpression

public Expression getExpression()

getLookupToken

public Token getLookupToken()

getLookupIndex

public Expression getLookupIndex()

getReadMethod

public Method getReadMethod()
Returns the method to invoke in order to perform the lookup. This is filled in by the type checker. If the expression type is an array, the read method is null. A code generator must still be able to get elements from an array.


setExpression

public void setExpression(Expression expr)

setLookupIndex

public void setLookupIndex(Expression lookupIndex)

setReadMethod

public void setReadMethod(Method m)

isNullSafe

public boolean isNullSafe()
Specified by:
isNullSafe in interface NullSafe

setNullSafe

public void setNullSafe(boolean nullSafe)
Specified by:
setNullSafe in interface NullSafe


Copyright © 1997-2012 TeaTrove.org. All Rights Reserved.