Package com.inductiveautomation.rm.base
Class RMKey
java.lang.Object
com.inductiveautomation.rm.base.RMKey
This class provides an optimized convenience for getting named values from arbitrary objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis is interface is implemented by objects that can get key values themselves.static interfaceThis is interface is implemented by objects that can get/set key value themselves.static classKeyAccessor - enclosed class for actually getting/setting values for a given object (class) and key.static interfacestatic classNoSetMethodException. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RMKey.KeyAccessorgetAccessor(Object anObj, String aKey) Returns the accessor object for a given object (class) and key.static intgetIntValue(Object anObj, String aKey) Returns an int value for a key.static Collection<String>static StringgetSanitizedKey(String aKey) Returns the given string with all invalid key characters stripped out.static StringgetStandard(String aKey) Returns the key in a standard format (strip is/get prefix and start with capital letter).static StringgetStringValue(Object anObj, String aKey) Returns a string value for a key.static ObjectReturns a value for given object and key.static <T> TReturns a value as given class, if appropriate.static ObjectgetValueImpl(Object anObj, String aKey) Returns a value for given object and key.static booleanReturns whether given object has an accessor for given key.static booleanReturns whether given string is a valid key (starts with letter and only contains letters, digits, white space and under bars).static voidSets a value for given object and key and value.static voidsetValueSafe(Object anObj, String aKey, Object aValue) Sets the value but only prints a warning if it fails.static voidsetValueSilent(Object anObj, String aKey, Object aValue) Tries to set value in given object, ignoring failure exceptions.
-
Constructor Details
-
RMKey
public RMKey()
-
-
Method Details
-
isKey
Returns whether given string is a valid key (starts with letter and only contains letters, digits, white space and under bars). -
getSanitizedKey
Returns the given string with all invalid key characters stripped out. If aKey is blank, null, or contains only invalid characters, resulting string will empty and therefore invalid. Resulting string may also end up being a duplicate of another key -- there's only so much we can do for the user. -
getKeys
-
getValue
Returns a value for given object and key. -
getValueImpl
Returns a value for given object and key. -
setValue
Sets a value for given object and key and value.- Throws:
Exception
-
setValueSafe
Sets the value but only prints a warning if it fails. -
setValueSilent
Tries to set value in given object, ignoring failure exceptions. -
hasKey
Returns whether given object has an accessor for given key. -
getIntValue
Returns an int value for a key. -
getStringValue
Returns a string value for a key. -
getValue
Returns a value as given class, if appropriate. -
getAccessor
Returns the accessor object for a given object (class) and key. -
getStandard
Returns the key in a standard format (strip is/get prefix and start with capital letter).
-