KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > model > jdo > FieldGroupElement


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * FieldGroupElement.java
26  *
27  * Created on February 29, 2000, 4:57 PM
28  */

29
30 package com.sun.jdo.api.persistence.model.jdo;
31
32 import com.sun.jdo.api.persistence.model.ModelException;
33
34 /**
35  *
36  * @author raccah
37  * @version %I%
38  */

39 public abstract class FieldGroupElement extends PersistenceMemberElement
40     implements FieldElementHolder
41 {
42     /** Create new FieldGroupElement with no implementation.
43      * This constructor should only be used for cloning and archiving.
44      */

45     public FieldGroupElement ()
46     {
47         this(null, null);
48     }
49
50     /** Create new FieldGroupElement with the provided implementation. The
51      * implementation is responsible for storing all properties of the object.
52      * @param impl the implementation to use
53      * @param declaringClass the class to attach to
54      */

55     public FieldGroupElement (FieldGroupElement.Impl impl,
56         PersistenceClassElement declaringClass)
57     {
58         super(impl, declaringClass);
59     }
60
61     /** @return implemetation factory for this field group
62      */

63     final Impl getFieldGroupImpl () { return (Impl)getImpl(); }
64
65     //================== Fields ===============================
66
// PersistenceFieldElement handling, implementation of FieldElementHolder
67

68     /** Add the supplied field to the collection of fields maintained by this
69      * holder.
70      * @param field the field to be added
71      * @exception ModelException if impossible
72      */

73     public void addField (PersistenceFieldElement field)
74         throws ModelException
75     {
76         addFields(new PersistenceFieldElement[]{field});
77     }
78
79     /** Add the supplied fields to the collection of fields maintained by this
80      * holder.
81      * @param fields the array of fields to be added
82      * @exception ModelException if impossible
83      */

84     public void addFields(PersistenceFieldElement[] fields)
85         throws ModelException
86     {
87         getFieldGroupImpl().changeFields(fields, Impl.ADD);
88     }
89
90     /** Remove the supplied field from the collection of fields maintained by
91      * this holder.
92      * @param field the field to be removed
93      * @exception ModelException if impossible
94      */

95     public void removeField (PersistenceFieldElement field)
96         throws ModelException
97     {
98         removeFields(new PersistenceFieldElement[]{field});
99     }
100
101     /** Removed the supplied fields from the collection of fields maintained
102      * by this holder.
103      * @param fields the array of fields to be removed
104      * @exception ModelException if impossible
105      */

106     public void removeFields (PersistenceFieldElement[] fields)
107         throws ModelException
108     {
109         getFieldGroupImpl().changeFields(fields, Impl.REMOVE);
110     }
111
112     /** Returns the collection of fields maintained by this holder in the form
113      * of an array.
114      * @return the fields maintained by this holder
115      */

116     public PersistenceFieldElement[] getFields ()
117     {
118         return getFieldGroupImpl().getFields();
119     }
120
121     /** Sets the collection of fields maintained by this holder to the contents
122      * of the supplied array.
123      * @param fields the fields maintained by this holder
124      * @exception ModelException if impossible
125      */

126     public void setFields (PersistenceFieldElement[] fields)
127         throws ModelException
128     {
129         getFieldGroupImpl().changeFields(fields, Impl.SET);
130     }
131
132     /** Returns the field with the supplied name from the collection of fields
133      * maintained by this holder.
134      * @param name the name of the field to be found
135      * @return the field with the supplied name, <code>null</code> if none exists
136      */

137     public PersistenceFieldElement getField (String JavaDoc name)
138     {
139         return getFieldGroupImpl().getField(name);
140     }
141
142     /** Tests whether the supplied field is in the collection of fields
143      * maintained by this holder.
144      * @param field the field to be tested
145      */

146     public boolean containsField (PersistenceFieldElement field)
147     {
148         return (getFieldGroupImpl().getField(field.getName()) != null);
149     }
150
151     /** Pluggable implementation of the storage of field element properties.
152      * @see PersistenceFieldElement#PersistenceFieldElement
153      */

154     public interface Impl extends PersistenceMemberElement.Impl
155     {
156         /** Change the set of fields.
157          * @param fields the new fields
158          * @param action {@link #ADD}, {@link #REMOVE}, or {@link #SET}
159          * @exception ModelException if impossible
160          */

161         public void changeFields (PersistenceFieldElement[] fields, int action)
162             throws ModelException;
163
164         /** Get all fields.
165          * @return the fields
166          */

167         public PersistenceFieldElement[] getFields ();
168
169         /** Find a field by name.
170          * @param name the name to match
171          * @return the field, or <code>null</code> if it does not exist
172          */

173         public PersistenceFieldElement getField (String JavaDoc name);
174     }
175 }
176
177
Popular Tags