|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.io.pof.PofHelper
public abstract class PofHelper
Collection of helper methods for POF streams.
Nested Class Summary | |
---|---|
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. |
Field Summary | |
---|---|
static BigDecimal |
BIGDECIMAL_ZERO
The default BigDecimal 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. |
Constructor Summary | |
---|---|
PofHelper()
|
Method Summary | |
---|---|
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 indentifier that represents the Java type of the specified object. |
static int |
getPofTypeId(Class clz,
PofContext ctx)
Return an indentifier that represents the POF type of the specified class. |
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 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 Object[] |
resizeArray(Object[] aoOld,
int cNew)
Expand the passed array to contain the specified number of elements, along the lines of the Collection.toArray
method. |
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. |
Field Detail |
---|
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
Constructor Detail |
---|
public PofHelper()
Method Detail |
---|
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 null
PofConstants
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 null
PofConstants
class T_* constants
IllegalArgumentException
- if the user type associated with the
given object is unknown to the specified PofContextpublic static Number convertNumber(Number number, int nJavaTypeId)
number
- the number to convertnJavaTypeId
- the Java type ID to convert to, one of the J_*
enumerated values
public static Date convertToDate(Object o)
o
- an Object of type Date, RawDate, RawTime or RawDateTime
public static Object[] resizeArray(Object[] aoOld, int cNew)
Collection.toArray
method.
aoOld
- the "template" array or nullcNew
- the number of desired elements in the new array
public static int decodeTinyInt(int n)
n
- the integer value that the integer is encoded as
public static char readChar(DataInput in) throws IOException
in
- the DataInput object to read from
IOException
public static BigInteger readBigInteger(DataInput in) throws IOException
in
- the DataInput object to read from
IOException
public static RawQuad readQuad(ReadBuffer.BufferInput in) throws IOException
in
- the DataInput object to read from
IOException
public 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 16
IOException
public static RawDate readRawDate(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF date value
IOException
public static RawTime readRawTime(ReadBuffer.BufferInput in) throws IOException
in
- the stream containing the POF time value
IOException
public static char readAsChar(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the POF stream containing the valuenType
- the POF type of the value
IOException
- 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 value
IOException
- 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 value
IOException
- 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 value
IOException
- 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 value
IOException
- 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 value
IOException
- 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 value
IOException
- 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 value
IOException
- 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 stream
IOException
public static void skipUniformValue(ReadBuffer.BufferInput in, int nType) throws IOException
in
- the BufferInput containing the POF streamnType
- the type of the value to skip
IOException
public static void skipPackedInts(ReadBuffer.BufferInput in, int c) throws IOException
in
- the BufferInput containing the POF streamc
- the number of packed integers to skip over
IOException
public static void writeBigInteger(WriteBuffer.BufferOutput out, BigInteger n) throws IOException
out
- the DataOutput to write ton
- the BigInteger value
IOException
public 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 16
IOException
public static int encodeTinyInt(int n)
n
- an integer between -1 and 22 inclusive
public 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
ISO8601
IOException
- 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 30
IOException
- 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 value
public 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)
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 zone
public 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
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |