01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.storage.search;
11:
12: /**
13: * A sortorder specifies sorting of a single field.
14: * <p>
15: * This corresponds to use of ORDER BY in SQL SELECT-syntax.
16: *
17: * @author Rob van Maris
18: * @version $Id: SortOrder.java,v 1.5 2007/12/06 08:13:36 michiel Exp $
19: * @since MMBase-1.7
20: */
21: public interface SortOrder {
22:
23: /** Order for <em>ascending</em> sort order. */
24: int ORDER_ASCENDING = 1;
25:
26: /** Order for <em>descending</em> sort order. */
27: int ORDER_DESCENDING = 2;
28:
29: /**
30: * Order descriptions corresponding to the order values:
31: * {@link #ORDER_ASCENDING}, and {@link #ORDER_DESCENDING}
32: */
33: public final static String[] ORDER_DESCRIPTIONS = new String[] {
34: null, // not specified
35: "ascending", "descending" };
36:
37: /**
38: * Gets the associated field.
39: * <p>
40: * This corresponds to a fieldname in a "ORDER BY" clause in SQL SELECT-syntax.
41: */
42: StepField getField();
43:
44: /**
45: * Gets the sort direction. This is be either ORDER_ASCENDING or ORDER_DESCENDING.
46: * <p>
47: * This corresponds to the use of ASC and DESC in SQL SELECT-syntax.
48: */
49: int getDirection();
50:
51: /**
52: * Whether sorting must happen case sensitivily. If not, normally something like ordering on the
53: * uppercased field will happen.
54: * @since MMBase-1.8
55: */
56: boolean isCaseSensitive();
57:
58: /**
59: * Compares this sortorder to the specified object. The result is
60: * <code>true</code> if and only if the argument is a non-null
61: * SortOrder object associated with the same field, using the same
62: * sort direction.
63: *
64: * @param obj The object to compare with.
65: * @return <code>true</code> if the objects are equal,
66: * <code>false</code> otherwise.
67: */
68: public boolean equals(Object obj);
69:
70: // javadoc is inherited
71: public int hashCode();
72:
73: /**
74: * Returns a string representation of this SortOrder.
75: * The string representation has the form
76: * "SortOrder(field:<field>, dir:<dir>)"
77: * where
78: * <ul>
79: * <li><em><field></em> is the field alias returned by
80: * <code>getField().getAlias()</code>
81: * <li><em><dir></em> is the direction returned by
82: * {@link #getDirection getDirection()}
83: * </ul>
84: *
85: * @return A string representation of this SortOrder.
86: */
87: public String toString();
88:
89: }
|