com.ibm.jzos.fields
Class ExternalDecimalAsBigDecimalField
- java.lang.Object
-
- com.ibm.jzos.fields.ExternalDecimalAsBigDecimalField
-
- All Implemented Interfaces:
- BigDecimalAccessor, Field
- Direct Known Subclasses:
- ZonedEmbeddedLeadingSignedBigDecimalField, ZonedEmbeddedTrailingSignedBigDecimalField, ZonedExternalLeadingSignedBigDecimalField, ZonedExternalTrailingSignedBigDecimalField
public class ExternalDecimalAsBigDecimalField extends java.lang.Object implements BigDecimalAccessor
An external (aka "display", "zoned") decimal field with BigDecimal accessors. A "scale" determines the implied number of digits in the fractional part of the field.- Since:
- 2.1.0
-
-
Constructor Summary
Constructors Constructor and Description ExternalDecimalAsBigDecimalField(int offset, int precision, int scale, boolean signed, boolean signTrailing, boolean signExternal, boolean blankWhenZero)Construct an instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and 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()booleanisBlankWhenZero()booleanisSigned()booleanisSignExternal()booleanisSignTrailing()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
-
ExternalDecimalAsBigDecimalField
public ExternalDecimalAsBigDecimalField(int offset, int precision, int scale, boolean signed, boolean signTrailing, boolean signExternal, boolean blankWhenZero)Construct an instance- Parameters:
offset- position of this fieldprecision- total number of digits.scale- number of digits (>=0) in the fractional part of the fieldsigned- if the field has a sign somewheresignTrailing- true if the sign follows the field, false if it precedes itsignExternal- true if the sign occupies a separate byte, false if it only occupies a high-order nibble Note: signTailing and signExternal are ignored if signed is not true.
-
-
Method Detail
-
getByteLength
public int getByteLength()
Description copied from interface:FieldAnswer the length of the field described by the receiver- Specified by:
getByteLengthin interfaceField- Returns:
- int
-
getOffset
public int getOffset()
Description copied from interface:FieldAnswer the offset of this field into some array of bytes
-
setOffset
public void setOffset(int offset)
- Specified by:
setOffsetin interfaceField- See Also:
Field.getOffset()
-
getPrecision
public int getPrecision()
-
isSigned
public boolean isSigned()
-
isSignExternal
public boolean isSignExternal()
-
isSignTrailing
public boolean isSignTrailing()
-
isBlankWhenZero
public boolean isBlankWhenZero()
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(byte[] buffer)
Description copied from interface:BigDecimalAccessorAnswer a BigDecimal from the given byte array buffer, at the offset of this field.- Specified by:
getBigDecimalin interfaceBigDecimalAccessor- Parameters:
buffer- the byte array- Returns:
- BigDecimal
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(byte[] buffer, int bufOffset)Description copied from interface:BigDecimalAccessorAnswer a BigDecimal from the given byte array buffer, at the bufOffset + offset of this field.- Specified by:
getBigDecimalin interfaceBigDecimalAccessor- Parameters:
buffer- the byte arraybufOffset- the additional offset into the byte array- Returns:
- BigDecimal
-
putBigDecimal
public void putBigDecimal(java.math.BigDecimal value, byte[] buffer) throws java.lang.IllegalArgumentExceptionDescription copied from interface:BigDecimalAccessorPut a BigDecimal into the given byte array buffer, at the offset of this 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.IllegalArgumentExceptionDescription copied from interface:BigDecimalAccessorPut a BigDecimal into the given byte array buffer, at the bufOffset + offset of this 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
-
getScale
public int getScale()
-
-