001: /**
002: * Copyright (C) 2001-2004 France Telecom R&D
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package org.objectweb.speedo.generation.jorm;
018:
019: import org.objectweb.jorm.api.PException;
020: import org.objectweb.jorm.metainfo.api.Class;
021: import org.objectweb.jorm.metainfo.api.ClassMapping;
022: import org.objectweb.jorm.metainfo.api.GenClassMapping;
023: import org.objectweb.jorm.metainfo.api.GenClassRef;
024: import org.objectweb.jorm.metainfo.api.Mapping;
025: import org.objectweb.jorm.metainfo.api.NameDef;
026: import org.objectweb.jorm.metainfo.api.PrimitiveElement;
027: import org.objectweb.jorm.metainfo.api.PrimitiveElementMapping;
028: import org.objectweb.speedo.api.SpeedoException;
029: import org.objectweb.speedo.metadata.SpeedoClass;
030: import org.objectweb.speedo.metadata.SpeedoCommonField;
031: import org.objectweb.speedo.metadata.SpeedoField;
032: import org.objectweb.speedo.metadata.SpeedoInheritedField;
033: import org.objectweb.speedo.metadata.SpeedoNoFieldColumn;
034: import org.objectweb.speedo.naming.api.MIBuilderHelper;
035:
036: /**
037: * This interface defines a builder of the mapping part of the Jorm meta
038: * information. It must be implemented for each mapper.
039: *
040: * @author S.Chassande-Barrioz
041: */
042: public interface JormMIMappingBuilder {
043:
044: /**
045: * It builds a ClassMapping, assignes it to the mapping and builds
046: * mapping structure for the class (RdbTable, directory name, ...).
047: * @param clazz is the Jorm meta object representing the class which the
048: * ClassMapping must be built.
049: * @param mapping is the Mapping instance which will host the ClassMapping.
050: * @return the ClassMapping instance built by the method (never null).
051: * @throws PException if it is not possible to build the ClassMapping
052: */
053: ClassMapping createClassMapping(Class clazz, SpeedoClass sc,
054: Mapping mapping) throws PException, SpeedoException;
055:
056: /**
057: * It builds a GenClassMapping, assignes it to the mapping and builds
058: * mapping structure for the class (RdbTable, directory name, ...).
059: * @param gcr is the Jorm meta object representing the gen class which the
060: * GenClassMapping must be built.
061: * @param mapping is the Mapping instance which will host the GenClassMapping.
062: * @param sf is the SpeedoField corresponding to the generic class.
063: * @return the GenClassMapping instance built by the method (never null).
064: * @throws PException if it is not possible to build the GenClassMapping
065: */
066: GenClassMapping createGenClassMapping(GenClassRef gcr,
067: SpeedoField sf, Mapping mapping) throws PException,
068: SpeedoException;
069:
070: /**
071: * It creates the mapping of a primitive field.
072: * @param pe is the Jorm meta object representing a primitive field
073: * @param cm is the MappingStructure which will host the mapping of the
074: * field
075: * @return a PrimitiveElementMapping corresponding to the given primitive
076: * field.
077: * @throws PException if it is not possible to build the mapping of the
078: * primitive field.
079: */
080: PrimitiveElementMapping createFieldMapping(PrimitiveElement pe,
081: SpeedoField sf, ClassMapping cm) throws PException,
082: SpeedoException;
083:
084: /**
085: * It creates the mapping of a hidden primitive field.
086: * @param pe is the Jorm meta object representing a primitive field
087: * @param cm is the MappingStructure which will host the mapping of the
088: * field
089: * @return a PrimitiveElementMapping corresponding to the given primitive
090: * field.
091: * @throws PException if it is not possible to build the mapping of the
092: * primitive field.
093: */
094: PrimitiveElementMapping createFieldMapping(PrimitiveElement pe,
095: SpeedoNoFieldColumn sf, ClassMapping cm) throws PException,
096: SpeedoException;
097:
098: /**
099: /**
100: * It creates the mapping of an inherited primitive field.
101: * @param pe is the Jorm meta object representing a primitive field
102: * @param sif is the SpeedoInheritedField meta object representing the
103: * inherited field.
104: * @param cm is the MappingStructure which will host the mapping of the
105: * field
106: * @return a PrimitiveElementMapping corresponding to the given primitive
107: * field.
108: */
109: PrimitiveElementMapping createFieldMapping(PrimitiveElement pe,
110: SpeedoInheritedField sif, ClassMapping cm)
111: throws PException, SpeedoException;
112:
113: /**
114: * It creates the mapping of a primitive field (element of the generic
115: * class).
116: * @param pe is the Jorm meta object representing a primitive field
117: * @param gcm is the MappingStructure which will host the mapping of the
118: * field
119: * @param sf is the Speedo meta object representing the persistent field
120: * referencing a generic class.
121: * @return a PrimitiveElementMapping corresponding to the given primitive
122: * field.
123: * @throws PException if it is not possible to build the mapping of the
124: * primitive field.
125: */
126: PrimitiveElementMapping createGenClassElementMapping(
127: PrimitiveElement pe, SpeedoField sf, GenClassMapping gcm)
128: throws PException, SpeedoException;
129:
130: /**
131: * It creates the mapping of a primitive field used as index in the generic
132: * class.
133: * @param pe is the Jorm meta object representing a primitive field
134: * @param gcm is the MappingStructure which will host the mapping of the
135: * field
136: * @param sf is the Speedo meta object representing the persistent field
137: * referencing a generic class.
138: * @return a PrimitiveElementMapping corresponding to the given primitive
139: * field.
140: * @throws PException if it is not possible to build the mapping of the
141: * primitive field.
142: */
143: PrimitiveElementMapping createGenClassIndexMapping(
144: PrimitiveElement pe, SpeedoField sf, GenClassMapping gcm)
145: throws PException, SpeedoException;
146:
147: /**
148: * Creates the mapping of the name def (JORM meta object) corresponding to
149: * the identifier of a persistent generic class (collection, map, ...).
150: * @param cm is the MappingStructure which will host the mapping of the
151: * generic class
152: * @param nd is the namedef corresponding to the identifier of the
153: * generic class
154: * @param sc is the Speedo meta object representing the persistent class.
155: */
156: void createClassIdentifierNameDefMapping(ClassMapping cm,
157: NameDef nd, SpeedoClass sc, MIBuilderHelper mibh)
158: throws PException, SpeedoException;
159:
160: /**
161: * Creates the mapping of the name def (JORM meta object) corresponding to
162: * the identifier of a persistent generic class (collection, map, ...).
163: * @param gcm is the MappingStructure which will host the mapping of the
164: * generic class
165: * @param nd is the namedef corresponding to the identifier of the
166: * generic class
167: * @param sf is the Speedo meta object representing the persistent field
168: * referencing a generic class.
169: */
170: void createGenClassIdentifierNameDefMapping(GenClassMapping gcm,
171: NameDef nd, SpeedoField sf, MIBuilderHelper mibh)
172: throws PException, SpeedoException;
173:
174: /**
175: * Creates the mapping of the name def (JORM meta object) corresponding to
176: * a reference to a persistent class from a persistent class.
177: * @param cm is the MappingStructure which will host the mapping of the
178: * reference
179: * @param nd is the namedef corresponding to the reference
180: * @param sf is the Speedo meta object representing the persistent field
181: * referencing a class.
182: */
183: void createClassRefNameDefMapping(ClassMapping cm, NameDef nd,
184: SpeedoCommonField sf) throws PException, SpeedoException;
185:
186: /**
187: * Creates the mapping of the name def (JORM meta object) corresponding to
188: * a reference to a persistent class from a generic persistent class.
189: * @param gcm is the MappingStructure which will host the mapping of the
190: * reference
191: * @param nd is the namedef corresponding to the reference
192: * @param sf is the Speedo meta object representing the persistent field
193: * referencing a generic class.
194: */
195: void createClassRefNameDefMapping(GenClassMapping gcm, NameDef nd,
196: SpeedoField sf) throws PException, SpeedoException;
197:
198: /**
199: * Creates the mapping of the name def (JORM meta object) corresponding to
200: * a reference to a persistent generic class.
201: * @param cm is the MappingStructure which will host the mapping of the
202: * reference
203: * @param nd is the namedef corresponding to the reference
204: * @param sf is the Speedo meta object representing the persistent field
205: * referencing a generic class.
206: */
207: void createGenClassRefNameDefMapping(ClassMapping cm, NameDef nd,
208: SpeedoCommonField sf) throws PException, SpeedoException;
209: }
|