01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: SetStore.java,v 1.4 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import com.triactive.jdo.StateManager;
14: import java.util.Collection;
15: import java.util.Iterator;
16:
17: /**
18: * Implements the backing store for a Set field.
19: * <p>
20: * Different implementations of SetStore employ different techniques for
21: * modeling the Java concept of a Set in a relational data store.
22: * Individual instances of SetStore are responsible for managing the storage
23: * for some Java class's Collection or Set field across all instances of that
24: * class.
25: *
26: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
27: * @version $Revision: 1.4 $
28: */
29:
30: public interface SetStore {
31: StoreManager getStoreManager();
32:
33: Class getElementType();
34:
35: boolean allowsNulls();
36:
37: Collection load(StateManager sm);
38:
39: int size(StateManager sm);
40:
41: boolean isEmpty(StateManager sm);
42:
43: boolean contains(StateManager sm, Object element);
44:
45: boolean add(StateManager sm, Object element);
46:
47: boolean addAll(StateManager sm, Collection elements);
48:
49: boolean remove(StateManager sm, Object element);
50:
51: void clear(StateManager sm);
52:
53: QueryStatement newQueryStatement(StateManager sm,
54: Class candidateClass);
55:
56: Query.ResultObjectFactory newResultObjectFactory(StateManager sm,
57: QueryStatement stmt);
58:
59: /**
60: * Create a subquery for the given query that joins a <code>SetStore</code>s
61: * element table to the owner table. This subquery can subsequently be used
62: * in an EXISTS expression to determine whether a Set is empty or not.
63: *
64: * @param ownerIDColumn The QueryColumn of the owner ID.
65: * @param setRangeVar The range variable for the "Set" table.
66: *
67: * @return A subquery for the given query that joins a <code>SetStore</code>s
68: * element table to the owner table.
69: */
70: QueryStatement getExistsSubquery(
71: QueryStatement.QueryColumn ownerIDColumn,
72: SQLIdentifier setRangeVar);
73:
74: QueryStatement.QueryColumn joinElementsTo(QueryStatement stmt,
75: QueryStatement.QueryColumn ownerIDColumn,
76: SQLIdentifier setRangeVar, Class filteredElementType,
77: SQLIdentifier elementRangeVar);
78: }
|