001: /**********************************************************************
002: Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: ...
017: **********************************************************************/package org.jpox.jdo;
018:
019: import java.io.Serializable;
020: import java.util.Collection;
021: import java.util.Set;
022:
023: import javax.jdo.FetchPlan;
024:
025: import org.jpox.exceptions.JPOXException;
026:
027: /**
028: * Implementation of a FetchPlan for JDO.
029: * Provides a JDO wrapper around the JPOX internal org.jpox.FetchPlan.
030: *
031: * @version $Revision: 1.6 $
032: */
033: public class JDOFetchPlan implements FetchPlan, Serializable {
034: org.jpox.FetchPlan fp = null;
035:
036: /**
037: * Constructor.
038: * @param fp FetchPlan
039: */
040: public JDOFetchPlan(org.jpox.FetchPlan fp) {
041: this .fp = fp;
042: }
043:
044: /**
045: * Accessor for the groups.
046: * @return The groups
047: */
048: public Set getGroups() {
049: return fp.getGroups();
050: }
051:
052: /**
053: * Method to add a group to the fetch plan.
054: * @param group The group to add
055: * @return The updated FetchPlan
056: */
057: public FetchPlan addGroup(String group) {
058: fp.addGroup(group);
059: return this ;
060: }
061:
062: /**
063: * Method to clear the fetch plan groups.
064: * @return The updated FetchPlan
065: */
066: public FetchPlan clearGroups() {
067: fp.clearGroups();
068: return this ;
069: }
070:
071: /**
072: * Method to remove a group from the FetchPlan.
073: * @param group The group to remove
074: * @return The updated FetchPlan
075: */
076: public FetchPlan removeGroup(String group) {
077: fp.removeGroup(group);
078: return this ;
079: }
080:
081: /**
082: * Method to set the FetchPlan to a single group.
083: * @param group The group to set
084: * @return The updated FetchPlan
085: */
086: public FetchPlan setGroup(String group) {
087: fp.setGroup(group);
088: return this ;
089: }
090:
091: /**
092: * Method to set the groups to the passed collection.
093: * @param groups Collection of groups
094: * @return Updated FetchPlan
095: */
096: public FetchPlan setGroups(Collection groups) {
097: fp.setGroups(groups);
098: return this ;
099: }
100:
101: /**
102: * Method to set the groups to the passed array.
103: * @param groups Collection of groups
104: * @return Updated FetchPlan
105: */
106: public FetchPlan setGroups(String[] groups) {
107: fp.setGroups(groups);
108: return this ;
109: }
110:
111: /**
112: * Accessor for the fetch size.
113: * @return The fetch size
114: */
115: public int getFetchSize() {
116: return fp.getFetchSize();
117: }
118:
119: /**
120: * Method to set the fetch size (large result sets).
121: * @param size The size
122: * @return Updated FetchPlan
123: */
124: public FetchPlan setFetchSize(int size) {
125: fp.setFetchSize(size);
126: return this ;
127: }
128:
129: /**
130: * Accessor for the max fetch depth.
131: * @return Max fetch depth
132: */
133: public int getMaxFetchDepth() {
134: return fp.getMaxFetchDepth();
135: }
136:
137: /**
138: * Method to set the max fetch depth.
139: * @param depth The depth
140: * @return Updated FetchPlan
141: */
142: public FetchPlan setMaxFetchDepth(int depth) {
143: try {
144: fp.setMaxFetchDepth(depth);
145: } catch (JPOXException jpe) {
146: throw JPOXJDOHelper.getJDOExceptionForJPOXException(jpe);
147: }
148: return this ;
149: }
150:
151: /**
152: * Accessor for the detachment options.
153: * @return Detachment options.
154: */
155: public int getDetachmentOptions() {
156: return fp.getDetachmentOptions();
157: }
158:
159: /**
160: * Accessor for the detachment root classes.
161: * @return Detachment root classes
162: */
163: public Class[] getDetachmentRootClasses() {
164: return fp.getDetachmentRootClasses();
165: }
166:
167: /**
168: * Accessor for the detachment roots.
169: * @return Detachment roots
170: */
171: public Collection getDetachmentRoots() {
172: return fp.getDetachmentRoots();
173: }
174:
175: /**
176: * Method to set the detachment options.
177: * @param options Detachment options
178: * @return Updated FetchPlan
179: */
180: public FetchPlan setDetachmentOptions(int options) {
181: try {
182: fp.setDetachmentOptions(options);
183: } catch (JPOXException jpe) {
184: throw JPOXJDOHelper.getJDOExceptionForJPOXException(jpe);
185: }
186: return this ;
187: }
188:
189: /**
190: * Method to set the detachment root classes.
191: * @param rootClasses The detachment root classes
192: * @return Updated FetchPlan
193: */
194: public FetchPlan setDetachmentRootClasses(Class[] rootClasses) {
195: try {
196: fp.setDetachmentRootClasses(rootClasses);
197: } catch (JPOXException jpe) {
198: throw JPOXJDOHelper.getJDOExceptionForJPOXException(jpe);
199: }
200: return this ;
201: }
202:
203: /**
204: * Method to set the detachment roots.
205: * @param roots Detachment roots
206: * @return Updated FetchPlan
207: */
208: public FetchPlan setDetachmentRoots(Collection roots) {
209: fp.setDetachmentRoots(roots);
210: return this;
211: }
212: }
|