| java.lang.Object abbot.script.ArgumentParser
ArgumentParser | public class ArgumentParser (Code) | | Provide parsing of a String into an array of appropriately typed
arguments. Arrays are indicated by square brackets, and arguments are
separated by commas, e.g.
- An empty String array (length zero): "[]"
- Three arguments "one,two,three"
- An array of length three: "[one,two,three]"
- A single-element array of integer: "[1]"
- A single null argument: "null"
- An array of two strings: "[one,two]"
- Commas must be escaped when they would otherwise be interpreted as an
argument separator:
"one,two%2ctwo,three" (2nd argument is "two,two")
|
Method Summary | |
public static String | encodeArguments(String[] args) | public static Object | eval(Resolver resolver, String arg, Class cls) Convert the given string into the given class, if possible,
using any available parsers if conversion to basic types fails.
The Resolver could be a parser, but it would need to adapt
automatically to whatever is the current context.
Performs property substitution on the argument prior to evaluating it.
Spaces are only trimmed from the argument if spaces have no meaning for
the target class. | public static Object[] | eval(Resolver resolver, String[] args, Class[] params) Evaluate the given set of arguments into the given set of types. | public static Parser | getParser(Class cls) Find a string parser for the given class. | public static boolean | isDefaultToString(String s) Returns whether the given String is the default toString()
implementation for the given Object. | public static String[] | parseArgumentList(String encodedArgs) Convert the given encoded String into an array of Strings.
Interprets strings of the format "[el1,el2,el3]" to be a single (array)
argument (such commas do not need escaping). | public static String | replace(String str, String s1, String s2) Replace all instances in the given String of s1 with s2. | public static Parser | setParser(Class cls, Parser parser) Set the parser for a given class. | public static String | substitute(Resolver resolver, String arg) Performs property substitutions on the argument priort to evaluating
it. | public static String | toString(Object value) Convert a value into a String representation. |
DEFAULT_TOSTRING | final public static String DEFAULT_TOSTRING(Code) | | |
eval | public static Object eval(Resolver resolver, String arg, Class cls) throws IllegalArgumentException, NoSuchReferenceException, ComponentSearchException(Code) | | Convert the given string into the given class, if possible,
using any available parsers if conversion to basic types fails.
The Resolver could be a parser, but it would need to adapt
automatically to whatever is the current context.
Performs property substitution on the argument prior to evaluating it.
Spaces are only trimmed from the argument if spaces have no meaning for
the target class.
|
getParser | public static Parser getParser(Class cls)(Code) | | Find a string parser for the given class. Returns null if none
found.
|
isDefaultToString | public static boolean isDefaultToString(String s)(Code) | | Returns whether the given String is the default toString()
implementation for the given Object.
|
parseArgumentList | public static String[] parseArgumentList(String encodedArgs)(Code) | | Convert the given encoded String into an array of Strings.
Interprets strings of the format "[el1,el2,el3]" to be a single (array)
argument (such commas do not need escaping).
Explicit commas and square brackets in arguments must be escaped by
preceding the character with a backslash ('\'). The strings
'(null)' and 'null' are interpreted as the value null.
Explicit spaces should be protected by double quotes, e.g.
" an argument bounded by spaces ".
|
setParser | public static Parser setParser(Class cls, Parser parser)(Code) | | Set the parser for a given class. Returns the old one, if any.
|
substitute | public static String substitute(Resolver resolver, String arg)(Code) | | Performs property substitutions on the argument priort to evaluating
it. Substitutions are not recursive.
|
toString | public static String toString(Object value)(Code) | | Convert a value into a String representation. Handles null values and
arrays. Returns null if the String representation is the default
class@pointer format.
|
|
|