|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dellroad.stuff.jibx.ParseUtil
public final class ParseUtil
JiBX parsing utility methods. These methods can be used as JiBX value serializer/deserializer methods.
| Method Summary | ||
|---|---|---|
static boolean |
deserializeBoolean(String string)
Boolean parser that allows "yes" and "no" as well as the usual "true", "false", "0", "1". |
|
static boolean |
deserializeBooleanStrictly(String string)
Deserialize a boolean strictly, only allowing the values true or false. |
|
static byte[] |
deserializeByteArray(String string)
Deserialize a byte array using ByteArrayEncoder. |
|
static byte[] |
deserializeByteArrayWithColons(String string)
Deserialize a byte array using MAC address notation (colon-separated). |
|
static Date |
deserializeDate(String date)
Deserialize a Date in the format supported by DateEncoder. |
|
static Date |
deserializeDate(String date,
String format)
Deserialize a Date. |
|
static Inet4Address |
deserializeInet4Address(String string)
Deserialize an Inet4Address. |
|
static int[] |
deserializeIntArray(String string)
Deserialize an array of integers separated by commas and/or whitespace. |
|
static String |
deserializeMatching(String regex,
String string)
JiBX String deserializer support method that verifies that the input string matches the
given regular expression. |
|
static Pattern |
deserializePattern(String string)
Deserialize a Pattern. |
|
static
|
deserializeReference(String string,
Class<T> type)
Deserialize an object by reference. |
|
static SimpleDateFormat |
deserializeSimpleDateFormat(String string)
Deserialize a SimpleDateFormat. |
|
static String |
deserializeString(String string)
Deserialize a String, allowing arbitrary characters via backslash escapes. |
|
static long |
deserializeTimeInterval(String string)
Derialize a millisecond-granularity time interval, e.g., "30s", "1d12h", "0.250s", etc. |
|
static TimeZone |
deserializeTimeZone(String string)
Deserialize a TimeZone. |
|
static URI |
deserializeURI(String string)
Deserialize an URI. |
|
static UUID |
deserializeUUID(String string)
Deserialize a UUID. |
|
static Date |
deserializeXSDDateTime(String date)
Deserialize a Date in XSD dateTime format. |
|
static String |
normalize(String string)
JiBX String deserializer that normalizes a string as is required by the xsd:token XSD type. |
|
static String |
serializeByteArray(byte[] array)
Serialize a byte array using ByteArrayEncoder. |
|
static String |
serializeByteArrayWithColons(byte[] array)
Serialize a byte array using MAC address notation (colon-separated). |
|
static String |
serializeDate(Date date)
Serialize a Date in the format supported by DateEncoder. |
|
static String |
serializeDate(Date date,
String format)
Serialize a Date. |
|
static String |
serializeInet4Address(Inet4Address addr)
Serialize an Inet4Address. |
|
static String |
serializeIntArray(int[] array)
Serialize an array of integers. |
|
static String |
serializePattern(Pattern pattern)
Deprecated. This method is does the same thing as JiBX's default serialization via Object.toString() |
|
static String |
serializeReference(Object obj)
Serialize an object by reference. |
|
static String |
serializeSimpleDateFormat(SimpleDateFormat simpleDateFormat)
Serialize a SimpleDateFormat. |
|
static String |
serializeString(String string)
Serialize a String. |
|
static String |
serializeTimeInterval(long value)
Serialize a millisecond-granularity time interval, e.g., "30s", "1d12h", "0.250s", etc. |
|
static String |
serializeTimeZone(TimeZone timeZone)
Serialize a TimeZone. |
|
static String |
serializeURI(URI uri)
Deprecated. This method is does the same thing as JiBX's default serialization via Object.toString() |
|
static String |
serializeXSDDateTime(Date date)
Serialize a Date to XSD dateTime format. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String deserializeString(String string)
throws JiBXParseException
String, allowing arbitrary characters via backslash escapes.
The string will be decoded by StringEncoder.decode(java.lang.String).
JiBXParseExceptionStringEncoder.decode(java.lang.String)public static String serializeString(String string)
String.
The string will be encoded by StringEncoder.encode(java.lang.String, boolean).
StringEncoder.encode(java.lang.String, boolean)
public static TimeZone deserializeTimeZone(String string)
throws JiBXParseException
TimeZone.
JiBXParseExceptionserializeTimeZone(java.util.TimeZone)public static String serializeTimeZone(TimeZone timeZone)
TimeZone.
deserializeTimeZone(java.lang.String)
public static URI deserializeURI(String string)
throws JiBXParseException
URI.
Note: there is no need for a custom serializer, as URI.toString() already does the right thing.
JiBXParseException@Deprecated public static String serializeURI(URI uri)
Object.toString()
URI.
public static <T> T deserializeReference(String string,
Class<T> type)
throws JiBXParseException
Invoke this method from your own custom deserializer to produce an result of the correct type.
The object must have been unmarshalled already and had its ID registered via IdMapper.setId(java.lang.Object, java.lang.String).
JiBXParseExceptionserializeReference(java.lang.Object),
IdMapperpublic static String serializeReference(Object obj)
The object must have been marshalled already and had its ID assigned via IdMapper.getId(java.lang.Object).
deserializeReference(java.lang.String, java.lang.Class) ,
IdMapper
public static UUID deserializeUUID(String string)
throws JiBXParseException
UUID.
Note: there is no need for a custom serializer, as UUID.toString() already does the right thing.
JiBXParseException
public static long deserializeTimeInterval(String string)
throws JiBXParseException
JiBXParseExceptionserializeTimeInterval(long)public static String serializeTimeInterval(long value)
deserializeTimeInterval(java.lang.String)
public static byte[] deserializeByteArray(String string)
throws JiBXParseException
ByteArrayEncoder.
JiBXParseExceptionByteArrayEncoderpublic static String serializeByteArray(byte[] array)
ByteArrayEncoder.
ByteArrayEncoder
public static byte[] deserializeByteArrayWithColons(String string)
throws JiBXParseException
JiBXParseExceptionserializeByteArrayWithColons(byte[])public static String serializeByteArrayWithColons(byte[] array)
deserializeByteArrayWithColons(java.lang.String)
public static Inet4Address deserializeInet4Address(String string)
throws JiBXParseException
Inet4Address. No DNS name resolution of any kind is performed.
JiBXParseExceptionserializeInet4Address(java.net.Inet4Address)public static String serializeInet4Address(Inet4Address addr)
Inet4Address.
deserializeInet4Address(java.lang.String)
public static SimpleDateFormat deserializeSimpleDateFormat(String string)
throws JiBXParseException
SimpleDateFormat.
JiBXParseExceptionserializeSimpleDateFormat(java.text.SimpleDateFormat)public static String serializeSimpleDateFormat(SimpleDateFormat simpleDateFormat)
SimpleDateFormat.
deserializeSimpleDateFormat(java.lang.String)
public static Date deserializeDate(String date,
String format)
throws JiBXParseException
Date. This method can be used as a deserialize support method.
date - date string to parseformat - format for SimpleDateFormat.
JiBXParseExceptionserializeDate(java.util.Date, java.lang.String)
public static String serializeDate(Date date,
String format)
throws JiBXParseException
Date. This method can be used as a serialize support method.
date - date to serializeformat - format for SimpleDateFormat.
JiBXParseExceptiondeserializeDate(java.lang.String, java.lang.String)
public static Date deserializeDate(String date)
throws JiBXParseException
Date in the format supported by DateEncoder.
JiBXParseExceptionDateEncoder
public static String serializeDate(Date date)
throws JiBXParseException
Date in the format supported by DateEncoder.
JiBXParseExceptionDateEncoder
public static Date deserializeXSDDateTime(String date)
throws JiBXParseException
Date in XSD dateTime format.
JiBXParseExceptionserializeXSDDateTime(java.util.Date),
XSD dateTime datatype
public static String serializeXSDDateTime(Date date)
throws JiBXParseException
Date to XSD dateTime format.
JiBXParseExceptiondeserializeXSDDateTime(java.lang.String),
XSD dateTime datatype
public static Pattern deserializePattern(String string)
throws JiBXParseException
Pattern.
Note: there is no need for a custom serializer, as Pattern.toString() already does the right thing.
JiBXParseException@Deprecated public static String serializePattern(Pattern pattern)
Object.toString()
Pattern.
public static String normalize(String string)
String deserializer that normalizes a string as is required by the xsd:token XSD type.
This removes leading and trailing whitespace, and collapses all interior whitespace
down to a single space character.
NullPointerException - if string is null
public static String deserializeMatching(String regex,
String string)
throws JiBXParseException
String deserializer support method that verifies that the input string matches the
given regular expression. This method can be invoked by custom deserializers that supply the
regular expression to it.
NullPointerException - if string of regex is null
JiBXParseException - if string does not match regex
PatternSyntaxException - if regex is not a valid regular expression
public static boolean deserializeBoolean(String string)
throws JiBXParseException
JiBXParseException - if the value is not recognizable as a booleandeserializeBooleanStrictly(java.lang.String)
public static boolean deserializeBooleanStrictly(String string)
throws JiBXParseException
true or false.
JiBXParseExceptiondeserializeBoolean(java.lang.String)
public static int[] deserializeIntArray(String string)
throws JiBXParseException
JiBXParseExceptionserializeIntArray(int[])
public static String serializeIntArray(int[] array)
throws JiBXParseException
JiBXParseExceptiondeserializeIntArray(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||