KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > criterion > AliasedProjection


1 //$Id: AliasedProjection.java,v 1.3 2005/02/12 07:19:13 steveebersole Exp $
2
package org.hibernate.criterion;
3
4 import org.hibernate.Criteria;
5 import org.hibernate.HibernateException;
6 import org.hibernate.type.Type;
7
8 /**
9  * @author Gavin King
10  */

11 public class AliasedProjection implements Projection {
12     
13     private final Projection projection;
14     private final String JavaDoc alias;
15     
16     public String JavaDoc toString() {
17         return projection.toString() + " as " + alias;
18     }
19     
20     protected AliasedProjection(Projection projection, String JavaDoc alias) {
21         this.projection = projection;
22         this.alias = alias;
23     }
24
25     public String JavaDoc toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
26     throws HibernateException {
27         return projection.toSqlString(criteria, position, criteriaQuery);
28     }
29
30     public String JavaDoc toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
31     throws HibernateException {
32         return projection.toGroupSqlString(criteria, criteriaQuery);
33     }
34
35     public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
36     throws HibernateException {
37         return projection.getTypes(criteria, criteriaQuery);
38     }
39
40     public String JavaDoc[] getColumnAliases(int loc) {
41         return projection.getColumnAliases(loc);
42     }
43
44     public Type[] getTypes(String JavaDoc alias, Criteria criteria, CriteriaQuery criteriaQuery)
45     throws HibernateException {
46         return this.alias.equals(alias) ?
47                 getTypes(criteria, criteriaQuery) :
48                 null;
49     }
50
51     public String JavaDoc[] getColumnAliases(String JavaDoc alias, int loc) {
52         return this.alias.equals(alias) ?
53                 getColumnAliases(loc) :
54                 null;
55     }
56
57     public String JavaDoc[] getAliases() {
58         return new String JavaDoc[]{ alias };
59     }
60
61     public boolean isGrouped() {
62         return projection.isGrouped();
63     }
64
65 }
66
Popular Tags