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
-
birthdate
-
-
firstName
-
-
id
-
-
lastName
-
-
middleInitial
-
-
serialVersionUID
-
-
Person()
-
-
Person(String, String)
- Constructor.
-
Person(String, String, char)
- Constructor.
-
equals(Object)
- Good Cloudscape practice requires that objects override
equals and hashCode so that = and <> operators work correctly
in SQL comparisons.
-
findPerson(Connection, int)
- Queries the People table to return the appropriate person
object based on the person's id.
-
getAge()
- Gets the age.
-
getFirstName()
- Gets the first name.
-
getId()
- Gets the person's ID.
-
getLastName()
- Gets the last name.
-
getName()
- Gets the full name.
-
getNextAvailableId(ApplicationMode)
- Gets an int that is the next available person_id from the DB.
-
hashCode()
- Good Cloudscape practice requires that objects override
equals and hashCode so that = and <> operators work correctly
in SQL comparisons.
-
parentInTable(Connection)
- Is the child's parent already in the table.
-
prepareStaticStatements(Connection)
-
-
printName()
- Does a system out of the name.
-
readExternal(ObjectInput)
-
-
setBirthdate(Date)
- Sets the person's age.
-
setId(int)
- Sets the person's ID.
-
toString()
- Returns getName()
-
writeExternal(ObjectOutput)
-
id
public int id
firstName
protected String firstName
lastName
protected String lastName
middleInitial
protected char middleInitial
birthdate
protected Date birthdate
serialVersionUID
public static final long serialVersionUID
Person
public Person()
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.
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.
setBirthdate
public void setBirthdate(Date bd)
- Sets the person's age.
- Parameters:
- bd - birth date.
getName
public String getName()
- Gets the full name.
getFirstName
public String getFirstName()
- Gets the first name.
getLastName
public String getLastName()
- Gets the last name.
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.
prepareStaticStatements
public static boolean prepareStaticStatements(Connection conn) throws SQLException
printName
public void printName()
- Does a system out of the name.
setId
public void setId(int i)
- Sets the person's ID.
- Parameters:
- i - the ID.
getId
public int getId()
- Gets the person's ID.
- Returns:
- int The ID.
getAge
public int getAge()
- Gets the age.
toString
public String toString()
- Returns getName()
- Overrides:
- toString in class Object
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.
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.
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
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
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
All Packages Class Hierarchy This Package Previous Next Index