001: /**
002: * Speedo: an implementation of JDO compliant personality on top of JORM generic
003: * I/O sub-system.
004: * Copyright (C) 2001-2004 France Telecom R&D
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: *
021: *
022: * Contact: speedo@objectweb.org
023: *
024: */package org.objectweb.speedo.mim.lib;
025:
026: import java.util.Arrays;
027: import java.util.Collection;
028: import java.util.HashSet;
029: import java.util.Set;
030:
031: import org.objectweb.speedo.mim.api.FetchPlanItf;
032:
033: /**
034: * @author Y.Bersihand
035: */
036: public class SpeedoFetchPlan implements FetchPlanItf {
037:
038: /**
039: * The list of groups contained in the fetch plan.
040: */
041: private Set groups = new HashSet();
042:
043: private int fetchSize;
044:
045: public SpeedoFetchPlan() {
046: groups.add(FetchPlanItf.DEFAULT);
047: }
048:
049: public SpeedoFetchPlan(String fgName) {
050: groups.add(fgName);
051: }
052:
053: /**
054: * Add a group into the fetch plan.
055: */
056: public FetchPlanItf speedoAddGroup(String fetchGroupName) {
057: if (fetchGroupName != null) {
058: groups.add(fetchGroupName);
059: }
060: return this ;
061: }
062:
063: /**
064: * Remove a group from the fetch plan.
065: */
066: public FetchPlanItf speedoRemoveGroup(String fetchGroupName) {
067: if (fetchGroupName != null) {
068: groups.remove(fetchGroupName);
069: }
070: return this ;
071: }
072:
073: public Collection speedoGetGroups() {
074: return groups;
075: }
076:
077: public FetchPlanItf speedoSetGroups(Collection fetchGroupNames) {
078: groups.clear();
079: if (fetchGroupNames != null) {
080: groups.addAll(fetchGroupNames);
081: }
082: return this ;
083: }
084:
085: public FetchPlanItf speedoClearGroups() {
086: groups.clear();
087: groups.add(FetchPlanItf.DEFAULT);
088: return this ;
089: }
090:
091: public FetchPlanItf speedoSetGroup(String fetchGroupName) {
092: groups.clear();
093: if (fetchGroupName != null) {
094: groups.add(fetchGroupName);
095: }
096: return this ;
097: }
098:
099: public FetchPlanItf speedoSetGroups(String[] fetchGroupNames) {
100: groups.clear();
101: if (fetchGroupNames != null) {
102: groups.addAll(Arrays.asList(fetchGroupNames));
103: }
104: return this ;
105: }
106:
107: public FetchPlanItf speedoSetFetchSize(int fetchSize) {
108: this .fetchSize = fetchSize;
109: return this ;
110: }
111:
112: public int speedoGetFetchSize() {
113: return fetchSize;
114: }
115: }
|