com.ibm.jzos.fields
Class ExternalDecimalAsBigDecimalField

java.lang.Object
  extended by com.ibm.jzos.fields.ExternalDecimalAsBigDecimalField
All Implemented Interfaces:
BigDecimalAccessor, Field

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 to the right of the decimal point.


Constructor Summary
ExternalDecimalAsBigDecimalField(int offset, int precision, int scale, boolean signed, boolean signTrailing, boolean signExternal, boolean blankWhenZero)
          Construct an instance
 
Method Summary
 boolean equals(java.math.BigDecimal a, java.math.BigDecimal b)
          Compare two BigDecimal instances, possibly null, for equality.
 java.math.BigDecimal getBigDecimal(byte[] buffer)
          Answer a BigDecimal from the given byte array buffer, at the offset of this field.
 java.math.BigDecimal getBigDecimal(byte[] buffer, int bufOffset)
          Answer a BigDecimal from the given byte array buffer, at the bufOffset + offset of this field.
 int getByteLength()
          Answer the length of the field described by the receiver
 int getOffset()
          Answer the offset of this field into some array of bytes
 int getPrecision()
           
 int getScale()
           
 boolean isBlankWhenZero()
           
 boolean isSigned()
           
 boolean isSignExternal()
           
 boolean isSignTrailing()
           
 void putBigDecimal(java.math.BigDecimal value, byte[] buffer)
          Put a BigDecimal into the given byte array buffer, at the offset of this field.
 void putBigDecimal(java.math.BigDecimal value, byte[] buffer, int bufOffset)
          Put a BigDecimal into the given byte array buffer, at the bufOffset + offset of this field.
 void setOffset(int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 field
precision - total number of digits.
scale - number of digits (>=0) to the right of decimal point
signed - if the field has a sign somewhere
signTrailing - true if the sign follows the field, false if it precedes it
signExternal - 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: Field
Answer the length of the field described by the receiver

Specified by:
getByteLength in interface Field
Returns:
int

getOffset

public int getOffset()
Description copied from interface: Field
Answer the offset of this field into some array of bytes

Specified by:
getOffset in interface Field
Returns:
int

setOffset

public void setOffset(int offset)
Specified by:
setOffset in interface Field
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: BigDecimalAccessor
Answer a BigDecimal from the given byte array buffer, at the offset of this field.

Specified by:
getBigDecimal in interface BigDecimalAccessor
Parameters:
buffer - the byte array
Returns:
BigDecimal

getBigDecimal

public java.math.BigDecimal getBigDecimal(byte[] buffer,
                                          int bufOffset)
Description copied from interface: BigDecimalAccessor
Answer a BigDecimal from the given byte array buffer, at the bufOffset + offset of this field.

Specified by:
getBigDecimal in interface BigDecimalAccessor
Parameters:
buffer - the byte array
bufOffset - the additional offset into the byte array
Returns:
BigDecimal

putBigDecimal

public void putBigDecimal(java.math.BigDecimal value,
                          byte[] buffer)
                   throws java.lang.IllegalArgumentException
Description copied from interface: BigDecimalAccessor
Put a BigDecimal into the given byte array buffer, at the offset of this field.

Specified by:
putBigDecimal in interface BigDecimalAccessor
Parameters:
value - the BigDecimal value
buffer - 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.IllegalArgumentException
Description copied from interface: BigDecimalAccessor
Put a BigDecimal into the given byte array buffer, at the bufOffset + offset of this field.

Specified by:
putBigDecimal in interface BigDecimalAccessor
Parameters:
value - the BigDecimal value
buffer - the byte array
bufOffset - 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 - BigDecimal
b - BigDecimal
Returns:
boolean true if equal, false otherwise

getScale

public int getScale()