public class DataUtils
extends java.lang.Object
| Constructor and Description |
|---|
DataUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object |
decodeBase64(java.lang.Object input)
Base64-decode a string and return it as a decoded String.
|
static byte[] |
encodeBase64(java.lang.Object input)
Base64-encode an object and return it as a byte array
|
static boolean |
getBooleanValue(java.lang.Object in)
Convert a generic object into a boolean value.
|
static boolean |
getBooleanValue(java.lang.Object in,
boolean encoded)
Convert a generic object into a boolean value.
|
static java.util.List<java.lang.Object> |
getCsvList(java.lang.String csv)
Converts a String containing a set of comma-separated values
and returns it as a java.util.List object.
|
static double |
getDoubleValue(java.lang.Object in)
Convert a generic object into a double value
|
static double |
getDoubleValue(java.lang.Object in,
boolean encoded)
Convert a generic object into a double value
|
static int |
getIntValue(java.lang.Object in)
Convert a generic object into an int value.
|
static int |
getIntValue(java.lang.Object in,
boolean encoded)
Convert a generic object into an int value.
|
static java.lang.String |
getStringValue(java.lang.Object in)
Convert a generic object into a String value.
|
static java.lang.String |
getStringValue(java.lang.Object in,
boolean encoded)
Convert a generic object into a String value.
|
static boolean |
validBoolean(java.lang.String val)
Validate whether a string contains a valid boolean value
|
public static int getIntValue(java.lang.Object in)
throws java.lang.NumberFormatException,
java.io.IOException
in - The object to convertjava.lang.NumberFormatException - if the value is not a valid integerjava.io.IOExceptionpublic static int getIntValue(java.lang.Object in,
boolean encoded)
throws java.lang.NumberFormatException,
java.io.IOException
in - The object to convertencoded - Whether the object is Base64-encodedjava.lang.NumberFormatException - if the value is not a valid integerjava.io.IOExceptionpublic static double getDoubleValue(java.lang.Object in)
throws java.lang.NumberFormatException,
java.io.IOException
in - The object to convertjava.lang.NumberFormatException - if the value is not a valid doublejava.io.IOExceptionpublic static double getDoubleValue(java.lang.Object in,
boolean encoded)
throws java.lang.NumberFormatException,
java.io.IOException
in - The object to convertencoded - Whether the object is Base64-encodedjava.lang.NumberFormatException - if the value is not a valid doublejava.io.IOExceptionpublic static boolean getBooleanValue(java.lang.Object in)
This function will also interpret the string values "1", "y", "yes", "true", and "on" as a boolean true value.
in - The object to convertpublic static boolean getBooleanValue(java.lang.Object in,
boolean encoded)
This function will also interpret the string values "1", "y", "yes", "true", and "on" as a boolean true value.
in - The object to convertencoded - Whether the object is Base64-encodedpublic static boolean validBoolean(java.lang.String val)
This function will interpret the string values "1", "y", "yes", "true", and "on" as a boolean true value.
This function will interpret the string values "2", "n", "no", "false", and "off" as a boolean false value.
val - The string to validatepublic static java.lang.String getStringValue(java.lang.Object in)
in - The object to convertpublic static java.lang.String getStringValue(java.lang.Object in,
boolean encoded)
in - The object to convertencoded - Whether the object is Base64-encodedpublic static java.util.List<java.lang.Object> getCsvList(java.lang.String csv)
Needs to be modified to handle decimal (Double) values as well.
csv - The comma-separated list of valuespublic static byte[] encodeBase64(java.lang.Object input)
input - The object to encodepublic static java.lang.Object decodeBase64(java.lang.Object input)
If anything other than a String is passed in, then assume the object is already decoded and just return it.
input - The Base64-encoded string to decode