com.solab.iso8583
Class IsoValue<T>

java.lang.Object
  extended by com.solab.iso8583.IsoValue<T>
All Implemented Interfaces:
Cloneable

public class IsoValue<T>
extends Object
implements Cloneable

Represents a value that is stored in a field inside an ISO8583 message. It can format the value when the message is generated. Some values have a fixed length, other values require a length to be specified so that the value can be padded to the specified length. LLVAR and LLLVAR values do not need a length specification because the length is calculated from the stored value.

Author:
Enrique Zamudio

Constructor Summary
IsoValue(IsoType t, T value)
           
IsoValue(IsoType t, T value, CustomField<T> custom)
          Creates a new instance that stores the specified value as the specified type.
IsoValue(IsoType t, T val, int len)
           
IsoValue(IsoType t, T val, int len, CustomField<T> custom)
          Creates a new instance that stores the specified value as the specified type.
 
Method Summary
 IsoValue<T> clone()
          Returns a copy of the receiver that references the same value object.
 boolean equals(Object other)
          Returns true of the other object is also an IsoValue and has the same type and length, and if other.getValue().equals(getValue()) returns true.
 int getLength()
          Returns the length of the stored value, of the length of the formatted value in case of NUMERIC or ALPHA.
 IsoType getType()
          Returns the ISO type to which the value must be formatted.
 T getValue()
          Returns the stored value without any conversion or formatting.
 int hashCode()
           
 String toString()
          Returns the formatted value as a String.
 void write(OutputStream outs, boolean binary)
          Writes the formatted value to a stream, with the length header if it's a variable length type.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IsoValue

public IsoValue(IsoType t,
                T value)

IsoValue

public IsoValue(IsoType t,
                T value,
                CustomField<T> custom)
Creates a new instance that stores the specified value as the specified type. Useful for storing LLVAR or LLLVAR types, as well as fixed-length value types like DATE10, DATE4, AMOUNT, etc.

Parameters:
t - the ISO type.
value - The value to be stored.
custom - An optional CustomField to encode/decode a custom value.

IsoValue

public IsoValue(IsoType t,
                T val,
                int len)

IsoValue

public IsoValue(IsoType t,
                T val,
                int len,
                CustomField<T> custom)
Creates a new instance that stores the specified value as the specified type. Useful for storing fixed-length value types.

Parameters:
t - The ISO8583 type for this field.
val - The value to store in the field.
len - The length for the value.
custom - An optional CustomField to encode/decode a custom value.
Method Detail

getType

public IsoType getType()
Returns the ISO type to which the value must be formatted.


getLength

public int getLength()
Returns the length of the stored value, of the length of the formatted value in case of NUMERIC or ALPHA. It doesn't include the field length header in case of LLVAR or LLLVAR.


getValue

public T getValue()
Returns the stored value without any conversion or formatting.


toString

public String toString()
Returns the formatted value as a String. The formatting depends on the type of the receiver.

Overrides:
toString in class Object

clone

public IsoValue<T> clone()
Returns a copy of the receiver that references the same value object.

Overrides:
clone in class Object

equals

public boolean equals(Object other)
Returns true of the other object is also an IsoValue and has the same type and length, and if other.getValue().equals(getValue()) returns true.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

write

public void write(OutputStream outs,
                  boolean binary)
           throws IOException
Writes the formatted value to a stream, with the length header if it's a variable length type.

Throws:
IOException