Package org.opencms.util
Class CmsDataTypeUtil
java.lang.Object
org.opencms.util.CmsDataTypeUtil
Utilities to handle basic data types.
- Since:
- 6.5.6
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
dataDeserialize
(byte[] data, String type) Returns the deserialized (if needed) object.static String
dataExport
(Object data) Returns a ready to export string representation of the given object.static Object
dataImport
(String value, String type) Returns the import data object.static byte[]
dataSerialize
(Object data) Serialize the given data.static String
format
(boolean data) Formats the given data into a string value.static String
format
(byte data) Formats the given data into a string value.static String
format
(char data) Formats the given data into a string value.static String
format
(double data) Formats the given data into a string value.static String
format
(float data) Formats the given data into a string value.static String
format
(int data) Formats the given data into a string value.static String
format
(long data) Formats the given data into a string value.static String
format
(short data) Formats the given data into a string value.static String
Formats the given data into a string value depending on the data type.static String
Formats the given data into a string value.static boolean
isParseable
(Class<?> clazz) Checks if the given class is representable as a string.static int
Converts Number to int.static Object
Returns an object of the given type (or a wrapper for base types) with the value of the given data.static Boolean
parseBoolean
(String data) Parses the given data as a boolean.static Byte
Parses the given data as a byte.static Character
Parses the given data as a char.static Date
Parses the given data as a date.static Double
parseDouble
(String data) Parses the given data as a double.static Float
parseFloat
(String data) Parses the given data as a float.static Integer
Parses the given data as an integer.static Long
Parses the given data as a long.static Short
parseShort
(String data) Parses the given data as a short.static CmsUUID
Parses the given data as an uuid.
-
Method Details
-
dataDeserialize
public static Object dataDeserialize(byte[] data, String type) throws IOException, ClassNotFoundException Returns the deserialized (if needed) object.- Parameters:
data
- the data to deserializetype
- the data type- Returns:
- the deserialized object
- Throws:
IOException
- if the inputstream failsClassNotFoundException
- if the serialized object fails
-
dataExport
Returns a ready to export string representation of the given object.For not parseable objects, base64 encoded string with the serialized object is generated.
- Parameters:
data
- the object to export- Returns:
- the string representation
- Throws:
IOException
- if something goes wrong
-
dataImport
public static Object dataImport(String value, String type) throws ClassNotFoundException, IOException Returns the import data object.- Parameters:
value
- the exported valuetype
- the expected data type- Returns:
- the import data object
- Throws:
ClassNotFoundException
- if something goes wrongIOException
- if something goes wrong
-
dataSerialize
Serialize the given data.- Parameters:
data
- the data to serialize- Returns:
- byte[] the serailized data
- Throws:
IOException
- if something goes wrong
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value depending on the data type.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
format
Formats the given data into a string value.- Parameters:
data
- the data to format- Returns:
- a string representation of the given data
-
isParseable
Checks if the given class is representable as a string.- Parameters:
clazz
- the type to test- Returns:
- if the given class is representable as a string
-
numberToInt
Converts Number to int.- Parameters:
n
- the number object- Returns:
- Number.inValue(), 0 - if the parameter is null
-
parse
Returns an object of the given type (or a wrapper for base types) with the value of the given data.- Parameters:
data
- the data to parseclazz
- the data type- Returns:
- the value of the given data
-
parseBoolean
Parses the given data as a boolean.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseByte
Parses the given data as a byte.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseChar
Parses the given data as a char.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseDate
Parses the given data as a date.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseDouble
Parses the given data as a double.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseFloat
Parses the given data as a float.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseInt
Parses the given data as an integer.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseLong
Parses the given data as a long.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseShort
Parses the given data as a short.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-
parseUUID
Parses the given data as an uuid.- Parameters:
data
- the data to parse- Returns:
- the converted data value
-