Package com.scivicslab.pojoactor.core
Class ActionArgs.ParsedArgs
java.lang.Object
com.scivicslab.pojoactor.core.ActionArgs.ParsedArgs
- Enclosing class:
ActionArgs
Unified accessor for action arguments.
Provides consistent access to arguments regardless of whether they came from array format or object format in YAML.
-
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONArrayasArray()Gets the underlying JSONArray (for array format).org.json.JSONObjectasObject()Gets the underlying JSONObject (for object format).get(int index) Gets string at index (for array format).Gets string at index with default (for array format).Gets string by key (for object format).Gets string by key with default (for object format).booleangetBoolean(int index) Gets boolean at index (for array format).booleangetBoolean(int index, boolean defaultValue) Gets boolean at index with default (for array format).booleangetBoolean(String key) Gets boolean by key (for object format).booleangetBoolean(String key, boolean defaultValue) Gets boolean by key with default (for object format).intgetInt(int index) Gets integer at index (for array format).intgetInt(int index, int defaultValue) Gets integer at index with default (for array format).intGets integer by key (for object format).intGets integer by key with default (for object format).booleanChecks if key exists (for object format).booleanisArray()Checks if arguments are in array format.booleanisEmpty()Checks if arguments are empty.booleanisObject()Checks if arguments are in object format.intlength()Gets the number of elements (for array format).raw()Gets the raw JSON string.
-
Method Details
-
raw
Gets the raw JSON string.- Returns:
- the original args string
-
isArray
public boolean isArray()Checks if arguments are in array format.- Returns:
- true if array format
-
isObject
public boolean isObject()Checks if arguments are in object format.- Returns:
- true if object format
-
length
public int length()Gets the number of elements (for array format).- Returns:
- array length, or 0 if not array format
-
isEmpty
public boolean isEmpty()Checks if arguments are empty.- Returns:
- true if empty
-
get
Gets string at index (for array format).- Parameters:
index- 0-based index- Returns:
- string value, or empty string if not found
-
get
Gets string at index with default (for array format).- Parameters:
index- 0-based indexdefaultValue- default if not found- Returns:
- string value
-
getInt
public int getInt(int index) Gets integer at index (for array format).- Parameters:
index- 0-based index- Returns:
- int value, or 0 if not found
-
getInt
public int getInt(int index, int defaultValue) Gets integer at index with default (for array format).- Parameters:
index- 0-based indexdefaultValue- default if not found- Returns:
- int value
-
getBoolean
public boolean getBoolean(int index) Gets boolean at index (for array format).- Parameters:
index- 0-based index- Returns:
- boolean value, or false if not found
-
getBoolean
public boolean getBoolean(int index, boolean defaultValue) Gets boolean at index with default (for array format).- Parameters:
index- 0-based indexdefaultValue- default if not found- Returns:
- boolean value
-
get
Gets string by key (for object format).- Parameters:
key- key name- Returns:
- string value, or empty string if not found
-
get
Gets string by key with default (for object format).- Parameters:
key- key namedefaultValue- default if not found- Returns:
- string value
-
getInt
Gets integer by key (for object format).- Parameters:
key- key name- Returns:
- int value, or 0 if not found
-
getInt
Gets integer by key with default (for object format).- Parameters:
key- key namedefaultValue- default if not found- Returns:
- int value
-
getBoolean
Gets boolean by key (for object format).- Parameters:
key- key name- Returns:
- boolean value, or false if not found
-
getBoolean
Gets boolean by key with default (for object format).- Parameters:
key- key namedefaultValue- default if not found- Returns:
- boolean value
-
has
Checks if key exists (for object format).- Parameters:
key- key name- Returns:
- true if key exists
-
asArray
public org.json.JSONArray asArray()Gets the underlying JSONArray (for array format).- Returns:
- JSONArray, or null if not array format
-
asObject
public org.json.JSONObject asObject()Gets the underlying JSONObject (for object format).- Returns:
- JSONObject, or null if not object format
-