husted 2002/10/28 07:17:13 Modified: scaffold/src/java/org/apache/commons/scaffold/util Scroller.java StorageBean.java Log: + StorageBean: Additional convenience methods. + Scroller: Add parameters property to reinvoke complex queries. Revision Changes Path 1.3 +76 -1 jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/util/Scroller.java Index: Scroller.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/util/Scroller.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Scroller.java 18 Oct 2002 20:45:49 -0000 1.2 +++ Scroller.java 28 Oct 2002 15:17:13 -0000 1.3 @@ -1,6 +1,12 @@ package org.apache.commons.scaffold.util; +import java.util.List; +import java.util.Map; + +import org.apache.commons.scaffold.text.ConvertUtils; + + /** * Scroller tracks the coordinates needed to manage * flipping through a result list using @@ -12,6 +18,8 @@ * * @author James Klicman <[EMAIL PROTECTED]> * @author Ted Husted + * @author WXXI Public Broadcasting Council + * @author OK State DEQ * @version $Revision$ $Date$ */ public class Scroller { @@ -25,6 +33,7 @@ public Scroller() { } + // ---------------------------------------------------------------- Properties @@ -204,6 +213,72 @@ */ public int getCount() { return(this.count); + } + + + /** + * Field for the parameters property [java.util.HashMap]. + */ + protected Map parameters = new java.util.HashMap(); + + + /** + * Set parameters + * @param parameters The new parameters value. + */ + public void setParameters(Map parameters) { + this.parameters = parameters; + } + + + /** + * Return parameters. + * @returns The parameters value. + */ + public Map getParameters() { + return(this.parameters); + } + + + /** + * Set a parameter + * @param key The parameter name + * @param value The parameter value + */ + public void putParameter(String key, String value) { + getParameters().put(key,value); + } + + + /** + * Set a parameter + * @param key The parameter name + * @param value The parameter value + */ + public boolean isParameters() { + return (!getParameters().isEmpty()); + } + + + /** + * Return parameters as a query string for use with a URI. + * @returns query string + */ + public String getQueryString(String uri) { + + return ConvertUtils.addParams(uri,getParameters()); + + } + + + /** + * Return parameters as a series of hidden HTML fields. + * @returns parameters as a series of hidden HTML fields. + */ + public String getHiddenFields() { + + return ConvertUtils.renderHiddenFields(getParameters()); + } 1.5 +59 -13 jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/util/StorageBean.java Index: StorageBean.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/util/StorageBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- StorageBean.java 12 Sep 2002 12:38:14 -0000 1.4 +++ StorageBean.java 28 Oct 2002 15:17:13 -0000 1.5 @@ -62,6 +62,7 @@ * @todo CommandStore objects * @author Ted Husted * @author OK State DEQ + * @author WXXI Public Broadcasting Council * @version $Revision$ $Date$ */ public interface StorageBean extends Storable,ProcessBean { @@ -148,7 +149,33 @@ public void populate(Map parameters) throws Exception; -// ---------------------------------------------------- Storage Methods +// -------------------------------------------------- Retrieval Methods + + + /** + * Count of matching entries. + * @param command Name of command to execute + * @param parameter A parameter to be used with command + * @return Count of matching entries + * @exception Resource exception if data access error occurs + */ + public int count( + String command, + Object parameter) + throws ResourceException; + + + /** + * Count of matching entries using LIKE statement + * @param command Name of command to execute + * @param parameter A String parameter to be used with LIKE command + * @return Count of matching entries + * @exception Resource exception if data access error occurs + */ + public int countLike( + String command, + String parameter) + throws ResourceException; /** @@ -157,8 +184,6 @@ * <p> * @param command Name of command to execute * @exception Resource exception if data access error occurs - * @author Ted Husted - * @version $Revision$ $Date$ */ public void executeUpdate(String command) throws ResourceException; @@ -170,8 +195,6 @@ * <p> * @param command Name of command to execute * @exception Resource exception if data access error occurs - * @author Ted Husted - * @version $Revision$ $Date$ */ public void executeUpdateRoot(String command) throws ResourceException; @@ -202,7 +225,7 @@ /** - * Retrieve a collection of beans from data stoarge. + * Retrieve a collection of beans from data storage. * <p> * @return Collection with entry or empty collection * @exception throws ResourceException if data access error occurs @@ -212,12 +235,33 @@ * collection * @param parameters An array of parameters to be used with command */ - public Collection findCollection(Object target, - String command, Object[] parameters) throws ResourceException; + public Collection findCollection( + Object target, + String command, + Object[] parameters) throws ResourceException; + + + /** + * Retrieve a collection of beans from data storage. + * <p> + * @return Collection with entry or empty collection + * @exception throws PropertiesException, ResourceException + * if data access error occurs + * @param target Object to use as factory when populating + * (e.g. this). + * @param command Name of the data access command + * collection + * @param parameter A String parameter to be used with command + */ + public Collection findCollectionLike( + Object target, + String command, + String parameter) throws ResourceException; + /** - * Retrieve a collection of beans from data stoarge. + * Retrieve a collection of beans from data storage. * <p> * @return Collection with entry or empty collection * @exception throws PropertiesException, ResourceException @@ -228,8 +272,11 @@ * collection * @param parameter A String parameter to be used with command */ - public Collection findCollectionLike(Object target, - String command, String parameter) throws ResourceException; + public Collection findCollectionLike( + Object target, + String command, + Object[] parameters) throws ResourceException; + /** @@ -252,7 +299,6 @@ String property, String value) throws ParameterException, PopulateException, ResourceException; - // ------------------------------------------------------------- store
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>