All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.serializabletypes.Person

java.lang.Object
   |
   +----JBMSTours.serializabletypes.Person

public class Person
extends Object
implements Externalizable
Look at the Source.

A Person is stored in the person column of the People table. Usually only subclasses (Adult and Child) are stored. A Person is a member of a Group.

These classes illustrate how you can store instances of subclasses in a column designed to store the superclass. In reality, these classes are probably too simple to store as objects--probably it is better to store the fields as simple data types.

BuildATour constructs the Persons.

See Also:
Adult, Child, Group, BuildATour

Variable Index

 o birthdate
 o firstName
 o id
 o lastName
 o middleInitial
 o serialVersionUID

Constructor Index

 o Person()
 o Person(String, String)
Constructor.
 o Person(String, String, char)
Constructor.

Method Index

 o equals(Object)
Good Cloudscape practice requires that objects override equals and hashCode so that = and <> operators work correctly in SQL comparisons.
 o findPerson(Connection, int)
Queries the People table to return the appropriate person object based on the person's id.
 o getAge()
Gets the age.
 o getFirstName()
Gets the first name.
 o getId()
Gets the person's ID.
 o getLastName()
Gets the last name.
 o getName()
Gets the full name.
 o getNextAvailableId(ApplicationMode)
Gets an int that is the next available person_id from the DB.
 o hashCode()
Good Cloudscape practice requires that objects override equals and hashCode so that = and <> operators work correctly in SQL comparisons.
 o parentInTable(Connection)
Is the child's parent already in the table.
 o prepareStaticStatements(Connection)
 o printName()
Does a system out of the name.
 o readExternal(ObjectInput)
 o setBirthdate(Date)
Sets the person's age.
 o setId(int)
Sets the person's ID.
 o toString()
Returns getName()
 o writeExternal(ObjectOutput)

Variables

 o id
 public int id
 o firstName
 protected String firstName
 o lastName
 protected String lastName
 o middleInitial
 protected char middleInitial
 o birthdate
 protected Date birthdate
 o serialVersionUID
 public static final long serialVersionUID

Constructors

 o Person
 public Person()
 o Person
 public Person(String first,
               String last)
Constructor. Takes a first name and a last name.

Parameters:
first - the first name.
last - the last name.
 o Person
 public Person(String first,
               String last,
               char a)
Constructor. Takes a first name, a last name, and a middle initial.

Parameters:
first - thefirst name.
last - the last name.
a - the middle initial.

Methods

 o setBirthdate
 public void setBirthdate(Date bd)
Sets the person's age.

Parameters:
bd - birth date.
 o getName
 public String getName()
Gets the full name.

 o getFirstName
 public String getFirstName()
Gets the first name.

 o getLastName
 public String getLastName()
Gets the last name.

 o getNextAvailableId
 public static int getNextAvailableId(ApplicationMode am) throws Throwable
Gets an int that is the next available person_id from the DB. Ups the value in the table by one. Uses a separate connection for optimal concurrency.

Parameters:
am - The application's mode
Returns:
The next available id in the table.
Throws: Throwable
thrown if database access fails.
 o prepareStaticStatements
 public static boolean prepareStaticStatements(Connection conn) throws SQLException
 o printName
 public void printName()
Does a system out of the name.

 o setId
 public void setId(int i)
Sets the person's ID.

Parameters:
i - the ID.
 o getId
 public int getId()
Gets the person's ID.

Returns:
int The ID.
 o getAge
 public int getAge()
Gets the age.

 o toString
 public String toString()
Returns getName()

Overrides:
toString in class Object
 o findPerson
 public static Person findPerson(Connection conn,
                                 int personId) throws SQLException
Queries the People table to return the appropriate person object based on the person's id.

Parameters:
conn - Connection
personId - id of person
Returns:
Person object
Throws: SQLException
Thrown if there is a SQL error.
 o parentInTable
 public boolean parentInTable(Connection conn) throws SQLException
Is the child's parent already in the table. (Used in a check constraint.)

Parameters:
conn - Connection
Returns:
boolean if parent is in table.
Throws: SQLException
Thrown if there is a SQL error.
 o equals
 public boolean equals(Object o)
Good Cloudscape practice requires that objects override equals and hashCode so that = and <> operators work correctly in SQL comparisons.

Parameters:
Object - object to compare it to
Returns:
boolean if the objects are equal
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Good Cloudscape practice requires that objects override equals and hashCode so that = and <> operators work correctly in SQL comparisons.

Parameters:
Object - object to compare it to
Returns:
boolean if the objects are equal
Overrides:
hashCode in class Object
 o writeExternal
 public void writeExternal(ObjectOutput out) throws IOException
 o readExternal
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

All Packages  Class Hierarchy  This Package  Previous  Next  Index