public abstract class PofHelper extends Base implements PofConstants
Modifier and Type | Class and Description |
---|---|
static class |
PofHelper.ReadableEntrySetMap
Map implementation backed by a List of Map.Entry objects.
|
static class |
PofHelper.WriteableEntrySetMap
Immutable Map implementation backed by a Set of Map.Entry objects.
|
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
static BigDecimal |
BIGDECIMAL_ZERO
The default BigDecimal value.
|
static BigInteger |
BIGINTEGER_MAX_LONG
The BigInteger representation of Long.MAX_VALUE.
|
static BigInteger |
BIGINTEGER_MIN_LONG
The BigInteger representation of Long.MIN_VALUE.
|
static Binary |
BINARY_EMPTY
An empty Binary value.
|
static boolean[] |
BOOLEAN_ARRAY_EMPTY
An empty array of bytes.
|
static byte[] |
BYTE_ARRAY_EMPTY
An empty array of bytes.
|
static char[] |
CHAR_ARRAY_EMPTY
An empty array of chars.
|
static Collection |
COLLECTION_EMPTY
An empty (and immutable) collection.
|
static double[] |
DOUBLE_ARRAY_EMPTY
An empty array of doubles.
|
static float[] |
FLOAT_ARRAY_EMPTY
An empty array of floats.
|
static int[] |
INT_ARRAY_EMPTY
An empty array of ints.
|
static long[] |
LONG_ARRAY_EMPTY
An empty array of longs.
|
static Object[] |
OBJECT_ARRAY_EMPTY
An empty array of objects.
|
static short[] |
SHORT_ARRAY_EMPTY
An empty array of shorts.
|
LOG_ALWAYS, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
J_BIG_DECIMAL, J_BIG_INTEGER, J_BINARY, J_BOOLEAN, J_BOOLEAN_ARRAY, J_BYTE, J_BYTE_ARRAY, J_CHAR_ARRAY, J_CHARACTER, J_COLLECTION, J_DATE, J_DATETIME, J_DOUBLE, J_DOUBLE_ARRAY, J_FLOAT, J_FLOAT_ARRAY, J_INT_ARRAY, J_INTEGER, J_LOCAL_DATE, J_LOCAL_DATETIME, J_LOCAL_TIME, J_LONG, J_LONG_ARRAY, J_MAP, J_NULL, J_OBJECT_ARRAY, J_OFFSET_DATETIME, J_OFFSET_TIME, J_QUAD, J_RAW_DATE, J_RAW_DATETIME, J_RAW_DAY_TIME_INTERVAL, J_RAW_TIME, J_RAW_TIME_INTERVAL, J_RAW_YEAR_MONTH_INTERVAL, J_SHORT, J_SHORT_ARRAY, J_SPARSE_ARRAY, J_STRING, J_TIME, J_TIMESTAMP, J_USER_TYPE, J_ZONED_DATETIME, MAX_DECIMAL128_SCALE, MAX_DECIMAL128_UNSCALED, MAX_DECIMAL32_SCALE, MAX_DECIMAL32_UNSCALED, MAX_DECIMAL64_SCALE, MAX_DECIMAL64_UNSCALED, MIN_DECIMAL128_SCALE, MIN_DECIMAL32_SCALE, MIN_DECIMAL64_SCALE, T_ARRAY, T_BOOLEAN, T_CHAR, T_CHAR_STRING, T_COLLECTION, T_DATE, T_DATETIME, T_DAY_TIME_INTERVAL, T_DECIMAL128, T_DECIMAL32, T_DECIMAL64, T_FLOAT128, T_FLOAT32, T_FLOAT64, T_IDENTITY, T_INT128, T_INT16, T_INT32, T_INT64, T_MAP, T_OCTET, T_OCTET_STRING, T_REFERENCE, T_SPARSE_ARRAY, T_TIME, T_TIME_INTERVAL, T_UNIFORM_ARRAY, T_UNIFORM_COLLECTION, T_UNIFORM_KEYS_MAP, T_UNIFORM_MAP, T_UNIFORM_SPARSE_ARRAY, T_UNKNOWN, T_YEAR_MONTH_INTERVAL, V_BOOLEAN_FALSE, V_BOOLEAN_TRUE, V_COLLECTION_EMPTY, V_FP_NAN, V_FP_NEG_INFINITY, V_FP_POS_INFINITY, V_INT_0, V_INT_1, V_INT_10, V_INT_11, V_INT_12, V_INT_13, V_INT_14, V_INT_15, V_INT_16, V_INT_17, V_INT_18, V_INT_19, V_INT_2, V_INT_20, V_INT_21, V_INT_22, V_INT_3, V_INT_4, V_INT_5, V_INT_6, V_INT_7, V_INT_8, V_INT_9, V_INT_NEG_1, V_REFERENCE_NULL, V_STRING_ZERO_LENGTH
Constructor and Description |
---|
PofHelper() |
Modifier and Type | Method and Description |
---|---|
static int |
calcDecimalSize(BigDecimal dec)
Determine the minimum size (in bytes) of the IEEE754 decimal type that
would be capable of holding the passed value.
|
static void |
checkDate(int nYear,
int nMonth,
int nDay)
Validate date information.
|
static void |
checkDayTimeInterval(int cDays,
int cHours,
int cMinutes,
int cSeconds,
int cNanos)
Validate a day-time interval.
|
static void |
checkDecimalRange(BigDecimal dec,
int cBytes)
Verify that the specified decimal value will fit in the specified
number of bits.
|
static void |
checkElementCount(int cElements)
Verify that the number of elements is valid.
|
static void |
checkReferenceRange(int nId)
Validate a reference identifier to make sure it is in a valid range.
|
static void |
checkTime(int nHour,
int nMinute,
int nSecond,
int nNano)
Validate time information.
|
static void |
checkTimeInterval(int cHours,
int cMinutes,
int cSeconds,
int cNanos)
Validate a time interval.
|
static void |
checkTimeZone(int nHourOffset,
int nMinuteOffset)
Check the specified timezone offset.
|
static void |
checkType(int nType)
Validate a type identifier.
|
static void |
checkYearMonthInterval(int cYears,
int cMonths)
Validate a year-month interval.
|
static Number |
convertNumber(Number number,
int nJavaTypeId)
Convert the passed number to the specified type.
|
static Date |
convertToDate(Object o)
Convert a date, time or date/time value to a Java Date.
|
static int |
decodeTinyInt(int n)
Decode an integer value from one of the reserved single-byte combined
type and value indicators.
|
static int |
encodeTinyInt(int n)
Encode an integer value into one of the reserved single-byte combined
type and value indicators.
|
static String |
formatDate(int nYear,
int nMonth,
int nDay)
Format a date in the form YYYY-MM-DD.
|
static String |
formatTime(int nHour,
int nMinute,
int nSecond,
int nNano,
boolean fUTC)
Format a time using the simplest applicable of the following formats:
HH:MM
HH:MM:SS
HH:MM:SS.MMM
HH:MM:SS.NNNNNNNNN
|
static String |
formatTime(int nHour,
int nMinute,
int nSecond,
int nNano,
int nHourOffset,
int nMinuteOffset)
Format a time using the simplest applicable of the following formats:
HH:MM(+|-)HH:MM
HH:MM:SS(+|-)HH:MM
HH:MM:SS.MMM(+|-)HH:MM
HH:MM:SS.NNNNNNNNN(+|-)HH:MM
|
static int |
getJavaTypeId(Object o,
PofContext ctx)
Return an identifier that represents the Java type of the specified
object.
|
static int |
getPofTypeId(Class clz,
PofContext ctx)
Return an identifier that represents the POF type of the specified
class.
|
static boolean |
isIntrinsicPofType(Class clz)
Determine if the given class can be represented as an intrinsic POF
type.
|
static BigDecimal |
readAsBigDecimal(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a BigDecimal.
|
static BigInteger |
readAsBigInteger(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a BigInteger.
|
static char |
readAsChar(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a char.
|
static double |
readAsDouble(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a double.
|
static float |
readAsFloat(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a float.
|
static int |
readAsInt(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to an integer.
|
static long |
readAsLong(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a long.
|
static RawQuad |
readAsQuad(ReadBuffer.BufferInput in,
int nType)
Read a value of the specified encoding from the POF stream and convert
it to a quad.
|
static BigDecimal |
readBigDecimal(ReadBuffer.BufferInput in,
int cBytes)
Read an IEEE754 value from the passed DataInput and convert it to a
Java BigDecimal.
|
static BigInteger |
readBigInteger(DataInput in)
Read a BigInteger value from the passed DataInput.
|
static char |
readChar(DataInput in)
Read a "char" value from the passed DataInput.
|
static LocalDate |
readLocalDate(ReadBuffer.BufferInput in)
Read a LocalDate value from a POF stream.
|
static LocalDateTime |
readLocalDateTime(ReadBuffer.BufferInput in)
Read a LocalDateTime value from a POF stream.
|
static LocalTime |
readLocalTime(ReadBuffer.BufferInput in)
Read a LocalTime value from a POF stream.
|
static OffsetDateTime |
readOffsetDateTime(ReadBuffer.BufferInput in)
Read a OffsetDateTime value from a POF stream.
|
static OffsetTime |
readOffsetTime(ReadBuffer.BufferInput in)
Read a OffsetTime value from a POF stream.
|
static RawQuad |
readQuad(ReadBuffer.BufferInput in)
Read a quad (a 128-bit base-2 IEEE754 value) from the passed DataInput
and convert it to a RawQuad.
|
static RawDate |
readRawDate(ReadBuffer.BufferInput in)
Read a RawDate value from a POF stream.
|
static RawTime |
readRawTime(ReadBuffer.BufferInput in)
Read a RawTime value from a POF stream.
|
static <T> T[] |
resizeArray(T[] aoOld,
int cNew)
Expand the passed array to contain the specified number of elements.
|
static void |
skipPackedInts(ReadBuffer.BufferInput in,
int c)
Skip the specified number of packed integers in the passed POF stream.
|
static void |
skipUniformValue(ReadBuffer.BufferInput in,
int nType)
Within the POF stream, skip the next POF value of the specified type.
|
static void |
skipValue(ReadBuffer.BufferInput in)
Within the POF stream, skip the next POF value.
|
static void |
writeBigDecimal(WriteBuffer.BufferOutput out,
BigDecimal dec,
int cBytes)
Write a BigDecimal to the passed DataOutput stream as a decimal value.
|
static void |
writeBigInteger(WriteBuffer.BufferOutput out,
BigInteger n)
Write a BigInteger as a packed int.
|
static void |
writeDate(WriteBuffer.BufferOutput out,
int nYear,
int nMonth,
int nDay)
Write a date value to a BufferOutput object.
|
static void |
writeTime(WriteBuffer.BufferOutput out,
int nHour,
int nMinute,
int nSecond,
int nNano,
int nTimeZoneType,
int nHourOffset,
int nMinuteOffset)
Write a time value to a BufferOutput object.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
public static final BigInteger BIGINTEGER_MAX_LONG
public static final BigInteger BIGINTEGER_MIN_LONG
public static final BigDecimal BIGDECIMAL_ZERO
public static final boolean[] BOOLEAN_ARRAY_EMPTY
public static final byte[] BYTE_ARRAY_EMPTY
public static final char[] CHAR_ARRAY_EMPTY
public static final short[] SHORT_ARRAY_EMPTY
public static final int[] INT_ARRAY_EMPTY
public static final long[] LONG_ARRAY_EMPTY
public static final float[] FLOAT_ARRAY_EMPTY
public static final double[] DOUBLE_ARRAY_EMPTY
public static final Object[] OBJECT_ARRAY_EMPTY
public static final Collection COLLECTION_EMPTY
public static final Binary BINARY_EMPTY
public static int getJavaTypeId(Object o, PofContext ctx)
o
- an object to determine the type ofctx
- the PofContext used to determine if the object is an
instance of a valid user type; must not be nullPofConstants
class J_* constantspublic static int getPofTypeId(Class clz, PofContext ctx)
clz
- the class; must not be nullctx
- the PofContext used to determine the type identifier of a
user type; must not be nullPofConstants
class T_* constantsIllegalArgumentException
- if the user type associated with the
given object is unknown to the specified PofContextpublic static boolean isIntrinsicPofType(Class clz)
clz
- the class; must not be nullpublic static Number convertNumber(Number number, int nJavaTypeId)
number
- the number to convertnJavaTypeId
- the Java type ID to convert to, one of the J_*
enumerated valuespublic static Date convertToDate(Object o)
o
- an Object of type Date, RawDate, RawTime or RawDateTimepublic static <T> T[] resizeArray(T[] aoOld, int cNew)
T
- the array typeaoOld
- the "template" array or nullcNew
- the number of desired elements in the new arraypublic static int decodeTinyInt(int n)
n
- the integer value that the integer is encoded aspublic static char readChar(DataInput in) throws IOException
in
- the DataInput object to read fromIOException
- on read errorpublic static BigInteger readBigInteger(DataInput in) throws IOException
in
- the DataInput object to read fromIOException
- on read errorpublic static RawQuad readQuad(ReadBuffer.BufferInput in) throws IOException
in
- the DataInput object to read fromIOException
- on read errorpublic static BigDecimal readBigDecimal(ReadBuffer.BufferInput in, int cBytes) throws IOException
in
- the DataInput object to read fromcBytes
- the number of bytes for the IEEE754 value: 4, 8 or 16IOException
- on read errorpublic static LocalDate readLocalDate(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date valueIOException
- on read errorpublic static LocalDateTime readLocalDateTime(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date valueIOException
- on read errorpublic static LocalTime readLocalTime(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date valueIOException
- on read errorpublic static OffsetDateTime readOffsetDateTime(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date valueIOException
- on read errorpublic static OffsetTime readOffsetTime(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date valueIOException
- on read errorpublic static RawDate readRawDate(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date valueIOException
- on read errorpublic static RawTime readRawTime(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF time valueIOException
- on read errorpublic static char readAsChar(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a char valuepublic static int readAsInt(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to an integer valuepublic static long readAsLong(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a long valuepublic static float readAsFloat(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a float valuepublic static double readAsDouble(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a double valuepublic static RawQuad readAsQuad(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a double valuepublic static BigInteger readAsBigInteger(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a BigInteger valuepublic static BigDecimal readAsBigDecimal(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the valueIOException
- if an I/O error occurs reading the POF stream, or
the POF value cannot be coerced to a BigDecimal valuepublic static void skipValue(ReadBuffer.BufferInput in) throws IOException
in
- the BufferInput containing the POF streamIOException
- on read errorpublic static void skipUniformValue(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the BufferInput containing the POF streamnType
- the type of the value to skipIOException
- on read errorpublic static void skipPackedInts(ReadBuffer.BufferInput in, int c) throws IOException
in
- the BufferInput containing the POF streamc
- the number of packed integers to skip overIOException
- on read errorpublic static void writeBigInteger(WriteBuffer.BufferOutput out, BigInteger n) throws IOException
out
- the DataOutput to write ton
- the BigInteger valueIOException
- on write errorpublic static void writeBigDecimal(WriteBuffer.BufferOutput out, BigDecimal dec, int cBytes) throws IOException
out
- the DataOutput to write todec
- the BigDecimal valuecBytes
- the number of bytes for the IEEE754 value: 4, 8 or 16IOException
- on write errorpublic static int encodeTinyInt(int n)
n
- an integer between -1 and 22 inclusivepublic static void writeDate(WriteBuffer.BufferOutput out, int nYear, int nMonth, int nDay) throws IOException
out
- the BufferOutput to write tonYear
- the year number as defined by ISO8601; note the
difference with the Java Date class, whose year is
relative to 1900nMonth
- the month number between 1 and 12 inclusive as defined
by ISO8601; note the difference from the Java Date
class, whose month value is 0-based (0-11)nDay
- the day number between 1 and 31 inclusive as defined by
ISO8601IOException
- thrown if the passed BufferOutput object throws an
IOException while the value is being written to itpublic static void writeTime(WriteBuffer.BufferOutput out, int nHour, int nMinute, int nSecond, int nNano, int nTimeZoneType, int nHourOffset, int nMinuteOffset) throws IOException
out
- the BufferOutput to write tonHour
- the hour between 0 and 23 inclusivenMinute
- the minute value between 0 and 59 inclusivenSecond
- the second value between 0 and 59 inclusive (and
theoretically 60 for a leap-second)nNano
- the nanosecond value between 0 and 999999999
inclusivenTimeZoneType
- 0 if the time value does not have an explicit time
zone, 1 if the time value is UTC and 2 if the time
zone has an explicit hour and minute offsetnHourOffset
- the timezone offset in hours from UTC, for example
0 for BST, -5 for EST and 1 for CETnMinuteOffset
- the timezone offset in minutes, for example 0 (in
most cases) or 30IOException
- thrown if the passed BufferOutput object throws an
IOException while the value is being written to itpublic static void checkType(int nType)
nType
- the type identifierpublic static void checkElementCount(int cElements)
cElements
- the number of elements in a complex data structurepublic static void checkReferenceRange(int nId)
nId
- the reference identitypublic static void checkDecimalRange(BigDecimal dec, int cBytes)
dec
- the decimal valuecBytes
- the number of bytes (4, 8 or 16)public static int calcDecimalSize(BigDecimal dec)
dec
- the decimal valuepublic static void checkDate(int nYear, int nMonth, int nDay)
nYear
- the year numbernMonth
- the month numbernDay
- the day numberpublic static void checkTime(int nHour, int nMinute, int nSecond, int nNano)
nHour
- the hour numbernMinute
- the minute numbernSecond
- the second numbernNano
- the nanosecond numberpublic static void checkTimeZone(int nHourOffset, int nMinuteOffset)
nHourOffset
- the hour offsetnMinuteOffset
- the minute offsetpublic static void checkYearMonthInterval(int cYears, int cMonths)
cYears
- the number of yearscMonths
- the number of monthspublic static void checkTimeInterval(int cHours, int cMinutes, int cSeconds, int cNanos)
cHours
- the number of hourscMinutes
- the number of minutescSeconds
- the number of secondscNanos
- the number of nanosecondspublic static void checkDayTimeInterval(int cDays, int cHours, int cMinutes, int cSeconds, int cNanos)
See http://www.builderau.com.au/architect/database/soa/SQL_basics_Datetime_and_interval_data_types/0,39024547,20269031,00.htm
cDays
- the number of dayscHours
- the number of hourscMinutes
- the number of minutescSeconds
- the number of secondscNanos
- the number of nanosecondspublic static String formatDate(int nYear, int nMonth, int nDay)
nYear
- the year numbernMonth
- the month numbernDay
- the day numberpublic static String formatTime(int nHour, int nMinute, int nSecond, int nNano, boolean fUTC)
nHour
- the hour numbernMinute
- the minute numbernSecond
- the second numbernNano
- the nanosecond numberfUTC
- true for UTC, false for no time zonepublic static String formatTime(int nHour, int nMinute, int nSecond, int nNano, int nHourOffset, int nMinuteOffset)
nHour
- the hour numbernMinute
- the minute numbernSecond
- the second numbernNano
- the nanosecond numbernHourOffset
- the timezone offset in hoursnMinuteOffset
- the timezone offset in minutes