org.deltava.beans
Class DatabaseBean

java.lang.Object
  extended by org.deltava.beans.DatabaseBean
All Implemented Interfaces:
Serializable, Comparable<Object>, Cacheable
Direct Known Subclasses:
ACARSError, ACARSMapEntry, AddressValidation, AssignmentInfo, CertificationRequirement, Channel, Client, Comment, Course, CourseComment, DatabaseBlobBean, DispatchScheduleEntry, EMailConfiguration, Entry, ExamSubPool, Flight, FlightInfo, FlightRoute, InactivityPurge, InstructionBusy, InstructionFlight, InstructionSession, Issue, Issue, IssueComment, IssueComment, LandingStatistics, LinkedImage, LogEntry, LoginAddress, MembershipTotals, Message, MessageThread, News, PollOption, PollVote, RegistrationBlock, Resource, Route, Server, Signup, StatusUpdate, TakeoffLanding, Test, ThreadNotifications, ThreadUpdate, TransferRequest, UserData

public abstract class DatabaseBean
extends Object
implements Serializable, Cacheable, Comparable<Object>

A common abstract class for beans stored in the database with a numeric primary key.

Since:
1.0
Version:
2.6
Author:
Luke
See Also:
Serialized Form

Constructor Summary
DatabaseBean()
           
 
Method Summary
 Object cacheKey()
          Returns the cache key for use in Form/DAO caches.
 int compareTo(Object o)
          Compares two database beans by comparing their IDs.
 boolean equals(Object o)
          Tests for equality by comparing the class and database ID.
 String getHexID()
          Returns the database ID of this bean, formatted to a hexadecimal string.
 int getID()
          Return the database ID of this bean.
 int hashCode()
          Returns the hash code of the database ID.
 void setID(int id)
          Update the database row ID of this bean.
static void validateID(int oldID, int newID)
          Validates a database ID.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseBean

public DatabaseBean()
Method Detail

getID

public int getID()
Return the database ID of this bean.

Returns:
The primary key of the entry in the table in the database that corresponds to this object

getHexID

public String getHexID()
Returns the database ID of this bean, formatted to a hexadecimal string.

Returns:
the hexadecimal formatted database ID, or an empty string if zero

setID

public void setID(int id)
Update the database row ID of this bean. This typically will only be called by a DAO

Parameters:
id - The primary key of the entry in the database that corresponds to this object.
Throws:
IllegalArgumentException - if the database ID is negative
IllegalStateException - if we are attempting to change the database ID
See Also:
validateID(int, int)

validateID

public static void validateID(int oldID,
                              int newID)
                       throws IllegalArgumentException,
                              IllegalStateException
Validates a database ID. Used to enforce database ID behavior - that the ID cannot be zero or negative, and it cannot be updated once set.

Parameters:
oldID - the old database ID
newID - the new database ID
Throws:
IllegalArgumentException - if the database ID is negative
IllegalStateException - if we are attempting to change the database ID

equals

public boolean equals(Object o)
Tests for equality by comparing the class and database ID.

Overrides:
equals in class Object
Parameters:
o - the object to compare with
Returns:
TRUE if the objects have the same class and database ID

compareTo

public int compareTo(Object o)
Compares two database beans by comparing their IDs.

Specified by:
compareTo in interface Comparable<Object>
See Also:
Comparable.compareTo(Object)

cacheKey

public Object cacheKey()
Returns the cache key for use in Form/DAO caches.

Specified by:
cacheKey in interface Cacheable
Returns:
the cache key

hashCode

public int hashCode()
Returns the hash code of the database ID.

Overrides:
hashCode in class Object


Copyright © 2004-2009 Global Virtual Airlines Group. All Rights Reserved.