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 field in an aggregated query.
14: * <p>
15: * Each field in a aggregated query has an aggregation type, which is one of
16: * the values listed below.
17: * </ul>
18: * This corresponds to an aggregated field in SQL SELECT-syntax.
19: *
20: * @author Rob van Maris
21: * @version $Id: AggregatedField.java,v 1.4 2005/04/25 14:56:57 pierre Exp $
22: * @since MMBase-1.7
23: */
24: public interface AggregatedField extends StepField {
25:
26: /**
27: * Aggregation type, resulting in grouping the results on non-null
28: * values of this field.
29: */
30: public final static int AGGREGATION_TYPE_GROUP_BY = 1;
31:
32: /**
33: * Aggregation type, resulting in count of non-null
34: * values in this field.
35: */
36: public final static int AGGREGATION_TYPE_COUNT = 2;
37:
38: /**
39: * Aggregation type, resulting in count of distinct non-null
40: * values in this field.
41: */
42: public final static int AGGREGATION_TYPE_COUNT_DISTINCT = 3;
43:
44: /** Aggregation type, resulting in minimum value in this field. */
45: public final static int AGGREGATION_TYPE_MIN = 4;
46:
47: /** Aggregation type, resulting in maximum value in this field. */
48: public final static int AGGREGATION_TYPE_MAX = 5;
49:
50: /**
51: * Search type descriptions corresponding to the search type values:
52: * {@link #AGGREGATION_TYPE_GROUP_BY}, {@link #AGGREGATION_TYPE_COUNT}, {@link #AGGREGATION_TYPE_COUNT_DISTINCT},
53: * {@link #AGGREGATION_TYPE_MIN}, and {@link #AGGREGATION_TYPE_MAX}
54: */
55: String[] AGGREGATION_TYPE_DESCRIPTIONS = new String[] { null, // not specified
56: "group by", "count", "count distinct", "min", "max" };
57:
58: /**
59: * Gets the aggregation type.
60: */
61: public int getAggregationType();
62:
63: /**
64: * Compares this aggregated field to the specified object. The result is
65: * <code>true</code> if and only if the argument is a non-null
66: * <code>AggregatedField</code> object associated with the same field,
67: * using the same alias, and having the same aggregation type.
68: *
69: * @param obj The object to compare with.
70: * @return <code>true</code> if the objects are equal,
71: * <code>false</code> otherwise.
72: */
73: public boolean equals(Object obj);
74:
75: /**
76: * Returns a string representation of this AggregatedField.
77: * The string representation has the form
78: * "AggregatedField(step:<step>, fieldname:<fieldname>,
79: * alias:<alias>, aggregationtype:<aggregationtype>)"
80: * where
81: * <ul>
82: * <li><em><step></em> is the step alias returned by
83: * <code>getStep().getAlias()</code> or,
84: * when the step alias is <code>null</code>, the step tablename
85: * returned by <code>getStep().getTableName()</code>.
86: * <li><em><fieldname></em> is the fieldname returned by
87: * {@link #getFieldName getFieldName()}
88: * <li><em><alias></em> is the alias returned by
89: * {@link #getAlias getAlias()}
90: * <li><em><aggregationtype></em> is the alias returned by
91: * {@link #getAggregationType getAggregationType()}
92: * </ul>
93: *
94: * @return A string representation of this AggregatedField.
95: */
96: public String toString();
97: }
|