You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hu...@apache.org on 2002/10/28 20:45:57 UTC

cvs commit: jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/util ScrollerBean.java Scroller.java

husted      2002/10/28 11:45:57

  Modified:    scaffold/src/java/org/apache/commons/scaffold/util
                        Scroller.java
  Added:       scaffold/src/java/org/apache/commons/scaffold/util
                        ScrollerBean.java
  Log:
  + ScrollerBean: Initial version.
  
  Revision  Changes    Path
  1.4       +12 -6     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Scroller.java	28 Oct 2002 15:17:13 -0000	1.3
  +++ Scroller.java	28 Oct 2002 19:45:57 -0000	1.4
  @@ -24,16 +24,22 @@
    */
   public class Scroller {
   
  -  public Scroller(int from, int limit, int count) {
  -     setFrom(from);
  -     setLimit(limit);
  -     setCount(count);
  +
  +  public Scroller(int entries, int from, int limit, int count) {
  +     calculate(entries,from,limit,count);
     }
   
  +
     public Scroller() {
     }
   
   
  +  /**
  +   * The maximum to return with a scrolling list.,
  +   */
  +  public static final int SCROLL_ROWS = 20;
  +
  +
   // ---------------------------------------------------------------- Properties
   
   
  @@ -394,7 +400,7 @@
      * @param entries The number of matches in this set
      * @param from The first absolute row in this set
      * @param count How many rows in the complete set
  -   * @param limit The maximum many rows in a subset
  +   * @param limit The maximum rows in a subset page
      */
     public void calculate(int entries, int from, int count, int limit) {
   
  
  
  
  1.1                  jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/util/ScrollerBean.java
  
  Index: ScrollerBean.java
  ===================================================================
  package org.apache.commons.scaffold.util;
  
  
  import java.util.Collection;
  
  import org.apache.commons.scaffold.lang.Tokens;
  
  import org.apache.commons.scaffold.lang.ParameterException;
  import org.apache.commons.scaffold.lang.ResourceException;
  
  
  /**
   * Base class for scrolling searches.
   *
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2002/10/28 19:45:57 $
   */
  public interface ScrollerBean {
  
  
      /**
       * The relative position of the first entry in this set.
       * @returns the position to start this set
       */
      public int getScrollFrom();
  
      public void setScrollFrom(int scrollFrom);
  
  
      /**
       * The number of entries to return [Scroller.SCROLL_ROWS].
       * @returns Entries per page.
       */
      public int getScrollRows();
  
  
      /**
       * The total number of entries in search list.
       * The default behavior returns a "like" search count
       * of entries matching the searchKey.
       * Override to provide functionality.
       * @returns total entries
       * @exception May throw an exception on data access error
       */
      public int getEntryCount() throws ResourceException;
  
  
      /**
       * Return new scroller using the
       * current starting point (getScrollFrom),
       * the default limit (set.SCROLL_ROWS),
       * and current count from Access (countCurrent).
       * @returns new Scroller using current and default settings.
       * @exception ResourceException on data access error
       */
      public Scroller getScroller(int entries) throws ResourceException;
  
  
      /**
       * Returns the String to use to retrieve the
       * appropriate query for this search.
       * Must be overridden or provide functionality.
       * @returns Value of command key
       */
      public String getCommandKey();
  
  
      /**
       * Return the array of parameters required by
       * insert and update commands for this object.
       * The default behavior sets the first parameter to
       * parameter, and the next two to the offset and
       * default number of scroller rolls.
       * Override for a different query pattern.
       * @returns Parameters for query
       * @exception ResourceException on data access error
       */
      public Object[] getParameters(Object parameter) throws ResourceException;
  
  
      /**
       * Returns the collection representing the result of the Search [null].
       * The default behavior performs a "like" search for the parameter
       * Override for an other search type.
       * Subclasses may ignor parameter argument
       * when <code>isParameter</code> is false.
       * @param target Bean to use for entries
       * @param parameter Value to use to match entries
       * @returns Collection with the result of the search
       */
      public Collection getResult(Object target, Object parameter)
              throws ResourceException;
  
  
      /**
       * Returns the String to use to describe the property
       * being searched ["property"].
       * Default method returns null.
       * Must be overridden or provide functionality.
       * @returns The search property
       */
      public String getSearchProperty();
  
  
      /**
       * Returns the String to use to describe the value
       * used in the search [null].
       * This can be the literal value used in the
       * query or (if isParameter==false) a description
       * of what the search returns.
       * Must be overridden or provide functionality.
       * @returns Value of search key
       */
      public String getSearchKey();
  
  
      /**
       * Returns the String to use to retrieve the
       * appropriate query to count the entries matching this search.
       * Must be overridden or provide functionality.
       * @returns Value of count key
       */
      public String getCountKey();
  
  
      /**
       * Returns whether this search takes a parameter
       * (e.g. primary key) [false].
       * Override this method to return true and
       * <code>getParameter</code> to return the
       * required parameter.
       * @returns True if this search uses a parameter
       */
      public boolean isParameter();
  
  
      /**
       * Whether to branch to "failure" if list returns zero entries.
       */
      public boolean isFailsOnEmpty ();
  
  
      /**
       * Returns the message token for an empty result
       * [Tokens.DATA_ACCESS_EMPTY].
       * May be used when isFailOnEmpty is true.
       * @returns Message token for an empty result.
       */
      public String getTokenEmptyMessage();
  
  
      /**
       * Returns the dispatch token for an empty result
       * [Tokens.FAILURE].
       * May be used when isFailOnEmpty is true.
       * @returns Message token for an empty result.
       */
      public String getTokenEmptyDispatch();
  
  
      /**
       * Invoke business logic; return result.
       */
      public Object scrollerSearch() throws Exception;
  
  
  } // end ScrollerBeanBase
  
  
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>