KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > mapping > ejb > ConversionHelper


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  * ConversionHelper.java
26  *
27  * Created on February 3, 2002, 12:34 PM
28  */

29
30 package com.sun.jdo.api.persistence.mapping.ejb;
31
32 import java.util.List JavaDoc;
33
34 /** Helper interface for the {@link MappingFile}.
35  * The mapping file classes use an object that
36  * implements this interface to assist in the conversion
37  * from the sun-cmp-mapping file, into a TP dot-mapping file.
38  * The APIs to the deployment descriptors differ at deployment time
39  * and at development time. This interface provides a level of abstraction
40  * for the needed information.
41  *
42  * @author vkraemer
43  * @version 1.0
44  */

45 public interface ConversionHelper {
46
47     public static final String JavaDoc ONE = "One"; // NOI18N
48
public static final String JavaDoc MANY = "Many"; // NOI18N
49

50     /** Computes the name of the TP implementation class for a bean.
51     * @param beanName The value of the ejb-name element for a bean.
52     * @return The full name of the TP class that implements
53     * the fields and relationships of an EJB.
54     */

55     public String JavaDoc getMappedClassName(String JavaDoc beanName);
56
57     /**
58     * @param beanName Name of bean to investigate for field.
59     * @param fieldName Name of field sought in named bean.
60     * @return True if the named bean has the named field
61     */

62     public boolean hasField(String JavaDoc beanName, String JavaDoc fieldName);
63
64     /**
65     */

66     public Object JavaDoc[] getFields(String JavaDoc beanName);
67     
68     /** Compute the keyness of a field.
69     * The value returned is the keyness of the field, if it is
70     * computable. If it is not, the candidate value is returned.
71     * @param ejbName The value of the ejb-name element for a bean.
72     * @param fieldName The name of a container managed field in the named bean.
73     * @param candidate The value "proposed" by the content of the sun-cmp-mapping file.
74     * @return The real value of the keyness of a field.
75     * This may be different than the candidate value,
76     * if the correct values of a fields keyness can
77     * be computed from available data.
78     */

79     public boolean isKey(String JavaDoc beanName, String JavaDoc fieldName, boolean candidate);
80     
81     /** Return the name of the opposite roles ejb-name
82     * @param ejbName The value of the ejb-name element for a bean.
83     * @param fieldName The name of a container managed field in the named bean.
84     * @return The ejb-name of the bean that is referenced by a
85     * relationship field. This is the ejb-name of the
86     * "other" roles relationship-role-source.
87     */

88     public String JavaDoc getRelationshipFieldContent(String JavaDoc ejbName, String JavaDoc fieldName);
89     
90     /**
91     * @param ejbName The ejb-name element for the bean
92     * @param fieldName The name of a container managed field in the named bean.
93     * @return The String values "One" or "Many".
94     */

95     public String JavaDoc getMultiplicity(String JavaDoc ejbName, String JavaDoc fieldName);
96        
97     /**
98     * @param ejbName The value of the ejb-name element for a bean.
99     * @param fieldName The name of a container managed field in the named bean.
100     * @return */

101     public String JavaDoc getRelationshipFieldType(String JavaDoc ejbName, String JavaDoc fieldName);
102     
103     /**
104     * @param ejbName The value of the ejb-name element for a bean.
105     * @param fieldName The name of a container managed field in the named bean.
106     * @return */

107     public String JavaDoc getInverseFieldName(String JavaDoc ejbName, String JavaDoc fieldName);
108
109     /**
110      * Returns flag whether the mapping conversion should apply the default
111      * strategy for dealing with unknown primary key classes. This method will
112      * only be called when {@link #generateFields} returns <code>true</code>.
113      * @param ejbName The value of the ejb-name element for a bean.
114      * @return <code>true</code> to apply the default unknown PK Class Strategy,
115      * <code>false</code> otherwise
116      */

117     public boolean applyDefaultUnknownPKClassStrategy(String JavaDoc ejbName);
118
119     /**
120      * Returns the name used for generated primary key fields.
121      * @return a string for key field name
122      */

123     public String JavaDoc getGeneratedPKFieldName();
124
125     /**
126      * Returns the prefix used for generated version fields.
127      * @return a string for version field name prefix
128      */

129     public String JavaDoc getGeneratedVersionFieldNamePrefix();
130     
131     /**
132     * @param ejbName The ejb-name element for the bean
133     * @param fieldName The name of a container managed field in the named bean.
134     * @return boolean flag indicating whether the objects in this collection field are to
135     * be deleted when this field' owning object is deleted.
136     */

137     public boolean relatedObjectsAreDeleted(String JavaDoc ejbName, String JavaDoc fieldName);
138         
139     /**
140      * Returns the flag whether the mapping conversion should generate
141      * relationship fields and primary key fields to support run-time.
142      * The version field is always created even {@link #generateFields} is
143      * <code>false</code> because it holds version column information.
144      * @return <code>true</code> to generate fields in the dot-mapping file
145      * (if they are not present).
146      */

147     public boolean generateFields();
148
149     /**
150      * Sets the flag whether the mapping conversion should generate relationship
151      * fields, primary key fields, and version fields to support run-time.
152      * @param generateFields a flag which indicates whether fields should be
153      * generated
154      */

155     public void setGenerateFields(boolean generateFields);
156
157     /** Returns the flag whether the mapping conversion should validate
158      * all fields against schema columns.
159      * @return <code>true</code> to validate all the fields in the dot-mapping
160      * file.
161      */

162     public boolean ensureValidation();
163
164     /**
165      * Sets the flag whether the mapping conversion should validate all fields
166      * against schema columns.
167      * @param isValidating a boolean of indicating validating fields or not
168      */

169     public void setEnsureValidation(boolean isValidating);
170
171     /**
172      * Returns <code>true</code> if the field is generated. There are three
173      * types of generated fields: generated relationships, unknown primary key
174      * fields, and version consistency fields.
175      * @param ejbName The ejb-name element for the bean
176      * @param fieldName The name of a container managed field in the named bean
177      * @return <code>true</code> if the field is generated; <code>false</code>
178      * otherwise.
179      */

180     public boolean isGeneratedField(String JavaDoc ejbName, String JavaDoc fieldName);
181
182     /** Flag whether the conversion helper generated the relationship field
183     * @param ejbName The ejb-name element for the bean
184     * @param fieldName The name of a container managed field in the named bean.
185     * @return <code>true</code> if the field was created by the conversion
186     * helper.
187     */

188     public boolean isGeneratedRelationship(String JavaDoc ejbName, String JavaDoc fieldName);
189
190     /**
191      * Returns a list of generated relationship field names.
192      * @param ejbName The ejb-name element for the bean
193      * @return a list of generated relationship field names
194      */

195     public List JavaDoc getGeneratedRelationships(String JavaDoc ejbName);
196 }
197
198
Popular Tags