id
Class ID

java.lang.Object
  extended by id.ID
All Implemented Interfaces:
java.lang.Comparable

public class ID
extends java.lang.Object
implements java.lang.Comparable


Constructor Summary
ID()
          Creates a new default instance of ID
ID(int len)
          Creates a new ranom instance of Id - given a length of Id assumes no check digit
ID(int len, boolean check)
          Creates a new random instance of Id - given a length of Id and whether a check digit is desired assumes no check digit
ID(java.lang.String str)
          Creates a new instance of Id - given a string
 
Method Summary
 char addCheckDigit()
          change id to add a check digit to the string
 boolean checkCheckDigit()
          Check to see if an Id has a proper check digit.
 int compareTo(java.lang.Object obj)
          Compares two Ids - needed for sorting - required since implements Comparable interface returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater
 boolean equals(ID toCompare)
          determine if a passed ID has the same contents as the calling object (Id number, required length, AND check digit).
 boolean equals(java.lang.Object toCompare)
          determine if a passed Id has the same contents as the calling object (Id number, required length, AND check digit) Overrides version in java.lang.Object
static char generateCheckDigit(java.lang.String basicPart)
          Generate a check digit based on a given "rest" of an ID.
static java.lang.String genRandomValidId()
          generate a random account number Length is not specified - make 4 digits by default.
static java.lang.String genRandomValidId(int len)
          generate a random account number Length is specified.
 boolean getCheckDig()
          report whether id has a check digit
 java.lang.String getId()
          report actual id string
 int getLength()
          report actual current id string length
 int getRequiredLen()
          report desired id string length
 void setCheckDig(boolean check)
          change whether id has a check digit
 void setId(java.lang.String str)
          change actual id string
 boolean setRequiredLen(int len)
          change desired id string length
 java.lang.String toShortString()
          give a shorter user friendly String version of the object.
 java.lang.String toString()
          give a user friendly String version of the object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ID

public ID()
Creates a new default instance of ID


ID

public ID(java.lang.String str)
Creates a new instance of Id - given a string


ID

public ID(int len)
Creates a new ranom instance of Id - given a length of Id assumes no check digit


ID

public ID(int len,
          boolean check)
Creates a new random instance of Id - given a length of Id and whether a check digit is desired assumes no check digit

Method Detail

getId

public java.lang.String getId()
report actual id string


getCheckDig

public boolean getCheckDig()
report whether id has a check digit


getRequiredLen

public int getRequiredLen()
report desired id string length


getLength

public int getLength()
report actual current id string length


setId

public void setId(java.lang.String str)
change actual id string


setCheckDig

public void setCheckDig(boolean check)
change whether id has a check digit


setRequiredLen

public boolean setRequiredLen(int len)
change desired id string length


addCheckDigit

public char addCheckDigit()
change id to add a check digit to the string


checkCheckDigit

public boolean checkCheckDigit()
Check to see if an Id has a proper check digit. Don't expect students will use this method in March 2008.


toString

public java.lang.String toString()
give a user friendly String version of the object

Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()
give a shorter user friendly String version of the object. This one doesn't actually override Object, but is very related to toString immediately above.


equals

public boolean equals(java.lang.Object toCompare)
determine if a passed Id has the same contents as the calling object (Id number, required length, AND check digit) Overrides version in java.lang.Object

Overrides:
equals in class java.lang.Object

equals

public boolean equals(ID toCompare)
determine if a passed ID has the same contents as the calling object (Id number, required length, AND check digit). Doesn't actually override Object, but goes with the one that does.


compareTo

public int compareTo(java.lang.Object obj)
Compares two Ids - needed for sorting - required since implements Comparable interface returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater

Specified by:
compareTo in interface java.lang.Comparable

genRandomValidId

public static java.lang.String genRandomValidId()
generate a random account number Length is not specified - make 4 digits by default. Don't expect students will use this method.


genRandomValidId

public static java.lang.String genRandomValidId(int len)
generate a random account number Length is specified. Don't expect students will use this method.


generateCheckDigit

public static char generateCheckDigit(java.lang.String basicPart)
Generate a check digit based on a given "rest" of an ID. Don't expect students will use this method in March 2008.