KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > impl > CollectionFilterImpl


1 //$Id: CollectionFilterImpl.java,v 1.4 2005/02/12 07:19:22 steveebersole Exp $
2
package org.hibernate.impl;
3
4 import java.util.Iterator JavaDoc;
5 import java.util.List JavaDoc;
6 import java.util.Map JavaDoc;
7
8 import org.hibernate.HibernateException;
9 import org.hibernate.ScrollableResults;
10 import org.hibernate.engine.SessionImplementor;
11 import org.hibernate.type.Type;
12
13 /**
14  * implementation of the <tt>Query</tt> interface for collection filters
15  * @author Gavin King
16  */

17 public class CollectionFilterImpl extends QueryImpl {
18
19     private Object JavaDoc collection;
20
21     public CollectionFilterImpl(String JavaDoc queryString, Object JavaDoc collection, SessionImplementor session) {
22         super(queryString, session);
23         this.collection = collection;
24     }
25
26
27     /**
28      * @see org.hibernate.Query#iterate()
29      */

30     public Iterator JavaDoc iterate() throws HibernateException {
31         verifyParameters();
32         Map JavaDoc namedParams = getNamedParams();
33         return getSession().iterateFilter(
34                 collection,
35                 bindParameterLists(namedParams),
36                 getQueryParameters(namedParams)
37         );
38     }
39
40     /**
41      * @see org.hibernate.Query#list()
42      */

43     public List JavaDoc list() throws HibernateException {
44         verifyParameters();
45         Map JavaDoc namedParams = getNamedParams();
46         return getSession().listFilter(
47                 collection,
48                 bindParameterLists(namedParams),
49                 getQueryParameters(namedParams)
50         );
51     }
52
53     /**
54      * @see org.hibernate.Query#scroll()
55      */

56     public ScrollableResults scroll() throws HibernateException {
57         throw new UnsupportedOperationException JavaDoc("Can't scroll filters");
58     }
59
60     public Type[] typeArray() {
61         List JavaDoc typeList = getTypes();
62         int size = typeList.size();
63         Type[] result = new Type[size+1];
64         for (int i=0; i<size; i++) result[i+1] = (Type) typeList.get(i);
65         return result;
66     }
67
68     public Object JavaDoc[] valueArray() {
69         List JavaDoc valueList = getValues();
70         int size = valueList.size();
71         Object JavaDoc[] result = new Object JavaDoc[size+1];
72         for (int i=0; i<size; i++) result[i+1] = valueList.get(i);
73         return result;
74     }
75
76 }
77
Popular Tags