- java.lang.Object
-
- com.ibm.jzos.fields.PackedDecimalAsBigDecimalField
-
- All Implemented Interfaces:
BigDecimalAccessor,Field
- Direct Known Subclasses:
PackedBigDecimalField
public class PackedDecimalAsBigDecimalField extends java.lang.Object implements BigDecimalAccessor
A packed decimalFieldwithBigDecimalaccessors. A "scale" determines the implied number of digits in the fractional portion of the field.- Since:
- 2.1.0
-
-
Constructor Summary
Constructors Constructor Description PackedDecimalAsBigDecimalField(int offset, int precision, int scale, boolean signed)Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.math.BigDecimal a, java.math.BigDecimal b)Compare two BigDecimal instances, possibly null, for equality.java.math.BigDecimalgetBigDecimal(byte[] buffer)Answer a BigDecimal from the given byte array buffer, at the offset of this field.java.math.BigDecimalgetBigDecimal(byte[] buffer, int bufOffset)Answer a BigDecimal from the given byte array buffer, at the bufOffset + offset of this field.intgetByteLength()Answer the length of the field described by the receiverintgetOffset()Answer the offset of this field into some array of bytesintgetPrecision()intgetScale()booleanisSigned()Answer true if the field is signed.voidputBigDecimal(java.math.BigDecimal value, byte[] buffer)Put a BigDecimal into the given byte array buffer, at the offset of this field.voidputBigDecimal(java.math.BigDecimal value, byte[] buffer, int bufOffset)Put a BigDecimal into the given byte array buffer, at the bufOffset + offset of this field.voidsetOffset(int offset)
-
-
-
Constructor Detail
-
PackedDecimalAsBigDecimalField
public PackedDecimalAsBigDecimalField(int offset, int precision, int scale, boolean signed)Construct an instance.- Parameters:
offset- int the offset of this fieldprecision- in the number of decimal digits of precision. If even, this value is rounded up to the next odd number.scale- the number of implied decimal digits in the fractional portion of the fieldsigned- boolean true if the value is signed, false if unsigned
-
-
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()
-
getScale
public int getScale()
-
isSigned
public boolean isSigned()
Answer true if the field is signed.
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(byte[] buffer) throws java.lang.IllegalArgumentExceptionAnswer a BigDecimal 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:
getBigDecimalin interfaceBigDecimalAccessor- Parameters:
buffer- the byte array- Returns:
- BigDecimal
- Throws:
java.lang.IllegalArgumentException- if the data has a invalid sign nibble
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(byte[] buffer, int bufOffset) throws java.lang.IllegalArgumentExceptionAnswer a BigDecimal 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:
getBigDecimalin interfaceBigDecimalAccessor- Parameters:
buffer- the byte arraybufOffset- the additional offset into the byte array- Returns:
- BigDecimal
- Throws:
java.lang.IllegalArgumentException- if the data has a invalid sign nibble
-
putBigDecimal
public void putBigDecimal(java.math.BigDecimal value, byte[] buffer) throws java.lang.IllegalArgumentExceptionPut a BigDecimal 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:
putBigDecimalin interfaceBigDecimalAccessor- Parameters:
value- the BigDecimal valuebuffer- the byte array- Throws:
java.lang.IllegalArgumentException- if the value is out of range
-
putBigDecimal
public void putBigDecimal(java.math.BigDecimal value, byte[] buffer, int bufOffset) throws java.lang.IllegalArgumentExceptionPut a BigDecimal 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:
putBigDecimalin interfaceBigDecimalAccessor- Parameters:
value- the BigDecimal valuebuffer- the byte arraybufOffset- the additional offset into the byte array- Throws:
java.lang.IllegalArgumentException- if the value is out of range
-
equals
public boolean equals(java.math.BigDecimal a, java.math.BigDecimal b)Compare two BigDecimal instances, possibly null, for equality.- Parameters:
a- BigDecimalb- BigDecimal- Returns:
- boolean true if equal, false otherwise
-
-