com.workingdogs.village
Class Record

java.lang.Object
  extended by com.workingdogs.village.Record

public class Record
extends java.lang.Object

A Record represents a row in the database. It contains a collection of Values which are the individual contents of each column in the row.

Version:
$Revision: 568 $
Author:
Jon S. Stevens

Constructor Summary
Record()
          This isn't used and doesn't do anything.
Record(DataSet ds)
          Creates a new Record and sets the parent dataset to the passed in value.
 
Method Summary
 java.lang.String asFormattedString(java.lang.String valueseparator, int[] maxwidths)
          return the value of each column as a string.
 DataSet dataset()
          Gets the DataSet for this Record
 java.lang.String getRefreshQueryString()
          This builds the SELECT statement in order to refresh the contents of this Record.
 java.lang.String getSaveString()
          Gets the appropriate SQL string for this record.
 Value getValue(int i)
          gets the value at index i
 Value getValue(java.lang.String columnName)
          TODO: DOCUMENT ME!
 boolean isAZombie()
          Determines if this record is a Zombie.
 void markForInsert()
          Marks this record to be inserted when a save is executed.
 void markForUpdate()
          Marks this record to be updated when a save is executed.
 void markRecordClean()
          Marks all the values in this record as clean.
 Record markToBeDeleted()
          Marks this record to be deleted when a save is executed.
 void markValueClean(int pos)
          marks a value at a given position as clean.
 void markValueClean(java.lang.String columnName)
          marks a value with a given column name as clean.
 void markValueDirty(int pos)
          marks a value at a given position as dirty.
 void markValueDirty(java.lang.String columnName)
          marks a value with a given column name as dirty.
 boolean needsToBeSaved()
          If the record is not clean, needs to be saved with an Update, Delete or Insert, it returns true.
 boolean recordIsClean()
          Goes through all the values in the record to determine if it is clean or not.
 void refresh(java.sql.Connection connection)
          This method refreshes this Record's Value's.
 int save()
          Saves the data in this Record to the database.
 int save(java.sql.Connection connection)
          Saves the data in this Record to the database.
 void saveWithoutStatusUpdate()
          TODO: DOCUMENT ME!
 Schema schema()
          Gets the schema for the parent DataSet
 Record setValue(int pos, java.math.BigDecimal value)
          sets the value at pos with a BigDecimal
 Record setValue(int pos, boolean value)
          sets the value at pos with a boolean
 Record setValue(int pos, byte[] value)
          sets the value at pos with a byte[]
 Record setValue(int pos, java.util.Date value)
          sets the value at pos with a java.util.Date
 Record setValue(int pos, java.sql.Date value)
          sets the value at pos with a java.sql.Date
 Record setValue(int pos, double value)
          sets the value at pos with a double
 Record setValue(int pos, float value)
          sets the value at pos with a float
 Record setValue(int pos, int value)
          sets the value at pos with a int
 Record setValue(int pos, long value)
          sets the value at pos with a long
 Record setValue(int pos, java.lang.String value)
          sets the value at pos with a String
 Record setValue(int pos, java.sql.Time value)
          sets the value at pos with a java.sql.Time
 Record setValue(int pos, java.sql.Timestamp value)
          sets the value at pos with a java.sql.Timestamp
 Record setValue(int pos, Value value)
          sets the value at pos with a Value
 Record setValue(java.lang.String columnName, java.math.BigDecimal value)
          sets the value at column name with a BigDecimal
 Record setValue(java.lang.String columnName, boolean value)
          sets the value at column name with a boolean
 Record setValue(java.lang.String columnName, byte[] value)
          sets the value at column name with a byte[]
 Record setValue(java.lang.String columnName, java.util.Date value)
          sets the value at column name with a java.util.Date
 Record setValue(java.lang.String columnName, java.sql.Date value)
          sets the value at column name with a java.sql.Date
 Record setValue(java.lang.String columnName, double value)
          sets the value at column name with a double
 Record setValue(java.lang.String columnName, float value)
          sets the value at column name with a float
 Record setValue(java.lang.String columnName, int value)
          sets the value at column name with a int
 Record setValue(java.lang.String columnName, long value)
          sets the value at column name with a long
 Record setValue(java.lang.String columnName, java.lang.String value)
          sets the value at column name with a String
 Record setValue(java.lang.String columnName, java.sql.Time value)
          sets the value at column name with a java.sql.Time
 Record setValue(java.lang.String columnName, java.sql.Timestamp value)
          sets the value at column name with a java.sql.Timestamp
 Record setValue(java.lang.String columnName, Value value)
          sets the value at column name with a Value
 Record setValueNull(int pos)
          sets the value at pos with a NULL
 Record setValueNull(java.lang.String columnName)
          sets the value at column name with a NULL
 int size()
          the number of columns in this object
 boolean toBeSavedWithDelete()
          whether or not this Record is to be saved with an SQL delete statement
 boolean toBeSavedWithInsert()
          whether or not this Record is to be saved with an SQL insert statement
 boolean toBeSavedWithUpdate()
          whether or not this Record is to be saved with an SQL update statement
 java.lang.String toString()
          This returns a representation of this Record
 Record unmarkToBeDeleted()
          Unmarks a record that has been marked for deletion.
 boolean valueIsClean(int i)
          Determines whether or not a value stored in the record is clean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Record

