|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jorphan.util.Converter
public class Converter
Converter utilities for TestBeans
Constructor Summary | |
---|---|
Converter()
|
Method Summary | |
---|---|
static Object |
convert(Object value,
Class<?> toType)
Convert the given value object to an object of the given type |
static String |
formatCalendar(Calendar date,
String pattern)
Format a calendar using a given pattern |
static String |
formatDate(Calendar date,
String pattern)
Format a date using a given pattern |
static String |
formatDate(Date date,
String pattern)
Format a date using a given pattern |
static String |
formatDate(Date date,
String pattern)
Format a date using a given pattern |
static String |
formatDate(String date,
String pattern)
Format a date using a given pattern |
static boolean |
getBoolean(Object o)
Convert object to boolean, or false if conversion
failed |
static boolean |
getBoolean(Object o,
boolean defaultValue)
Convert object to boolean, or defaultValue if conversion
failed |
static Calendar |
getCalendar(Object o)
Converts the given object to a calendar object. |
static Calendar |
getCalendar(Object date,
Calendar defaultValue)
Converts the given object to a calendar object. |
static char |
getChar(Object o)
Convert object to char, or ' ' if no conversion can be applied |
static char |
getChar(Object o,
char defaultValue)
Convert object to char, or defaultValue if no conversion can
be applied |
static Date |
getDate(Object date)
Converts the given object to a Date object. |
static Date |
getDate(Object date,
Date defaultValue)
Converts the given object to a Date object. |
static double |
getDouble(Object o)
Convert object to double, or 0 if conversion
failed |
static double |
getDouble(Object o,
double defaultValue)
Convert object to double, or defaultValue if conversion
failed |
static File |
getFile(Object o)
Converts an object to a File |
static float |
getFloat(Object o)
Convert object to float, or 0 if conversion
failed |
static float |
getFloat(Object o,
float defaultValue)
Convert object to float, or defaultValue if conversion
failed |
static int |
getInt(Object o)
Converts object to an integer, defaults to 0 if object is
not convertible or is null . |
static int |
getInt(Object o,
int defaultValue)
Convert object to integer, return defaultValue if object is not
convertible or is null . |
static long |
getLong(Object o)
Converts object to a long, defaults to 0 if object is not
convertible or is null |
static long |
getLong(Object o,
long defaultValue)
Converts object to a long, return defaultValue if object is
not convertible or is null . |
static String |
getString(Object o)
Converts object to a String, defaults to empty string if object is null. |
static String |
getString(Object o,
String defaultValue)
Converts object to a String, return defaultValue if object
is null . |
static String |
insertLineBreaks(String v,
String insertion)
Replace newlines "\n" with insertion |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Converter()
Method Detail |
---|
public static Object convert(Object value, Class<?> toType)
value
- object to converttoType
- type to convert object to
public static Calendar getCalendar(Object date, Calendar defaultValue)
defaultValue
if the given object can't be converted.
date
- object that should be converted to a Calendar
defaultValue
- default value that will be returned if date
can
not be converted
Calendar
representing the given date
or
defaultValue
if conversion failedpublic static Calendar getCalendar(Object o)
o
- object that should be converted to a Calendar
Calendar
representing the given o
or a new
GregorianCalendar
using the current time if conversion
failedpublic static Date getDate(Object date)
Date
object. Defaults to the
current time if the given object can't be converted.
date
- object that should be converted to a Date
Date
representing the given date
or
the current time if conversion failedpublic static Date getDate(Object date, Date defaultValue)
Date
object. Defaults to the
defaultValue
if the given object can't be converted.
date
- object that should be converted to a Date
defaultValue
- default value that will be returned if date
can
not be converted
Date
representing the given date
or
defaultValue
if conversion failedpublic static float getFloat(Object o, float defaultValue)
defaultValue
if conversion
failed
o
- object to convertdefaultValue
- default value to use, when conversion failed
defaultValue
if conversion
failedpublic static float getFloat(Object o)
0
if conversion
failed
o
- object to convert
0
if conversion
failedpublic static double getDouble(Object o, double defaultValue)
defaultValue
if conversion
failed
o
- object to convertdefaultValue
- default value to use, when conversion failed
defaultValue
if conversion
failedpublic static double getDouble(Object o)
0
if conversion
failed
o
- object to convert
0
if conversion
failedpublic static boolean getBoolean(Object o)
false
if conversion
failed
o
- object to convert
false
if conversion
failedpublic static boolean getBoolean(Object o, boolean defaultValue)
defaultValue
if conversion
failed
o
- object to convertdefaultValue
- default value to use, when conversion failed
defaultValue
if conversion
failedpublic static int getInt(Object o, int defaultValue)
defaultValue
if object is not
convertible or is null
.
o
- object to convertdefaultValue
- default value to be used when no conversion can be done
public static char getChar(Object o)
o
- object to convert
public static char getChar(Object o, char defaultValue)
defaultValue
if no conversion can
be applied
o
- object to convertdefaultValue
- default value to use, when conversion failed
defaultValue
if conversion failedpublic static int getInt(Object o)
0
if object is
not convertible or is null
.
o
- object to convert
0
if conversion failedpublic static long getLong(Object o, long defaultValue)
defaultValue
if object is
not convertible or is null
.
o
- object to convertdefaultValue
- default value to use, when conversion failed
defaultValue
when conversion
failedpublic static long getLong(Object o)
0
if object is not
convertible or is null
o
- object to convert
0
if conversion failedpublic static String formatDate(Date date, String pattern)
date
- date to formatpattern
- pattern to use for formatting
null
IllegalArgumentException
- when pattern
is invalidpublic static String formatDate(Date date, String pattern)
date
- date to formatpattern
- pattern to use for formatting
null
IllegalArgumentException
- when pattern
is invalidpublic static String formatDate(String date, String pattern)
date
- date to formatpattern
- pattern to use for formatting
null
IllegalArgumentException
- when pattern
is invalidpublic static String formatDate(Calendar date, String pattern)
date
- date to formatpattern
- pattern to use for formatting
null
IllegalArgumentException
- when pattern
is invalidpublic static String formatCalendar(Calendar date, String pattern)
date
- calendar to formatpattern
- pattern to use for formatting
null
IllegalArgumentException
- when pattern
is invalidpublic static String getString(Object o, String defaultValue)
defaultValue
if object
is null
.
o
- object to convertdefaultValue
- default value to use when conversion failed
defaultValue
when conversion
failedpublic static String insertLineBreaks(String v, String insertion)
insertion
v
- String in which the newlines should be replacedinsertion
- new string which should be used instead of "\n"
insertion
public static String getString(Object o)
o
- object to convert
public static File getFile(Object o)
File
o
- object to convert (must be a String
or a File
)
IllegalArgumentException
- when object can not be converted
|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |