KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > mim > lib > SpeedoFetchPlan


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  */

25
26 package org.objectweb.speedo.mim.lib;
27
28 import java.util.Arrays JavaDoc;
29 import java.util.Collection JavaDoc;
30 import java.util.Set JavaDoc;
31 import java.util.HashSet JavaDoc;
32
33 import javax.jdo.FetchPlan;
34
35
36 /**
37  * @author Y.Bersihand
38  */

39 public class SpeedoFetchPlan implements FetchPlan {
40
41     /**
42      * The list of groups contained in the fetch plan.
43      */

44     private Set JavaDoc groups = new HashSet JavaDoc();
45
46     private int fetchSize;
47     
48     public SpeedoFetchPlan(){
49         groups.add(FetchPlan.DEFAULT);
50     }
51
52     public SpeedoFetchPlan(String JavaDoc fgName){
53         groups.add(fgName);
54     }
55     
56     /**
57      * Add a group into the fetch plan.
58      */

59     public FetchPlan addGroup(String JavaDoc fetchGroupName){
60         if (fetchGroupName != null){
61             groups.add(fetchGroupName);
62         }
63         return this;
64     }
65     
66     /**
67      * Remove a group from the fetch plan.
68      */

69     public FetchPlan removeGroup(String JavaDoc fetchGroupName){
70         if (fetchGroupName != null){
71             groups.remove(fetchGroupName);
72         }
73         return this;
74     }
75
76     public Collection JavaDoc getGroups(){
77         return groups;
78     }
79
80     public FetchPlan setGroups(Collection JavaDoc fetchGroupNames){
81         groups.clear();
82         if (fetchGroupNames != null){
83             groups.addAll(fetchGroupNames);
84         }
85         return this;
86     }
87
88     public FetchPlan clearGroups() {
89         groups.clear();
90         groups.add(FetchPlan.DEFAULT);
91         return this;
92     }
93     public FetchPlan setGroup(String JavaDoc fetchGroupName) {
94         groups.clear();
95         if (fetchGroupName != null){
96             groups.add(fetchGroupName);
97         }
98         return this;
99     }
100     public FetchPlan setGroups(String JavaDoc[] fetchGroupNames) {
101         groups.clear();
102         if (fetchGroupNames != null){
103             groups.addAll(Arrays.asList(fetchGroupNames));
104         }
105         return this;
106     }
107
108     public FetchPlan setFetchSize(int fetchSize){
109         this.fetchSize = fetchSize;
110         return this;
111     }
112
113     public int getFetchSize(){
114         return fetchSize;
115     }
116 }
117
Popular Tags