|
TagLib documentation | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.alweb.doff.util.Parameter
public class Parameter
Represents an untyped parameter and provides a way to converts easily a
string into primitive types. Value specified at constructor will be
automatically trimmed (unless null).
| Field Summary | |
|---|---|
static Parameter |
EMPTY_PARAMETER
Represents an empty parameter, with null as value. |
| Constructor Summary | |
|---|---|
Parameter(String value)
Constructs a new parameter from its value. |
|
| Method Summary | ||
|---|---|---|
int |
compareTo(Object other)
|
|
boolean |
equals(Object other)
|
|
boolean |
exists()
Determines if this parameter exists (has a value). |
|
static ParameterConverter |
getConverter()
Returns the parameter converter. |
|
static void |
setConverter(ParameterConverter converter)
Sets the parameter converter for the entire application. |
|
|
to(Class<T> type)
Tries to converts this parameter to specified type with null as
default value. |
|
|
to(Class<T> type,
T defaultValue)
Tries to converts this parameter to specified type with specified default value. |
|
boolean |
toBoolean()
Tries to convert this parameter value to a Boolean. |
|
Boolean |
toBoolean(Boolean defaultValue)
Tries to convert this parameter value to a Boolean. |
|
Date |
toDate()
Tries to convert this parameter value as a Date. |
|
Date |
toDate(DateFormat format)
Tries to convert this parameter value as a Date. |
|
Date |
toDate(DateFormat format,
Date defaultValue)
Tries to convert this parameter value as a Date. |
|
double |
toDouble()
Tries to convert this parameter value as Double format. |
|
Double |
toDouble(Double defaultValue)
Tries to convert this parameter value as Double format. |
|
|
toEnum(Class<T> enumType)
Tries to convert this parameter value as an Enum. |
|
|
toEnum(Class<T> enumType,
T defaultValue)
Tries to convert this parameter value as an Enum. |
|
int |
toInt()
Tries to convert this parameter value as Integer format. |
|
Integer |
toInt(Integer defaultValue)
Tries to convert this parameter value as Integer format. |
|
List<Parameter> |
toList()
Tries to convert this parameter as a List of parameter with those
delimiters: ,; \t\n |
|
|
toList(Class<T> type)
Tries to converts this parameter to a list of specified elements type. |
|
|
toList(Class<T> type,
String delimiters)
Tries to converts this parameter to a list of specified elements type with specified delimiters. |
|
List<Parameter> |
toList(String delimiters)
Tries to convert this parameter as a List of parameter with
specified delimiters. |
|
long |
toLong()
Tries to convert this parameter value as Long format. |
|
Long |
toLong(Long defaultValue)
Tries to convert this parameter value as Long format. |
|
String |
toString()
Provides a string representation of this parameter. |
|
String |
toString(boolean trimmed)
Provides a string representation of this parameter. |
|
String |
toString(String defaultValue)
Provides a String representation of this parameter. |
|
String |
toString(String defaultValue,
boolean trimmed)
Provides a string representation of this parameter. |
|
URL |
toURL()
Tries to converts this parameter to an URL. |
|
URL |
toURL(URL defaultValue)
Tries to converts this parameter to an URL. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Parameter EMPTY_PARAMETER
null as value. Use this
constant instead of creating a new one.
| Constructor Detail |
|---|
public Parameter(String value)
null value means
that parameter doesn't exists.
exists()| Method Detail |
|---|
public static final ParameterConverter getConverter()
false.
setConverter(ParameterConverter)public static final void setConverter(ParameterConverter converter)
public int compareTo(Object other)
compareTo in interface Comparable<Object>public boolean equals(Object other)
equals in class Objectpublic boolean exists()
false if value specified at the constructor is null,
true otherwise.
Parameter(String)public <T> T to(Class<T> type)
null as
default value.
IllegalArgumentException - if type is not supported.setConverter(ParameterConverter)
public <T> T to(Class<T> type,
T defaultValue)
Tries to converts this parameter to specified type with specified default value.
Supported types are: Parameter, String, Integer,
Long, Double, Boolean, Date,
List, URL and Enum.
If specified type is not supported the converted is checked.
IllegalArgumentException - if type is not supported.setConverter(ParameterConverter)public boolean toBoolean()
Boolean. The default
value (if doesn't exists or malformed) is false. True texts are: "true",
"yes", "on" and "1". False texts are: "false", "no", "off" and "0".
toBoolean(Boolean)public Boolean toBoolean(Boolean defaultValue)
Boolean. True texts
are: "true", "yes", "on" and "1". False texts are: "false", "no", "off"
and "0".
defaultValue - The default value if parameter doesn't exists or
doesn't represents a boolean.public Date toDate()
Date. The default
value is null and the date format is "yyyy-MM-dd".
toDate(DateFormat)public Date toDate(DateFormat format)
Date. The default
value is null.
format - The format used for parsing the date.
NullPointerException - if specified format is null.toDate(DateFormat, Date)
public Date toDate(DateFormat format,
Date defaultValue)
Date.
format - The format used for parsing the date.defaultValue - The default value if date is malformed.
NullPointerException - if specified format is null.DateFormat.parse(String)public double toDouble()
Double format. The
default value is 0.
toDouble(Double)public Double toDouble(Double defaultValue)
Double format.
defaultValue - The default value if parameter doesn't exists or
doesn't represents a double.Double.parseDouble(String)public <T extends Enum<T>> T toEnum(Class<T> enumType)
Enum. Enumeration
values must be in upper case. The default value (if missing or malformed)
is null.
enumType - The type of the enum.
NullPointerException - if specified type is null.
public <T extends Enum<T>> T toEnum(Class<T> enumType,
T defaultValue)
Enum. Enumeration
values must be in upper case.
enumType - The type of the enum.defaultValue - The default value if malformed or missing.
NullPointerException - if specified type is null.public int toInt()
Integer format. The
default value is 0.
toInt(Integer)public Integer toInt(Integer defaultValue)
Integer format.
defaultValue - The default value if parameter doesn't exists or
doesn't represents an integer.Integer.parseInt(String)public List<Parameter> toList()
List of parameter with those
delimiters: ,; \t\n
toList(String)public <T> List<T> toList(Class<T> type)
NullPointerException - if specified type is null.toList(Class, String)
public <T> List<T> toList(Class<T> type,
String delimiters)
NullPointerException - if specified type is null.StringTokenizerpublic List<Parameter> toList(String delimiters)
List of parameter with
specified delimiters.
public long toLong()
Long format. The default
value is 0.
toLong(Long)public Long toLong(Long defaultValue)
Long format.
defaultValue - The default value if parameter doesn't exists or
doesn't represents a long.Long.parseLong(String)public String toString()
toString in class ObjecttoString(String, boolean)public String toString(boolean trimmed)
trimmed - true in order to trim the value, false
otherwise.
toString(String, boolean)public String toString(String defaultValue)
String representation of this parameter.
defaultValue - The default value if this parameter doesn't exists.
toString(String, boolean)
public String toString(String defaultValue,
boolean trimmed)
defaultValue - The default value if this parameter doesn't exists.trimmed - true in order to trim the value, false
otherwise.
exists()public URL toURL()
null
public URL toURL(URL defaultValue)
|
TagLib documentation | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||