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 defined 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.)x

Cloudscape automatically assigns the integer value in the person_id column (DEFAULT AUTOINCREMENT) whenever a row is inserted. This class uses the updatePersonWithAutoincrementValue method to find out what that value was and then to update the Person object to assign that value to this.id. 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 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 updatePersonWithAutoincrementValue(Connection)
Get info about the last AUTOINCREMENT value inserted into the People table, and assign that number to the Person object inserted in the same row, and also return the new (updated) Person object.
 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 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 updatePersonWithAutoincrementValue
 public void updatePersonWithAutoincrementValue(Connection conn) throws SQLException
Get info about the last AUTOINCREMENT value inserted into the People table, and assign that number to the Person object inserted in the same row, and also return the new (updated) Person object. It is expected that you would call this method after inserting a person into the database.

Parameters:
conn - the connection to the database.
Returns:
the Person object updated with its id (that Person object is also updated in the database during this method).
Throws: SQLException
thrown if database access fails.
 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