public Record()
This isn't used and doesn't do anything.


Record

public Record(DataSet ds)
       throws DataSetException,
              java.sql.SQLException
Creates a new Record and sets the parent dataset to the passed in value. This method also creates the Value objects which are associated with this Record.

Parameters:
ds - TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
Method Detail

save

public int save()
         throws DataSetException,
                java.sql.SQLException
Saves the data in this Record to the database. Uses the parent dataset's connection.

Returns:
1 if the save completed. 0 otherwise.
Throws:
DataSetException - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!

save

public int save(java.sql.Connection connection)
         throws DataSetException,
                java.sql.SQLException
Saves the data in this Record to the database. Uses the connection passed into it.

Parameters:
connection - TODO: DOCUMENT ME!
Returns:
1 if the save completed. 0 otherwise.
Throws:
DataSetException - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!

getSaveString

public java.lang.String getSaveString()
                               throws DataSetException
Gets the appropriate SQL string for this record.

Returns:
SQL string
Throws:
DataSetException - TODO: DOCUMENT ME!

getValue

public Value getValue(int i)
               throws DataSetException
gets the value at index i

Parameters:
i - TODO: DOCUMENT ME!
Returns:
the Value object at index i
Throws:
DataSetException - TODO: DOCUMENT ME!

getValue

public Value getValue(java.lang.String columnName)
               throws DataSetException
TODO: DOCUMENT ME!

Parameters:
columnName - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

size

public int size()
the number of columns in this object

Returns:
the number of columns in this object

toBeSavedWithInsert

public boolean toBeSavedWithInsert()
whether or not this Record is to be saved with an SQL insert statement

Returns:
true if saved with insert

toBeSavedWithUpdate

public boolean toBeSavedWithUpdate()
whether or not this Record is to be saved with an SQL update statement

Returns:
true if saved with update

toBeSavedWithDelete

public boolean toBeSavedWithDelete()
whether or not this Record is to be saved with an SQL delete statement

Returns:
true if saved with delete

markRecordClean

public void markRecordClean()
                     throws DataSetException
Marks all the values in this record as clean.

Throws:
DataSetException - TODO: DOCUMENT ME!

markForInsert

public void markForInsert()
                   throws DataSetException
Marks this record to be inserted when a save is executed.

Throws:
DataSetException - TODO: DOCUMENT ME!

markForUpdate

public void markForUpdate()
                   throws DataSetException
Marks this record to be updated when a save is executed.

Throws:
DataSetException - TODO: DOCUMENT ME!

markToBeDeleted

public Record markToBeDeleted()
                       throws DataSetException
Marks this record to be deleted when a save is executed.

Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

unmarkToBeDeleted

public Record unmarkToBeDeleted()
                         throws DataSetException
Unmarks a record that has been marked for deletion.

WARNING: You must reset the save type before trying to save this record again.

Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!
See Also:
markForUpdate(), markForInsert(), markToBeDeleted()

markValueClean

public void markValueClean(int pos)
                    throws DataSetException
marks a value at a given position as clean.

Parameters:
pos - TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

markValueClean

public void markValueClean(java.lang.String columnName)
                    throws DataSetException
marks a value with a given column name as clean.

Parameters:
columnName - TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

markValueDirty

public void markValueDirty(int pos)
                    throws DataSetException
marks a value at a given position as dirty.

Parameters:
pos - TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

markValueDirty

public void markValueDirty(java.lang.String columnName)
                    throws DataSetException
marks a value with a given column name as dirty.

Parameters:
columnName - TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       java.math.BigDecimal value)
                throws DataSetException
sets the value at pos with a BigDecimal

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       boolean value)
                throws DataSetException
sets the value at pos with a boolean

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       byte[] value)
                throws DataSetException
sets the value at pos with a byte[]

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       java.util.Date value)
                throws DataSetException
sets the value at pos with a java.util.Date

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       java.sql.Date value)
                throws DataSetException
