org.liquidsite.core.data
Class AbstractPeer

java.lang.Object
  extended byorg.liquidsite.core.data.AbstractPeer
Direct Known Subclasses:
AttributePeer, ConfigurationPeer, ContentPeer, DomainPeer, GroupPeer, HostPeer, LockPeer, PermissionPeer, PreferencePeer, UserGroupPeer, UserPeer

public abstract class AbstractPeer
extends java.lang.Object

An abstract data object peer. This class provides some of the functionality needed by all data object peers. The data object peers each provide specialized static methods for operating on the data objects by retrieving and storing them to the data source (i.e. a database).


Constructor Summary
protected AbstractPeer(java.lang.String name)
          Creates a new peer for the specified database object.
 
Method Summary
protected  long count(DataSource src, DatabaseQuery query)
          Performs a database query that returns a single number as the result.
protected  void delete(DataSource src, DatabaseQuery query)
          Performs a database delete statement.
protected abstract  AbstractData getDataObject()
          Returns a new instance of the data object.
protected  void insert(DataSource src, DatabaseQuery query)
          Performs a database insert statement.
protected  AbstractData select(DataSource src, DatabaseQuery query)
          Performs a database select query.
protected  java.util.ArrayList selectList(DataSource src, DatabaseQuery query)
          Performs a database list select query.
protected  void update(DataSource src, DatabaseQuery query)
          Performs a database update statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPeer

protected AbstractPeer(java.lang.String name)
Creates a new peer for the specified database object.

Parameters:
name - the database object name
Method Detail

getDataObject

protected abstract AbstractData getDataObject()
Returns a new instance of the data object.

Returns:
a new instance of the data object

count

protected long count(DataSource src,
                     DatabaseQuery query)
              throws DataObjectException
Performs a database query that returns a single number as the result. The data source will NOT be closed after this operation.

Parameters:
src - the data source to use
query - the database query
Returns:
the query result number, or zero (0) if no results were found
Throws:
DataObjectException - if the query couldn't be executed correctly, or the results were malformed

select

protected AbstractData select(DataSource src,
                              DatabaseQuery query)
                       throws DataObjectException
Performs a database select query. This query is supposed to return either one or zero rows. The data source will NOT be closed after this operation.

Parameters:
src - the data source to use
query - the database query
Returns:
the database object found, or null if the query didn't match any row
Throws:
DataObjectException - if the query couldn't be executed correctly, or the results were malformed

selectList

protected java.util.ArrayList selectList(DataSource src,
                                         DatabaseQuery query)
                                  throws DataObjectException
Performs a database list select query. This query is supposed to zero or more rows. The data source will NOT be closed after this operation.

Parameters:
src - the data source to use
query - the database query
Returns:
the list of database objects found
Throws:
DataObjectException - if the query couldn't be executed correctly, or the results were malformed

insert

protected void insert(DataSource src,
                      DatabaseQuery query)
               throws DataObjectException
Performs a database insert statement. No database results are returned. The data source will NOT be closed after this operation.

Parameters:
src - the data source to use
query - the database query
Throws:
DataObjectException - if the statement couldn't be executed correctly

update

protected void update(DataSource src,
                      DatabaseQuery query)
               throws DataObjectException
Performs a database update statement. No database results are returned. The data source will NOT be closed after this operation.

Parameters:
src - the data source to use
query - the database query
Throws:
DataObjectException - if the statement couldn't be executed correctly

delete

protected void delete(DataSource src,
                      DatabaseQuery query)
               throws DataObjectException
Performs a database delete statement. No database results are returned. The data source will NOT be closed after this operation.

Parameters:
src - the data source to use
query - the database query
Throws:
DataObjectException - if the statement couldn't be executed correctly