Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

sosc::Validatable Class Reference

Inheritance diagram for sosc::Validatable:

sosc::CreditCard sosc::ISBN sosc::SIN sosc::UPC sosc::AmericanExpress sosc::MasterCard sosc::Visa List of all members.

Public Methods

String getNumber ()
String getType ()
String toString ()
boolean equals (Object o)
final boolean validate ()

Protected Methods

 Validatable (final String num, final String typ)
boolean checkPrefix ()
abstract boolean checkSize ()
abstract boolean checkDigits (int[] digits)

Protected Attributes

final String number

Private Attributes

final String type
boolean isValid
boolean validated

Detailed Description

The Validatable class provides methods and fields that are used when creating the following objects: Master Card, American Express, Visa, SIN, UPC, ISBN.

Definition at line 8 of file Validatable.java.


Constructor & Destructor Documentation

sosc::Validatable::Validatable final String    num,
final String    typ
[inline, protected]
 

Validatable sets the values of the number and type fields

Parameters:
num  the number related to the Validatable object
typ  the type related to the Validatable object
Returns:
none

Definition at line 68 of file Validatable.java.

References sosc::Validatable::number, and sosc::Validatable::type.


Member Function Documentation

abstract boolean sosc::Validatable::checkDigits int    digits[] [protected, pure virtual]
 

Referenced by sosc::Validatable::validate().

boolean sosc::Validatable::checkPrefix   [inline, protected]
 

Code for checkPrefix() is only provided here as a default for the classes that don't require the checkPrefix() method such as SIN or UPC. Any class that inherites this method will override it if it needs it.

Parameters:
none 
Returns:
always returns true

Reimplemented in sosc::AmericanExpress, sosc::MasterCard, and sosc::Visa.

Definition at line 120 of file Validatable.java.

Referenced by sosc::Validatable::validate().

abstract boolean sosc::Validatable::checkSize   [protected, pure virtual]
 

The implementation of checkSize() and checkDigits is most likely going to be different for any classes that inherit from Validatable. However, any class that inherits from Validatable will probably have them in some way; thus, they have been provided here as abstracts.

Implemented in sosc::AmericanExpress, sosc::ISBN, sosc::MasterCard, sosc::SIN, sosc::UPC, and sosc::Visa.

Referenced by sosc::Validatable::validate().

boolean sosc::Validatable::equals Object    o [inline]
 

The equals method checks to see if the object passed in is equal to the current object.

Parameters:
o  the object to be compared against
Returns:
the result of the comparison

Reimplemented in sosc::ISBN, sosc::SIN, and sosc::UPC.

Definition at line 80 of file Validatable.java.

References sosc::Validatable::number.

String sosc::Validatable::getNumber   [inline]
 

getNumber() returns the value stored in the private number field

Parameters:
none 
Returns:
the value in the number field

Definition at line 37 of file Validatable.java.

References sosc::Validatable::number.

String sosc::Validatable::getType   [inline]
 

getType() returns the value stored in the private type field

Parameters:
none 
Returns:
the value in the type field

Definition at line 47 of file Validatable.java.

References sosc::Validatable::type.

String sosc::Validatable::toString   [inline]
 

toString() returns the value in the number field

Parameters:
none 
Returns:
the value in the number field

Definition at line 57 of file Validatable.java.

References sosc::Validatable::number.

final boolean sosc::Validatable::validate   [inline]
 

The validate method checks to see if the value stored in the number field is a valid number of the related type.

Parameters:
none 
Returns:
the value stored in the isValid field

Definition at line 94 of file Validatable.java.

References sosc::Validatable::checkDigits(), sosc::Validatable::checkPrefix(), sosc::Validatable::checkSize(), sosc::Validatable::isValid, sosc::Validatable::number, and sosc::Validatable::validated.


Member Data Documentation

boolean sosc::Validatable::isValid [private]
 

Holds the result returned by the validate() method

Definition at line 23 of file Validatable.java.

Referenced by sosc::Validatable::validate().

final String sosc::Validatable::number [protected]
 

Holds the number related to the Validatable instance

Definition at line 18 of file Validatable.java.

Referenced by sosc::UPC::checkDigits(), sosc::SIN::checkDigits(), sosc::ISBN::checkDigits(), sosc::CreditCard::checkDigits(), sosc::Visa::checkPrefix(), sosc::MasterCard::checkPrefix(), sosc::AmericanExpress::checkPrefix(), sosc::Visa::checkSize(), sosc::UPC::checkSize(), sosc::SIN::checkSize(), sosc::MasterCard::checkSize(), sosc::ISBN::checkSize(), sosc::AmericanExpress::checkSize(), sosc::Validatable::equals(), sosc::Validatable::getNumber(), sosc::Validatable::toString(), sosc::Validatable::Validatable(), and sosc::Validatable::validate().

final String sosc::Validatable::type [private]
 

Holds the name/type of the Validatable instance

Definition at line 13 of file Validatable.java.

Referenced by sosc::Validatable::getType(), and sosc::Validatable::Validatable().

boolean sosc::Validatable::validated [private]
 

Set to true after the first time the validate() method is run on an object.

Definition at line 29 of file Validatable.java.

Referenced by sosc::Validatable::validate().


The documentation for this class was generated from the following file:
Generated on Mon Jul 14 17:19:22 2003 for SOSC by doxygen1.2.15