Class RMKeyChain

java.lang.Object
com.inductiveautomation.rm.base.RMKeyChain

public class RMKeyChain extends Object
This class evaluates a string expression on a given object: RMKeyChain.getValue(object, expression).
  • Constructor Details

  • Method Details

    • getKeyChain

      public static RMKeyChain getKeyChain(@Nullable Object aSource)
      Returns a keyChain for aSource (should be a String or existing RMKeyChain).
    • getAssignments

      public static Map getAssignments()
      Returns a thread-local assignments map.
    • getOp

      public RMKeyChain.Op getOp()
      Returns the top level operator of the keychain.
    • getValue

      public Object getValue()
      Returns the value of the keychain.
    • getValueString

      public String getValueString()
      Returns the value of the keychain as a string.
    • getChildCount

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

      public Object getChild(int anIndex)
      Returns the child at the given index in the keychain.
    • addChild

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

      public 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.
    • subchain

      public RMKeyChain subchain(int anIndex)
      Override to give list chance to implement this.
    • getValue

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

      @Nullable public static Object getValue(Object anObj, RMKeyChain aKeyChain)
      Returns the result of evaluating the given key chain on the given object.
    • getValue

      public static Object getValue(Object aRoot, Object anObj, RMKeyChain aKeyChain)
      Returns the result of evaluating the given key chain on the given object.
    • getValueImpl

      public static Object getValueImpl(Object aRoot, 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.
    • getValueList

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

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

      public static Number getNumberValue(Object anObj, Object aKeyChain)
      Convenience - returns a number for an object and key chain.
    • getIntValue

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

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

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

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

      @Nullable public static List getListValue(Object anObj, Object aKeyChain)
      Convenience - returns a list for an object and key chain.
    • getValue

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

      public boolean anyKeyReferencesKey(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.Op anOp)
      Returns whether key contains given op.
    • getError

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

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

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

      public static void setValue(Object anObj, RMKeyChain aKeyChain, Object aValue)
      Sets the given value for the given key chain + property. This is a real bogus loser implementation that only supports Op.Key and Op.Chain.
    • setEnumValue

      public static void setEnumValue(Object anObj, RMKeyChain aKeyChain)
      Sets the given value for the given key chain + property. This is a real bogus loser implementation.
    • setValueSafe

      public static void setValueSafe(Object anObj, String aKey, Object aValue)
      Sets the value but only prints a warning if it fails.
    • setValueSilent

      public static void setValueSilent(Object anObj, String aKey, Object aValue)
      Tries to set value in given object, ignoring failure exceptions.
    • toString

      public String toString()
      Returns a string representation of the key chain.
      Overrides:
      toString in class Object
    • addFunctionClass

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