Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jdaemon.era.sql
Class Query  view Query download Query.java

java.lang.Object
  extended byorg.jdaemon.era.sql.Query
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
TableQuery

public abstract class Query
extends java.lang.Object
implements java.lang.Cloneable

Class encapsulating the programmatic construction of SQL Queries of various types.


Nested Class Summary
static class Query.Constraint
          Class encapsulating a Constraint in a query.
 
Field Summary
private  org.jdaemon.util.sql.ConnectionManager connection_manager
          Manager for a database connection
private  org.jdaemon.util.QuickList constraints
          list of Constraint object operating on this Query
 
Constructor Summary
Query(org.jdaemon.util.sql.ConnectionManager connection_manager)
          Creates a new instance of Query with an empty list of constraints.
Query(org.jdaemon.util.sql.ConnectionManager connection_manager, org.jdaemon.util.QuickList constraints)
          Query constructor
 
Method Summary
 void addConstraint(java.lang.String attribute, int operator, java.lang.Object operand)
          Add a new constraint to a query.
 Query cloneQuery()
          Clone a query.
 boolean equals(java.lang.Object other)
          Equality operator.
protected abstract  java.util.Iterator getAggregates(org.jdaemon.util.sql.ConnectionManager connection, org.jdaemon.era.Grouping grouping)
          Abstract method - retrieve attribute values and agregates from a database connection This method provides should be overridden in order to provide and implementation for getAggregates(grouping).
 java.util.Iterator getAggregates(org.jdaemon.era.Grouping grouping)
          Get an iterator of aggregate values of objects conforming to the constraints applied to this query The iterator returned is an iterator over array objects.
 org.jdaemon.util.sql.ConnectionManager getConnectionManager()
          get the connection manager used by this query
 org.jdaemon.util.QuickList getConstraints()
          get the list of constraints used by this query
protected abstract  java.util.Iterator getValues(org.jdaemon.util.sql.ConnectionManager connection, java.lang.String[] attributes, org.jdaemon.era.Sort[] sorts)
          Abstract method - retrieve attribute values from a database connection This method provides should be overridden in order to provide and implementation for getValues(attributes, sorts).
 java.util.Iterator getValues(java.lang.String[] attribute_names, org.jdaemon.era.Sort[] sorts)
          Get an iteator over all the values which conform the constraints applied to this query.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraints

private org.jdaemon.util.QuickList constraints
list of Constraint object operating on this Query


connection_manager

private org.jdaemon.util.sql.ConnectionManager connection_manager
Manager for a database connection

Constructor Detail

Query

public Query(org.jdaemon.util.sql.ConnectionManager connection_manager,
             org.jdaemon.util.QuickList constraints)
Query constructor


Query

public Query(org.jdaemon.util.sql.ConnectionManager connection_manager)
Creates a new instance of Query with an empty list of constraints. Utility method which is equivalent to Query(connection_manager, QuickList.EMPTY)

Method Detail

equals

public boolean equals(java.lang.Object other)
Equality operator. Query objects are deemed to be equal if all of the below conditions apply:
  • The connection factory used by this query equals the connection factory used by the other query
  • All of the constraints in this query and in the other query are both individually equal and were applied in the same order


getConnectionManager

public org.jdaemon.util.sql.ConnectionManager getConnectionManager()
get the connection manager used by this query


getConstraints

public org.jdaemon.util.QuickList getConstraints()
get the list of constraints used by this query


cloneQuery

public Query cloneQuery()
Clone a query. Utility wrapper around clone() method. All subclasses of query should be clonable. This should be easy to achive since copies of a Query can share a reference to the same list of constraints.


addConstraint

public void addConstraint(java.lang.String attribute,
                          int operator,
                          java.lang.Object operand)
Add a new constraint to a query.


getValues

public java.util.Iterator getValues(java.lang.String[] attribute_names,
                                    org.jdaemon.era.Sort[] sorts)
                             throws java.sql.SQLException,
                                    org.jdaemon.util.resource.ResourceManagerException
Get an iteator over all the values which conform the constraints applied to this query. The iterator returned is an iterator over array objects. Each array object contains attribute values from the objects in the underlying dataset, in the order in which they are specified in the attribute_names array. Only objects which conform to the constraints already applied to this query will be selected. Objects will be visited in the order specified by the sorts array.


getAggregates

public java.util.Iterator getAggregates(org.jdaemon.era.Grouping grouping)
                                 throws java.sql.SQLException,
                                        org.jdaemon.util.resource.ResourceManagerException
Get an iterator of aggregate values of objects conforming to the constraints applied to this query The iterator returned is an iterator over array objects. Each array object contains attributes, and the values of aggregate functions applied to certain attributes over a range, as specified in the Grouping parameter. Only attributes from objects in the underlying dataset which conform to the constraints already applied to this query will be selected.


getValues

protected abstract java.util.Iterator getValues(org.jdaemon.util.sql.ConnectionManager connection,
                                                java.lang.String[] attributes,
                                                org.jdaemon.era.Sort[] sorts)
                                         throws java.sql.SQLException,
                                                org.jdaemon.util.resource.ResourceManagerException
Abstract method - retrieve attribute values from a database connection This method provides should be overridden in order to provide and implementation for getValues(attributes, sorts).


getAggregates

protected abstract java.util.Iterator getAggregates(org.jdaemon.util.sql.ConnectionManager connection,
                                                    org.jdaemon.era.Grouping grouping)
                                             throws java.sql.SQLException,
                                                    org.jdaemon.util.resource.ResourceManagerException
Abstract method - retrieve attribute values and agregates from a database connection This method provides should be overridden in order to provide and implementation for getAggregates(grouping).