Package com.reportmill.base
Class RMKeyChain
- java.lang.Object
-
- com.reportmill.base.RMKeyChain
-
public class RMKeyChain extends java.lang.Object
This class provides the powerful RMKeyChain.valueForKeyChain() functiionality.
-
-
Field Summary
Fields Modifier and Type Field Description static byte
Add
static byte
And
static byte
ArgList
static byte
ArrayIndex
static byte
Assignment
static byte
Conditional
static byte
Divide
static byte
Equal
static byte
FunctionCall
static byte
GreaterThan
static byte
GreaterThanOrEqual
static byte
Key
static byte
LessThan
static byte
LessThanOrEqual
static byte
Mod
static byte
Multiply
static byte
Negate
static byte
Not
static byte
NotEqual
static byte
Null
static byte
Or
static byte
String
static byte
Subtract
static byte
Value
-
Constructor Summary
Constructors Constructor Description RMKeyChain(byte oper)
Node constructor.RMKeyChain(byte oper, java.lang.Object child)
Node constructor.RMKeyChain(byte oper, java.lang.Object left, java.lang.Object right)
Node constructor.RMKeyChain(java.lang.Object cond, java.lang.Object tExp, java.lang.Object fExp)
Node constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(java.lang.Object child)
Adds a child to the end of the keychain's child list.static void
addFunctionClass(java.lang.Class c)
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.static boolean
booleanValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a boolean for an object and keychain.java.lang.Object
clone()
Standard clone implementation.static double
doubleValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a double for an object and keychain.boolean
equals(java.lang.Object anObj)
Standard equals implementation.static java.lang.reflect.Method
findAggregateMethod(java.lang.String aString)
Returns a method for a method name (assuming {List,KeyChain} args).static java.lang.reflect.Method
findFunctionMethod(java.lang.String aString, java.lang.Class[] argClasses)
Returns a method for a method name and the given argument classes.static float
floatValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a float for an object and keychain.static java.lang.String
getAndResetError()
Returns the last error encountered by the keychain parser and resets paser.static java.util.Map
getAssignments()
Returns a thread-local assignments map.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 java.lang.String
getError()
Returns the last error encountered by the keychain parser (or null).RMKeyChain
getNext()
Returns the next keychain in the chain.byte
getOperand()
Returns the top level operand of the keychain.java.lang.Object
getValue()
Returns the value of the keychain.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(int anOp)
Returns whether key contains given op.boolean
hasPageReference()
Returns whether given key has a Page/PageMax key reference.static int
intValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns an int for an object and keychain.static RMKeyChain
keyChain(java.lang.Object aSource)
Returns a keyChain for aSource (should be a String or existing RMKeyChain).static java.util.List
listValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a list for an object and keychain.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 void
setValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain, java.lang.Object aValue)
static java.lang.String
stringValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a string for an object and keychain.static java.lang.Object
super_valueForKeyChain(java.lang.Object anObj, RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain on the given object.java.lang.String
toString()
Returns a string representation of the keychain.static java.lang.Object
valueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
Returns the result of evaluating the given key chain on the given object.static java.lang.Object
valueForKeyChainFunctionCall(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
valueForKeyChainKey(java.lang.Object anObj, RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain (assumed to be a simple key) on the given object.static java.lang.Object
valueForKeyChainList(java.util.List aList, RMKeyChain aKeyChain)
Returns the result of evaluating the given keychain on the given list.
-
-
-
Field Detail
-
Add
public static final byte Add
- See Also:
- Constant Field Values
-
Subtract
public static final byte Subtract
- See Also:
- Constant Field Values
-
Multiply
public static final byte Multiply
- See Also:
- Constant Field Values
-
Divide
public static final byte Divide
- See Also:
- Constant Field Values
-
Mod
public static final byte Mod
- See Also:
- Constant Field Values
-
Negate
public static final byte Negate
- See Also:
- Constant Field Values
-
Key
public static final byte Key
- See Also:
- Constant Field Values
-
Value
public static final byte Value
- See Also:
- Constant Field Values
-
String
public static final byte String
- See Also:
- Constant Field Values
-
ArgList
public static final byte ArgList
- See Also:
- Constant Field Values
-
FunctionCall
public static final byte FunctionCall
- See Also:
- Constant Field Values
-
ArrayIndex
public static final byte ArrayIndex
- See Also:
- Constant Field Values
-
Null
public static final byte Null
- See Also:
- Constant Field Values
-
GreaterThan
public static final byte GreaterThan
- See Also:
- Constant Field Values
-
LessThan
public static final byte LessThan
- See Also:
- Constant Field Values
-
GreaterThanOrEqual
public static final byte GreaterThanOrEqual
- See Also:
- Constant Field Values
-
LessThanOrEqual
public static final byte LessThanOrEqual
- See Also:
- Constant Field Values
-
Equal
public static final byte Equal
- See Also:
- Constant Field Values
-
NotEqual
public static final byte NotEqual
- See Also:
- Constant Field Values
-
Not
public static final byte Not
- See Also:
- Constant Field Values
-
And
public static final byte And
- See Also:
- Constant Field Values
-
Or
public static final byte Or
- See Also:
- Constant Field Values
-
Conditional
public static final byte Conditional
- See Also:
- Constant Field Values
-
Assignment
public static final byte Assignment
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RMKeyChain
public RMKeyChain(byte oper)
Node constructor.
-
RMKeyChain
public RMKeyChain(byte oper, java.lang.Object child)
Node constructor.
-
RMKeyChain
public RMKeyChain(byte oper, 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
-
keyChain
public static RMKeyChain keyChain(java.lang.Object aSource)
Returns a keyChain for aSource (should be a String or existing RMKeyChain).
-
getAssignments
public static java.util.Map getAssignments()
Returns a thread-local assignments map.
-
getOperand
public byte getOperand()
Returns the top level operand 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.
-
valueForKeyChain
public static java.lang.Object valueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
Returns the result of evaluating the given key chain on the given object.
-
setValueForKeyChain
public static void setValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain, java.lang.Object aValue)
-
super_valueForKeyChain
public static java.lang.Object super_valueForKeyChain(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 valueForKeyChain but still have access to default implementation.
-
valueForKeyChainKey
public static java.lang.Object valueForKeyChainKey(java.lang.Object anObj, RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain (assumed to be a simple key) on the given object.
-
valueForKeyChainFunctionCall
public static java.lang.Object valueForKeyChainFunctionCall(java.lang.Object anObj, RMKeyChain aKeyChain)
Returns the result of evaluating the given key chain (assumed to be a function) on the given object.
-
valueForKeyChainList
public static java.lang.Object valueForKeyChainList(java.util.List aList, RMKeyChain aKeyChain)
Returns the result of evaluating the given keychain on the given list.
-
stringValueForKeyChain
public static java.lang.String stringValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a string for an object and keychain.
-
intValueForKeyChain
public static int intValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns an int for an object and keychain.
-
floatValueForKeyChain
public static float floatValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a float for an object and keychain.
-
doubleValueForKeyChain
public static double doubleValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a double for an object and keychain.
-
booleanValueForKeyChain
public static boolean booleanValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a boolean for an object and keychain.
-
listValueForKeyChain
public static java.util.List listValueForKeyChain(java.lang.Object anObj, java.lang.Object aKeyChain)
VFK convenience - returns a list for an object and keychain.
-
addFunctionClass
public static void addFunctionClass(java.lang.Class c)
Adds a class to the list of classes that RM queries for functions.
-
findAggregateMethod
public static java.lang.reflect.Method findAggregateMethod(java.lang.String aString)
Returns a method for a method name (assuming {List,KeyChain} args).
-
findFunctionMethod
public static java.lang.reflect.Method findFunctionMethod(java.lang.String aString, java.lang.Class[] argClasses)
Returns a method for a method name and the given argument classes.
-
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(int anOp)
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 keychain parser (or null).
-
getAndResetError
public static java.lang.String getAndResetError()
Returns the last error encountered by the keychain parser and resets paser.
-
toString
public java.lang.String toString()
Returns a string representation of the keychain.- Overrides:
toString
in classjava.lang.Object
-
clone
public java.lang.Object clone()
Standard clone implementation.- Overrides:
clone
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object anObj)
Standard equals implementation.- Overrides:
equals
in classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
Simple main implementation, so RM's expressions can be used for simple math.
-
-