BinHelpers

Overview

The BinHelpers class contains static methods used to aid in byte and streaming operations.

Location


Class Methods


booleanFromBuffer

Converts the given byte array to a boolean.

 

class method booleanFromBuffer(aBuffer: array of SByte): Boolean

 

static Boolean booleanFromBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT32 to create boolean from. If the array size is not equal to SIZE_INT32, an exception will be thrown.

booleanToBuffer

Converts the given boolean to a byte array

 

class method booleanToBuffer(aValue: Boolean): array of SByte

 

static SByte[] booleanToBuffer(Boolean aValue)

Parameters:

  • aValue: Given boolean value to create a byte array from

byteFromBuffer

Converts the given byte array to a byte.

 

class method byteFromBuffer(aBuffer: array of SByte): SByte

 

static SByte byteFromBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_BYTE to create byte from. If the array size is not equal to SIZE_BYTE, an exception will be thrown.

byteToBuffer

Converts the given byte to a byte array.

 

class method byteToBuffer(aValue: SByte): array of SByte

 

static SByte[] byteToBuffer(SByte aValue)

Parameters:

  • aValue: Given byte value to create a byte array from

copyOf

 

class method copyOf(aSource: array of SByte; aLength: Integer): array of SByte

 

static SByte[] copyOf(SByte[] aSource, Integer aLength)

Parameters:

  • aSource:
  • aLength:

copyOfRange

 

class method copyOfRange(aSource: array of SByte; aStart: Integer; aEnd: Integer): array of SByte

 

static SByte[] copyOfRange(SByte[] aSource, Integer aStart, Integer aEnd)

Parameters:

  • aSource:
  • aStart:
  • aEnd:

currencyFromBigEndianBuffer

Converts the given BE byte array to a decimal.

 

class method currencyFromBigEndianBuffer(aBuffer: array of SByte): BigDecimal

 

static BigDecimal currencyFromBigEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with SIZE_CURRENCY size to create currency from. If the array size is not equal to SIZE_CURRENCY, an exception will be thrown.

currencyFromLittleEndianBuffer

Converts the given LE byte array to a decimal.

 

class method currencyFromLittleEndianBuffer(aBuffer: array of SByte): BigDecimal

 

static BigDecimal currencyFromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with SIZE_CURRENCY size to create currency from. If the array size is not equal to SIZE_CURRENCY, an exception will be thrown.

currencyToBigEndianBuffer

Converts the given BigDecimal to a BE byte array.

 

class method currencyToBigEndianBuffer(aValue: BigDecimal): array of SByte

 

static SByte[] currencyToBigEndianBuffer(BigDecimal aValue)

Parameters:

  • aValue: BigDecimal value to convert to a BE byte array.

currencyToLittleEndianBuffer

Converts the given BigDecimal to a LE byte array.

 

class method currencyToLittleEndianBuffer(aValue: BigDecimal): array of SByte

 

static SByte[] currencyToLittleEndianBuffer(BigDecimal aValue)

Parameters:

  • aValue: BigDecimal value to convert to a LE byte array.

decimalFromLittleEndianBuffer

Converts the given LE byte array to a BigDecimal.

 

class method decimalFromLittleEndianBuffer(aBuffer: array of SByte): BigDecimal

 

static BigDecimal decimalFromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with SIZE_DECIMAL size to create currency from. If the array size is not equal to SIZE_DECIMAL an exception will be thrown.

decimalToLittleEndianBuffer

Converts the given BigDecimal to a LE byte array.

 

class method decimalToLittleEndianBuffer(aValue: BigDecimal): array of SByte

 

static SByte[] decimalToLittleEndianBuffer(BigDecimal aValue)

Parameters:

  • aValue: BigDecimal value to convert to a LE byte array.

delphiDateToJavaDate

Converts a double to a Date where the value of the given double represents the number of days that have passed since December 30th 1899 and the fractional part of the double represents a fraction of a 24 hour day.

 

class method delphiDateToJavaDate(aValue: Double): Date

 

static Date delphiDateToJavaDate(Double aValue)

Parameters:

  • aValue: Double value, which represents date and time in Delphi, to get Date from.

doubleFromBigEndianBuffer

Converts the given BE byte array to a double.

 

class method doubleFromBigEndianBuffer(aBuffer: array of SByte): Double

 

static Double doubleFromBigEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_DOUBLE to create double from. If the array size is not equal to SIZE_SIZE_DOUBLE, an exception will be thrown.

doubleFromLittleEndianBuffer

Converts the given LE byte array to a double.

 

class method doubleFromLittleEndianBuffer(aBuffer: array of SByte): Double

 

