edu.lasalle.redmond.IDs
Class Id

java.lang.Object
  extended by edu.lasalle.redmond.IDs.Id
All Implemented Interfaces:
java.lang.Comparable

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


Field Summary
protected  int secret
           
 
Constructor Summary
Id()
          Creates a new 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 ranom 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()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

secret

protected int secret
Constructor Detail

Id

public Id()
Creates a new 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 ranom instance of Id - given a length of Id and whether a check digit is desired assumes no check digit

Method Detail

genRandomValidId

public static java.lang.String genRandomValidId()
generate a random account number Length is not specified - make 4 digits by default


genRandomValidId

public static java.lang.String genRandomValidId(int len)
generate a random account number Length is specified


generateCheckDigit

public static char generateCheckDigit(java.lang.String basicPart)
Generate a check digit based on a given "rest" of an ID


checkCheckDigit

public boolean checkCheckDigit()
Check to see if an Id has a proper check digit


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


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()

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)


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

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