Package cds.savot.model.interpreter
Class IntegerInterpreter
- java.lang.Object
-
- cds.savot.model.interpreter.BinaryFieldInterpreter<java.lang.Integer>
-
- cds.savot.model.interpreter.IntegerInterpreter
-
public class IntegerInterpreter extends BinaryFieldInterpreter<java.lang.Integer>
Binary interpreter for the type "int" of VOTable.
- Null value = 0xffffffff
- Size = 4 bytes
- Java type = Integer
- Since:
- 09/2011
- Author:
- Gregory Mantelet
-
-
Field Summary
-
Fields inherited from class cds.savot.model.interpreter.BinaryFieldInterpreter
arraySeparator, arraySizeInterpreter, fixArraySizes, NB_BYTES, nbItems, strNullValue, TYPE_LABEL
-
-
Constructor Summary
Constructors Constructor Description IntegerInterpreter()
IntegerInterpreter(int[] arraysizes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Integer
convertPrimary(java.lang.Object value)
Converts/Casts the given object into an object of type T.java.lang.Integer
decodePrimary(byte[] b, int offset)
Decodes only one data of type T from the given bytes array.byte[]
encodePrimary(java.lang.Integer value)
Encodes a single value of type T in binary.protected java.lang.Class<java.lang.Integer[]>
getArrayClass()
Gets the precise array type.-
Methods inherited from class cds.savot.model.interpreter.BinaryFieldInterpreter
arraySizeToString, convertIntoArray, convertToString, createEmptyArray, createInterpreter, decode, encode, getArraySize, getPadding, getPadding, readBytes
-
-
-
-
Constructor Detail
-
IntegerInterpreter
public IntegerInterpreter() throws BinaryInterpreterException
- Throws:
BinaryInterpreterException
-
IntegerInterpreter
public IntegerInterpreter(int[] arraysizes) throws BinaryInterpreterException
- Throws:
BinaryInterpreterException
-
-
Method Detail
-
decodePrimary
public java.lang.Integer decodePrimary(byte[] b, int offset) throws BinaryInterpreterException
Description copied from class:BinaryFieldInterpreter
Decodes only one data of type T from the given bytes array.
WARNING:
bytes
is supposed to contain enough bytes (>=BinaryFieldInterpreter.NB_BYTES
) from the given offset.- Specified by:
decodePrimary
in classBinaryFieldInterpreter<java.lang.Integer>
- Parameters:
b
- Array to use to extract enough bytes so that decoding one data of type T.offset
- Position from which bytes must be read.- Returns:
- The decoded value.
- Throws:
BinaryInterpreterException
- If an error occurs while decoding bytes.
-
getArrayClass
protected java.lang.Class<java.lang.Integer[]> getArrayClass()
Description copied from class:BinaryFieldInterpreter
Gets the precise array type.
Generally:
T[].class
, where T must be a concrete class.- Specified by:
getArrayClass
in classBinaryFieldInterpreter<java.lang.Integer>
- Returns:
- The class of an array of type T.
-
convertPrimary
protected java.lang.Integer convertPrimary(java.lang.Object value) throws BinaryInterpreterException
Description copied from class:BinaryFieldInterpreter
Converts/Casts the given object into an object of type T.- Specified by:
convertPrimary
in classBinaryFieldInterpreter<java.lang.Integer>
- Parameters:
value
- The value to cast. (MAY BE NULL)- Returns:
- The casted value.
- Throws:
BinaryInterpreterException
- If there is an error while converting the given value.
-
encodePrimary
public byte[] encodePrimary(java.lang.Integer value) throws BinaryInterpreterException
Description copied from class:BinaryFieldInterpreter
Encodes a single value of type T in binary.
NOTE: If the given value is null,
BinaryFieldInterpreter.getPadding()
will be returned.- Specified by:
encodePrimary
in classBinaryFieldInterpreter<java.lang.Integer>
- Parameters:
value
- The value to encode. (MAY BE NULL).- Returns:
- The value encoded in binary.
- Throws:
BinaryInterpreterException
- If there is an error while encoding the given value.
-
-