java.lang.Object
com.ibm.jzos.fields.PackedDecimalAsIntField
- All Implemented Interfaces:
Field,IntAccessor
- Direct Known Subclasses:
PackedSignedIntField,PackedUnsignedIntField
A packed decimal
Field up to 9 digits (5 bytes) with int accessors.
- Since:
- 2.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionPackedDecimalAsIntField(int offset, int precision, boolean signed) Construct an instance -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompare an Integer, possibly null, with an int for equality.intAnswer the length of the field described by the receiverintgetInt(byte[] buffer) Answer a int from the given byte array buffer, at the offset of this field.intgetInt(byte[] buffer, int bufOffset) Answer a int from the given byte array buffer, at the bufOffset + offset of this field.intAnswer the offset of this field into some array of bytesintAnswer the number of decimal digits of precision.booleanisSigned()Answer whether the field is signedvoidputInt(int value, byte[] buffer) Put a int into the given byte array buffer, at the offset of this field.voidputInt(int value, byte[] buffer, int bufOffset) Put a int into the given byte array buffer, at the bufOffset + offset of this field.voidsetOffset(int offset)
-
Constructor Details
-
PackedDecimalAsIntField
public PackedDecimalAsIntField(int offset, int precision, boolean signed) Construct an instance- Parameters:
offset- position of this fieldprecision- total number of digits invalid input: '<'= 9. If even, this value is rounded up to the next odd number.signed- if true the last nibble is a sign
-
-
Method Details
-
getByteLength
public int getByteLength()Answer the length of the field described by the receiver- Specified by:
getByteLengthin interfaceField- Returns:
- int
-
getOffset
public int getOffset()Answer the offset of this field into some array of bytes -
setOffset
public void setOffset(int offset) -
getPrecision
public int getPrecision()Answer the number of decimal digits of precision.- Returns:
- int
-
getInt
Answer a int from the given byte array buffer, at the offset of this field.Note: the data is not checked for valid decimal digits, although the sign nibble is checked for a valid value in the range x'A'-x'F'.
- Specified by:
getIntin interfaceIntAccessor- Parameters:
buffer- the byte array- Returns:
- int
- Throws:
IllegalArgumentException- if the field contains an invalid sign
-
getInt
Answer a int from the given byte array buffer, at the bufOffset + offset of this field.Note: the data is not checked for valid decimal digits, although the sign nibble is checked for a valid value in the range x'A'-x'F'.
- Specified by:
getIntin interfaceIntAccessor- Parameters:
buffer- the byte arraybufOffset- the additional offset into the byte array- Returns:
- int
- Throws:
IllegalArgumentException- if the field contains an invalid sign
-
putInt
Put a int into the given byte array buffer, at the offset of this field.Note: If the field is unsigned, a x'F' is supplied as the sign nibble in the field.
- Specified by:
putIntin interfaceIntAccessor- Parameters:
value- the signed int valuebuffer- the byte array- Throws:
IllegalArgumentException- if the value is out of range
-
putInt
Put a int into the given byte array buffer, at the bufOffset + offset of this field.Note: If the field is unsigned, a x'F' is supplied as the sign nibble in the field.
- Specified by:
putIntin interfaceIntAccessor- Parameters:
value- the signed int valuebuffer- the byte arraybufOffset- the additional offset into the byte array- Throws:
IllegalArgumentException- if the value is out of range
-
isSigned
public boolean isSigned()Answer whether the field is signed- Specified by:
isSignedin interfaceIntAccessor
-
equals
Compare an Integer, possibly null, with an int for equality.- Parameters:
anInteger-anInt-- Returns:
- boolean true if equal, false otherwise
-