KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > model > jdo > impl > FieldGroupElementImpl


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  * FieldGroupElementImpl.java
26  *
27  * Created on March 2, 2000, 6:28 PM
28  */

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

41 public class FieldGroupElementImpl extends PersistenceMemberElementImpl
42     implements FieldGroupElement.Impl
43 {
44     /** Fields of the field group element. */
45     private PersistenceElementCollection _fields;
46
47     /** Create new FieldGroupElementImpl with no corresponding name. This
48      * constructor should only be used for cloning and archiving.
49      */

50     public FieldGroupElementImpl ()
51     {
52         this(null);
53     }
54
55     /** Creates new FieldGroupElementImpl with the corresponding name
56      * @param name the name of the element
57      */

58     public FieldGroupElementImpl (String JavaDoc name)
59     {
60         super(name);
61         _fields = new PersistenceElementCollection(this, PROP_FIELDS,
62             new PersistenceFieldElement[0]);
63     }
64
65     /** Find a field by name.
66      * @param name the name to match
67      * @return the field, or <code>null</code> if it does not exist
68      */

69     public PersistenceFieldElement getField (String JavaDoc name)
70     {
71         return (PersistenceFieldElement)_fields.getElement(name);
72     }
73
74     /** Get all fields.
75      * @return the fields
76      */

77     public PersistenceFieldElement[] getFields ()
78     {
79         return (PersistenceFieldElement[])_fields.getElements();
80     }
81
82
83     /** Change the set of fields.
84      * @param fields the new fields
85      * @param action {@link #ADD}, {@link #REMOVE}, or {@link #SET}
86      * @exception ModelException if impossible
87      */

88     public void changeFields (PersistenceFieldElement[] fields, int action)
89         throws ModelException
90     {
91         _fields.changeElements(fields, action);
92     }
93
94     //=============== extra methods needed for xml archiver ==============
95

96     /** Returns the field collection of this field group element. This
97      * method should only be used internally and for cloning and archiving.
98      * @return the field collection of this field group element
99      */

100     public PersistenceElementCollection getCollection () { return _fields; }
101
102     /** Set the field collection of this field group element to the supplied
103      * collection. This method should only be used internally and for
104      * cloning and archiving.
105      * @param collection the field collection of this field group element
106      */

107     public void setCollection (PersistenceElementCollection collection)
108     {
109         _fields = collection;
110     }
111 }
112
Popular Tags