com.solab.iso8583
Enum IsoType

java.lang.Object
  extended by java.lang.Enum<IsoType>
      extended by com.solab.iso8583.IsoType
All Implemented Interfaces:
Serializable, Comparable<IsoType>

public enum IsoType
extends Enum<IsoType>

Defines the possible values types that can be used in the fields. Some types required the length of the value to be specified (NUMERIC and ALPHA). Other types have a fixed length, like dates and times. Other types do not require a length to be specified, like LLVAR and LLLVAR.

Author:
Enrique Zamudio

Enum Constant Summary
ALPHA
          A fixed-length alphanumeric value.
AMOUNT
          An amount, expressed in cents with a fixed length of 12.
DATE_EXP
          A date in format yyMM
DATE10
          A date in format MMddHHmmss
DATE4
          A date in format MMdd
LLLVAR
          A variable length alphanumeric value with a 3-digit header length.
LLVAR
          A variable length alphanumeric value with a 2-digit header length.
NUMERIC
          A fixed-length numeric value.
TIME
          Time of day in format HHmmss
 
Method Summary
 String format(BigDecimal value, int length)
          Formats the BigDecimal as an AMOUNT, NUMERIC, or a String.
 String format(Date value)
          Formats a Date if the receiver is DATE10, DATE4, DATE_EXP or TIME; throws an exception otherwise.
 String format(long value, int length)
          Formats the integer value as a NUMERIC, an AMOUNT, or a String.
 String format(String value, int length)
          Formats the string to the given length (length is only useful if type is ALPHA).
 int getLength()
          Returns the length of the type if it's always fixed, or 0 if it's variable.
 boolean needsLength()
          Returns true if the type needs a specified length.
static IsoType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static IsoType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NUMERIC

public static final IsoType NUMERIC
A fixed-length numeric value. It is zero-filled to the left.


ALPHA

public static final IsoType ALPHA
A fixed-length alphanumeric value. It is filled with spaces to the right.


LLVAR

public static final IsoType LLVAR
A variable length alphanumeric value with a 2-digit header length.


LLLVAR

public static final IsoType LLLVAR
A variable length alphanumeric value with a 3-digit header length.


DATE10

public static final IsoType DATE10
A date in format MMddHHmmss


DATE4

public static final IsoType DATE4
A date in format MMdd


DATE_EXP

public static final IsoType DATE_EXP
A date in format yyMM


TIME

public static final IsoType TIME
Time of day in format HHmmss


AMOUNT

public static final IsoType AMOUNT
An amount, expressed in cents with a fixed length of 12.

Method Detail

values

public static IsoType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (IsoType c : IsoType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static IsoType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

needsLength

public boolean needsLength()
Returns true if the type needs a specified length.


getLength

public int getLength()
Returns the length of the type if it's always fixed, or 0 if it's variable.


format

public String format(Date value)
Formats a Date if the receiver is DATE10, DATE4, DATE_EXP or TIME; throws an exception otherwise.


format

public String format(String value,
                     int length)
Formats the string to the given length (length is only useful if type is ALPHA).


format

public String format(long value,
                     int length)
Formats the integer value as a NUMERIC, an AMOUNT, or a String.


format

public String format(BigDecimal value,
                     int length)
Formats the BigDecimal as an AMOUNT, NUMERIC, or a String.