edu.hussam.database.sql
Class DatabaseRecord

java.lang.Object
extended by edu.hussam.database.sql.DatabaseRecord
All Implemented Interfaces:
Record, java.lang.Comparable<Record>

public class DatabaseRecord
extends java.lang.Object
implements Record, java.lang.Comparable<Record>


Field Summary
protected  java.util.Map<java.lang.String,java.lang.Object>entries
           
 
Constructor Summary
DatabaseRecord(RecordHome home, java.util.Map<java.lang.String,java.lang.Object> entries)
           
DatabaseRecord(RecordHome home, java.lang.Object primary)
           
DatabaseRecord(RecordHome home, Record record, java.lang.Object primary)
           
 
Method Summary
 voidcanRead(java.lang.String entryName)
          Checks if you can read this entry.
 voidcanWrite(java.lang.String entryName)
          Checks if the entry value can be changed.
 voidcheckAlive()
          Checks if this Record is still usefull.
 intcompareTo(Record r)
           
protected  voidfinalize()
           
protected  java.lang.Objectget(java.lang.String entryName)
           
 java.util.Map<java.lang.String,java.lang.Object>getEntries()
          Returns all entries. a map of Map
 java.lang.ObjectgetEntry(java.lang.String entryName)
          returns the value of the given entry.
 RecordHomegetHome()
          Returns the RecordHome from which this Record belongs to.
 java.lang.ObjectgetKey()
          Returns the key of this Record.
 java.lang.ObjectgetRecord(java.lang.String entryName)
          returns the record given the entry name.
 booleanisLocked()
          Sets the entry without checking the accessability.
 voidlock()
           
protected  voidset(java.lang.String entryName, java.lang.Object entry)
           
 voidsetEntries(java.util.Map<java.lang.String,java.lang.Object> entries)
          Sets the given entries to this Record.Map
 voidsetEntry(java.lang.String entryName, java.lang.Object entry)
          Sets the given entry with the given object.
 java.lang.StringtoString()
           
 voidunlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

entries

protected java.util.Map<java.lang.String,java.lang.Object> entries
Constructor Detail

DatabaseRecord

public DatabaseRecord(RecordHome home,
                      java.lang.Object primary)

DatabaseRecord

public DatabaseRecord(RecordHome home,
                      java.util.Map<java.lang.String,java.lang.Object> entries)

DatabaseRecord

public DatabaseRecord(RecordHome home,
Record record,
                      java.lang.Object primary)
               throws DatabaseException
Throws:
DatabaseException
Method Detail

getHome

public RecordHome getHome()
Description copied from interface: Record
Returns the RecordHome from which this Record belongs to.

Specified by:
getHome in interface Record
Returns:
The record home of factory of this Record.

isLocked

public boolean isLocked()
Sets the entry without checking the accessability.


lock

public void lock()
          throws DatabaseException
Throws:
DatabaseException

unlock

public void unlock()
            throws DatabaseException
Throws:
DatabaseException

set

protected void set(java.lang.String entryName,
                   java.lang.Object entry)
            throws DatabaseException
Throws:
DatabaseException

setEntry

public void setEntry(java.lang.String entryName,
                     java.lang.Object entry)
              throws DatabaseException
Description copied from interface: Record
Sets the given entry with the given object.

Specified by:
setEntry in interface Record
Parameters:
entryName - the name of the entry. it can reflect a column name in a database table.
entry - the value of the entry.
Throws:
DatabaseException - if a problem happens.

get

protected java.lang.Object get(java.lang.String entryName)
                        throws DatabaseException
Throws:
DatabaseException

getEntry

public java.lang.Object getEntry(java.lang.String entryName)
                          throws DatabaseException
Description copied from interface: Record
returns the value of the given entry.

Specified by:
getEntry in interface Record
Parameters:
entryName - the entry name, can be column name in a database table.
Returns:
the value of this entry in this reocrd.
Throws:
DatabaseException - if a problem occurs.

getRecord

public java.lang.Object getRecord(java.lang.String entryName)
                           throws DatabaseException
Description copied from interface: Record
returns the record given the entry name. (if it really represents a record)

Specified by:
getRecord in interface Record
Parameters:
entryName - the name of the entry, can be a column name in a database table.
Returns:
the value of this entry, or the Record if this entry represents a forign key.
Throws:
DatabaseException - if a problem happens.

setEntries

public void setEntries(java.util.Map<java.lang.String,java.lang.Object> entries)
                throws DatabaseException
Description copied from interface: Record
Sets the given entries to this Record.Map

Specified by:
setEntries in interface Record
Parameters:
entries - a map containg entry names, and their values.
Throws:
DatabaseException - If a problem occures.

getEntries

public java.util.Map<java.lang.String,java.lang.Object> getEntries()
                                                            throws DatabaseException
Description copied from interface: Record
Returns all entries. a map of Map

Specified by:
getEntries in interface Record
Returns:
a map of entry names and their values.
Throws:
DatabaseException - if a problem happens.

getKey

public java.lang.Object getKey()
Description copied from interface: Record
Returns the key of this Record.

Specified by:
getKey in interface Record
Returns:
returns the value that makes this record unique. it can be a primary key in a database table.

canWrite

public void canWrite(java.lang.String entryName)
              throws DatabaseException
Description copied from interface: Record
Checks if the entry value can be changed. Throws an exception if you cannot.

Specified by:
canWrite in interface Record
Parameters:
entryName - the name of the entry.
Throws:
DatabaseException - if a problem happens.

canRead

public void canRead(java.lang.String entryName)
             throws DatabaseException
Description copied from interface: Record
Checks if you can read this entry.

Specified by:
canRead in interface Record
Parameters:
entryName - the name of the entry.
Throws:
DatabaseException - if a problem happens.

checkAlive

public void checkAlive()
                throws DatabaseException
Description copied from interface: Record
Checks if this Record is still usefull.

Specified by:
checkAlive in interface Record
Throws:
DatabaseException - if a problem happens.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Record r)
Specified by:
compareTo in interface java.lang.Comparable<Record>

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object