static Double doubleFromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_DOUBLE to create double from. If the array size is not equal to SIZE_SIZE_DOUBLE, an exception will be thrown.

doubleToBigEndianBuffer

Converts the given double to a BE byte array.

 

class method doubleToBigEndianBuffer(aValue: Double): array of SByte

 

static SByte[] doubleToBigEndianBuffer(Double aValue)

Parameters:

  • aValue: Given double value to create a BE byte array from.

doubleToLittleEndianBuffer

Converts the given double to a LE byte array.

 

class method doubleToLittleEndianBuffer(aValue: Double): array of SByte

 

static SByte[] doubleToLittleEndianBuffer(Double aValue)

Parameters:

  • aValue: Given double value to create a LE byte array from.

int16FromBigEndianBuffer

Converts the given BE byte array to a short.

 

class method int16FromBigEndianBuffer(aBuffer: array of SByte): SmallInt

 

static SmallInt int16FromBigEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT16 to create short from. If the array size is not equal to SIZE_INT16, an exception will be thrown.

int16FromLittleEndianBuffer

Converts the given LE byte array to a short.

 

class method int16FromLittleEndianBuffer(aBuffer: array of SByte): SmallInt

 

static SmallInt int16FromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT16 to create short from. If the array size is not equal to SIZE_INT16, an exception will be thrown.

int16ToBigEndianBuffer

Converts the given short to a BE byte array.

 

class method int16ToBigEndianBuffer(aValue: SmallInt): array of SByte

 

static SByte[] int16ToBigEndianBuffer(SmallInt aValue)

Parameters:

  • aValue: Given short value to create a BE byte array from

int16ToLittleEndianBuffer

Converts the given short to a LE byte array.

 

class method int16ToLittleEndianBuffer(aValue: SmallInt): array of SByte

 

static SByte[] int16ToLittleEndianBuffer(SmallInt aValue)

Parameters:

  • aValue: Given short value to create a LE byte array from.

int32FromBigEndianBuffer

Converts the given BE byte array to an int.

 

class method int32FromBigEndianBuffer(aBuffer: array of SByte): Integer

 

static Integer int32FromBigEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT32 to create int from. If the array size is not equal to SIZE_INT32, an exception will be thrown.

int32FromLittleEndianBuffer

Converts the given LE byte array to an int.

 

class method int32FromLittleEndianBuffer(aBuffer: array of SByte): Integer

 

static Integer int32FromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT32 to create int from. If the array size is not equal to SIZE_INT32, an exception will be thrown.

int32ToBigEndianBuffer

Converts the given int to a BE byte array.

 

class method int32ToBigEndianBuffer(aValue: Integer): array of SByte

 

static SByte[] int32ToBigEndianBuffer(Integer aValue)

Parameters:

  • aValue: Given int value to create a BE byte array from.

int32ToLittleEndianBuffer

Converts the given int to a LE byte array.

 

class method int32ToLittleEndianBuffer(aValue: Integer): array of SByte

 

static SByte[] int32ToLittleEndianBuffer(Integer aValue)

Parameters:

  • aValue: Given int value to create a LE byte array from.

int64FromBigEndianBuffer

Converts the given BE byte array to a long.

 

class method int64FromBigEndianBuffer(aBuffer: array of SByte): Int64

 

static Int64 int64FromBigEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT64 to create long from. If the array size is not equal to SIZE_INT64, an exception will be thrown.

int64FromLittleEndianBuffer

Converts the given lE byte array to a long.

 

class method int64FromLittleEndianBuffer(aBuffer: array of SByte): Int64

 

static Int64 int64FromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_INT64 to create long from. If the array size is not equal to SIZE_INT64, an exception will be thrown.

int64ToBigEndianBuffer

Converts the given long to a BE byte array.

 

class method int64ToBigEndianBuffer(aValue: Int64): array of SByte

 

static SByte[] int64ToBigEndianBuffer(Int64 aValue)

Parameters:

  • aValue: Given long value to create a BE byte array from.

int64ToLittleEndianBuffer

Converts the given long to a LE byte array.

 

class method int64ToLittleEndianBuffer(aValue: Int64): array of SByte

 

static SByte[] int64ToLittleEndianBuffer(Int64 aValue)

Parameters:

  • aValue: Given long value to create a LE byte array from.

invalidBufferSize

Class method that just raises Exception with message "BinHelpers : Invalid buffer size passed". Raises on attempt converting byte array to value with wrong size. This exception indicates that message was broken.

 

class method invalidBufferSize

 

static void invalidBufferSize()

javaDateToDelphiDate

Converts a Date to a double where the value represents the number of days that have passed since December 30th 1899 and the fractional part of the double represents a fraction of a 24 hour day.

 

