|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.jibx.runtime.Utility
public abstract class Utility
Utility class supplying static methods. Date serialization is based on the algorithms published by Peter Baum (http://www.capecod.net/~pbaum). All date handling is done according to the W3C Schema specification, which uses a proleptic Gregorian calendar with no year 0. Note that this differs from the Java date handling, which uses a discontinuous Gregorian calendar.
| Field Summary | |
|---|---|
static int |
MINIMUM_GROWN_ARRAY_SIZE
Minimum size for array returned by growArray(java.lang.Object). |
| Constructor Summary | |
|---|---|
Utility()
|
|
| Method Summary | |
|---|---|
static java.util.List |
arrayListFactory()
Factory method to create a java.util.ArrayList as the
implementation of a java.util.List. |
static byte[] |
deserializeBase64(java.lang.String text)
Parse base64 data from text. |
static char |
deserializeCharString(java.lang.String text)
Deserialize char value from text as character value. |
static java.util.Date |
deserializeDate(java.lang.String text)
Deserialize date from text. |
static java.util.Date |
deserializeDateTime(java.lang.String text)
Deserialize date from general dateTime text. |
static java.util.ArrayList |
deserializeList(java.lang.String text,
IListItemDeserializer ideser)
Convert whitespace-separated list of values. |
static java.sql.Date |
deserializeSqlDate(java.lang.String text)
Deserialize SQL date from text. |
static java.sql.Time |
deserializeSqlTime(java.lang.String text)
Deserialize time from text. |
static java.sql.Timestamp |
deserializeTimestamp(java.lang.String text)
Deserialize timestamp from general dateTime text. |
static java.lang.String[] |
deserializeTokenList(java.lang.String text)
Deserialize a list of whitespace-separated tokens into an array of strings. |
static void |
encodeChunk(int base,
byte[] byts,
java.lang.StringBuffer buff)
Encode a chunk of data to base64 encoding. |
static int |
enumValue(java.lang.String target,
java.lang.String[] enums,
int[] vals)
Find text value in enumeration. |
static java.lang.Object |
growArray(java.lang.Object base)
Grow array of arbitrary type. |
static boolean |
ifBoolean(java.lang.String text)
Check if a text string is a valid boolean representation. |
static boolean |
ifByte(java.lang.String text)
Check if a text string is a valid byte representation. |
static boolean |
ifDate(java.lang.String text)
Check if a text string follows the schema date format. |
static boolean |
ifDateTime(java.lang.String text)
Check if a text string follows the schema dateTime format. |
static boolean |
ifDigits(java.lang.String text,
int offset,
int limit)
Check if a portion of a text string consists of decimal digits. |
static boolean |
ifFixedDigits(java.lang.String text,
int offset,
java.lang.String bound)
Check if a portion of a text string is a bounded string of decimal digits. |
static boolean |
ifInIntegerRange(java.lang.String text,
int digitmax,
java.lang.String abslimit)
Check if a text string is a valid integer subtype representation. |
static boolean |
ifInt(java.lang.String text)
Check if a text string is a valid int representation. |
static boolean |
ifInteger(java.lang.String text)
Check if a text string is a valid integer representation. |
static boolean |
ifLong(java.lang.String text)
Check if a text string is a valid long representation. |
static boolean |
ifShort(java.lang.String text)
Check if a text string is a valid short representation. |
static boolean |
ifTime(java.lang.String text)
Check if a text string follows the schema dateTime format. |
static boolean |
ifTimeSuffix(java.lang.String text,
int offset)
Check if a text string ends with a valid time suffix. |
static boolean |
ifZoneSuffix(java.lang.String text,
int offset)
Check if a text string ends with a valid zone suffix. |
static boolean |
isEqual(java.lang.Object a,
java.lang.Object b)
General object comparison method. |
static byte[] |
parseBase64(java.lang.String text)
Parse base64 data from text. |
static boolean |
parseBoolean(java.lang.String text)
Parse boolean value from text. |
static byte |
parseByte(java.lang.String text)
Parse byte value from text. |
static char |
parseChar(java.lang.String text)
Parse char value from text as unsigned 16-bit integer. |
static char |
parseCharString(java.lang.String text)
Parse char value from text as character value. |
static long |
parseDate(java.lang.String text)
Convert date text to Java date. |
static long |
parseDateTime(java.lang.String text)
Parse general dateTime value from text. |
static double |
parseDouble(java.lang.String text)
Parse double value from text. |
static float |
parseFloat(java.lang.String text)
Parse float value from text. |
static int |
parseInt(java.lang.String text)
Parse integer value from text. |
static long |
parseLong(java.lang.String text)
Parse long value from text. |
static short |
parseShort(java.lang.String text)
Parse short value from text. |
static long |
parseTime(java.lang.String text,
int start,
int length)
Parse general time value from text. |
static long |
parseYear(java.lang.String text)
Convert gYear text to Java date. |
static long |
parseYearMonth(java.lang.String text)
Convert gYearMonth text to Java date. |
static java.lang.Object |
resizeArray(int size,
java.lang.Object base)
Resize array of arbitrary type. |
static boolean |
safeEquals(java.lang.Object a,
java.lang.Object b)
Safe equals test. |
static java.lang.String |
serializeBase64(byte[] byts)
Serialize byte array to base64 text. |
static java.lang.String |
serializeBoolean(boolean value)
Serialize boolean value to text. |
static java.lang.String |
serializeByte(byte value)
Serialize byte value to text. |
static java.lang.String |
serializeChar(char value)
Serialize char value to text as unsigned 16-bit integer. |
static java.lang.String |
serializeCharString(char value)
Serialize char value to text as string of length one. |
static java.lang.String |
serializeDate(java.util.Date date)
Serialize date to general date text. |
static java.lang.String |
serializeDate(long time)
Serialize time to general date text. |
static java.lang.String |
serializeDateTime(java.util.Date date)
Serialize date to general dateTime text. |
static java.lang.String |
serializeDateTime(long time)
Serialize time to general dateTime text. |
static java.lang.String |
serializeDateTime(long time,
boolean zone)
Serialize time to general dateTime text. |
static java.lang.String |
serializeDouble(double value)
Serialize double value to text. |
static java.lang.String |
serializeFloat(float value)
Serialize float value to text. |
static java.lang.String |
serializeInt(int value)
Serialize int value to text. |
static java.lang.String |
serializeLong(long value)
Serialize long value to text. |
static java.lang.String |
serializeShort(short value)
Serialize short value to text. |
static java.lang.String |
serializeSqlDate(java.sql.Date date)
Serialize SQL date to general date text. |
static java.lang.String |
serializeSqlTime(java.sql.Time time)
Serialize time to standard text. |
static void |
serializeTime(int time,
java.lang.StringBuffer buff)
Serialize time to general time text in buffer. |
static java.lang.String |
serializeTimestamp(java.sql.Timestamp stamp)
Serialize timestamp to general dateTime text. |
static java.lang.String |
serializeTokenList(java.lang.String[] tokens)
Serialize an array of strings into a whitespace-separated token list. |
static java.lang.String |
serializeYear(java.util.Date date)
Serialize date to general gYear text. |
static java.lang.String |
serializeYear(long time)
Serialize time to general gYear text. |
static java.lang.String |
serializeYearMonth(java.util.Date date)
Serialize date to general gYearMonth text. |
static java.lang.String |
serializeYearMonth(long time)
Serialize time to general gYearMonth text. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MINIMUM_GROWN_ARRAY_SIZE
growArray(java.lang.Object).
| Constructor Detail |
|---|
public Utility()
| Method Detail |
|---|
public static int parseInt(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeInt(int value)
value - int value to be serialized
public static boolean ifBoolean(java.lang.String text)
text -
true if valid boolean, false if not
public static long parseLong(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeLong(long value)
value - long value to be serialized
public static long parseYear(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse error
public static short parseShort(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeShort(short value)
value - short value to be serialized
public static byte parseByte(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeByte(byte value)
value - byte value to be serialized
public static boolean parseBoolean(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeBoolean(boolean value)
value - boolean value to be serialized
public static char parseChar(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeChar(char value)
value - char value to be serialized
public static char parseCharString(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse error
public static char deserializeCharString(java.lang.String text)
throws JiBXException
text - text to be parsed (may be null)
JiBXException - on parse errorpublic static java.lang.String serializeCharString(char value)
value - char value to be serialized
public static float parseFloat(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeFloat(float value)
value - float value to be serialized
public static double parseDouble(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse errorpublic static java.lang.String serializeDouble(double value)
value - double value to be serialized
public static long parseYearMonth(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse error
public static long parseDate(java.lang.String text)
throws JiBXException
java.util.Date but will typically not be the
expected value if you're using a java.util.Calendar on the
result. In this case you probably want to instead use deserializeSqlDate(String), which does adjust the value to match
the local time zone.
text - text to be parsed
JiBXException - on parse error
public static java.util.Date deserializeDate(java.lang.String text)
throws JiBXException
null input.
Note that the returned value is based on UTC, which matches the
definition of java.util.Date but will typically not be the
expected value if you're using a java.util.Calendar on the
result. In this case you probably want to instead use deserializeSqlDate(String), which does adjust the value to match
the local time zone.
text - text to be parsed (may be null)
null if passed null
input
JiBXException - on parse error
public static java.sql.Date deserializeSqlDate(java.lang.String text)
throws JiBXException
null input.
text - text to be parsed (may be null)
null if passed null
input
JiBXException - on parse error
public static long parseTime(java.lang.String text,
int start,
int length)
throws JiBXException
text - text to be parsedstart - offset of first character of time valuelength - number of characters in time value
JiBXException - on parse error
public static long parseDateTime(java.lang.String text)
throws JiBXException
text - text to be parsed
JiBXException - on parse error
public static java.util.Date deserializeDateTime(java.lang.String text)
throws JiBXException
null input.
text - text to be parsed (may be null)
null if passed null
input
JiBXException - on parse error
public static java.sql.Timestamp deserializeTimestamp(java.lang.String text)
throws JiBXException
null input.
text - text to be parsed (may be null)
null if passed
null input
JiBXException - on parse error
public static java.sql.Time deserializeSqlTime(java.lang.String text)
throws JiBXException
null input.
text - text to be parsed (may be null)
null if passed null
input
JiBXException - on parse errorpublic static java.lang.String serializeYear(long time)
time - time to be converted, as milliseconds from January 1, 1970
public static java.lang.String serializeYear(java.util.Date date)
date - date to be converted
public static java.lang.String serializeYearMonth(long time)
time - time to be converted, as milliseconds from January 1, 1970
public static java.lang.String serializeYearMonth(java.util.Date date)
date - date to be converted
public static java.lang.String serializeDate(long time)
time - time to be converted, as milliseconds from January 1, 1970
public static java.lang.String serializeDate(java.util.Date date)
java.util.Date but may not match the value as
serialized using java.util.Calendar (which assumes values
are in the local time zone). To work with values in the local time zone
you want to instead use serializeSqlDate(java.sql.Date).
date - date to be converted
public static java.lang.String serializeSqlDate(java.sql.Date date)
java.sql.Date type.
date - date to be converted
public static void serializeTime(int time,
java.lang.StringBuffer buff)
time - time to be converted, as milliseconds in daybuff - buffer for appending time text
public static java.lang.String serializeDateTime(long time,
boolean zone)
time - time to be converted, as milliseconds from January 1, 1970zone - flag for trailing 'Z' to be appended to indicate UTC
public static java.lang.String serializeDateTime(long time)
time - time to be converted, as milliseconds from January 1, 1970
public static java.lang.String serializeDateTime(java.util.Date date)
date - date to be converted
public static java.lang.String serializeTimestamp(java.sql.Timestamp stamp)
stamp - timestamp to be converted
public static java.lang.String serializeSqlTime(java.sql.Time time)
time - time to be converted
public static boolean isEqual(java.lang.Object a,
java.lang.Object b)
a - first object to be comparedb - second object to be compared
true if both objects are null, or if
a.equals(b); false otherwise
public static int enumValue(java.lang.String target,
java.lang.String[] enums,
int[] vals)
throws JiBXException
target - text to be found in enumerationenums - ordered array of texts included in enumerationvals - array of values to be returned for corresponding text match
positions (position returned directly if this is null)
JiBXException - if target text not found in enumeration
public static byte[] parseBase64(java.lang.String text)
throws JiBXException
text - text to be parsed (may include extra characters)
JiBXException - if invalid character in base64 representation
public static byte[] deserializeBase64(java.lang.String text)
throws JiBXException
text - text to be parsed (may be null, or include extra characters)
JiBXException - if invalid character in base64 representation
public static void encodeChunk(int base,
byte[] byts,
java.lang.StringBuffer buff)
base - starting offset within byte arraybyts - byte data arraybuff - buffer for encoded textpublic static java.lang.String serializeBase64(byte[] byts)
byts - byte data array
public static java.lang.Object resizeArray(int size,
java.lang.Object base)
size - new aray sizebase - array to be resized
public static java.lang.Object growArray(java.lang.Object base)
base - array to be grown
public static java.util.List arrayListFactory()
java.util.ArrayList as the
implementation of a java.util.List.
java.util.ArrayList
public static java.util.ArrayList deserializeList(java.lang.String text,
IListItemDeserializer ideser)
throws JiBXException
text - value to be convertedideser - list item deserializer
null if input
null, or if nonrecoverable error)
JiBXException - if error in deserializing text
public static java.lang.String[] deserializeTokenList(java.lang.String text)
throws JiBXException
text - value text
JiBXException - on error in marshallingpublic static java.lang.String serializeTokenList(java.lang.String[] tokens)
tokens - array of strings to be serialized
public static boolean safeEquals(java.lang.Object a,
java.lang.Object b)
null.
a - b -
true if both null or a.equals(b),
false otherwise
public static boolean ifInIntegerRange(java.lang.String text,
int digitmax,
java.lang.String abslimit)
text - (non-null)digitmax - maximum number of digits allowedabslimit - largest absolute value allowed (null if no
limit)
true if valid representation, false if
notpublic static boolean ifByte(java.lang.String text)
text - (non-null)
true if valid byte, false if notpublic static boolean ifShort(java.lang.String text)
text - (non-null)
true if valid short, false if notpublic static boolean ifInt(java.lang.String text)
text - (non-null)
true if valid int, false if notpublic static boolean ifLong(java.lang.String text)
text - (non-null)
true if valid long, false if notpublic static boolean ifInteger(java.lang.String text)
text - (non-null)
true if valid integer, false if not
public static boolean ifDigits(java.lang.String text,
int offset,
int limit)
text - offset - starting offsetlimit - ending offset plus one (false return if the
text length is less than this value)
true if digits, false if not
public static boolean ifFixedDigits(java.lang.String text,
int offset,
java.lang.String bound)
text - offset - bound -
true if bounded decimal, false if not
public static boolean ifZoneSuffix(java.lang.String text,
int offset)
text - offset -
true if valid suffix, false if notpublic static boolean ifDate(java.lang.String text)
text - (non-null)
true if date format, false if not
public static boolean ifTimeSuffix(java.lang.String text,
int offset)
text - offset -
true if valid suffix, false if notpublic static boolean ifDateTime(java.lang.String text)
text - (non-null)
true if date format, false if notpublic static boolean ifTime(java.lang.String text)
text - (non-null)
true if date format, false if not
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||