Apache JMeter

org.apache.jorphan.util
Class Converter

java.lang.Object
  extended by org.apache.jorphan.util.Converter

public class Converter
extends Object

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)
           
static String formatDate(Calendar date, String pattern)
           
static String formatDate(Date date, String pattern)
           
static String formatDate(Date date, String pattern)
           
static String formatDate(String date, String pattern)
           
static boolean getBoolean(Object o)
           
static boolean getBoolean(Object o, boolean defaultValue)
           
static Calendar getCalendar(Object o)
           
static Calendar getCalendar(Object date, Calendar defaultValue)
          Converts the given object to a calendar object.
static char getChar(Object o)
           
static char getChar(Object o, char defaultValue)
           
static Date getDate(Object date)
           
static Date getDate(Object date, Date defaultValue)
           
static double getDouble(Object o)
           
static double getDouble(Object o, double defaultValue)
           
static File getFile(Object o)
           
static float getFloat(Object o)
           
static float getFloat(Object o, float defaultValue)
           
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Method Detail

convert

public static Object convert(Object value,
                             Class<?> toType)
Convert the given value object to an object of the given type

Parameters:
value -
toType -
Returns:
Object

getCalendar

public static Calendar getCalendar(Object date,
                                   Calendar defaultValue)
Converts the given object to a calendar object. Defaults to the current date if the given object can't be converted.

Parameters:
date -
Returns:
Calendar

getCalendar

public static Calendar getCalendar(Object o)

getDate

public static Date getDate(Object date)

getDate

public static Date getDate(Object date,
                           Date defaultValue)

getFloat

public static float getFloat(Object o,
                             float defaultValue)

getFloat

public static float getFloat(Object o)

getDouble

public static double getDouble(Object o,
                               double defaultValue)

getDouble

public static double getDouble(Object o)

getBoolean

public static boolean getBoolean(Object o)

getBoolean

public static boolean getBoolean(Object o,
                                 boolean defaultValue)

getInt

public static int getInt(Object o,
                         int defaultValue)
Convert object to integer, return defaultValue if object is not convertible or is null.

Parameters:
o -
defaultValue -
Returns:
int

getChar

public static char getChar(Object o)

getChar

public static char getChar(Object o,
                           char defaultValue)

getInt

public static int getInt(Object o)
Converts object to an integer, defaults to 0 if object is not convertible or is null.

Parameters:
o -
Returns:
int

getLong

public static long getLong(Object o,
                           long defaultValue)
Converts object to a long, return defaultValue if object is not convertible or is null.

Parameters:
o -
defaultValue -
Returns:
long

getLong

public static long getLong(Object o)
Converts object to a long, defaults to 0 if object is not convertible or is null

Parameters:
o -
Returns:
long

formatDate

public static String formatDate(Date date,
                                String pattern)

formatDate

public static String formatDate(Date date,
                                String pattern)

formatDate

public static String formatDate(String date,
                                String pattern)

formatDate

public static String formatDate(Calendar date,
                                String pattern)

formatCalendar

public static String formatCalendar(Calendar date,
                                    String pattern)

getString

public static String getString(Object o,
                               String defaultValue)
Converts object to a String, return defaultValue if object is null.

Parameters:
o -
defaultValue -
Returns:
String

insertLineBreaks

public static String insertLineBreaks(String v,
                                      String insertion)

getString

public static String getString(Object o)
Converts object to a String, defaults to empty string if object is null.

Parameters:
o -
Returns:
String

getFile

public static File getFile(Object o)

Apache JMeter

Copyright © 1998-2012 Apache Software Foundation. All Rights Reserved.