ReportMill 11 API

com.reportmill.base
Class RMKeyChain

java.lang.Object
  extended by com.reportmill.base.RMKeyChain
All Implemented Interfaces:
java.lang.Cloneable

public class RMKeyChain
extends java.lang.Object
implements java.lang.Cloneable

This class evaluates a string expression on a given object: RMKeyChain.getValue(object, expression).


Nested Class Summary
static interface RMKeyChain.Get
          This is interface is implemented by objects that can get keychain values themselves.
static interface RMKeyChain.GetSet
          is interface is implemented by objects that can get/set keychain values themselves.
static class RMKeyChain.Operator
           
 
Constructor Summary
RMKeyChain(java.lang.Object cond, java.lang.Object tExp, java.lang.Object fExp)
          Node constructor.
RMKeyChain(RMKeyChain.Operator anOperator)
          Node constructor.
RMKeyChain(RMKeyChain.Operator anOperator, java.lang.Object child)
          Node constructor.
RMKeyChain(RMKeyChain.Operator anOperator, java.lang.Object left, java.lang.Object right)
          Node constructor.
 
Method Summary
 void addChild(java.lang.Object child)
          Adds a child to the end of the keychain's child list.
static void addFunctionClass(java.lang.Class aClass)
          Adds a class to the list of classes that RM queries for functions.
 boolean anyKeyReferencesKey(java.lang.String aKey)
          Returns whether given key is used anywhere in expression.
 java.lang.Object clone()
          Standard clone implementation.
 boolean equals(java.lang.Object anObj)
          Standard equals implementation.
static java.lang.String getAndResetError()
          Returns the last error encountered by the key chain parser and resets parser.
static java.util.Map getAssignments()
          Returns a thread-local assignments map.
static boolean getBoolValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Convenience - returns a boolean for an object and key chain.
 java.lang.Object getChild(int i)
          Returns the child at the given index in the keychain.
 int getChildCount()
          Returns the number of children in the keychain.
 RMKeyChain getChildKeyChain(int i)
          Returns the child at the given index in the keychain as a keychain.
 java.lang.String getChildString(int i)
          Returns the child at the given index in the keychain as a string.
static double getDoubleValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Convenience - returns a double for an object and key chain.
static java.lang.String getError()
          Returns the last error encountered by the key chain parser (or null).
static float getFloatValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Convenience - returns a float for an object and key chain.
static int getIntValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Convenience - returns an int for an object and key chain.
static RMKeyChain getKeyChain(java.lang.Object aSource)
          Returns a keyChain for aSource (should be a String or existing RMKeyChain).
static java.util.List getListValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Convenience - returns a list for an object and key chain.
 RMKeyChain getNext()
          Returns the next keychain in the chain.
 RMKeyChain.Operator getOperator()
          Returns the top level operator of the keychain.
static java.lang.String getStringValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Convenience - returns a string for an object and key chain.
 java.lang.Object getValue()
          Returns the value of the keychain.
static java.lang.Object getValue(java.lang.Object anObj, java.lang.Object aKeyChain)
          Returns the result of evaluating the given key chain on the given object.
static
<T> T
getValue(java.lang.Object anObj, java.lang.Object aKeyChain, java.lang.Class<T> aClass)
          Returns a key value if it is of given class (otherwise null).
static java.lang.Object getValueFunctionCall(java.lang.Object anObj, RMKeyChain aKeyChain)
          Returns the result of evaluating the given key chain (assumed to be a function) on the given object.
static java.lang.Object getValueImpl(java.lang.Object anObj, RMKeyChain aKeyChain)
          Returns the result of evaluating the given key chain on the given object.
static java.lang.Object getValueList(java.util.List aList, RMKeyChain aKeyChain)
          Returns the result of evaluating the given key chain on the given list.
 java.lang.String getValueString()
          Returns the value of the keychain as a string.
 boolean hasAggregate()
          Returns whether key has an aggregate key in it.
 boolean hasOp(RMKeyChain.Operator anOperator)
          Returns whether key contains given op.
 boolean hasPageReference()
          Returns whether given key has a Page/PageMax key reference.
static boolean isValidKey(java.lang.String aString)
          Check syntax of string.
static void main(java.lang.String[] args)
          Simple main implementation, so RM's expressions can be used for simple math.
 void setLastNode(RMKeyChain ln)
          Sets the last node in the keychain.
 void setNext(RMKeyChain aKeyChain)
          Sets the next keychain in the chain.
 void setValue(java.lang.Object val)
          Sets the value of the keychain.
static boolean setValue(java.lang.Object anObj, java.lang.Object aKeyChain, java.lang.Object aValue)
          Sets the given value for the given key chain + property.
 java.lang.String toString()
          Returns a string representation of the key chain.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RMKeyChain

public RMKeyChain(RMKeyChain.Operator anOperator)
Node constructor.


RMKeyChain

public RMKeyChain(RMKeyChain.Operator anOperator,
                  java.lang.Object child)
Node constructor.


RMKeyChain

public RMKeyChain(RMKeyChain.Operator anOperator,
                  java.lang.Object left,
                  java.lang.Object right)
Node constructor.


RMKeyChain

public RMKeyChain(java.lang.Object cond,
                  java.lang.Object tExp,
                  java.lang.Object fExp)
Node constructor.

Method Detail

getKeyChain

public static RMKeyChain getKeyChain(java.lang.Object aSource)
Returns a keyChain for aSource (should be a String or existing RMKeyChain).


isValidKey

public static boolean isValidKey(java.lang.String aString)
Check syntax of string. Returns true if the string is a valid Key.


getAssignments

public static java.util.Map getAssignments()
Returns a thread-local assignments map.


getOperator

public RMKeyChain.Operator getOperator()
Returns the top level operator of the keychain.


getNext

public RMKeyChain getNext()
Returns the next keychain in the chain.


setNext

public void setNext(RMKeyChain aKeyChain)
Sets the next keychain in the chain.


setLastNode

public void setLastNode(RMKeyChain ln)
Sets the last node in the keychain.


getValue

public java.lang.Object getValue()
Returns the value of the keychain.


getValueString

public java.lang.String getValueString()
Returns the value of the keychain as a string.


setValue

public void setValue(java.lang.Object val)
Sets the value of the keychain.


getChildCount

public int getChildCount()
Returns the number of children in the keychain.


getChild

public java.lang.Object getChild(int i)
Returns the child at the given index in the keychain.


getChildString

public java.lang.String getChildString(int i)
Returns the child at the given index in the keychain as a string.


getChildKeyChain

public RMKeyChain getChildKeyChain(int i)
Returns the child at the given index in the keychain as a keychain.


addChild

public void addChild(java.lang.Object child)
Adds a child to the end of the keychain's child list.


getValue

public static java.lang.Object getValue(java.lang.Object anObj,
                                        java.lang.Object aKeyChain)
Returns the result of evaluating the given key chain on the given object.


getValueImpl

public static java.lang.Object getValueImpl(java.lang.Object anObj,
                                            RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain on the given object. Broken out so objects can implement custom getKeyChainValue but still have access to default implementation.


getValueFunctionCall

public static java.lang.Object getValueFunctionCall(java.lang.Object anObj,
                                                    RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain (assumed to be a function) on the given object.


getValueList

public static java.lang.Object getValueList(java.util.List aList,
                                            RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain on the given list.


getStringValue

public static java.lang.String getStringValue(java.lang.Object anObj,
                                              java.lang.Object aKeyChain)
Convenience - returns a string for an object and key chain.


getIntValue

public static int getIntValue(java.lang.Object anObj,
                              java.lang.Object aKeyChain)
Convenience - returns an int for an object and key chain.


getFloatValue

public static float getFloatValue(java.lang.Object anObj,
                                  java.lang.Object aKeyChain)
Convenience - returns a float for an object and key chain.


getDoubleValue

public static double getDoubleValue(java.lang.Object anObj,
                                    java.lang.Object aKeyChain)
Convenience - returns a double for an object and key chain.


getBoolValue

public static boolean getBoolValue(java.lang.Object anObj,
                                   java.lang.Object aKeyChain)
Convenience - returns a boolean for an object and key chain.


getListValue

public static java.util.List getListValue(java.lang.Object anObj,
                                          java.lang.Object aKeyChain)
Convenience - returns a list for an object and key chain.


getValue

public static <T> T getValue(java.lang.Object anObj,
                             java.lang.Object aKeyChain,
                             java.lang.Class<T> aClass)
Returns a key value if it is of given class (otherwise null).


addFunctionClass

public static void addFunctionClass(java.lang.Class aClass)
Adds a class to the list of classes that RM queries for functions.


anyKeyReferencesKey

public boolean anyKeyReferencesKey(java.lang.String aKey)
Returns whether given key is used anywhere in expression. Current version is really hard coded to require key to be isolated (not a part of a key chain).


hasPageReference

public boolean hasPageReference()
Returns whether given key has a Page/PageMax key reference.


hasOp

public boolean hasOp(RMKeyChain.Operator anOperator)
Returns whether key contains given op.


hasAggregate

public boolean hasAggregate()
Returns whether key has an aggregate key in it.


getError

public static java.lang.String getError()
Returns the last error encountered by the key chain parser (or null).


getAndResetError

public static java.lang.String getAndResetError()
Returns the last error encountered by the key chain parser and resets parser.


setValue

public static boolean setValue(java.lang.Object anObj,
                               java.lang.Object aKeyChain,
                               java.lang.Object aValue)
Sets the given value for the given key chain + property. This is a real bogus loser implementation.


clone

public java.lang.Object clone()
Standard clone implementation.

Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object anObj)
Standard equals implementation.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of the key chain.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Simple main implementation, so RM's expressions can be used for simple math.


ReportMill 11 API