01: //$Id: CollectionFilterImpl.java 8524 2005-11-04 21:28:49Z steveebersole $
02: package org.hibernate.impl;
03:
04: import java.util.Iterator;
05: import java.util.List;
06: import java.util.Map;
07:
08: import org.hibernate.HibernateException;
09: import org.hibernate.ScrollableResults;
10: import org.hibernate.engine.SessionImplementor;
11: import org.hibernate.engine.query.ParameterMetadata;
12: import org.hibernate.type.Type;
13:
14: /**
15: * implementation of the <tt>Query</tt> interface for collection filters
16: * @author Gavin King
17: */
18: public class CollectionFilterImpl extends QueryImpl {
19:
20: private Object collection;
21:
22: public CollectionFilterImpl(String queryString, Object collection,
23: SessionImplementor session,
24: ParameterMetadata parameterMetadata) {
25: super (queryString, session, parameterMetadata);
26: this .collection = collection;
27: }
28:
29: /**
30: * @see org.hibernate.Query#iterate()
31: */
32: public Iterator iterate() throws HibernateException {
33: verifyParameters();
34: Map namedParams = getNamedParams();
35: return getSession().iterateFilter(collection,
36: expandParameterLists(namedParams),
37: getQueryParameters(namedParams));
38: }
39:
40: /**
41: * @see org.hibernate.Query#list()
42: */
43: public List list() throws HibernateException {
44: verifyParameters();
45: Map namedParams = getNamedParams();
46: return getSession().listFilter(collection,
47: expandParameterLists(namedParams),
48: getQueryParameters(namedParams));
49: }
50:
51: /**
52: * @see org.hibernate.Query#scroll()
53: */
54: public ScrollableResults scroll() throws HibernateException {
55: throw new UnsupportedOperationException("Can't scroll filters");
56: }
57:
58: public Type[] typeArray() {
59: List typeList = getTypes();
60: int size = typeList.size();
61: Type[] result = new Type[size + 1];
62: for (int i = 0; i < size; i++)
63: result[i + 1] = (Type) typeList.get(i);
64: return result;
65: }
66:
67: public Object[] valueArray() {
68: List valueList = getValues();
69: int size = valueList.size();
70: Object[] result = new Object[size + 1];
71: for (int i = 0; i < size; i++)
72: result[i + 1] = valueList.get(i);
73: return result;
74: }
75:
76: }
|