|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.finra.jtaf.core.commands.context.ManipulateContextHelper
public class ManipulateContextHelper
Helper class used for context commands plan for context manipulation: action = {replace out with in|prepend in to out|append in to out} valuein indexin|keyin|null foreach = {value in list|key in map|value in map|int|null} change = {expand to singleton list|collapse list to set|expand set to map keys|convert map keys to set|convert set to list|convert map values to list} valueout indexout|keyout|null foreach = {value in list|key in map|value in map|int|null} change = {collapse list to set|expand set to map keys|convert map keys to set|convert set to list|convert map values to list
Field Summary | |
---|---|
static String |
ACTION_ATTRIBUTE
|
static String |
APPEND_ACTION
|
static String |
CHANGE_IN_ATTRIBUTE
|
static String |
INDEX_IN_ATTRIBUTE
|
static String |
INDEX_OUT_ATTRIBUTE
|
static String |
KEY_IN_ATTRIBUTE
|
static String |
KEY_OUT_ATTRIBUTE
|
static String |
NONE_CHANGE
|
static String |
PREPEND_ACTION
|
static String |
REPLACE_ACTION
|
static String |
SINGLETON_CHANGE
|
static String |
VALUE_IN_ATTRIBUTE
|
static String |
VALUE_OUT_ATTRIBUTE
|
Constructor Summary | |
---|---|
ManipulateContextHelper(AbstractContextCmd cmd,
Map<?,?> globalCtx)
|
Method Summary | ||
---|---|---|
boolean |
getBooleanOrDefault(String attributeName,
boolean defaultValue)
Like the above, except it returns a default value if the attribute is not set |
|
float |
getFloatOrDefault(String attributeName,
float defaultValue)
Like the above, except it returns a default value if the attribute is not set |
|
int |
getIntegerOrDefault(String attributeName,
int defaultValue)
Like the above, except it returns a default value if the attribute is not set |
|
Integer |
getOptionalInteger(String key)
Returns an Integer stored in the context or null if there isn't one |
|
Object |
getOptionalObject(String key)
Grabs an Object from the Context. |
|
String |
getOptionalString(String attributeName)
Returns a String stored in the context or null if there isn't one |
|
boolean |
getRequiredBoolean(String attributeName)
Returns a float stored in the context or throws a NullPointerException is one isn't |
|
float |
getRequiredFloat(String attributeName)
Returns a float stored in the context or throws a NullPointerException is one isn't |
|
int |
getRequiredInteger(String attributeName)
Returns an integer value, or throws a NullPointerException if the value is not present |
|
Object |
getRequiredObject(String key)
Grabs an object from the Context, or throws an exception if the Object does not exist. |
|
String |
getRequiredString(String attributeName)
Returns a String stored in the context or throws a NullPointerException is one isn't |
|
String |
getStringOrDefault(String attributeName,
String defaultValue)
Like the above, except it returns a default value if the attribute is not set |
|
Object |
getValueIn(String valueInAttribute,
Integer index)
Returns the value stored in a list in the context |
|
Object |
getValueIn(String valueInAttribute,
Integer index,
Object key)
Returns the values stored in an object in the context |
|
Object |
getValueIn(String valueInAttribute,
Object key)
Returns the value stored in a map in the context |
|
String |
getVerifiedAction()
Checks to make sure the current "action" in context is an acceptable value |
|
void |
setContext(IInvocationContext ctx)
Sets a context to use instead of the global context provided in the constructor |
|
void |
setValueOut(String valueOutAttribute,
List<Object> list,
Object value)
Appends an object to a list stored in the context |
|
void |
setValueOut(String valueOutAttribute,
List<Object> list,
Object value,
int index)
Stores a value in a list in the context |
|
|
setValueOut(String valueOutAttribute,
List<T> list,
List<T> value)
Appends all the values of a list into another list that is stored in the context |
|
|
setValueOut(String valueOutAttribute,
List<T> list,
List<T> value,
int index)
Stores all the values of a list into another list that is stored in the context |
|
|
setValueOut(String valueOutAttribute,
Map<? super K,? super T> list,
T value,
K key)
Stores a value in a map stored in the context |
|
void |
setValueOut(String valueOutAttribute,
Object value)
Stored an object in the context |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ACTION_ATTRIBUTE
public static final String REPLACE_ACTION
public static final String PREPEND_ACTION
public static final String APPEND_ACTION
public static final String VALUE_IN_ATTRIBUTE
public static final String INDEX_IN_ATTRIBUTE
public static final String KEY_IN_ATTRIBUTE
public static final String CHANGE_IN_ATTRIBUTE
public static final String SINGLETON_CHANGE
public static final String VALUE_OUT_ATTRIBUTE
public static final String INDEX_OUT_ATTRIBUTE
public static final String KEY_OUT_ATTRIBUTE
public static final String NONE_CHANGE
Constructor Detail |
---|
public ManipulateContextHelper(AbstractContextCmd cmd, Map<?,?> globalCtx)
Method Detail |
---|
public void setContext(IInvocationContext ctx)
ctx
- The context to usepublic String getVerifiedAction()
public Object getValueIn(String valueInAttribute, Integer index, Object key)
valueInAttribute
- The location of the object in the contextindex
- The index, if valueInAttribute refers to a listkey
- The key if valueInAttribute refers to a map
public Object getValueIn(String valueInAttribute, Object key)
valueInAttribute
- The location of the map in the contextkey
- the key in the map stored in the context where to retrieve the value
public Object getValueIn(String valueInAttribute, Integer index)
valueInAttribute
- The location of the list in the contextindex
- The index in the list stored in the context from where to retrieve the value
public void setValueOut(String valueOutAttribute, List<Object> list, Object value, int index)
valueOutAttribute
- Where to store the resulting list in the contextlist
- The list in which to store the valuevalue
- The value to store in the listindex
- The index in the list in which to store the valuepublic void setValueOut(String valueOutAttribute, List<Object> list, Object value)
valueOutAttribute
- Where to store the resulting list in the contextlist
- The list in which to store the valuevalue
- The value to store in the listpublic <T> void setValueOut(String valueOutAttribute, List<T> list, List<T> value)
valueOutAttribute
- Where to store the resulting list in the contextlist
- The list in which to store the valuesvalue
- The list of values being storedpublic <T> void setValueOut(String valueOutAttribute, List<T> list, List<T> value, int index)
valueOutAttribute
- Where to store the resulting list in the contextlist
- The list in which to store the valuesvalue
- The list of values being storedindex
- The index in the list in which to store the valuepublic <T,K> void setValueOut(String valueOutAttribute, Map<? super K,? super T> list, T value, K key)
valueOutAttribute
- Where to store the resulting map in the contextlist
- The map in which to store the valuesvalue
- The value being stored in the mapkey
- The key at which to store the value in the mappublic void setValueOut(String valueOutAttribute, Object value)
valueOutAttribute
- Where to store the object in the contextvalue
- The object to store in the contextpublic Object getOptionalObject(String key)
key
-
public Object getRequiredObject(String key)
key
-
public int getRequiredInteger(String attributeName)
attributeName
- ctx
-
public int getIntegerOrDefault(String attributeName, int defaultValue)
attributeName
- ctx
- defaultValue
-
public float getRequiredFloat(String attributeName)
attributeName
- Where in the context the float is stored
public float getFloatOrDefault(String attributeName, float defaultValue)
attributeName
- Where in the context the float is storeddefaultValue
- The value to return if the context does not contain a value at attributeName
public String getRequiredString(String attributeName)
attributeName
- Where in the context the String is stored
public String getStringOrDefault(String attributeName, String defaultValue)
attributeName
- attributeName Where in the context the String is storeddefaultValue
- The value to return if the context does not contain a value at attributeName
public String getOptionalString(String attributeName)
attributeName
- Where in the context the String is stored
public boolean getRequiredBoolean(String attributeName)
attributeName
- Where in the context the boolean is stored
public boolean getBooleanOrDefault(String attributeName, boolean defaultValue)
attributeName
- Where in the context the boolean is storeddefaultValue
- The value to return if the context does not contain a value at attributeName
public Integer getOptionalInteger(String key)
key
- Where in the context the Integer is stored
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |