All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.serializabletypes.Child

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

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

A Child is a subclass of a Person. Persons are members of groups. Persons get stored in the People Table. This class illustrates how you can store a subclass in a table. BuildATour constructs the People objects.

See Also:
BuildATour, Group, Person, Adult

Constructor Index

 o Child()
 o Child(String, String)
Constructor.
 o Child(String, String, char)
Constructor.
 o Child(String, String, int)
Constructor.

Method Index

 o getParent()
Gets the id number of the parent in the group.
 o parentInTable(Connection)
Is the child's parent already in the table? Can be used in a check constraint.
 o readExternal(ObjectInput)
 o setParent(int)
Sets the id number child's parent.
 o writeExternal(ObjectOutput)

Constructors

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

Parameters:
first - the first name.
last - the last name.
 o Child
 public Child(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.
 o Child
 public Child(String first,
              String last,
              int pid)
Constructor. Takes a first name, a last name, a middle initial, and parentid.

Parameters:
first - thefirst name.
last - the last name.
pid - the parent's id

Methods

 o setParent
 public void setParent(int pid)
Sets the id number child's parent.

Parameters:
pid - id number of parent.
 o getParent
 public int getParent()
Gets the id number of the parent in the group.

 o parentInTable
 public boolean parentInTable(Connection conn) throws SQLException
Is the child's parent already in the table? Can be used in a check constraint. If you want to ensure that a Child's parent exists in the table when inserting the Child. Note, however, that this won't prevent you from deleting the Parent later on. (A foreign key constraint would prevent you from doing that.)

Parameters:
conn - Connection
Returns:
boolean if parent is in table.
Throws: SQLException
Thrown if there is an SQL error.
Overrides:
parentInTable in class Person
 o writeExternal
 public void writeExternal(ObjectOutput out) throws IOException
Throws: IOException
from write failures
Overrides:
writeExternal in class Person
 o readExternal
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Throws: IOException
from read failures
Throws: ClassNotFoundException
from conversion failures
Overrides:
readExternal in class Person

All Packages  Class Hierarchy  This Package  Previous  Next  Index