|
intarsys runtime library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.intarsys.tools.functor.ArgTools
public class ArgTools
Tool class to ease handling of arguments.
Field Summary | |
---|---|
static IFunctor |
toString
|
Constructor Summary | |
---|---|
ArgTools()
|
Method Summary | ||
---|---|---|
static IArgs |
getArgs(IArgs args,
String name,
IArgs defaultValue)
The argument value at name as an IArgs instance. |
|
static boolean |
getBool(IArgs args,
String name,
boolean defaultValue)
The argument value at name as a boolean . |
|
static byte |
getByte(IArgs args,
String name,
byte defaultValue)
The argument value at name as a byte . |
|
static char |
getChar(IArgs args,
String name,
char defaultValue)
The argument value at name as a char . |
|
static char[] |
getCharArray(IArgs args,
String name,
char[] defaultValue)
The argument value at name as a char[] . |
|
static Class |
getClass(IArgs args,
String name,
Class defaultValue)
The argument value at name as a Class . |
|
static Date |
getDate(IArgs args,
String name,
Date defaultValue)
The argument value at name as a Date . |
|
static
|
getEnumItem(IArgs args,
EnumMeta<T> meta,
String name)
The argument value at name as a EnumItem . |
|
static
|
getEnumItem(IArgs args,
EnumMeta<T> meta,
String name,
String defaultValue)
The argument value at name as a EnumItem . |
|
static File |
getFile(IArgs args,
String name,
File defaultValue)
The argument value at name as a File . |
|
static float |
getFloat(IArgs args,
String name,
float defaultValue)
The argument value at name as a float . |
|
static int |
getInt(IArgs args,
String name,
int defaultValue)
The argument value at name as a int . |
|
static ILocator |
getLocator(IArgs args,
String name,
ILocator defaultValue,
ILocatorFactory factory)
The argument value at name as a ILocator . |
|
static List<ILocator> |
getLocators(IArgs args,
String name,
ILocatorFactory factory)
The argument value at name as a List . |
|
static Map |
getMap(IArgs args,
String name,
Map defaultValue)
The argument value at name as a Map . |
|
static Object |
getObject(IArgs args,
String name,
Object defaultValue)
The argument value at name as a Object . |
|
static Point2D |
getPoint(IArgs args,
String name,
Point2D defaultValue)
The argument value at name as a Point2D . |
|
static String |
getString(IArgs args,
String name,
String defaultValue)
The argument value at name as a String . |
|
static String |
prefix(String prefix,
String name)
Create a new argument name from name by prefixing with
prefix . |
|
static IArgs |
toArgs(Object value)
Cast or convert value to an IArgs . |
|
static List |
toList(IArgs args)
Convert the args to a List . |
|
static Map |
toMap(IArgs args)
Convert the args to a Map . |
|
static String |
toString(IArgs args,
String prefix)
Create a printable String for args . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final IFunctor toString
Constructor Detail |
---|
public ArgTools()
Method Detail |
---|
public static IArgs getArgs(IArgs args, String name, IArgs defaultValue)
name
as an IArgs
instance. If
the argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, IArgs
, String
, Map
and List
.
args
- name
- defaultValue
-
name
as an IArgs
instance.public static boolean getBool(IArgs args, String name, boolean defaultValue)
name
as a boolean
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Boolean
, String
.
args
- name
- defaultValue
-
name
as a boolean
.public static byte getByte(IArgs args, String name, byte defaultValue)
name
as a byte
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Number
, String
.
args
- name
- defaultValue
-
name
as a byte
.public static char getChar(IArgs args, String name, char defaultValue)
name
as a char
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Character
, String
.
args
- name
- defaultValue
-
name
as a char
.public static char[] getCharArray(IArgs args, String name, char[] defaultValue) throws IllegalArgumentException
name
as a char[]
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, String
, char[]
. Unlike
the other conversion methods, this one throws an
IllegalArgumentException, if the value is not of type String
or char[]
.
args
- name
- defaultValue
-
name
as a String
.
IllegalArgumentException
- if value is not of type String
or
char[]
public static Class getClass(IArgs args, String name, Class defaultValue)
name
as a Class
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Boolean
, String
.
args
- name
- defaultValue
-
name
as a Class
.public static Date getDate(IArgs args, String name, Date defaultValue)
name
as a Date
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Date
, String
.
args
- name
- defaultValue
-
name
as a Date
.public static <T extends EnumItem> T getEnumItem(IArgs args, EnumMeta<T> meta, String name)
name
as a EnumItem
. If the
argument value is not provided or not convertible, the enumeration
default value is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, EnumItem
, String
.
args
- meta
- name
-
name
as a EnumItem
.public static <T extends EnumItem> T getEnumItem(IArgs args, EnumMeta<T> meta, String name, String defaultValue)
name
as a EnumItem
. If the
argument value is not provided or not convertible, the enumeration item
with the id defaultValuee
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, EnumItem
, String
.
args
- meta
- name
-
name
as a EnumItem
.public static File getFile(IArgs args, String name, File defaultValue)
name
as a File
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, File
, String
,
ILocator
.
args
- name
- defaultValue
-
name
as a Date
.public static float getFloat(IArgs args, String name, float defaultValue)
name
as a float
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Number
, String
.
args
- name
- defaultValue
-
name
as a float
.public static int getInt(IArgs args, String name, int defaultValue)
name
as a int
. If the argument
value is not provided or not convertible, defaultValue
is
returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Number
, String
.
args
- name
- defaultValue
-
name
as a int
.public static ILocator getLocator(IArgs args, String name, ILocator defaultValue, ILocatorFactory factory)
name
as a ILocator
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, ILocator
, String
,
File
args
- name
- defaultValue
- factory
-
name
as a ILocator
.public static List<ILocator> getLocators(IArgs args, String name, ILocatorFactory factory)
name
as a List
. If
the argument value is not provided, null
is returned.
This method performs the necessary casts and conversions. Supported input
types are Collection
, Collection
,
Collection
args
- name
- factory
-
name
as a
.public static Map getMap(IArgs args, String name, Map defaultValue)
name
as a Map
. If the argument
value is not provided or not convertible, defaultValue
is
returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Map
, String
.
args
- name
- defaultValue
-
name
as a Map
.public static Object getObject(IArgs args, String name, Object defaultValue)
name
as a Object
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Object
.
args
- name
- defaultValue
-
name
as a Object
.public static Point2D getPoint(IArgs args, String name, Point2D defaultValue)
name
as a Point2D
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, Point2D
, String
.
args
- name
- defaultValue
-
name
as a Point2D
.public static String getString(IArgs args, String name, String defaultValue)
name
as a String
. If the
argument value is not provided or not convertible,
defaultValue
is returned.
This method performs the necessary casts and conversions. Supported input
types are null
, String
, Object
.
args
- name
- defaultValue
-
name
as a String
.public static String prefix(String prefix, String name)
name
by prefixing with
prefix
.
prefix
- name
-
public static IArgs toArgs(Object value)
value
to an IArgs
.
value
-
IArgs
created from value
.public static List toList(IArgs args)
args
to a List
.
args
-
List
representation of the args
public static Map toMap(IArgs args)
args
to a Map
.
args
-
Map
representation of the args
public static String toString(IArgs args, String prefix)
String
for args
.
args
- prefix
-
|
intarsys runtime library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |