org.apache.jdo.tck.pc.company
Class Person

java.lang.Object
  extended byorg.apache.jdo.tck.pc.company.Person
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator, DeepEquality, IPerson, java.io.Serializable
Direct Known Subclasses:
Employee

public class Person
extends java.lang.Object
implements IPerson, java.io.Serializable, java.lang.Comparable, java.util.Comparator, DeepEquality

This class represents a person.

See Also:
Serialized Form

Nested Class Summary
static class Person.Oid
          This class is used to represent the application identifier for the Person class.
 
Field Summary
protected static java.text.SimpleDateFormat formatter
           
 
Constructor Summary
protected Person()
          This is the JDO-required no-args constructor.
  Person(long personid, java.lang.String firstname, java.lang.String lastname, java.lang.String middlename, java.util.Date birthdate)
          Construct a Person instance.
  Person(long personid, java.lang.String firstname, java.lang.String lastname, java.lang.String middlename, java.util.Date birthdate, IAddress address)
          Construct a Person instance.
 
Method Summary
static int compare(IPerson o1, IPerson o2)
          Compares its two IPerson arguments for order.
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compare two instances.
 int compareTo(IPerson other)
          Compares this object with the specified Person object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean deepCompareFields(java.lang.Object other, EqualityHelper helper)
          Returns true if all the fields of this instance are deep equal to the coresponding fields of the specified Person.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 IAddress getAddress()
          Get the address.
 java.util.Date getBirthdate()
          Get the person's birthdate.
protected  java.lang.String getFieldRepr()
          Returns a String representation of the non-relationship fields.
 java.lang.String getFirstname()
          Get the person's first name.
 java.lang.String getLastname()
          Get the person's last name.
 java.lang.String getMiddlename()
          Get the person's middle name.
 long getPersonid()
          Get the person's id.
 java.lang.String getPhoneNumber(java.lang.String type)
          Get the phone number for the specified phone number type.
 java.util.Map getPhoneNumbers()
          Get the map of phone numbers as an unmodifiable map.
 int hashCode()
          Returns a hash code value for the object.
 java.lang.String putPhoneNumber(java.lang.String type, java.lang.String phoneNumber)
          Associates the specified phone number with the specified type in the map of phone numbers of this person.
 java.lang.String removePhoneNumber(java.lang.String type)
          Remove a phoneNumber from the map of phone numbers.
 void setAddress(IAddress address)
          Set the address.
 void setBirthdate(java.util.Date birthdate)
          Set the person's birthdate.
 void setFirstname(java.lang.String firstname)
          Set the person's first name.
 void setLastname(long personid)
          Set the person's id.
 void setLastname(java.lang.String lastname)
          Set the person's last name.
 void setMiddlename(java.lang.String middlename)
          Set the person's middle name.
 void setPersonid(long id)
          Set the id associated with this object.
 void setPhoneNumbers(java.util.Map phoneNumbers)
          Set the phoneNumber map to be in this person.
 java.lang.String toString()
          Returns a String representation of a Person object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

formatter

protected static java.text.SimpleDateFormat formatter
Constructor Detail

Person

protected Person()
This is the JDO-required no-args constructor.


Person

public Person(long personid,
              java.lang.String firstname,
              java.lang.String lastname,
              java.lang.String middlename,
              java.util.Date birthdate)
Construct a Person instance.

Parameters:
personid - The person identifier.
firstname - The person's first name.
lastname - The person's last name.
middlename - The person's middle name.
birthdate - The person's birthdate.

Person

public Person(long personid,
              java.lang.String firstname,
              java.lang.String lastname,
              java.lang.String middlename,
              java.util.Date birthdate,
              IAddress address)
Construct a Person instance.

Parameters:
personid - The person identifier.
firstname - The person's first name.
lastname - The person's last name.
middlename - The person's middle name.
birthdate - The person's birthdate.
address - The person's address.
Method Detail

setPersonid

public void setPersonid(long id)
Set the id associated with this object.

Specified by:
setPersonid in interface IPerson
Parameters:
id - the id.

getPersonid

public long getPersonid()
Get the person's id.

Specified by:
getPersonid in interface IPerson
Returns:
The personid.

setLastname

public void setLastname(long personid)
Set the person's id.

Parameters:
personid - The personid.

getLastname

public java.lang.String getLastname()
Get the person's last name.

Specified by:
getLastname in interface IPerson
Returns:
The last name.

setLastname

public void setLastname(java.lang.String lastname)
Set the person's last name.

Specified by:
setLastname in interface IPerson
Parameters:
lastname - The last name.

getFirstname

public java.lang.String getFirstname()
Get the person's first name.

Specified by:
getFirstname in interface IPerson
Returns:
The first name.

setFirstname

public void setFirstname(java.lang.String firstname)
Set the person's first name.

Specified by:
setFirstname in interface IPerson
Parameters:
firstname - The first name.

getMiddlename

public java.lang.String getMiddlename()
Get the person's middle name.

Specified by:
getMiddlename in interface IPerson
Returns:
The middle name.

setMiddlename

public void setMiddlename(java.lang.String middlename)
Set the person's middle name.

Specified by:
setMiddlename in interface IPerson
Parameters:
middlename - The middle name.

getAddress

public IAddress getAddress()
Get the address.

Specified by:
getAddress in interface IPerson
Returns:
The address.

setAddress

public void setAddress(IAddress address)
Set the address.

Specified by:
setAddress in interface IPerson
Parameters:
address - The address.

getBirthdate

public java.util.Date getBirthdate()
Get the person's birthdate.

Specified by:
getBirthdate in interface IPerson
Returns:
The person's birthdate.

setBirthdate

public void setBirthdate(java.util.Date birthdate)
Set the person's birthdate.

Specified by:
setBirthdate in interface IPerson
Parameters:
birthdate - The person's birthdate.

getPhoneNumbers

public java.util.Map getPhoneNumbers()
Get the map of phone numbers as an unmodifiable map.

Specified by:
getPhoneNumbers in interface IPerson
Returns:
The map of phone numbers, as an unmodifiable map.

getPhoneNumber

public java.lang.String getPhoneNumber(java.lang.String type)
Get the phone number for the specified phone number type.

Parameters:
type - The phone number type ("home", "work", "mobile", etc.).
Returns:
The phone number associated with specified type, or null if there was no phone number for the type.

putPhoneNumber

public java.lang.String putPhoneNumber(java.lang.String type,
                                       java.lang.String phoneNumber)
Associates the specified phone number with the specified type in the map of phone numbers of this person.

Parameters:
type - The phone number type ("home", "work", "mobile", etc.).
phoneNumber - The phone number
Returns:
The previous phone number associated with specified type, or null if there was no phone number for the type.

removePhoneNumber

public java.lang.String removePhoneNumber(java.lang.String type)
Remove a phoneNumber from the map of phone numbers.

Parameters:
type - The phone number type ("home", "work", "mobile", etc.).
Returns:
The previous phone number associated with specified type, or null if there was no phone number for the type.

setPhoneNumbers

public void setPhoneNumbers(java.util.Map phoneNumbers)
Set the phoneNumber map to be in this person.

Specified by:
setPhoneNumbers in interface IPerson
Parameters:
phoneNumbers - The map of phoneNumbers for this person.

toString

public java.lang.String toString()
Returns a String representation of a Person object.

Returns:
a string representation of a Person object.

getFieldRepr

protected java.lang.String getFieldRepr()
Returns a String representation of the non-relationship fields.

Returns:
a String representation of the non-relationship fields.

deepCompareFields

public boolean deepCompareFields(java.lang.Object other,
                                 EqualityHelper helper)
Returns true if all the fields of this instance are deep equal to the coresponding fields of the specified Person.

Specified by:
deepCompareFields in interface DeepEquality
Parameters:
other - the object with which to compare.
helper - EqualityHelper to keep track of instances that have already been processed.
Returns:
true if all the fields are deep equal; false otherwise.
Throws:
java.lang.ClassCastException - if the specified instances' type prevents it from being compared to this instance.

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - - if the specified object's type prevents it from being compared to this Object.

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compare two instances. This is a method in Comparator.

Specified by:
compare in interface java.util.Comparator

compareTo

public int compareTo(IPerson other)
Compares this object with the specified Person object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
other - The Person object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified Person object.

compare

public static int compare(IPerson o1,
                          IPerson o2)
Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Parameters:
o1 - the first IPerson object to be compared.
o2 - the second IPerson object to be compared.
Returns:
a negative integer, zero, or a positive integer as the first object is less than, equal to, or greater than the second object.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Specified by:
equals in interface java.util.Comparator
Parameters:
obj - the object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the object.

Returns:
a hash code value for this object.


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.