org.vizzini.database
Class Record

java.lang.Object
  extended by org.vizzini.util.GenericData
      extended by org.vizzini.database.Record
All Implemented Interfaces:
Cloneable, Comparable, IRecord, IGenericData

 class Record
extends GenericData
implements IRecord

Provides a generic data object which can be stored in a database.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
 
Fields inherited from interface org.vizzini.database.IRecord
INVALID_ID
 
Constructor Summary
Record(IDatabase database, ITableData tableData)
          Construct this object.
Record(IDatabase database, String tableName)
          Construct this object.
 
Method Summary
 void associate(IRecord another)
          Associate this to the given record using a join known to the database.
 Object clone()
          Clone this object.
 int compareTo(Object another)
          Compare this object to another.
 void delete()
          Delete this object from the database.
 void disassociate(IRecord another)
          Diassociate this from the given object.
 String getAsDBString(String propertyName)
          Return the property value for the given property name, formatted as a database string.
 List getAssociated()
          Return objects of all tables which are associated to this object.
 List getAssociated(ITableData tableData)
          Return objects of the given table which are associated to this object.
 List getAssociated(String tableName)
          Return objects of the given table which are associated to this object.
 IDatabase getDatabase()
          Return the database.
 int getId()
          Return the object ID.
 Iterator getJoins()
          Return an iterator over IAssociation s which involve this object's table.
 Iterator getJunctions()
          Return an iterator over IAssociation s which involve this object's table.
 ITableData getTableData()
          Return the table data.
 String getTableName()
          Return the table name.
 int hashCode()
          Return the hash code.
 void insert()
          Insert this object into the database.
protected static void printList(String title, List rows)
           
 void reload()
          Reload this object from the database.
 void set(String propertyName, Class type, Object value)
          Set the value of the named property.
 String toDebugString()
          Return a string representation of this object.
 String toString()
          Return a string representation of this object.
 String toXMLString()
          Return an XML string representation of this object.
 void update()
          Update this object in the database.
 
Methods inherited from class org.vizzini.util.GenericData
clear, copy, equals, get, getPropertyNames, getType, set, set, set, set, set, set
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.util.IGenericData
clear, copy, equals, get, getPropertyNames, getType, set, set, set, set, set, set
 

Constructor Detail

Record

public Record(IDatabase database,
              String tableName)
Construct this object.

Parameters:
database - The database.
tableName - The table name.
Since:
v0.3

Record

public Record(IDatabase database,
              ITableData tableData)
Construct this object.

Parameters:
database - The database.
tableData - The table data.
Since:
v0.3
Method Detail

associate

public void associate(IRecord another)
               throws SQLException
Associate this to the given record using a join known to the database.

Specified by:
associate in interface IRecord
Throws:
SQLException
Since:
v0.3

clone

public Object clone()
Clone this object.

Specified by:
clone in interface IRecord
Specified by:
clone in interface IGenericData
Overrides:
clone in class GenericData
Since:
v0.3

compareTo

public int compareTo(Object another)
Compare this object to another.

Specified by:
compareTo in interface Comparable
Specified by:
compareTo in interface IRecord
Specified by:
compareTo in interface IGenericData
Overrides:
compareTo in class GenericData
Returns:
-1, 0, +1 if this is less than, equal to, or greater than another.
Since:
v0.3

delete

public void delete()
            throws SQLException
Delete this object from the database.

Specified by:
delete in interface IRecord
Throws:
SQLException
Since:
v0.3

disassociate

public void disassociate(IRecord another)
                  throws SQLException
Diassociate this from the given object.

Specified by:
disassociate in interface IRecord
Throws:
SQLException
Since:
v0.3

getAsDBString

public String getAsDBString(String propertyName)
Return the property value for the given property name, formatted as a database string.

Specified by:
getAsDBString in interface IRecord
Since:
v0.3

getAssociated

public List getAssociated()
                   throws SQLException
Return objects of all tables which are associated to this object.

Specified by:
getAssociated in interface IRecord
Throws:
SQLException
Since:
v0.3

getAssociated

public List getAssociated(String tableName)
                   throws SQLException
Return objects of the given table which are associated to this object.

Specified by:
getAssociated in interface IRecord
Throws:
SQLException
Since:
v0.3

getAssociated

public List getAssociated(ITableData tableData)
                   throws SQLException
Return objects of the given table which are associated to this object.

Specified by:
getAssociated in interface IRecord
Throws:
SQLException
Since:
v0.3

getDatabase

public IDatabase getDatabase()
Return the database.

Specified by:
getDatabase in interface IRecord
Since:
v0.3

getId

public int getId()
Return the object ID.

Specified by:
getId in interface IRecord
Since:
v0.3

getJoins

public Iterator getJoins()
Return an iterator over IAssociation s which involve this object's table.

Specified by:
getJoins in interface IRecord
Since:
v0.3

getJunctions

public Iterator getJunctions()
Return an iterator over IAssociation s which involve this object's table.

Specified by:
getJunctions in interface IRecord
Since:
v0.3

getTableData

public ITableData getTableData()
Return the table data.

Specified by:
getTableData in interface IRecord
Since:
v0.3

getTableName

public String getTableName()
Return the table name.

Specified by:
getTableName in interface IRecord
Since:
v0.3

hashCode

public int hashCode()
Return the hash code.

Specified by:
hashCode in interface IGenericData
Overrides:
hashCode in class GenericData
Since:
v0.3

insert

public void insert()
            throws SQLException
Insert this object into the database.

Specified by:
insert in interface IRecord
Throws:
SQLException
Since:
v0.3

reload

public void reload()
            throws SQLException
Reload this object from the database.

Specified by:
reload in interface IRecord
Throws:
SQLException
Since:
v0.3

set

public void set(String propertyName,
                Class type,
                Object value)
Set the value of the named property. Overrides the super method to convert the property name to uppercase.

Specified by:
set in interface IRecord
Specified by:
set in interface IGenericData
Overrides:
set in class GenericData
Since:
v0.3

toDebugString

public String toDebugString()
Return a string representation of this object.

Specified by:
toDebugString in interface IRecord
Since:
v0.3

toString

public String toString()
Return a string representation of this object.

Specified by:
toString in interface IRecord
Specified by:
toString in interface IGenericData
Overrides:
toString in class GenericData
Since:
v0.3

toXMLString

public String toXMLString()
Return an XML string representation of this object.

Specified by:
toXMLString in interface IRecord
Since:
v0.3

update

public void update()
            throws SQLException
Update this object in the database.

Specified by:
update in interface IRecord
Throws:
SQLException
Since:
v0.3

printList

protected static void printList(String title,
                                List rows)


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02