com.buildforge.services.common.dbo
Class DBObject

java.lang.Object
  extended by com.buildforge.services.common.dbo.DBObject
Direct Known Subclasses:
AccessGroupDBO, BOMDBO, BOMManifestDBO, BuildClassDBO, CollectorDBO, CollectorPropertyDBO, CronDBO, DataDBO, EngineDBO, EnvironmentDBO, EnvironmentEntryDBO, FilterDBO, FilterPatternDBO, GeoAwareDBObject, InterfaceDBO, LdapDBO, LogDBO, ManifestDBO, ManifestPropertyDBO, MessageDBO, NoteDBO, ResultDBO, ScopeDBO, SelectorDBO, SelectorPropertyDBO, SemaphoreDBO, ServerAuthDBO, ServerDBO, SessionDBO, StepDBO, SysConfigDBO, TagVarDBO, TemplateDBO, TimeZoneDBO, UserDBO

public abstract class DBObject
extends java.lang.Object

Everything that is a persistant object should implement this interface. This class also provides several convenience methods that check for or report common error conditions.

Although there are exceptions, a DBObject generally corresponds to a single row in the Build Forge schema and provides an abstraction for accessing or manipulating it.


Constructor Summary
DBObject()
           
 
Method Summary
 APIException badId()
          Returns an exception indicating that this object has an invalid id.
 APIException badName()
          Returns an exception indicating that this object has an invalid name.
 void checkDead()
          Verifies that this object is not live.
 void checkLive()
          Verifies that this object is live.
 APIException collision(java.lang.String field, int value)
          Returns an exception indicating that this object would cause a data collision on the specified field.
 APIException collision(java.lang.String field, java.lang.String value)
          Returns an exception indicating that this object would cause a data collision on the specified field.
abstract  DBObject fromArray(java.lang.Object[] data)
          Deserialize the database object's settings from a request array.
abstract  java.lang.String getTypeKey()
          Retrieve the key that should be used to look up the display name for a data type.
abstract  boolean isLive()
          Checks whether or not the object is live.
abstract  java.lang.Object[] toArray()
          Serializes this database object as an array of objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBObject

public DBObject()
Method Detail

getTypeKey

public abstract java.lang.String getTypeKey()
Retrieve the key that should be used to look up the display name for a data type.

Returns:
the type key for this object's class

isLive

public abstract boolean isLive()
Checks whether or not the object is live. Note that this is not valid for object types that do not have a unique identifier. Those for which no reasonable implementation exists should always return false.

Returns:
true iff liveness is a valid concept for this object, and the object is live; otherwise, false is returned.

checkDead

public final void checkDead()
                     throws APIException
Verifies that this object is not live. This is determined by calling isLive(). If it is not live, then no action is taken; otherwise, an exception is thrown.

Throws:
APIException - if the object is live

checkLive

public final void checkLive()
                     throws APIException
Verifies that this object is live. This is determined by calling isLive(). If it is live, then no action is taken; otherwise, an exception is thrown.

Throws:
APIException - if the object is not live

badId

public final APIException badId()
Returns an exception indicating that this object has an invalid id.


badName

public final APIException badName()
Returns an exception indicating that this object has an invalid name.


collision

public final APIException collision(java.lang.String field,
                                    java.lang.String value)
Returns an exception indicating that this object would cause a data collision on the specified field.

Parameters:
field - the field that would cause the collision (indirect)
value - the value of the field that collides
Returns:
the new exception

collision

public final APIException collision(java.lang.String field,
                                    int value)
Returns an exception indicating that this object would cause a data collision on the specified field.

Parameters:
field - the field that would cause the collision (indirect)
value - the value of the field that collides
Returns:
the new exception

toArray

public abstract java.lang.Object[] toArray()
Serializes this database object as an array of objects. As specified in the description for Protocol, all supported protocols transfer database objects in this form.


fromArray

public abstract DBObject fromArray(java.lang.Object[] data)
                            throws APIException
Deserialize the database object's settings from a request array. This method is used to reconstruct a database object from the array that was created by toArray().

Parameters:
data - the object list that renders this object
Returns:
this object, for convenience
Throws:
APIException - if there is something wrong with the serialized data that interferes with the reconstruction of the object. The most obvious reason for this would be if the serialized array contains the wrong number of fields or otherwise does not match the serialized form for this type of database object.