01: /*
02: $Header: /cvsroot/xorm/xorm/src/org/xorm/datastore/DataFetchGroup.java,v 1.3 2002/10/21 05:19:13 wbiggs Exp $
03:
04: This file is part of XORM.
05:
06: XORM is free software; you can redistribute it and/or modify
07: it under the terms of the GNU General Public License as published by
08: the Free Software Foundation; either version 2 of the License, or
09: (at your option) any later version.
10:
11: XORM is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with XORM; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package org.xorm.datastore;
21:
22: import java.util.Set;
23: import java.util.Map;
24: import java.util.HashMap;
25: import java.util.LinkedHashSet;
26:
27: /**
28: * A DataFetchGroup is used to provide information to a DatastoreDriver
29: * instance about which Columns need to be fetched for a read() operation.
30: */
31: public class DataFetchGroup {
32: private Set columns;
33: private Map columnToSubgroup = new HashMap();
34:
35: public DataFetchGroup() {
36: columns = new LinkedHashSet();
37: }
38:
39: public DataFetchGroup(Set columns) {
40: this .columns = columns;
41: }
42:
43: public void addColumn(Column column) {
44: columns.add(column);
45: }
46:
47: /**
48: * Returns true if the specified Column should be fetched.
49: */
50: public boolean shouldFetch(Column column) {
51: return columns.contains(column);
52: }
53:
54: public void addSubgroup(Column column, DataFetchGroup subgroup) {
55: columnToSubgroup.put(column, subgroup);
56: }
57:
58: public Set getColumns() {
59: return columns;
60: }
61:
62: public Set getSubgroupColumns() {
63: return columnToSubgroup.keySet();
64: }
65:
66: public DataFetchGroup getSubgroup(Column column) {
67: return (DataFetchGroup) columnToSubgroup.get(column);
68: }
69:
70: public Table getTable() {
71: // FIXME INITIALIZE IN CONSTRUCTOR
72: return ((Column) columns.iterator().next()).getTable();
73: }
74: }
|