You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2001/05/01 05:33:36 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/db Criteria.java

dlr         01/04/30 20:33:36

  Modified:    src/java/org/apache/turbine/util/db Criteria.java
  Log:
  Integrated patch by Travis Low to provide a consistant and correctly
  documented interface to SQL's ORDER BY clause.  Deprecated
  addOrderByColumn(), as it duplicates the purpose served by the new
  addAscendingOrderByColumn(), but has a more ambiguous interface.  If
  anyone has a problem with this change, I'm open to discussion of
  better alternatives.
  
  Revision  Changes    Path
  1.27      +35 -5     jakarta-turbine/src/java/org/apache/turbine/util/db/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/Criteria.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Criteria.java	2001/04/26 23:57:09	1.26
  +++ Criteria.java	2001/05/01 03:33:35	1.27
  @@ -81,7 +81,7 @@
    * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
    * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
    * @author <a href="mailto:eric@dobbse.net">Eric Dobbs</a>
  - * @version $Id: Criteria.java,v 1.26 2001/04/26 23:57:09 jmcnally Exp $
  + * @version $Id: Criteria.java,v 1.27 2001/05/01 03:33:35 dlr Exp $
    */
   public class Criteria extends Hashtable
   {
  @@ -159,6 +159,16 @@
        */
       public static final String JOIN = "JOIN";
   
  +    /**
  +     * "Order by" qualifier - ascending
  +     */
  +    public static final String ASC = "ASC";
  +
  +    /**
  +     * "Order by" qualifier - descending
  +     */
  +    public static final String DESC = "DESC";
  +
       private static final int DEFAULT_CAPACITY = 10;
   
       private boolean ignoreCase = false;
  @@ -1511,14 +1521,34 @@
       }
   
       /**
  -     * Add order by column name.
  +     * @deprecated Use addAscendingOrderByColumn() instead.
  +     */
  +    public Criteria addOrderByColumn( String name )
  +    {
  +        return addAscendingOrderByColumn(name);
  +    }
  +
  +    /**
  +     * Add order by column name, explicitly specifying ascending.
        *
  -     * @param name A String with the name of the order column.
  +     * @param name The name of the column to order by.
        * @return A modified Criteria object.
        */
  -    public Criteria addOrderByColumn( String name )
  +    public Criteria addAscendingOrderByColumn( String name )
  +    {
  +        orderByColumns.add( name + " " + ASC );
  +        return this;
  +    }
  +
  +    /**
  +     * Add order by column name, explicitly specifying descending.
  +     *
  +     * @param name The name of the column to order by.
  +     * @return A modified Criteria object.
  +     */
  +    public Criteria addDescendingOrderByColumn( String name )
       {
  -        orderByColumns.add( name );
  +        orderByColumns.add( name + " " + DESC );
           return this;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org