Package org.jibx.runtime
Class Utility
java.lang.Object
org.jibx.runtime.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.
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DateDate for setting change to Gregorian calendar.private static final long[]Millisecond count prior to start of month in March 1-biased year.static final String[]Empty array of strings.private static final longNumber of milliseconds in a day as a long.static final intMinimum size for array returned bygrowArray(java.lang.Object).(package private) static final int[]Day number for start of month in non-leap year.(package private) static final int[]Day number for start of month in non-leap year.private static final longAverage number of milliseconds in a year within century.private static final longNumber of milliseconds in a normal century.private static final intNumber of milliseconds in a day.private static final intNumber of milliseconds in an hour.private static final intNumber of milliseconds in a minute.private static final longNumber of milliseconds in a (non-leap) year.private static final charPad character for base64 encoding.private static final char[]Characters used in base64 encoding.private static final byte[]Values corresponding to characters used in bas64 encoding.(package private) static final longMillisecond value of base time for internal representation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ListFactory method to create ajava.util.ArrayListas the implementation of ajava.util.List.private static intdecodeChunk(int base, char[] chrs, int fill, byte[] byts) Decode a chunk of data from base64 encoding.static byte[]deserializeBase64(String text) Parse base64 data from text.static BooleandeserializeBoolean(String text) Deserialize boolean value from text.static chardeserializeCharString(String text) Deserialize char value from text as character value.static DatedeserializeDate(String text) Deserialize date from text.static DatedeserializeDateTime(String text) Deserialize date from general dateTime text.static ArrayListdeserializeList(String text, IListItemDeserializer ideser) Convert whitespace-separated list of values.static DatedeserializeSqlDate(String text) Deserialize SQL date from text.static TimedeserializeSqlTime(String text) Deserialize time from text.static TimestampdeserializeTimestamp(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 voidencodeChunk(int base, byte[] byts, StringBuffer buff) Encode a chunk of data to base64 encoding.static intFind text value in enumeration.protected static voidformatTwoDigits(int value, StringBuffer buff) Format a positive number as two digits.protected static voidformatYear(long value, StringBuffer buff) Format time in milliseconds to year number.protected static longformatYearMonth(long value, StringBuffer buff) Format time in milliseconds to year number and month number.protected static intformatYearMonthDay(long value, StringBuffer buff) Format time in milliseconds to year number, month number, and day number.protected static voidformatYearNumber(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 ObjectGrow array of arbitrary type.static booleanCheck if a text string is a valid boolean representation.static booleanCheck if a text string is a valid byte representation.static booleanCheck if a text string follows the schema date format.static booleanifDateTime(String text) Check if a text string follows the schema dateTime format.static booleanCheck if a text string is a valid decimal representation.static booleanCheck if a portion of a text string consists of decimal digits.static booleanifEqualSubstring(String match, String text, int offset) Check if a substring matches a supplied value.static booleanifFixedDigits(String text, int offset, String bound) Check if a portion of a text string is a bounded string of decimal digits.static booleanifInIntegerRange(String text, int digitmax, String abslimit) Check if a text string is a valid integer subtype representation.static booleanCheck if a text string is a valid int representation.static booleanCheck if a text string is a valid integer representation.static booleanCheck if a text string is a valid long representation.static booleanCheck if a text string is a valid short representation.static booleanCheck if a text string follows the schema dateTime format.static booleanifTimeSuffix(String text, int offset) Check if a text string ends with a valid time suffix.static booleanifZoneSuffix(String text, int offset) Check if a text string ends with a valid zone suffix.static booleanGeneral object comparison method.static byte[]parseBase64(String text) Parse base64 data from text.static booleanparseBoolean(String text) Parse boolean value from text.static byteParse byte value from text.static charParse char value from text as unsigned 16-bit integer.static charparseCharString(String text) Parse char value from text as character value.static longConvert date text to Java date.static longparseDateTime(String text) Parse general dateTime value from text.(package private) static intparseDigits(String text, int offset, int length) Parse digits in text as integer value.static doubleparseDouble(String text) Parse double value from text.static floatparseFloat(String text) Parse float value from text.static intParse integer value from text.static longParse long value from text.static shortparseShort(String text) Parse short value from text.static longParse general time value from text.static longparseTimeNoOffset(String text, int start, int length) Parse general time value from text.static longConvert gYear text to Java date.static longparseYearMonth(String text) Convert gYearMonth text to Java date.static ObjectresizeArray(int size, Object base) Resize array of arbitrary type.static booleansafeEquals(Object a, Object b) Safe equals test.static StringserializeBase64(byte[] byts) Serialize byte array to base64 text.static StringserializeBoolean(boolean value) Serialize boolean value to text.static StringserializeBoolean(Boolean value) Serialize boolean value to text.static StringserializeByte(byte value) Serialize byte value to text.static StringserializeChar(char value) Serialize char value to text as unsigned 16-bit integer.static StringserializeCharString(char value) Serialize char value to text as string of length one.static StringserializeDate(long time) Serialize time to general date text.static StringserializeDate(Date date) Serialize date to general date text.static StringserializeDateTime(long time) Serialize time to general dateTime text.static StringserializeDateTime(long time, boolean zone) Serialize time to general dateTime text.static StringserializeDateTime(Date date) Serialize date to general dateTime text.static StringserializeDouble(double value) Serialize double value to text.static voidserializeExplicitOffset(int offset, StringBuffer buff) Serialize time zone offset to buffer.static StringserializeFloat(float value) Serialize float value to text.static StringserializeInt(int value) Serialize int value to text.static StringserializeLong(long value) Serialize long value to text.static voidserializeOffset(int offset, StringBuffer buff) Serialize time zone offset to buffer.static StringserializeShort(short value) Serialize short value to text.static StringserializeSqlDate(Date date) Serialize SQL date to general date text.static StringserializeSqlTime(Time time) Serialize time to standard text.static voidserializeTime(int time, StringBuffer buff) Serialize time to general time text in buffer.static StringserializeTimestamp(Timestamp stamp) Serialize timestamp to general dateTime text.static StringserializeTokenList(String[] tokens) Serialize an array of strings into a whitespace-separated token list.static StringserializeYear(long time) Serialize time to general gYear text.static StringserializeYear(Date date) Serialize date to general gYear text.static StringserializeYearMonth(long time) Serialize time to general gYearMonth text.static StringserializeYearMonth(Date date) Serialize date to general gYearMonth text.
-
Field Details
-
EMPTY_STRING_ARRAY
Empty array of strings. -
MINIMUM_GROWN_ARRAY_SIZE
public static final int MINIMUM_GROWN_ARRAY_SIZEMinimum size for array returned bygrowArray(java.lang.Object).- See Also:
-
MSPERMINUTE
private static final int MSPERMINUTENumber of milliseconds in a minute.- See Also:
-
MSPERHOUR
private static final int MSPERHOURNumber of milliseconds in an hour.- See Also:
-
MSPERDAY
private static final int MSPERDAYNumber of milliseconds in a day.- See Also:
-
LMSPERDAY
private static final long LMSPERDAYNumber of milliseconds in a day as a long.- See Also:
-
MSPERYEAR
private static final long MSPERYEARNumber of milliseconds in a (non-leap) year.- See Also:
-
MSPERAVGYEAR
private static final long MSPERAVGYEARAverage number of milliseconds in a year within century.- See Also:
-
MSPERCENTURY
private static final long MSPERCENTURYNumber of milliseconds in a normal century.- See Also:
-
TIME_BASE
static final long TIME_BASEMillisecond value of base time for internal representation. This gives the bias relative to January 1 of the year 1 C.E.- See Also:
-
MONTHS_NONLEAP
static final int[] MONTHS_NONLEAPDay number for start of month in non-leap year. -
MONTHS_LEAP
static final int[] MONTHS_LEAPDay number for start of month in non-leap year. -
BIAS_MONTHMS
private static final long[] BIAS_MONTHMSMillisecond count prior to start of month in March 1-biased year. -
BEGINNING_OF_TIME
Date for setting change to Gregorian calendar. -
PAD_CHAR
private static final char PAD_CHARPad character for base64 encoding.- See Also:
-
s_base64Chars
private static final char[] s_base64CharsCharacters used in base64 encoding. -
s_base64Values
private static final byte[] s_base64ValuesValues corresponding to characters used in bas64 encoding.
-
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
parseDigits
Parse digits in text as integer value. This internal method is used for number values embedded within lexical structures. Only decimal digits can be included in the text range parsed.- Parameters:
text- text to be parsedoffset- starting offset in textlength- number of digits to be parsed- Returns:
- converted positive integer value
- Throws:
JiBXException- on parse error
-
parseInt
Parse integer value from text. Integer values are parsed with optional leading sign flag, followed by any number of digits.- Parameters:
text- text to be parsed- Returns:
- converted integer value
- Throws:
JiBXException- on parse error
-
serializeInt
Serialize int value to text.- Parameters:
value- int value to be serialized- Returns:
- text representation of value
-
ifBoolean
Check if a text string is a valid boolean representation.- Parameters:
text-- Returns:
trueif valid boolean,falseif not
-
parseLong
Parse long value from text. Long values are parsed with optional leading sign flag, followed by any number of digits.- Parameters:
text- text to be parsed- Returns:
- converted long value
- Throws:
JiBXException- on parse error
-
serializeLong
Serialize long value to text.- Parameters:
value- long value to be serialized- Returns:
- text representation of value
-
parseYear
Convert gYear text to Java date. Date values are expected to be in W3C XML Schema standard format as CCYY, with optional leading sign.- Parameters:
text- text to be parsed- Returns:
- start of year date as millisecond value from 1 C.E.
- Throws:
JiBXException- on parse error
-
parseShort
Parse short value from text. Short values are parsed with optional leading sign flag, followed by any number of digits.- Parameters:
text- text to be parsed- Returns:
- converted short value
- Throws:
JiBXException- on parse error
-
serializeShort
Serialize short value to text.- Parameters:
value- short value to be serialized- Returns:
- text representation of value
-
parseByte
Parse byte value from text. Byte values are parsed with optional leading sign flag, followed by any number of digits.- Parameters:
text- text to be parsed- Returns:
- converted byte value
- Throws:
JiBXException- on parse error
-
serializeByte
Serialize byte value to text.- Parameters:
value- byte value to be serialized- Returns:
- text representation of value
-
parseBoolean
Parse boolean value from text. Boolean values are parsed as either text "true" and "false", or "1" and "0" numeric equivalents.- Parameters:
text- text to be parsed- Returns:
- converted boolean value
- Throws:
JiBXException- on parse error
-
deserializeBoolean
Deserialize boolean value from text. If the text isnullthis just returnsnull; otherwise it returns the wrapped parsed value.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted Boolean value
- Throws:
JiBXException- on parse error
-
serializeBoolean
Serialize boolean value to text. This serializes the value using the text representation as "true" or "false".- Parameters:
value- boolean value to be serialized- Returns:
- text representation of value
-
serializeBoolean
Serialize boolean value to text. If the value isnullthis just returnsnull; otherwise it serializes the value usingserializeBoolean(boolean).- Parameters:
value- value to be serialized- Returns:
- text representation of value
-
parseChar
Parse char value from text as unsigned 16-bit integer. Char values are parsed with optional leading sign flag, followed by any number of digits.- Parameters:
text- text to be parsed- Returns:
- converted char value
- Throws:
JiBXException- on parse error
-
serializeChar
Serialize char value to text as unsigned 16-bit integer.- Parameters:
value- char value to be serialized- Returns:
- text representation of value
-
parseCharString
Parse char value from text as character value. This requires that the string must be of length one.- Parameters:
text- text to be parsed- Returns:
- converted char value
- Throws:
JiBXException- on parse error
-
deserializeCharString
Deserialize char value from text as character value. This requires that the string must be null or of length one.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted char value
- Throws:
JiBXException- on parse error
-
serializeCharString
Serialize char value to text as string of length one.- Parameters:
value- char value to be serialized- Returns:
- text representation of value
-
parseFloat
Parse float value from text. This uses the W3C XML Schema format for floats, with the exception that it will accept "+NaN" and "-NaN" as valid formats. This is not in strict compliance with the specification, but is included for interoperability with other Java XML processing.- Parameters:
text- text to be parsed- Returns:
- converted float value
- Throws:
JiBXException- on parse error
-
serializeFloat
Serialize float value to text.- Parameters:
value- float value to be serialized- Returns:
- text representation of value
-
parseDouble
Parse double value from text. This uses the W3C XML Schema format for doubles, with the exception that it will accept "+NaN" and "-NaN" as valid formats. This is not in strict compliance with the specification, but is included for interoperability with other Java XML processing.- Parameters:
text- text to be parsed- Returns:
- converted double value
- Throws:
JiBXException- on parse error
-
serializeDouble
Serialize double value to text.- Parameters:
value- double value to be serialized- Returns:
- text representation of value
-
parseYearMonth
Convert gYearMonth text to Java date. Date values are expected to be in W3C XML Schema standard format as CCYY-MM, with optional leading sign.- Parameters:
text- text to be parsed- Returns:
- start of month in year date as millisecond value
- Throws:
JiBXException- on parse error
-
parseDate
Convert date text to Java date. Date values are expected to be in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone (though the time zone is ignored in this case). Note that the returned value is based on UTC, which matches the definition ofjava.util.Datebut will typically not be the expected value if you're using ajava.util.Calendaron the result. In this case you probably want to instead usedeserializeSqlDate(String), which does adjust the value to match the local time zone.- Parameters:
text- text to be parsed- Returns:
- start of day in month and year date as millisecond value
- Throws:
JiBXException- on parse error
-
deserializeDate
Deserialize date from text. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone (though the time zone is ignored in this case). This method follows standard JiBX deserializer usage requirements by accepting anullinput. Note that the returned value is based on UTC, which matches the definition ofjava.util.Datebut will typically not be the expected value if you're using ajava.util.Calendaron the result. In this case you probably want to instead usedeserializeSqlDate(String), which does adjust the value to match the local time zone.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeSqlDate
Deserialize SQL date from text. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign and trailing time zone (though the time zone is ignored in this case). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
parseTimeNoOffset
Parse general time value from text. Time values are expected to be in W3C XML Schema standard format as hh:mm:ss.fff, with optional leading sign and trailing time zone. This method ignores any time zone offset, just converting the value as supplied.- Parameters:
text- text to be parsedstart- offset of first character of time valuelength- number of characters in time value- Returns:
- converted time as millisecond value
- Throws:
JiBXException- on parse error
-
parseTime
Parse general time value from text. Time values are expected to be in W3C XML Schema standard format as hh:mm:ss.fff, with optional leading sign and trailing time zone. This method always adjusts the returned value to UTC if a time zone offset is supplied.- Parameters:
text- text to be parsedstart- offset of first character of time valuelength- number of characters in time value- Returns:
- converted time as millisecond value
- Throws:
JiBXException- on parse error
-
parseDateTime
Parse general dateTime value from text. Date values are expected to be in W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss.fff, with optional leading sign and trailing time zone. This method always adjusts the returned value to UTC if a time zone offset is supplied.- Parameters:
text- text to be parsed- Returns:
- converted date as millisecond value
- Throws:
JiBXException- on parse error
-
deserializeDateTime
Deserialize date from general dateTime text. Date values are expected to match W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss, with optional leading minus sign and trailing seconds decimal, as necessary. This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted date, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeTimestamp
Deserialize timestamp from general dateTime text. Timestamp values are represented in the same way as regular dates, but allow more precision in the fractional second value (down to nanoseconds). This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted timestamp, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
deserializeSqlTime
Deserialize time from text. Time values obey the rules of the time portion of a dataTime value. This method follows standard JiBX deserializer usage requirements by accepting anullinput.- Parameters:
text- text to be parsed (may benull)- Returns:
- converted time, or
nullif passednullinput - Throws:
JiBXException- on parse error
-
formatYearNumber
Format year number consistent with W3C XML Schema definitions, using a minimum of four digits padded with zeros if necessary. A leading minus sign is included for years prior to 1 C.E.- Parameters:
year- number to be formattedbuff- text formatting buffer
-
formatTwoDigits
Format a positive number as two digits. This uses an optional leading zero digit for values less than ten.- Parameters:
value- number to be formatted (0to99)buff- text formatting buffer
-
formatYear
Format time in milliseconds to year number. The resulting year number format is consistent with W3C XML Schema definitions, using a minimum of four digits padded with zeros if necessary. A leading minus sign is included for years prior to 1 C.E.- Parameters:
value- time in milliseconds to be converted (from 1 C.E.)buff- text formatting buffer
-
formatYearMonth
Format time in milliseconds to year number and month number. The resulting year number format is consistent with W3C XML Schema definitions, using a minimum of four digits for the year and exactly two digits for the month.- Parameters:
value- time in milliseconds to be converted (from 1 C.E.)buff- text formatting buffer- Returns:
- number of milliseconds into month
-
formatYearMonthDay
Format time in milliseconds to year number, month number, and day number. The resulting year number format is consistent with W3C XML Schema definitions, using a minimum of four digits for the year and exactly two digits each for the month and day.- Parameters:
value- time in milliseconds to be converted (from 1 C.E.)buff- text formatting buffer- Returns:
- number of milliseconds into day
-
serializeYear
Serialize time to general gYear text. Date values are formatted in W3C XML Schema standard format as CCYY, with optional leading sign included if necessary.- Parameters:
time- time to be converted, as milliseconds from January 1, 1970- Returns:
- converted gYear text
-
serializeYear
Serialize date to general gYear text. Date values are formatted in W3C XML Schema standard format as CCYY, with optional leading sign included if necessary.- Parameters:
date- date to be converted- Returns:
- converted gYear text
-
serializeYearMonth
Serialize time to general gYearMonth text. Date values are formatted in W3C XML Schema standard format as CCYY-MM, with optional leading sign included if necessary.- Parameters:
time- time to be converted, as milliseconds from January 1, 1970- Returns:
- converted gYearMonth text
-
serializeYearMonth
Serialize date to general gYearMonth text. Date values are formatted in W3C XML Schema standard format as CCYY-MM, with optional leading sign included if necessary.- Parameters:
date- date to be converted- Returns:
- converted gYearMonth text
-
serializeDate
Serialize time to general date text. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign included if necessary.- Parameters:
time- time to be converted, as milliseconds from January 1, 1970- Returns:
- converted date text
-
serializeDate
Serialize date to general date text. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign included if necessary. Note that the conversion is based on UTC, which matches the definition ofjava.util.Datebut may not match the value as serialized usingjava.util.Calendar(which assumes values are in the local time zone). To work with values in the local time zone you want to instead useserializeSqlDate(java.sql.Date).- Parameters:
date- date to be converted- Returns:
- converted date text
-
serializeSqlDate
Serialize SQL date to general date text. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DD, with optional leading sign included if necessary. This interprets the date value with respect to the local time zone, as fits the definition of thejava.sql.Datetype.- Parameters:
date- date to be converted- Returns:
- converted date text
-
serializeExplicitOffset
Serialize time zone offset to buffer. Time zone offset values are always formatted in W3C XML Schema standard format as +/-hh:mm (even if the offset is zero).- Parameters:
offset- milliseconds to be subtracted to get UTC from local timebuff- buffer for appending time text
-
serializeOffset
Serialize time zone offset to buffer. Time zone offset values are formatted in W3C XML Schema standard format as +/-hh:mm, with 'Z' used if the offset is zero.- Parameters:
offset- milliseconds to be subtracted to get UTC from local timebuff- buffer for appending time text
-
serializeTime
Serialize time to general time text in buffer. Time values are formatted in W3C XML Schema standard format as hh:mm:ss, with optional trailing seconds decimal, as necessary. This form uses a supplied buffer to support flexible use, including with dateTime combination values.- Parameters:
time- time to be converted, as milliseconds in daybuff- buffer for appending time text
-
serializeDateTime
Serialize time to general dateTime text. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss, with optional leading sign and trailing seconds decimal, as necessary.- Parameters:
time- time to be converted, as milliseconds from January 1, 1970zone- flag for trailing 'Z' to be appended to indicate UTC- Returns:
- converted dateTime text
-
serializeDateTime
Serialize time to general dateTime text. This method is provided for backward compatibility. It generates the dateTime text without the trailing 'Z' to indicate UTC.- Parameters:
time- time to be converted, as milliseconds from January 1, 1970- Returns:
- converted dateTime text
-
serializeDateTime
Serialize date to general dateTime text. Date values are formatted in W3C XML Schema standard format as CCYY-MM-DDThh:mm:ssZ, with optional leading sign and trailing seconds decimal, as necessary.- Parameters:
date- date to be converted- Returns:
- converted dateTime text
-
serializeTimestamp
Serialize timestamp to general dateTime text. Timestamp values are represented in the same way as regular dates, but allow more precision in the fractional second value (down to nanoseconds).- Parameters:
stamp- timestamp to be converted- Returns:
- converted dateTime text
-
serializeSqlTime
Serialize time to standard text. Time values are formatted in W3C XML Schema standard format as hh:mm:ss, with optional trailing seconds decimal, as necessary. The standard conversion does not append a time zone indication.- Parameters:
time- time to be converted- Returns:
- converted time text
-
isEqual
General object comparison method. Don't know why Sun hasn't seen fit to include this somewhere, but at least it's easy to write (over and over again).- Parameters:
a- first object to be comparedb- second object to be compared- Returns:
trueif both objects arenull, or ifa.equals(b);falseotherwise
-
enumValue
Find text value in enumeration. This first does a binary search through an array of allowed text matches. If a separate array of corresponding values is supplied, the value at the matched position is returned; otherwise the match index is returned directly.- Parameters:
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 isnull)- Returns:
- enumeration value for target text
- Throws:
JiBXException- if target text not found in enumeration
-
decodeChunk
private static int decodeChunk(int base, char[] chrs, int fill, byte[] byts) Decode a chunk of data from base64 encoding. The length of a chunk is always 4 characters in the base64 representation, but may be 1, 2, or 3 bytes of data, as determined by whether there are any pad characters at the end of the base64 representation- Parameters:
base- starting offset within base64 character arraychrs- character array for base64 text representationfill- starting offset within byte data arraybyts- byte data array- Returns:
- number of decoded bytes
-
parseBase64
Parse base64 data from text. This converts the base64 data into a byte array of the appopriate length. In keeping with the recommendations,- Parameters:
text- text to be parsed (may include extra characters)- Returns:
- byte array of data
- Throws:
JiBXException- if invalid character in base64 representation
-
deserializeBase64
Parse base64 data from text. This converts the base64 data into a byte array of the appopriate length. In keeping with the recommendations,- Parameters:
text- text to be parsed (may be null, or include extra characters)- Returns:
- byte array of data
- Throws:
JiBXException- if invalid character in base64 representation
-
encodeChunk
Encode a chunk of data to base64 encoding. Converts the next three bytes of data into four characters of text representation, using padding at the end of less than three bytes of data remain.- Parameters:
base- starting offset within byte arraybyts- byte data arraybuff- buffer for encoded text
-
serializeBase64
Serialize byte array to base64 text. In keeping with the specification, this adds a line break every 76 characters in the encoded representation.- Parameters:
byts- byte data array- Returns:
- base64 encoded text
-
resizeArray
Resize array of arbitrary type.- Parameters:
size- new aray sizebase- array to be resized- Returns:
- resized array, with all data to minimum of the two sizes copied
-
growArray
Grow array of arbitrary type. The returned array is double the size of the original array, providing this is at least the defined minimum size.- Parameters:
base- array to be grown- Returns:
- array of twice the size as original array, with all data copied
-
arrayListFactory
Factory method to create ajava.util.ArrayListas the implementation of ajava.util.List.- Returns:
- new
java.util.ArrayList
-
deserializeList
public static ArrayList deserializeList(String text, IListItemDeserializer ideser) throws JiBXException Convert whitespace-separated list of values. This implements the whitespace skipping, calling the supplied item deserializer for handling each individual value.- Parameters:
text- value to be convertedideser- list item deserializer- Returns:
- list of deserialized items (
nullif inputnull, or if nonrecoverable error) - Throws:
JiBXException- if error in deserializing text
-
deserializeTokenList
Deserialize a list of whitespace-separated tokens into an array of strings.- Parameters:
text- value text- Returns:
- created class instance
- Throws:
JiBXException- on error in marshalling
-
serializeTokenList
Serialize an array of strings into a whitespace-separated token list.- Parameters:
tokens- array of strings to be serialized- Returns:
- list text
-
safeEquals
Safe equals test. This does an equals comparison for objects which may benull.- Parameters:
a-b-- Returns:
trueif bothnullor a.equals(b),falseotherwise
-
ifEqualSubstring
Check if a substring matches a supplied value.- Parameters:
match- comparison texttext- string to be comparedoffset- starting offset for comparison- Returns:
trueif substring match,falseif not
-
ifInIntegerRange
Check if a text string is a valid integer subtype representation.- Parameters:
text- (non-null)digitmax- maximum number of digits allowedabslimit- largest absolute value allowed (nullif no limit)- Returns:
trueif valid representation,falseif not
-
ifByte
Check if a text string is a valid byte representation.- Parameters:
text- (non-null)- Returns:
trueif valid byte,falseif not
-
ifShort
Check if a text string is a valid short representation.- Parameters:
text- (non-null)- Returns:
trueif valid short,falseif not
-
ifInt
Check if a text string is a valid int representation.- Parameters:
text- (non-null)- Returns:
trueif valid int,falseif not
-
ifLong
Check if a text string is a valid long representation.- Parameters:
text- (non-null)- Returns:
trueif valid long,falseif not
-
ifInteger
Check if a text string is a valid integer representation.- Parameters:
text- (non-null)- Returns:
trueif valid integer,falseif not
-
ifDigits
Check if a portion of a text string consists of decimal digits.- Parameters:
text-offset- starting offsetlimit- ending offset plus one (falsereturn if the text length is less than this value)- Returns:
trueif digits,falseif not
-
ifDecimal
Check if a text string is a valid decimal representation.- Parameters:
text- (non-null)- Returns:
trueif valid decimal,falseif not
-
ifFixedDigits
Check if a portion of a text string is a bounded string of decimal digits. This is used for checking fixed-length decimal fields with a maximum value.- Parameters:
text-offset-bound-- Returns:
trueif bounded decimal,falseif not
-
ifZoneSuffix
Check if a text string ends with a valid zone suffix. This accepts an empty suffix, the single letter 'Z', or an offset of +/-HH:MM.- Parameters:
text-offset-- Returns:
trueif valid suffix,falseif not
-
ifDate
Check if a text string follows the schema date format. This does not assure that the text string is actually a valid date representation, since it doesn't fully check the value ranges (such as the day number range for a particular month).- Parameters:
text- (non-null)- Returns:
trueif date format,falseif not
-
ifTimeSuffix
Check if a text string ends with a valid time suffix. This matches the format HH:MM:SS with optional training fractional seconds and optional time zone.- Parameters:
text-offset-- Returns:
trueif valid suffix,falseif not
-
ifDateTime
Check if a text string follows the schema dateTime format. This does not assure that the text string is actually a valid dateTime representation, since it doesn't fully check the value ranges (such as the day number range for a particular month).- Parameters:
text- (non-null)- Returns:
trueif date format,falseif not
-
ifTime
Check if a text string follows the schema dateTime format. This does not assure that the text string is actually a valid dateTime representation, since it doesn't fully check the value ranges (such as the day number range for a particular month).- Parameters:
text- (non-null)- Returns:
trueif date format,falseif not
-