org.fudgemsg.types
Class ByteArrayFieldType

java.lang.Object
  extended by org.fudgemsg.FudgeFieldType<byte[]>
      extended by org.fudgemsg.types.ByteArrayFieldType
All Implemented Interfaces:
Serializable

public class ByteArrayFieldType
extends FudgeFieldType<byte[]>

The type definition for a byte array.

See Also:
Serialized Form

Field Summary
static ByteArrayFieldType LENGTH_128_INSTANCE
          Standard Fudge field type: byte array of length 128.
static ByteArrayFieldType LENGTH_16_INSTANCE
          Standard Fudge field type: byte array of length 16.
static ByteArrayFieldType LENGTH_20_INSTANCE
          Standard Fudge field type: byte array of length 20.
static ByteArrayFieldType LENGTH_256_INSTANCE
          Standard Fudge field type: byte array of length 256.
static ByteArrayFieldType LENGTH_32_INSTANCE
          Standard Fudge field type: byte array of length 32.
static ByteArrayFieldType LENGTH_4_INSTANCE
          Standard Fudge field type: byte array of length 4.
static ByteArrayFieldType LENGTH_512_INSTANCE
          Standard Fudge field type: byte array of length 512.
static ByteArrayFieldType LENGTH_64_INSTANCE
          Standard Fudge field type: byte array of length 64.
static ByteArrayFieldType LENGTH_8_INSTANCE
          Standard Fudge field type: byte array of length 8.
static ByteArrayFieldType VARIABLE_SIZED_INSTANCE
          Standard Fudge field type: arbitrary length byte array.
 
Method Summary
static ByteArrayFieldType getBestMatch(byte[] array)
          Reduces an arbitrary byte array to the most efficient type from the standard Fudge types.
 int getVariableSize(byte[] value, FudgeTaxonomy taxonomy)
          Gets the number of bytes used to encode a value.
 byte[] readValue(DataInput input, int dataSize)
          Reads a value of this type to the output.
 void writeValue(DataOutput output, byte[] value)
          Writes a value of this type to the output.
 
Methods inherited from class org.fudgemsg.FudgeFieldType
equals, getFixedSize, getJavaType, getTypeId, hashCode, isVariableSize, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VARIABLE_SIZED_INSTANCE

public static final ByteArrayFieldType VARIABLE_SIZED_INSTANCE
Standard Fudge field type: arbitrary length byte array. See FudgeTypeDictionary.BYTE_ARRAY_TYPE_ID.


LENGTH_4_INSTANCE

public static final ByteArrayFieldType LENGTH_4_INSTANCE
Standard Fudge field type: byte array of length 4. See FudgeTypeDictionary.BYTE_ARR_4_TYPE_ID.


LENGTH_8_INSTANCE

public static final ByteArrayFieldType LENGTH_8_INSTANCE
Standard Fudge field type: byte array of length 8. See FudgeTypeDictionary.BYTE_ARR_8_TYPE_ID.


LENGTH_16_INSTANCE

public static final ByteArrayFieldType LENGTH_16_INSTANCE
Standard Fudge field type: byte array of length 16. See FudgeTypeDictionary.BYTE_ARR_16_TYPE_ID.


LENGTH_20_INSTANCE

public static final ByteArrayFieldType LENGTH_20_INSTANCE
Standard Fudge field type: byte array of length 20. See FudgeTypeDictionary.BYTE_ARR_20_TYPE_ID.


LENGTH_32_INSTANCE

public static final ByteArrayFieldType LENGTH_32_INSTANCE
Standard Fudge field type: byte array of length 32. See FudgeTypeDictionary.BYTE_ARR_32_TYPE_ID.


LENGTH_64_INSTANCE

public static final ByteArrayFieldType LENGTH_64_INSTANCE
Standard Fudge field type: byte array of length 64. See FudgeTypeDictionary.BYTE_ARR_64_TYPE_ID.


LENGTH_128_INSTANCE

public static final ByteArrayFieldType LENGTH_128_INSTANCE
Standard Fudge field type: byte array of length 128. See FudgeTypeDictionary.BYTE_ARR_128_TYPE_ID.


LENGTH_256_INSTANCE

public static final ByteArrayFieldType LENGTH_256_INSTANCE
Standard Fudge field type: byte array of length 256. See FudgeTypeDictionary.BYTE_ARR_256_TYPE_ID.


LENGTH_512_INSTANCE

public static final ByteArrayFieldType LENGTH_512_INSTANCE
Standard Fudge field type: byte array of length 512. See FudgeTypeDictionary.BYTE_ARR_512_TYPE_ID.

Method Detail

getBestMatch

public static ByteArrayFieldType getBestMatch(byte[] array)
Reduces an arbitrary byte array to the most efficient type from the standard Fudge types.

Parameters:
array - the array
Returns:
the most efficient ByteArrayFieldType available

getVariableSize

public int getVariableSize(byte[] value,
                           FudgeTaxonomy taxonomy)
Gets the number of bytes used to encode a value.

A variable width type must override this method. A fixed width type will return the fixed size.

Overrides:
getVariableSize in class FudgeFieldType<byte[]>
Parameters:
value - the value to check, not used for fixed width types
taxonomy - the taxonomy being used for the encoding, not used for fixed width types
Returns:
the size in bytes

readValue

public byte[] readValue(DataInput input,
                        int dataSize)
                 throws IOException
Reads a value of this type to the output.

This is intended for use by variable width types and must read the given value. The implementation must read exactly the number of bytes passed into the method.

Overrides:
readValue in class FudgeFieldType<byte[]>
Parameters:
input - the input source to read the value from, not null
dataSize - the number of bytes of data to read
Returns:
the value that was read
Throws:
IOException - if an error occurs, which must be wrapped by the caller

writeValue

public void writeValue(DataOutput output,
                       byte[] value)
                throws IOException
Writes a value of this type to the output.

This is intended for use by variable width types and must write the given value. The implementation must write exactly the number of bytes returned by the size calculation.

Overrides:
writeValue in class FudgeFieldType<byte[]>
Parameters:
output - the output target to write the value to, not null
value - the value to write
Throws:
IOException - if an error occurs, which must be wrapped by the caller


Copyright 2009-Present by OpenGamma Inc. and individual contributors
Released under the Apache License, Version 2.0