net.sf.bacchus
Class Rtn

java.lang.Object
  extended by net.sf.bacchus.Rtn

public class Rtn
extends Object

A routing transit number.


Field Summary
static int MAX_RTN
          The maximum valid RTN.
 
Constructor Summary
Rtn()
          Creates an RTN with an undefined value.
Rtn(int value)
          Creates an RTN with the given value and a computed check digit.
Rtn(int value, int check)
          Creates an RTN with the given value and check digit.
 
Method Summary
static int computeCheckDigit(Integer rtn)
          Computes the check digit for a routing transit number.
 int getCheck()
          Gets the check digit.
 int getRtn()
          Gets the 8 digit RTN without the check digit, or zero if it is not set.
 void normalize()
          Normalizes the RTN so it does not contain an unnecessary explicit check digit.
 void setCheck(int check)
          Sets the check digit.
 void setRtn(int rtn)
          Sets the 8 digit RTN without the check digit.
 String toString()
          Formats the full 9 digit RTN.
 void validate()
          Validates this RTN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_RTN

public static final int MAX_RTN
The maximum valid RTN.

See Also:
Constant Field Values
Constructor Detail

Rtn

public Rtn()
Creates an RTN with an undefined value.


Rtn

public Rtn(int value)
Creates an RTN with the given value and a computed check digit.

Parameters:
value - the 8 digit RTN without the check digit.

Rtn

public Rtn(int value,
           int check)
Creates an RTN with the given value and check digit. Neither the value nor the check digit are validated.

Parameters:
value - the 8 digit RTN without the check digit.
check -
Method Detail

computeCheckDigit

public static int computeCheckDigit(Integer rtn)
Computes the check digit for a routing transit number. If the RTN is null or out of range, returns 0.

Parameters:
rtn - the routing transit number.
Returns:
the check digit.

getRtn

public int getRtn()
Gets the 8 digit RTN without the check digit, or zero if it is not set.

Returns:
the RTN

setRtn

public void setRtn(int rtn)
Sets the 8 digit RTN without the check digit.

Parameters:
rtn - the RTN.
See Also:
getRtn()

getCheck

public int getCheck()
Gets the check digit. If it is set explicitly, that value is returned, otherwise computes it from the RTN using computeCheckDigit(Integer).

Returns:
the check digit.

setCheck

public void setCheck(int check)
Sets the check digit.

Parameters:
check - the check digit.
See Also:
getCheck()

validate

public void validate()
              throws InvalidRecordException
Validates this RTN. The RTN must be set and within the range 1 through MAX_RTN. If the check digit is set, it must be correct. This method does not check whether the RTN is actually assigned.

Throws:
InvalidRecordException - if this RTN is not valid.

normalize

public void normalize()
Normalizes the RTN so it does not contain an unnecessary explicit check digit.


toString

public String toString()
Formats the full 9 digit RTN.

Overrides:
toString in class Object
Returns:


Copyright © 2008-2009 Bacchus Development Team. All Rights Reserved.