|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectpatterntesting.runtime.util.Converter
public final class Converter
The Class Converter to convert objects from one type to another type.
| Method Summary | |
|---|---|
static String |
classToResource(String name)
Converts a classname (e.g. |
static Serializable |
deserialize(byte[] bytes)
Deserializes the given byte array and returns it as object. |
static String |
getMemoryAsString(long mem)
Gets the memory as string. |
static String |
getTimeAsString(double timeInMillis)
Gets the time as string with the corresponding unit. |
static String |
getTimeAsString(double timeInMillis,
Locale locale)
Gets the time as string with the corresponding unit. |
static String |
getTimeAsString(long timeInMillis)
Gets the time as string with the corresponding unit. |
static String |
packageToResource(String name)
Converts a package name (e.g. |
static String |
resourceToClass(String name)
Converts a resource (e.g. |
static byte[] |
serialize(Serializable object)
Serializes the given object and returns it as byte array. |
static String |
toAbsolutePath(URI uri)
Converts an URI into a file and returns it as absolute pathname. |
static Date |
toDate(String s)
Converts a string to a date by trying different date patterns. |
static Date |
toDate(String s,
String pattern)
Converts a string to a date with the help of the given pattern. |
static File |
toFile(String uri)
Converts an URI into a file. |
static File |
toFile(URI uri)
Converts an URI into a file. |
static String |
toLongString(Map<?,?> pairs)
If you want to print the system properties as key-value pairs (e.g. |
static String |
toLongString(Object obj)
Converts an object into a long representation as the normal toString method. |
static String |
toLongString(Object[] array)
If you want to print each element of an array into a single line you can use this method here. |
static String |
toLongString(StackTraceElement[] stacktrace)
This implementation prints the stacktrace in a similar way as the printStacktrace method of Throwable does it. |
static String |
toResource(Class<?> clazz)
To resource. |
static String |
toResource(Package p)
To resource. |
static String |
toShortString(Number number)
To short string. |
static String |
toShortString(Object obj)
Converts an object to its toString representation. |
static String |
toShortString(Object[] array)
To short string. |
static SortedSet<?> |
toSortedSet(Enumeration<?> enumeration)
Converts an Enumeration into a SortedSet. |
static String |
toString(Date date,
String pattern)
Converts a date to string using the default locale. |
static String |
toString(Date date,
String pattern,
Locale locale)
Converts a date to string using the default locale. |
static String |
toString(Enumeration<?> enumeration)
To string. |
static String |
toString(Object obj)
Converts an object into its string representation. |
static String |
toString(Object[] array)
An empty array or null is mapped to "" (empty string). |
static String[] |
toStringArray(Object[] array)
Each object inside the array is converted into its toString() representation. |
static String[] |
toStringArray(Set<? extends Object> set)
Each object inside the Set is converted into its toString() representation. |
static URI |
toURI(String uri)
If a URL contains illegal characters for an URI (like blanks) this should be automatically converted (e.g. to "%20") |
static URI |
toURI(URL url)
If a URL contains illegal characters for an URI (like blanks) this should be automatically converted (e.g. to "%20") |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String getMemoryAsString(long mem)
mem - the mem
public static String getTimeAsString(long timeInMillis)
timeInMillis - the time in millis
public static String getTimeAsString(double timeInMillis)
timeInMillis - the time in millis
public static String getTimeAsString(double timeInMillis,
Locale locale)
timeInMillis - the time in millislocale - the locale
public static String classToResource(String name)
name - e.g. "java.lang.String"
public static String toResource(Class<?> clazz)
clazz - the clazz
public static String packageToResource(String name)
name - e.g. "java.lang"
public static String toResource(Package p)
p - the p
public static String resourceToClass(String name)
name - e.g. "/java/lang/String.class"
public static URI toURI(URL url)
url - the URL to be converted
public static URI toURI(String uri)
uri - the URL to be converted
public static File toFile(URI uri)
uri - e.g. URI("file:/tmp")
public static File toFile(String uri)
uri - the uri as string
public static String toAbsolutePath(URI uri)
uri - e.g. URI("file:/tmp")
public static String toString(Object obj)
obj - the obj
public static String toString(Enumeration<?> enumeration)
enumeration - the enumeration
public static String toShortString(Object obj)
If the resulting toString representation looks like the default
implementation of Object.toString() the package name will be
removed from the result. For other toString results
StringUtils.abbreviate(String, int) will be used to cut it if
necessary.
obj - the obj
public static String toShortString(Number number)
number - the number
public static String toLongString(Object obj)
obj - the obj
public static String toString(Object[] array)
array - e.g. an int array {1, 2, 3}
public static String toShortString(Object[] array)
array - the array
public static String toLongString(Map<?,?> pairs)
pairs - e.g. the system properties
public static String toLongString(Object[] array)
array - the array
public static String toLongString(StackTraceElement[] stacktrace)
Throwable does it.
stacktrace - the array
public static String[] toStringArray(Object[] array)
array - e.g. an int array {1, 2, 3}
public static String[] toStringArray(Set<? extends Object> set)
set - the set
public static String toString(Date date,
String pattern)
date - a valid datepattern - e.g. "dd-MMM-yyyy"
public static String toString(Date date,
String pattern,
Locale locale)
date - a valid datepattern - e.g. "dd-MMM-yyyy"locale - e.g. new Locale("de")
public static Date toDate(String s)
s - e.g. "28-Nov-2009" or "Thu Nov 26 14:30:25 CET 2009"
public static Date toDate(String s,
String pattern)
s - e.g. "28-Nov-2009"pattern - e.g. "dd-MMM-yyyy"
public static SortedSet<?> toSortedSet(Enumeration<?> enumeration)
enumeration - the Enumeration
public static byte[] serialize(Serializable object)
throws NotSerializableException
object - the object to be serialized
NotSerializableException - the not serializable exception
public static Serializable deserialize(byte[] bytes)
throws ClassNotFoundException
bytes - the byte array
ClassNotFoundException - if byte array can't be deserialized
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||