com.ibm.jzos.fields
Class ExternalDecimalAsLongField

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

public class ExternalDecimalAsLongField
extends java.lang.Object
implements LongAccessor

An external (aka "display", "zoned") decimal field up to 18 digits with long accessors.


Constructor Summary
ExternalDecimalAsLongField(int offset, int precision, boolean signed, boolean signTrailing, boolean signExternal, boolean blankWhenZero)
          Construct an instance
 
Method Summary
 boolean equals(java.lang.Long aLong, long along)
          Compare a Long, possibly null, with a long for equality.
 int getByteLength()
          Answer the length of the field described by the receiver
 int getLength()
           
 long getLong(byte[] buffer)
          Answer a long value from the given byte array buffer, at the offset of this field.
 long getLong(byte[] buffer, int bufOffset)
          Answer a long value from the given byte array buffer, at the bufOffset + offset of this field.
 int getOffset()
          Answer the offset of this field into some array of bytes
 int getPrecision()
           
 boolean isBlankWhenZero()
           
 boolean isSigned()
          Answer whether the field is signed
 boolean isSignExternal()
           
 boolean isSignTrailing()
           
 void putLong(long value, byte[] buffer)
          Put a long value into the given byte array buffer, at the offset of this field.
 void putLong(long value, byte[] buffer, int bufOffset)
          Put a long value into the given byte array buffer, at the bufOffset + offset of this field.
 void setOffset(int offset)
           
 void setSignExternal(boolean signExternal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExternalDecimalAsLongField

public ExternalDecimalAsLongField(int offset,
                                  int precision,
                                  boolean signed,
                                  boolean signTrailing,
                                  boolean signExternal,
                                  boolean blankWhenZero)
Construct an instance

Parameters:
offset - position of this field
precision - total number of digits <= 18.
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: signTrailing 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()

getLong

public long getLong(byte[] buffer)
Answer a long value from the given byte array buffer, at the offset of this field.

Specified by:
getLong in interface LongAccessor
Parameters:
buffer - the byte array
Returns:
long

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. TODO need to verify proper runtime optimization of this method.

Specified by:
getLong in interface LongAccessor
Parameters:
buffer - the byte array
bufOffset - the additional offset into the byte array
Returns:
long

putLong

public void putLong(long value,
                    byte[] buffer)
             throws java.lang.IllegalArgumentException
Put a long value into the given byte array buffer, at the offset of this field.

Specified by:
putLong in interface LongAccessor
Parameters:
value - the long value
buffer - 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.IllegalArgumentException
Put a long value into the given byte array buffer, at the bufOffset + offset of this field.

Specified by:
putLong in interface LongAccessor
Parameters:
value - the long value
buffer - the byte array
bufOffset - 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:
isSigned in interface LongAccessor

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

isBlankWhenZero

public boolean isBlankWhenZero()

isSignExternal

public boolean isSignExternal()

isSignTrailing

public boolean isSignTrailing()

getLength

public int getLength()

getPrecision

public int getPrecision()

setSignExternal

public void setSignExternal(boolean signExternal)