sets the value at pos with a java.sql.Date

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       double value)
                throws DataSetException
sets the value at pos with a double

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       float value)
                throws DataSetException
sets the value at pos with a float

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       int value)
                throws DataSetException
sets the value at pos with a int

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       long value)
                throws DataSetException
sets the value at pos with a long

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       java.lang.String value)
                throws DataSetException
sets the value at pos with a String

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       java.sql.Time value)
                throws DataSetException
sets the value at pos with a java.sql.Time

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       java.sql.Timestamp value)
                throws DataSetException
sets the value at pos with a java.sql.Timestamp

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(int pos,
                       Value value)
                throws DataSetException
sets the value at pos with a Value

Parameters:
pos - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       java.math.BigDecimal value)
                throws DataSetException
sets the value at column name with a BigDecimal

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       boolean value)
                throws DataSetException
sets the value at column name with a boolean

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       byte[] value)
                throws DataSetException
sets the value at column name with a byte[]

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       java.util.Date value)
                throws DataSetException
sets the value at column name with a java.util.Date

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       java.sql.Date value)
                throws DataSetException
sets the value at column name with a java.sql.Date

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       double value)
                throws DataSetException
sets the value at column name with a double

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       float value)
                throws DataSetException
sets the value at column name with a float

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       int value)
                throws DataSetException
sets the value at column name with a int

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       long value)
                throws DataSetException
sets the value at column name with a long

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       java.lang.String value)
                throws DataSetException
sets the value at column name with a String

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       java.sql.Time value)
                throws DataSetException
sets the value at column name with a java.sql.Time

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       java.sql.Timestamp value)
                throws DataSetException
sets the value at column name with a java.sql.Timestamp

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValue

public Record setValue(java.lang.String columnName,
                       Value value)
                throws DataSetException
sets the value at column name with a Value

Parameters:
columnName - TODO: DOCUMENT ME!
value - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValueNull

public Record setValueNull(int pos)
                    throws DataSetException
sets the value at pos with a NULL

Parameters:
pos - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

setValueNull

public Record setValueNull(java.lang.String columnName)
                    throws DataSetException
sets the value at column name with a NULL

Parameters:
columnName - TODO: DOCUMENT ME!
Returns:
TODO: DOCUMENT ME!
Throws:
DataSetException - TODO: DOCUMENT ME!

isAZombie

public boolean isAZombie()
Determines if this record is a Zombie. A Zombie is a record that has been deleted from the database, but not yet removed from the DataSet.

Returns:
a boolean

needsToBeSaved

public boolean needsToBeSaved()
If the record is not clean, needs to be saved with an Update, Delete or Insert, it returns true.

Returns:
boolean

valueIsClean

public boolean valueIsClean(int i)
Determines whether or not a value stored in the record is clean.

Parameters:
i - TODO: DOCUMENT ME!
Returns:
true if clean

recordIsClean

public boolean recordIsClean()
Goes through all the values in the record to determine if it is clean or not.

Returns:
true if clean

refresh

public void refresh(java.sql.Connection connection)
             throws DataSetException,
                    java.sql.SQLException
This method refreshes this Record's Value's. It can only be performed on a Record that has not been modified and has been created with a TableDataSet and corresponding KeyDef.

Parameters:
connection -
Throws:
DataSetException
java.sql.SQLException

getRefreshQueryString

public java.lang.String getRefreshQueryString()
                                       throws DataSetException
This builds the SELECT statement in order to refresh the contents of this Record. It depends on a valid KeyDef to exist and it must have been created with a TableDataSet.

Returns:
the SELECT string
Throws:
DataSetException

saveWithoutStatusUpdate

public void saveWithoutStatusUpdate()
                             throws DataSetException
TODO: DOCUMENT ME!

Throws:
DataSetException - TODO: DOCUMENT ME!

schema

public Schema schema()
              throws DataSetException
Gets the schema for the parent DataSet

Returns:
the schema for the parent DataSet
Throws:
DataSetException - TODO: DOCUMENT ME!

dataset

public DataSet dataset()
Gets the DataSet for this Record

Returns:
the DataSet for this Record

asFormattedString

public java.lang.String asFormattedString(java.lang.String valueseparator,
                                          int[] maxwidths)
                                   throws DataSetException
return the value of each column as a string. Not yet implemented!

Parameters:
valueseparator -
maxwidths -
Returns:
the formatted string
Throws:
DataSetException

toString

public java.lang.String toString()
This returns a representation of this Record

Overrides:
toString in class java.lang.Object
Returns:
java.lang.String


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.