class method javaDateToDelphiDate(aValue: Date): Double

 

static Double javaDateToDelphiDate(Date aValue)

Parameters:

  • aValue: Date value to convert to Delphi date representation.

singleFromBigEndianBuffer

Converts the given BE byte array to a float.

 

class method singleFromBigEndianBuffer(aBuffer: array of SByte): Single

 

static Single singleFromBigEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_SINGLE to create float from. If the array size is not equal to SIZE_SINGLE, an exception will be thrown.

singleFromLittleEndianBuffer

Converts the given LE byte array to a float.

 

class method singleFromLittleEndianBuffer(aBuffer: array of SByte): Single

 

static Single singleFromLittleEndianBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_SINGLE to create float from. If the array size is not equal to SIZE_SINGLE, an exception will be thrown.

singleToBigEndianBuffer

Converts the given float to a BE byte array.

 

class method singleToBigEndianBuffer(aValue: Single): array of SByte

 

static SByte[] singleToBigEndianBuffer(Single aValue)

Parameters:

  • aValue: Given float value to create a BE byte array from.

singleToLittleEndianBuffer

Converts the given float to a LE byte array.

 

class method singleToLittleEndianBuffer(aValue: Single): array of SByte

 

static SByte[] singleToLittleEndianBuffer(Single aValue)

Parameters:

  • aValue: Given float value to create a LE byte array from.

stringFromAnsiStringBuffer

Treats the given byte array as containing an 8 bit ANSI String and converts it to a string variable using the Charset property from Proxy class.

 

class method stringFromAnsiStringBuffer(aBuffer: array of SByte): String

 

static String stringFromAnsiStringBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Incoming bytes buffer.

stringFromUtf8StringBuffer

Treats the given byte array as containing a 16 bit unicode WideString and converts it to a string variable.

 

class method stringFromUtf8StringBuffer(aBuffer: array of SByte): String

 

static String stringFromUtf8StringBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Incoming bytes buffer.

stringFromWideStringBuffer

Treats the given byte array as containing a UTF-8 encoded string and converts it to a string variable.

 

class method stringFromWideStringBuffer(aBuffer: array of SByte): String

 

static String stringFromWideStringBuffer(SByte[] aBuffer)

Parameters:

  • aBuffer: Incoming bytes buffer.

stringToAnsiStringBuffer

Converts the given String to a byte array in 8 bit ANSI format, using the Charset property from Proxy class..

 

class method stringToAnsiStringBuffer(aValue: String): array of SByte

 

static SByte[] stringToAnsiStringBuffer(String aValue)

Parameters:

  • aValue: Incoming string.

stringToUtf8StringBuffer

Converts the given String to a byte array in UTF-8 format.

 

class method stringToUtf8StringBuffer(aValue: String): array of SByte

 

static SByte[] stringToUtf8StringBuffer(String aValue)

Parameters:

  • aValue: Incoming string.

stringToWideStringBuffer

Converts the given String to a byte array in WideString format.

 

class method stringToWideStringBuffer(aValue: String): array of SByte

 

static SByte[] stringToWideStringBuffer(String aValue)

Parameters:

  • aValue: Incoming string.

unexpectedBinaryLength

Class method that just raises Exception with message "BinMessage : Invalid binary length read from stream" Raises on attempt reading bytes buffer with size more than whole message size. This exception indicates that message was broken.

 

class method unexpectedBinaryLength

 

static void unexpectedBinaryLength()

unexpectedEndOfStream

Class method that just raises Exception with message "BinMessage : Unexpected end of stream" Raises on attempt reading message with length less than binary header size. This exception indicates that message was broken.

 

class method unexpectedEndOfStream

 

static void unexpectedEndOfStream()

unexpectedStringLength

Class method that just raises Exception with message "BinMessage : Invalid string length read from stream" Raises on attempt reading string with length more than whole message size. This exception indicates that message was broken.

 

class method unexpectedStringLength

 

static void unexpectedStringLength()

uuidFromByteArray

Converts the given byte array to a UUID.

 

class method uuidFromByteArray(aBuffer: array of SByte): UUID

 

static UUID uuidFromByteArray(SByte[] aBuffer)

Parameters:

  • aBuffer: Byte array with a size that equals SIZE_UUID to create UUID from. If the array size is not equal to SIZE_UUID, an exception will be thrown.

uuidToByteArray

Converts the given UUID to a byte array.

 

class method uuidToByteArray(aUUID: UUID): array of SByte

 

static SByte[] uuidToByteArray(UUID aUUID)

Parameters:

  • aUUID: Given UUID value to create a byte array from.

 

  • BinHelpers Class: