com.ibm.jzos.fields
Class PackedDecimalAsLongField
- java.lang.Object
-
- com.ibm.jzos.fields.PackedDecimalAsLongField
-
- All Implemented Interfaces:
- Field, LongAccessor
- Direct Known Subclasses:
- PackedSignedLongField, PackedUnsignedLongField
public class PackedDecimalAsLongField extends java.lang.Object implements LongAccessor
A packed decimalFieldup to 18 digits (10 bytes) with long accessors.- Since:
- 2.1.0
-
-
Constructor Summary
Constructors Constructor and Description PackedDecimalAsLongField(int offset, int precision, boolean signed)Construct an instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanequals(java.lang.Long aLong, long along)Compare a Long, possibly null, with a long for equality.intgetByteLength()Answer the length of the field described by the receiverlonggetLong(byte[] buffer)Answer a long value from the given byte array buffer, at the offset of this field.longgetLong(byte[] buffer, int bufOffset)Answer a long value from the given byte array buffer, at the bufOffset + offset of this field.intgetOffset()Answer the offset of this field into some array of bytesintgetPrecision()Answer the number of decimal digits of precision.booleanisSigned()Answer whether the field is signedvoidputLong(long value, byte[] buffer)Put a long value into the given byte array buffer, at the offset of this field.voidputLong(long value, byte[] buffer, int bufOffset)Put a long value into the given byte array buffer, at the bufOffset + offset of this field.voidsetOffset(int offset)
-
-
-
Constructor Detail
-
PackedDecimalAsLongField
public PackedDecimalAsLongField(int offset, int precision, boolean signed)Construct an instance- Parameters:
offset- position of this fieldprecision- total number of digits <= 18. If even, this value is rounded up to the next odd number.signed- if true the last nibble is a sign
-
-
Method Detail
-
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)
- Specified by:
setOffsetin interfaceField- See Also:
getOffset()
-
getPrecision
public int getPrecision()
Answer the number of decimal digits of precision.- Returns:
- int
-
getLong
public long getLong(byte[] buffer) throws java.lang.IllegalArgumentExceptionAnswer a long value 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:
getLongin interfaceLongAccessor- Parameters:
buffer- the byte array- Returns:
- long
- Throws:
java.lang.IllegalArgumentException- if the field contains an invalid sign
-
getLong
public long getLong(byte[] buffer, int bufOffset)Answer a long value 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:
getLongin interfaceLongAccessor- Parameters:
buffer- the byte arraybufOffset- the additional offset into the byte array- Returns:
- long
- Throws:
java.lang.IllegalArgumentException- if the field contains an invalid sign
-
putLong
public void putLong(long value, byte[] buffer) throws java.lang.IllegalArgumentExceptionPut a long value 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:
putLongin interfaceLongAccessor- Parameters:
value- the signed int valuebuffer- the byte array- Throws:
java.lang.IllegalArgumentException- if the value is out of range
-
putLong
public void putLong(long value, byte[] buffer, int bufOffset) throws java.lang.IllegalArgumentExceptionPut a long value 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:
putLongin interfaceLongAccessor- Parameters:
value- the signed int valuebuffer- the byte arraybufOffset- the additional offset into the byte array- Throws:
java.lang.IllegalArgumentException- if the value is out of range
-
isSigned
public boolean isSigned()
Answer whether the field is signed- Specified by:
isSignedin interfaceLongAccessor
-
equals
public boolean equals(java.lang.Long aLong, long along)Compare a Long, possibly null, with a long for equality.- Parameters:
aLong-along-- Returns:
- boolean true if equal, false otherwise
-
-