|
|||||||||
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 | ||
---|---|---|
protected static ILocator |
createLocator(java.lang.Object optionValue,
ILocator defaultValue,
ILocatorFactory factory)
|
|
static IArgs |
getArgs(IArgs args,
java.lang.String name,
IArgs defaultValue)
The argument value at name as an IArgs instance. |
|
static boolean |
getBool(IArgs args,
java.lang.String name,
boolean defaultValue)
The argument value at name as a boolean. |
|
static byte |
getByte(IArgs args,
java.lang.String name,
byte defaultValue)
The argument value at name as a byte. |
|
static char |
getChar(IArgs args,
java.lang.String name,
char defaultValue)
The argument value at name as a char. |
|
static char[] |
getCharArray(IArgs args,
java.lang.String name,
char[] defaultValue)
The argument value at name as a char[]. |
|
static java.lang.Class |
getClass(IArgs args,
java.lang.String name,
java.lang.Class defaultValue)
The argument value at name as a Class . |
|
static java.util.Date |
getDate(IArgs args,
java.lang.String name,
java.util.Date defaultValue)
The argument value at name as a Date . |
|
static
|
getEnumItem(IArgs args,
EnumMeta<T> meta,
java.lang.String name)
The argument value at name as a EnumItem . |
|
static
|
getEnumItem(IArgs args,
EnumMeta<T> meta,
java.lang.String name,
java.lang.String defaultValue)
The argument value at name as a EnumItem . |
|
static java.io.File |
getFile(IArgs args,
java.lang.String name,
java.io.File defaultValue)
The argument value at name as a File . |
|
static float |
getFloat(IArgs args,
java.lang.String name,
float defaultValue)
The argument value at name as a float. |
|
static int |
getInt(IArgs args,
java.lang.String name,
int defaultValue)
The argument value at name as a int. |
|
static ILocator |
getLocator(IArgs args,
java.lang.String name,
ILocator defaultValue,
ILocatorFactory factory)
The argument value at name as a ILocator . |
|
static java.util.List<ILocator> |
getLocators(IArgs args,
java.lang.String name,
ILocatorFactory factory)
The argument value at name as a List |
|
static java.util.Map |
getMap(IArgs args,
java.lang.String name,
java.util.Map defaultValue)
The argument value at name as a Map . |
|
static java.lang.Object |
getObject(IArgs args,
java.lang.String name,
java.lang.Object defaultValue)
The argument value at name as a Object . |
|
static java.awt.geom.Point2D |
getPoint(IArgs args,
java.lang.String name,
java.awt.geom.Point2D defaultValue)
The argument value at name as a Point2D . |
|
static java.lang.String |
getString(IArgs args,
java.lang.String name,
java.lang.String defaultValue)
The argument value at name as a String . |
|
static java.lang.String |
prefix(java.lang.String prefix,
java.lang.String name)
Create a new argument name from name by prefixing with
prefix . |
|
static IArgs |
toArgs(java.lang.Object value)
Cast or convert value to an IArgs . |
|
static java.util.List |
toList(IArgs args)
Convert the args to a List . |
|
static java.util.Map |
toMap(IArgs args)
Convert the args to a Map . |
|
static java.lang.String |
toString(IArgs args,
java.lang.String prefix)
Create a printable String for args . |
|
protected static void |
toStringArgs(java.lang.String prefix,
java.lang.StringBuilder sb,
java.lang.String name,
IArgs value)
|
|
protected static void |
toStringPlain(java.lang.String prefix,
java.lang.StringBuilder sb,
java.lang.String name,
java.lang.Object value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final IFunctor toString
Constructor Detail |
---|
public ArgTools()
Method Detail |
---|
protected static ILocator createLocator(java.lang.Object optionValue, ILocator defaultValue, ILocatorFactory factory)
public static IArgs getArgs(IArgs args, java.lang.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, java.lang.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, java.lang.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, java.lang.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, java.lang.String name, char[] defaultValue) throws java.lang.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
.
java.lang.IllegalArgumentException
- if value is not of type String
or
char[]
public static java.lang.Class getClass(IArgs args, java.lang.String name, java.lang.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 java.util.Date getDate(IArgs args, java.lang.String name, java.util.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, java.lang.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, java.lang.String name, java.lang.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 java.io.File getFile(IArgs args, java.lang.String name, java.io.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, java.lang.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, java.lang.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, java.lang.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 java.util.List<ILocator> getLocators(IArgs args, java.lang.String name, ILocatorFactory factory)
name
as a Listnull
is returned.
This method performs the necessary casts and conversions. Supported input
types are Collection
of ILocator
, String
and
File
.
args
- name
- factory
-
name
as a List
.public static java.util.Map getMap(IArgs args, java.lang.String name, java.util.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 java.lang.Object getObject(IArgs args, java.lang.String name, java.lang.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 java.awt.geom.Point2D getPoint(IArgs args, java.lang.String name, java.awt.geom.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 java.lang.String getString(IArgs args, java.lang.String name, java.lang.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 java.lang.String prefix(java.lang.String prefix, java.lang.String name)
name
by prefixing with
prefix
.
prefix
- name
-
public static IArgs toArgs(java.lang.Object value)
value
to an IArgs
.
value
-
IArgs
created from value
.public static java.util.List toList(IArgs args)
args
to a List
.
args
-
List
representation of the args
public static java.util.Map toMap(IArgs args)
args
to a Map
.
args
-
Map
representation of the args
public static java.lang.String toString(IArgs args, java.lang.String prefix)
String
for args
.
args
- prefix
-
protected static void toStringArgs(java.lang.String prefix, java.lang.StringBuilder sb, java.lang.String name, IArgs value)
protected static void toStringPlain(java.lang.String prefix, java.lang.StringBuilder sb, java.lang.String name, java.lang.Object value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |