Class PofHelper
Collection of helper methods for POF streams.
Inherited Members
Namespace: Tangosol.IO.Pof
Assembly: Coherence.dll
Syntax
public abstract class PofHelper
Fields
BIGDECIMAL_ZERO
The default BigDecimal value.
Declaration
public static readonly decimal BIGDECIMAL_ZERO
Field Value
Type | Description |
---|---|
decimal |
BINARY_EMPTY
An empty Binary value.
Declaration
public static readonly Binary BINARY_EMPTY
Field Value
Type | Description |
---|---|
Binary |
BOOLEAN_ARRAY_EMPTY
An empty array of bytes.
Declaration
public static readonly bool[] BOOLEAN_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
bool[] |
BYTE_ARRAY_EMPTY
An empty array of bytes.
Declaration
public static readonly byte[] BYTE_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
byte[] |
CHAR_ARRAY_EMPTY
An empty array of chars.
Declaration
public static readonly char[] CHAR_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
char[] |
COLLECTION_EMPTY
An empty (and immutable) collection.
Declaration
public static readonly ICollection COLLECTION_EMPTY
Field Value
Type | Description |
---|---|
ICollection |
DOUBLE_ARRAY_EMPTY
An empty array of doubles.
Declaration
public static readonly double[] DOUBLE_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
double[] |
INT16_ARRAY_EMPTY
An empty array of shorts.
Declaration
public static readonly short[] INT16_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
short[] |
INT32_ARRAY_EMPTY
An empty array of ints.
Declaration
public static readonly int[] INT32_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
int[] |
INT64_ARRAY_EMPTY
An empty array of longs.
Declaration
public static readonly long[] INT64_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
long[] |
OBJECT_ARRAY_EMPTY
An empty array of objects.
Declaration
public static readonly object[] OBJECT_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
object[] |
SINGLE_ARRAY_EMPTY
An empty array of floats.
Declaration
public static readonly float[] SINGLE_ARRAY_EMPTY
Field Value
Type | Description |
---|---|
float[] |
Methods
CalcDecimalSize(decimal)
Determine the minimum size (in bytes) of the IEEE754 decimal type that would be capable of holding the passed value.
Declaration
public static int CalcDecimalSize(decimal value)
Parameters
Type | Name | Description |
---|---|---|
decimal | value | The decimal value. |
Returns
Type | Description |
---|---|
int | The number of bytes (4, 8 or 16). |
CheckDate(int, int, int)
Validate date information.
Declaration
public static void CheckDate(int year, int month, int day)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year number. |
int | month | The month number. |
int | day | The day number. |
CheckDayTimeInterval(int, int, int, int, int)
Validate a day-time interval.
Declaration
public static void CheckDayTimeInterval(int days, int hours, int minutes, int seconds, int nanos)
Parameters
Type | Name | Description |
---|---|---|
int | days | The number of days. |
int | hours | The number of hours. |
int | minutes | The number of minutes. |
int | seconds | The number of seconds. |
int | nanos | The number of nanoseconds. |
CheckDecimalRange(decimal, int)
Verify that the specified Decimal value will fit in the specified number of bytes.
Declaration
public static void CheckDecimalRange(decimal dec, int cBytes)
Parameters
Type | Name | Description |
---|---|---|
decimal | dec | The Decimal value. |
int | cBytes | The number of bytes (4, 8 or 16). |
CheckElementCount(int)
Verify that the number of elements is valid.
Declaration
public static void CheckElementCount(int elementCount)
Parameters
Type | Name | Description |
---|---|---|
int | elementCount | The number of elements in a complex data structure. |
CheckReferenceRange(int)
Validate a reference identifier to make sure it is in a valid range.
Declaration
public static void CheckReferenceRange(int id)
Parameters
Type | Name | Description |
---|---|---|
int | id | The reference identity. |
CheckTime(int, int, int, int)
Validate time information.
Declaration
public static void CheckTime(int hour, int minute, int second, int nano)
Parameters
Type | Name | Description |
---|---|---|
int | hour | The hour number. |
int | minute | The minute number. |
int | second | The second number. |
int | nano | The nanosecond number. |
CheckTimeInterval(int, int, int, int)
Validate a time interval.
Declaration
public static void CheckTimeInterval(int hours, int minutes, int seconds, int nanos)
Parameters
Type | Name | Description |
---|---|---|
int | hours | The number of hours. |
int | minutes | The number of minutes. |
int | seconds | The number of seconds. |
int | nanos | The number of nanoseconds. |
CheckTimeZone(int, int)
Check the specified timezone offset.
Declaration
public static void CheckTimeZone(int hourOffset, int minuteOffset)
Parameters
Type | Name | Description |
---|---|---|
int | hourOffset | The hour offset. |
int | minuteOffset | The minute offset. |
CheckType(int)
Validate a type identifier.
Declaration
public static void CheckType(int typeId)
Parameters
Type | Name | Description |
---|---|---|
int | typeId | The type identifier. |
CheckYearMonthInterval(int, int)
Validate a year-month interval.
Declaration
public static void CheckYearMonthInterval(int years, int months)
Parameters
Type | Name | Description |
---|---|---|
int | years | The number of years. |
int | months | The number of months. |
ContainsPackedInt32(byte[], int)
Determine if the specified byte array contains a packed 32-bit integer.
Declaration
public static bool ContainsPackedInt32(byte[] buffer, int count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The byte array that contains the packed 32-bit integer. |
int | count | The total number of bytes that have been written into the byte array. |
Returns
Type | Description |
---|---|
bool | true if the specified byte array contains a packed 32-bit integer; false, otherwise. |
ConvertNumber(object, int)
Convert the passed number to the specified type.
Declaration
public static object ConvertNumber(object number, int dotNetTypeId)
Parameters
Type | Name | Description |
---|---|---|
object | number | The number to convert. |
int | dotNetTypeId | The .NET type ID to convert to, one of the PofConstants struct T_* constants. |
Returns
Type | Description |
---|---|
object | The number converted to the specified type. |
DecodeTinyInt(int)
Decode an integer value from one of the reserved single-byte combined type and value indicators.
Declaration
public static int DecodeTinyInt(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n | The integer value that the integer is encoded as. |
Returns
Type | Description |
---|---|
int | An integer between -1 and 22, inclusive. |
EncodeTinyInt(int)
Encode an integer value into one of the reserved single-byte combined type and value indicators.
Declaration
public static int EncodeTinyInt(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n | An integer between -1 and 22, inclusive. |
Returns
Type | Description |
---|---|
int | The integer value that the integer is encoded as. |
FormatDate(int, int, int)
Format a date in the form YYYY-MM-DD.
Declaration
public static string FormatDate(int year, int month, int day)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year number. |
int | month | The month number. |
int | day | The day number. |
Returns
Type | Description |
---|---|
string | Return the date in the form YYYY-MM-DD. |
FormatTime(int, int, int, int, bool)
Format a time.
Declaration
public static string FormatTime(int hour, int minute, int second, int nano, bool isUTC)
Parameters
Type | Name | Description |
---|---|---|
int | hour | The hour number. |
int | minute | The minute number. |
int | second | The second number. |
int | nano | The nanosecond number. |
bool | isUTC | true for UTC, false for no time zone. |
Returns
Type | Description |
---|---|
string | A time string. |
Remarks
Time format is the simplest applicable of the following formats:
- HH:MM
- HH:MM:SS
- HH:MM:SS.MMM
- HH:MM:SS.NNNNNNNNN
FormatTime(int, int, int, int, int, int)
Format a time.
Declaration
public static string FormatTime(int hour, int minute, int second, int nano, int hourOffset, int minuteOffset)
Parameters
Type | Name | Description |
---|---|---|
int | hour | The hour number. |
int | minute | The minute number. |
int | second | The second number. |
int | nano | The nanosecond number. |
int | hourOffset | The timezone offset in hours. |
int | minuteOffset | The timezone offset in minutes. |
Returns
Type | Description |
---|---|
string | A time string. |
Remarks
Time format is 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
GetDotNetType(int)
Returns a .NET Type based on the POF type identifer.
Declaration
public static Type GetDotNetType(int pofTypeId)
Parameters
Type | Name | Description |
---|---|---|
int | pofTypeId | POF type identifier. |
Returns
Type | Description |
---|---|
Type | A .NET Type for the specified POF type identifier. |
GetDotNetTypeId(object, IPofContext)
Returns an identifier that represents the .NET type of the specified object.
Declaration
public static int GetDotNetTypeId(object obj, IPofContext ctx)
Parameters
Type | Name | Description |
---|---|---|
object | obj | An object to determine the type of. |
IPofContext | ctx | The IPofContext used to determine if the object is
an instance of a valid user type; must not be |
Returns
Type | Description |
---|---|
int | One of the PofConstants struct N_* constants. |
GetPofTypeId(Type, IPofContext)
Return an identifier that represents the POF type of the specified type.
Declaration
public static int GetPofTypeId(Type type, IPofContext ctx)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type; must not be |
IPofContext | ctx | The IPofContext used to determine the type
identifier of a user type; must not be |
Returns
Type | Description |
---|---|
int | One of the PofConstants struct T_* constants. |
Exceptions
Type | Condition |
---|---|
ArgumentException | If the user type associated with the given object is unknown to the specified IPofContext. |
IsIntrinsicPofType(Type)
Determine if the given type can be represented as an intrinsic POF type.
Declaration
public static bool IsIntrinsicPofType(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The object type; must not be |
Returns
Type | Description |
---|---|
bool | true if the given type can be represented as an intrinsic POF type; false, otherwise. |
LengthPackedInt32(int)
Determine the number of bytes required to encode the given integer using a packed 32-bit format.
Declaration
public static byte LengthPackedInt32(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n | The integer to be encoded. |
Returns
Type | Description |
---|---|
byte | The total number of bytes required to encode the given integer (0 - 5). |
ReadAsChar(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to a char.
Declaration
public static char ReadAsChar(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
char | The POF value as a char. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a char value. |
ReadAsDecimal(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to a Decimal.
Declaration
public static decimal ReadAsDecimal(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
decimal | The POF value as a Decimal. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a Decimal value. |
ReadAsDouble(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to a Double.
Declaration
public static double ReadAsDouble(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
double | The POF value as a Double. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a Double value. |
ReadAsInt32(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to an Int32.
Declaration
public static int ReadAsInt32(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
int | The POF value as an Int32. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to an Int32 value. |
ReadAsInt64(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to an Int64.
Declaration
public static long ReadAsInt64(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
long | The POF value as an Int64. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to an Int64 value. |
ReadAsRawInt128(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to an RawInt128.
Declaration
public static RawInt128 ReadAsRawInt128(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
RawInt128 | The POF value as an RawInt128. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to an Int64 value. |
ReadAsSingle(DataReader, int)
Read a value of the specified encoding from the POF stream and convert it to a Single.
Declaration
public static float ReadAsSingle(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The POF stream containing the value. |
int | typeId | The POF type of the value. |
Returns
Type | Description |
---|---|
float | The POF value as a Single. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a Single value. |
ReadChar(DataReader)
Read a Char value from the passed DataReader.
Declaration
public static char ReadChar(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The DataReader object to read from. |
Returns
Type | Description |
---|---|
char | A char value. |
ReadDate(DataReader)
Read a literal DateTime value from a POF stream.
Declaration
public static DateTime ReadDate(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The stream containing the POF date value. |
Returns
Type | Description |
---|---|
DateTime | A literal date value. |
ReadDateTime(DataReader)
Read a literal DateTime value from a POF stream.
Declaration
public static DateTime ReadDateTime(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The stream containing the POF date-time value. |
Returns
Type | Description |
---|---|
DateTime | A literal DateTime value. |
Remarks
This method will ignore any time zone information (if present), and return literal date-time value, as encoded in the stream.
ReadDecimal(DataReader)
Read Decimal value from DataReader.
Declaration
public static decimal ReadDecimal(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | DataReader stream to read value from. |
Returns
Type | Description |
---|---|
decimal | Decimal value read from stream. |
ReadDecimal(DataReader, int)
Read Decimal value from DataReader.
Declaration
public static decimal ReadDecimal(DataReader reader, int size)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | DataReader stream to read value from. |
int | size | Number of bytes to read from the stream. |
Returns
Type | Description |
---|---|
decimal | Decimal value read from stream. |
ReadRawTime(DataReader)
Read a RawTime value from a POF stream.
Declaration
public static RawTime ReadRawTime(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The stream containing the POF time value. |
Returns
Type | Description |
---|---|
RawTime | A literal Time value. |
ReadUniversalDateTime(DataReader)
Read a UTC DateTime value from a POF stream.
Declaration
public static DateTime ReadUniversalDateTime(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The stream containing the POF date-time value. |
Returns
Type | Description |
---|---|
DateTime | A UTC DateTime value. |
Remarks
This method will use time zone information (if present) to determine a UTC value of the encoded POF date-time value.
ResizeArray(Array, int)
Expand the passed array to contain the specified number of elements.
Declaration
public static Array ResizeArray(Array array, int newSize)
Parameters
Type | Name | Description |
---|---|---|
Array | array | The "template" array or |
int | newSize | The number of desired elements in the new array. |
Returns
Type | Description |
---|---|
Array | The old array, if it was big enough, or a new array of the same type. |
ResizeArray(Array, int, Type)
Expand the passed array to contain the specified number of elements.
Declaration
public static Array ResizeArray(Array array, int newSize, Type elementType)
Parameters
Type | Name | Description |
---|---|---|
Array | array | The "template" array or |
int | newSize | The number of desired elements in the new array. |
Type | elementType | Type of the array elements. |
Returns
Type | Description |
---|---|
Array | The old array, if it was big enough, or a new array of the same type. |
SkipPackedInts(DataReader, int)
Skip the specified number of packed integers in the passed POF stream.
Declaration
public static void SkipPackedInts(DataReader reader, int count)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The DataReader containing the POF stream. |
int | count | The number of packed integers to skip over. |
SkipUniformValue(DataReader, int)
Within the POF stream, skip the next POF value of the specified type.
Declaration
public static void SkipUniformValue(DataReader reader, int typeId)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The DataReader containing the POF stream. |
int | typeId | The type of the value to skip. |
SkipValue(DataReader)
Within the POF stream, skip the next POF value.
Declaration
public static void SkipValue(DataReader reader)
Parameters
Type | Name | Description |
---|---|---|
DataReader | reader | The DataReader containing the POF stream. |
WriteDate(DataWriter, int, int, int)
Write a date value to a DataWriter object.
Declaration
public static void WriteDate(DataWriter writer, int year, int month, int day)
Parameters
Type | Name | Description |
---|---|---|
DataWriter | writer | The DataWriter to write to. |
int | year | The year number as defined by ISO8601. |
int | month | The month number between 1 and 12 inclusive as defined by ISO8601. |
int | day | The day number between 1 and 31 inclusive as defined by ISO8601. |
Exceptions
Type | Condition |
---|---|
IOException | If the passed DataWriter object throws an exception while the value is being written to it. |
WriteDecimal(DataWriter, decimal)
Write a Decimal to the passed DataWriter stream as a decimal value.
Declaration
public static void WriteDecimal(DataWriter writer, decimal value)
Parameters
Type | Name | Description |
---|---|---|
DataWriter | writer | The DataWriter to write to. |
decimal | value | The Decimal value. |
WriteDecimal(DataWriter, decimal, int)
Write a Decimal to the passed DataWriter stream as a decimal value.
Declaration
public static void WriteDecimal(DataWriter writer, decimal value, int cBytes)
Parameters
Type | Name | Description |
---|---|---|
DataWriter | writer | The DataWriter to write to. |
decimal | value | The Decimal value. |
int | cBytes | Number of bytes to write. |
WriteTime(DataWriter, int, int, int, int, int, TimeSpan)
Write a time value to a DataWriter object.
Declaration
public static void WriteTime(DataWriter writer, int hour, int minute, int second, int nano, int timeZoneType, TimeSpan zoneOffset)
Parameters
Type | Name | Description |
---|---|---|
DataWriter | writer | The DataWriter to write to. |
int | hour | The hour between 0 and 23, inclusive. |
int | minute | The minute value between 0 and 59, inclusive. |
int | second | The second value between 0 and 59, inclusive (and theoretically 60 for a leap-second). |
int | nano | The nanosecond value between 0 and 999999999, inclusive. |
int | timeZoneType | 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 offset. |
TimeSpan | zoneOffset | The timezone offset from UTC, for example 0 for BST, -5 for EST and +1 for CET. |
Exceptions
Type | Condition |
---|---|
IOException | If the passed DataWriter object throws an exception while the value is being written to it. |