public abstract class Utility extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
EMPTY_STRING_ARRAY
Empty array of strings.
|
static int |
MINIMUM_GROWN_ARRAY_SIZE
Minimum size for array returned by
growArray(java.lang.Object). |
| Constructor and Description |
|---|
Utility() |
| Modifier and Type | Method and Description |
|---|---|
static List |
arrayListFactory()
Factory method to create a
java.util.ArrayList as the
implementation of a java.util.List. |
static byte[] |
deserializeBase64(String text)
Parse base64 data from text.
|
static Boolean |
deserializeBoolean(String text)
Deserialize boolean value from text.
|
static char |
deserializeCharString(String text)
Deserialize char value from text as character value.
|
static Date |
deserializeDate(String text)
Deserialize date from text.
|
static Date |
deserializeDateTime(String text)
Deserialize date from general dateTime text.
|
static ArrayList |
deserializeList(String text,
IListItemDeserializer ideser)
Convert whitespace-separated list of values.
|
static Date |
deserializeSqlDate(String text)
Deserialize SQL date from text.
|
static Time |
deserializeSqlTime(String text)
Deserialize time from text.
|
static Timestamp |
deserializeTimestamp(String text)
Deserialize timestamp from general dateTime text.
|
static String[] |
deserializeTokenList(String text)
Deserialize a list of whitespace-separated tokens into an array of
strings.
|
static void |
encodeChunk(int base,
byte[] byts,
StringBuffer buff)
Encode a chunk of data to base64 encoding.
|
static int |
enumValue(String target,
String[] enums,
int[] vals)
Find text value in enumeration.
|
protected static void |
formatTwoDigits(int value,
StringBuffer buff)
Format a positive number as two digits.
|
protected static void |
formatYear(long value,
StringBuffer buff)
Format time in milliseconds to year number.
|
protected static long |
formatYearMonth(long value,
StringBuffer buff)
Format time in milliseconds to year number and month number.
|
protected static int |
formatYearMonthDay(long value,
StringBuffer buff)
Format time in milliseconds to year number, month number, and day
number.
|
protected static void |
formatYearNumber(long year,
StringBuffer buff)
Format year number consistent with W3C XML Schema definitions, using a
minimum of four digits padded with zeros if necessary.
|
static Object |
growArray(Object base)
Grow array of arbitrary type.
|
static boolean |
ifBoolean(String text)
Check if a text string is a valid boolean representation.
|
static boolean |
ifByte(String text)
Check if a text string is a valid byte representation.
|
static boolean |
ifDate(String text)
Check if a text string follows the schema date format.
|
static boolean |
ifDateTime(String text)
Check if a text string follows the schema dateTime format.
|
static boolean |
ifDecimal(String text)
Check if a text string is a valid decimal representation.
|
static boolean |
ifDigits(String text,
int offset,
int limit)
Check if a portion of a text string consists of decimal digits.
|
static boolean |
ifEqualSubstring(String match,
String text,
int offset)
Check if a substring matches a supplied value.
|
static boolean |
ifFixedDigits(String text,
int offset,
String bound)
Check if a portion of a text string is a bounded string of decimal
digits.
|
static boolean |
ifInIntegerRange(String text,
int digitmax,
String abslimit)
Check if a text string is a valid integer subtype representation.
|
static boolean |
ifInt(String text)
Check if a text string is a valid int representation.
|
static boolean |
ifInteger(String text)
Check if a text string is a valid integer representation.
|
static boolean |
ifLong(String text)
Check if a text string is a valid long representation.
|
static boolean |
ifShort(String text)
Check if a text string is a valid short representation.
|
static boolean |
ifTime(String text)
Check if a text string follows the schema dateTime format.
|
static boolean |
ifTimeSuffix(String text,
int offset)
Check if a text string ends with a valid time suffix.
|
static boolean |
ifZoneSuffix(String text,
int offset)
Check if a text string ends with a valid zone suffix.
|
static boolean |
isEqual(Object a,
Object b)
General object comparison method.
|
static byte[] |
parseBase64(String text)
Parse base64 data from text.
|
static boolean |
parseBoolean(String text)
Parse boolean value from text.
|
static byte |
parseByte(String text)
Parse byte value from text.
|
static char |
parseChar(String text)
Parse char value from text as unsigned 16-bit integer.
|
static char |
parseCharString(String text)
Parse char value from text as character value.
|
static long |
parseDate(String text)
Convert date text to Java date.
|
static long |
parseDateTime(String text)
Parse general dateTime value from text.
|
static double |
parseDouble(String text)
Parse double value from text.
|
static float |
parseFloat(String text)
Parse float value from text.
|
static int |
parseInt(String text)
Parse integer value from text.
|
static long |
parseLong(String text)
Parse long value from text.
|
static short |
parseShort(String text)
Parse short value from text.
|
static long |
parseTime(String text,
int start,
int length)
Parse general time value from text.
|
static long |
parseTimeNoOffset(String text,
int start,
int length)
Parse general time value from text.
|
static long |
parseYear(String text)
Convert gYear text to Java date.
|
static long |
parseYearMonth(String text)
Convert gYearMonth text to Java date.
|
static Object |
resizeArray(int size,
Object base)
Resize array of arbitrary type.
|
static boolean |
safeEquals(Object a,
Object b)
Safe equals test.
|
static String |
serializeBase64(byte[] byts)
Serialize byte array to base64 text.
|
static String |
serializeBoolean(boolean value)
Serialize boolean value to text.
|
static String |
serializeBoolean(Boolean value)
Serialize boolean value to text.
|
static String |
serializeByte(byte value)
Serialize byte value to text.
|
static String |
serializeChar(char value)
Serialize char value to text as unsigned 16-bit integer.
|
static String |
serializeCharString(char value)
Serialize char value to text as string of length one.
|
static String |
serializeDate(Date date)
Serialize date to general date text.
|
static String |
serializeDate(long time)
Serialize time to general date text.
|
static String |
serializeDateTime(Date date)
Serialize date to general dateTime text.
|
static String |
serializeDateTime(long time)
Serialize time to general dateTime text.
|
static String |
serializeDateTime(long time,
boolean zone)
Serialize time to general dateTime text.
|
static String |
serializeDouble(double value)
Serialize double value to text.
|
static void |
serializeExplicitOffset(int offset,
StringBuffer buff)
Serialize time zone offset to buffer.
|
static String |
serializeFloat(float value)
Serialize float value to text.
|
static String |
serializeInt(int value)
Serialize int value to text.
|
static String |
serializeLong(long value)
Serialize long value to text.
|
static void |
serializeOffset(int offset,
StringBuffer buff)
Serialize time zone offset to buffer.
|
static String |
serializeShort(short value)
Serialize short value to text.
|
static String |
serializeSqlDate(Date date)
Serialize SQL date to general date text.
|
static String |
serializeSqlTime(Time time)
Serialize time to standard text.
|
static void |
serializeTime(int time,
StringBuffer buff)
Serialize time to general time text in buffer.
|
static String |
serializeTimestamp(Timestamp stamp)
Serialize timestamp to general dateTime text.
|
static String |
serializeTokenList(String[] tokens)
Serialize an array of strings into a whitespace-separated token list.
|
static String |
serializeYear(Date date)
Serialize date to general gYear text.
|
static String |
serializeYear(long time)
Serialize time to general gYear text.
|
static String |
serializeYearMonth(Date date)
Serialize date to general gYearMonth text.
|
static String |
serializeYearMonth(long time)
Serialize time to general gYearMonth text.
|
public static final String[] EMPTY_STRING_ARRAY
public static final int MINIMUM_GROWN_ARRAY_SIZE
growArray(java.lang.Object).public static int parseInt(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeInt(int value)
value - int value to be serializedpublic static boolean ifBoolean(String text)
text - true if valid boolean, false if notpublic static long parseLong(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeLong(long value)
value - long value to be serializedpublic static long parseYear(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static short parseShort(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeShort(short value)
value - short value to be serializedpublic static byte parseByte(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeByte(byte value)
value - byte value to be serializedpublic static boolean parseBoolean(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static Boolean deserializeBoolean(String text) throws JiBXException
null
this just returns null; otherwise it returns the wrapped
parsed value.text - text to be parsed (may be null)JiBXException - on parse errorpublic static String serializeBoolean(boolean value)
value - boolean value to be serializedpublic static String serializeBoolean(Boolean value)
null this
just returns null; otherwise it serializes the value using
serializeBoolean(boolean).value - value to be serializedpublic static char parseChar(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeChar(char value)
value - char value to be serializedpublic static char parseCharString(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static char deserializeCharString(String text) throws JiBXException
text - text to be parsed (may be null)JiBXException - on parse errorpublic static String serializeCharString(char value)
value - char value to be serializedpublic static float parseFloat(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeFloat(float value)
value - float value to be serializedpublic static double parseDouble(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static String serializeDouble(double value)
value - double value to be serializedpublic static long parseYearMonth(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static long parseDate(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 parsedJiBXException - on parse errorpublic static Date deserializeDate(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
inputJiBXException - on parse errorpublic static Date deserializeSqlDate(String text) throws JiBXException
null input.text - text to be parsed (may be null)null if passed null
inputJiBXException - on parse errorpublic static long parseTimeNoOffset(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 valueJiBXException - on parse errorpublic static long parseTime(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 valueJiBXException - on parse errorpublic static long parseDateTime(String text) throws JiBXException
text - text to be parsedJiBXException - on parse errorpublic static Date deserializeDateTime(String text) throws JiBXException
null input.text - text to be parsed (may be null)null if passed null
inputJiBXException - on parse errorpublic static Timestamp deserializeTimestamp(String text) throws JiBXException
null input.text - text to be parsed (may be null)null if passed
null inputJiBXException - on parse errorpublic static Time deserializeSqlTime(String text) throws JiBXException
null input.text - text to be parsed (may be null)null if passed null
inputJiBXException - on parse errorprotected static void formatYearNumber(long year,
StringBuffer buff)
year - number to be formattedbuff - text formatting bufferprotected static void formatTwoDigits(int value,
StringBuffer buff)
value - number to be formatted (0 to 99)buff - text formatting bufferprotected static void formatYear(long value,
StringBuffer buff)
value - time in milliseconds to be converted (from 1 C.E.)buff - text formatting bufferprotected static long formatYearMonth(long value,
StringBuffer buff)
value - time in milliseconds to be converted (from 1 C.E.)buff - text formatting bufferprotected static int formatYearMonthDay(long value,
StringBuffer buff)
value - time in milliseconds to be converted (from 1 C.E.)buff - text formatting bufferpublic static String serializeYear(long time)
time - time to be converted, as milliseconds from January 1, 1970public static String serializeYear(Date date)
date - date to be convertedpublic static String serializeYearMonth(long time)
time - time to be converted, as milliseconds from January 1, 1970public static String serializeYearMonth(Date date)
date - date to be convertedpublic static String serializeDate(long time)
time - time to be converted, as milliseconds from January 1, 1970public static String serializeDate(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 convertedpublic static String serializeSqlDate(Date date)
java.sql.Date type.date - date to be convertedpublic static void serializeExplicitOffset(int offset,
StringBuffer buff)
offset - milliseconds to be subtracted to get UTC from local timebuff - buffer for appending time textpublic static void serializeOffset(int offset,
StringBuffer buff)
offset - milliseconds to be subtracted to get UTC from local timebuff - buffer for appending time textpublic static void serializeTime(int time,
StringBuffer buff)
time - time to be converted, as milliseconds in daybuff - buffer for appending time textpublic static 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 UTCpublic static String serializeDateTime(long time)
time - time to be converted, as milliseconds from January 1, 1970public static String serializeDateTime(Date date)
date - date to be convertedpublic static String serializeTimestamp(Timestamp stamp)
stamp - timestamp to be convertedpublic static String serializeSqlTime(Time time)
time - time to be convertedpublic static boolean isEqual(Object a, Object b)
a - first object to be comparedb - second object to be comparedtrue if both objects are null, or if
a.equals(b); false otherwisepublic static int enumValue(String target, 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 enumerationpublic static byte[] parseBase64(String text) throws JiBXException
text - text to be parsed (may include extra characters)JiBXException - if invalid character in base64 representationpublic static byte[] deserializeBase64(String text) throws JiBXException
text - text to be parsed (may be null, or include extra characters)JiBXException - if invalid character in base64 representationpublic static void encodeChunk(int base,
byte[] byts,
StringBuffer buff)
base - starting offset within byte arraybyts - byte data arraybuff - buffer for encoded textpublic static String serializeBase64(byte[] byts)
byts - byte data arraypublic static Object resizeArray(int size, Object base)
size - new aray sizebase - array to be resizedpublic static Object growArray(Object base)
base - array to be grownpublic static List arrayListFactory()
java.util.ArrayList as the
implementation of a java.util.List.java.util.ArrayListpublic static ArrayList deserializeList(String text, IListItemDeserializer ideser) throws JiBXException
text - value to be convertedideser - list item deserializernull if input
null, or if nonrecoverable error)JiBXException - if error in deserializing textpublic static String[] deserializeTokenList(String text) throws JiBXException
text - value textJiBXException - on error in marshallingpublic static String serializeTokenList(String[] tokens)
tokens - array of strings to be serializedpublic static boolean safeEquals(Object a, Object b)
null.a - b - true if both null or a.equals(b),
false otherwisepublic static boolean ifEqualSubstring(String match, String text, int offset)
match - comparison texttext - string to be comparedoffset - starting offset for comparisontrue if substring match, false if notpublic static boolean ifInIntegerRange(String text, int digitmax, 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(String text)
text - (non-null)true if valid byte, false if notpublic static boolean ifShort(String text)
text - (non-null)true if valid short, false if notpublic static boolean ifInt(String text)
text - (non-null)true if valid int, false if notpublic static boolean ifLong(String text)
text - (non-null)true if valid long, false if notpublic static boolean ifInteger(String text)
text - (non-null)true if valid integer, false if notpublic static boolean ifDigits(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 notpublic static boolean ifDecimal(String text)
text - (non-null)true if valid decimal, false if notpublic static boolean ifFixedDigits(String text, int offset, String bound)
text - offset - bound - true if bounded decimal, false if notpublic static boolean ifZoneSuffix(String text, int offset)
text - offset - true if valid suffix, false if notpublic static boolean ifDate(String text)
text - (non-null)true if date format, false if notpublic static boolean ifTimeSuffix(String text, int offset)
text - offset - true if valid suffix, false if notpublic static boolean ifDateTime(String text)
text - (non-null)true if date format, false if notpublic static boolean ifTime(String text)
text - (non-null)true if date format, false if notCopyright © 2005-2014 jibx.org. All Rights Reserved.