|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hyphenType.util.soc.StringObjectConversion
public final class StringObjectConversion
Converts strings to objects and vice-versa.
Method Summary | ||
---|---|---|
static
|
fromString(Class<? extends T> clazz,
String value)
Translates a string into an object. |
|
static
|
fromString(Class<? extends T> clazz,
String value,
boolean arrayForgiving)
Translates a string into an object. |
|
static
|
fromString(Class<? extends T> clazz,
String value,
boolean arrayForgiving,
String separator)
Translates a string into an object. |
|
static
|
fromString(Class<? extends T> clazz,
String value,
boolean arrayForgiving,
String arrayStart,
String arrayEnd,
String arraySeparator)
Translates a string into an object. |
|
static Object |
toPrimitive(Class clazz,
Object object)
Parses the object into a primitive. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T fromString(Class<? extends T> clazz, String value) throws StringParsingError
clazz
is String
, simply returns the string value
received. If clazz
is primitive or a wrapper for a primitive,
returns the result of calling a valueOf
method. If clazz
is
of a type Class
, it searches for the class using
Class.forName(String)
. Finally, if clazz
does not match
any of those tests, tries to construct a new object, guessing that
clazz
has a constructor that receives only a String
.
T
- The type to convert to.clazz
- The same as the type T.value
- The string value of the object.
StringParsingError
- If there is any reflection problem.public static <T> T fromString(Class<? extends T> clazz, String value, boolean arrayForgiving) throws StringParsingError
clazz
is String
, simply returns the string value
received. If clazz
is primitive or a wrapper for a primitive,
returns the result of calling a valueOf
method. If clazz
is
of a type Class
, it searches for the class using
Class.forName(String)
. Finally, if clazz
does not match
any of those tests, tries to construct a new object, guessing that
clazz
has a constructor that receives only a String
.
T
- The type to convert to.clazz
- The same as the type T.value
- The string value of the object.arrayForgiving
- Whether it will forgive the absence of square brackets.
StringParsingError
- If there is any reflection problem.public static <T> T fromString(Class<? extends T> clazz, String value, boolean arrayForgiving, String separator) throws StringParsingError
clazz
is String
, simply returns the string value
received. If clazz
is primitive or a wrapper for a primitive,
returns the result of calling a valueOf
method. If clazz
is
of a type Class
, it searches for the class using
Class.forName(String)
. Finally, if clazz
does not match
any of those tests, tries to construct a new object, guessing that
clazz
has a constructor that receives only a String
.
T
- The type to convert to.clazz
- The same as the type T.value
- The string value of the object.arrayForgiving
- Whether it will forgive the absence of square brackets.
StringParsingError
- If there is any reflection problem.public static <T> T fromString(Class<? extends T> clazz, String value, boolean arrayForgiving, String arrayStart, String arrayEnd, String arraySeparator) throws StringParsingError
clazz
is String
, simply returns the string value
received. If clazz
is primitive or a wrapper for a primitive,
returns the result of calling a valueOf
method. If clazz
is
of a type Class
, it searches for the class using
Class.forName(String)
. Finally, if clazz
does not match
any of those tests, tries to construct a new object, guessing that
clazz
has a constructor that receives only a String
.
T
- The type to convert to.clazz
- The same as the type T.value
- The string value of the object.arrayForgiving
- Whether it will forgive the absence of square brackets.arrayStart
- arrayEng
- arraySeparator
-
StringParsingError
public static Object toPrimitive(Class clazz, Object object)
clazz
- The primitive class.object
- The object that will be converted to a primitive.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |