1 package com.bonevich.erj.mof.impl;
2 import ru.novosoft.mdf.impl.*;
3 import javax.jmi.xmi.*;
4 import ru.novosoft.mdf.ext.*;
5 import ru.novosoft.mdf.impl.xmi.writers.*;
6 import org.xml.sax.*;
7 import org.xml.sax.helpers.*;
8 import java.util.*;
9
10 public final class ErjRepositoryImplXMIWriter extends ru.novosoft.mdf.impl.XMI11WriterSAX2
11 {
12 public ErjRepositoryImplXMIWriter()
13 {
14 }
15
16
17 /***
18 * Processes element content and writes it as element.
19 *
20 * @param me mdf element whose content need be processed.
21 * @exception SAXException
22 * @author dida
23 */
24 protected void processContentAsElements( MDFObject me) throws SAXException
25 {
26 ru.novosoft.mdf.ext.MDFClass proxy = null;
27 if (me instanceof com.bonevich.erj.mof.interfaces.model.KeyConstraint)
28 {
29 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
30 com.bonevich.erj.mof.interfaces.model.KeyConstraint ce = (com.bonevich.erj.mof.interfaces.model.KeyConstraint)me;
31 refValueAsElement(ErjInfoModel_NAMESPACE_URI, "KeyConstraint.relation", "Relation", ce.getRelation());
32 refListValuesAsElements(ErjInfoModel_NAMESPACE_URI, "KeyConstraint.attributes", "Attribute", ce.getAttributes());
33 }
34 if (me instanceof com.bonevich.erj.mof.interfaces.model.Schema)
35 {
36 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
37 com.bonevich.erj.mof.interfaces.model.Schema ce = (com.bonevich.erj.mof.interfaces.model.Schema)me;
38 processOwnedElements(ErjInfoModel_NAMESPACE_URI, "Schema.relations", "ErjInfoModel:Schema.relations", ((com.bonevich.erj.mof.interfaces.model.Schema)me).getRelations() );
39 processOwnedElements(ErjInfoModel_NAMESPACE_URI, "Schema.domains", "ErjInfoModel:Schema.domains", ((com.bonevich.erj.mof.interfaces.model.Schema)me).getDomains() );
40 }
41 if (me instanceof com.bonevich.erj.mof.interfaces.model.ModelElement)
42 {
43 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
44 com.bonevich.erj.mof.interfaces.model.ModelElement ce = (com.bonevich.erj.mof.interfaces.model.ModelElement)me;
45 stringValueAsElement(ErjInfoModel_NAMESPACE_URI, "ModelElement.name", ce.getName());
46 stringValueAsElement(ErjInfoModel_NAMESPACE_URI, "ModelElement.identifier", ce.getIdentifier());
47 stringValueAsElement(ErjInfoModel_NAMESPACE_URI, "ModelElement.description", ce.getDescription());
48 }
49 if (me instanceof com.bonevich.erj.mof.interfaces.model.ForeignKey)
50 {
51 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
52 com.bonevich.erj.mof.interfaces.model.ForeignKey ce = (com.bonevich.erj.mof.interfaces.model.ForeignKey)me;
53 enumValueAsElement(ErjInfoModel_NAMESPACE_URI, "ForeignKey.cardinality", ce.getCardinality());
54 refListValuesAsElements(ErjInfoModel_NAMESPACE_URI, "ForeignKey.referent", "Relation", ce.getReferent());
55 }
56 if (me instanceof com.bonevich.erj.mof.interfaces.model.Domain)
57 {
58 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
59 com.bonevich.erj.mof.interfaces.model.Domain ce = (com.bonevich.erj.mof.interfaces.model.Domain)me;
60 processOwnedElement(ErjInfoModel_NAMESPACE_URI, "Domain.dataType", "ErjInfoModel:Domain.dataType", ((com.bonevich.erj.mof.interfaces.model.Domain)me).getDataType() );
61 enumValueAsElement(ErjInfoModel_NAMESPACE_URI, "Domain.defaultConstraint", ce.getDefaultConstraint());
62 processStruct(ErjInfoModel_NAMESPACE_URI, "Domain.defaultValue", "ErjInfoModel:Domain.defaultValue", ((com.bonevich.erj.mof.interfaces.model.Domain)me).getDefaultValue() );
63 refValueAsElement(ErjInfoModel_NAMESPACE_URI, "Domain.schema", "Schema", ce.getSchema());
64 }
65 if (me instanceof com.bonevich.erj.mof.interfaces.model.Relation)
66 {
67 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
68 com.bonevich.erj.mof.interfaces.model.Relation ce = (com.bonevich.erj.mof.interfaces.model.Relation)me;
69 refValueAsElement(ErjInfoModel_NAMESPACE_URI, "Relation.schema", "Schema", ce.getSchema());
70 processOwnedElements(ErjInfoModel_NAMESPACE_URI, "Relation.attributes", "ErjInfoModel:Relation.attributes", ((com.bonevich.erj.mof.interfaces.model.Relation)me).getAttributes() );
71 processOwnedElements(ErjInfoModel_NAMESPACE_URI, "Relation.keys", "ErjInfoModel:Relation.keys", ((com.bonevich.erj.mof.interfaces.model.Relation)me).getKeys() );
72 }
73 if (me instanceof com.bonevich.erj.mof.interfaces.model.DataType)
74 {
75 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
76 com.bonevich.erj.mof.interfaces.model.DataType ce = (com.bonevich.erj.mof.interfaces.model.DataType)me;
77 stringValueAsElement(ErjInfoModel_NAMESPACE_URI, "DataType.name", ce.getName());
78 stringValueAsElement(ErjInfoModel_NAMESPACE_URI, "DataType.descriptor", ce.getDescriptor());
79 }
80 if (me instanceof com.bonevich.erj.mof.interfaces.model.Attribute)
81 {
82 proxy = (ru.novosoft.mdf.ext.MDFClass)me.refGetClass();
83 com.bonevich.erj.mof.interfaces.model.Attribute ce = (com.bonevich.erj.mof.interfaces.model.Attribute)me;
84 enumValueAsElement(ErjInfoModel_NAMESPACE_URI, "Attribute.constraint", ce.getConstraint());
85 processStruct(ErjInfoModel_NAMESPACE_URI, "Attribute.defaultValue", "ErjInfoModel:Attribute.defaultValue", ((com.bonevich.erj.mof.interfaces.model.Attribute)me).getDefaultValue() );
86 refValueAsElement(ErjInfoModel_NAMESPACE_URI, "Attribute.relation", "Relation", ce.getRelation());
87 refValueAsElement(ErjInfoModel_NAMESPACE_URI, "Attribute.type", "AttributeType", ce.getType());
88 }
89 }
90
91 /***
92 * Processes associations. It's invoked only after all model elements was processed.
93 *
94 * @exception SAXException
95 * @author cap & dida
96 */
97 protected void processAssociations() throws SAXException
98 {
99 }
100
101
102 /***
103 * Returns string presentation of enumeration value.
104 *
105 * @param val enumeration value
106 * @return string presentation of enumeration value
107 */
108 protected String getValueForEnum( Object val )
109 {
110 if (val == com.bonevich.erj.mof.interfaces.model.AttributeConstraintEnum.NULL)
111 {
112 return "NULL";
113 }
114 if (val == com.bonevich.erj.mof.interfaces.model.AttributeConstraintEnum.NOTNULL)
115 {
116 return "NOTNULL";
117 }
118 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ZERO_TO_ZERO)
119 {
120 return "ZERO_TO_ZERO";
121 }
122 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ONE_TO_ZERO)
123 {
124 return "ONE_TO_ZERO";
125 }
126 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ONE_TO_ONE)
127 {
128 return "ONE_TO_ONE";
129 }
130 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ZERO_TO_MANY)
131 {
132 return "ZERO_TO_MANY";
133 }
134 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ONE_TO_MANY)
135 {
136 return "ONE_TO_MANY";
137 }
138 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ZERO_TO_MANY_MANDATORY)
139 {
140 return "ZERO_TO_MANY_MANDATORY";
141 }
142 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.ONE_TO_MANY_MANDATORY)
143 {
144 return "ONE_TO_MANY_MANDATORY";
145 }
146 if (val == com.bonevich.erj.mof.interfaces.model.CardinalityEnum.MANY_TO_MANY)
147 {
148 return "MANY_TO_MANY";
149 }
150 throw new RuntimeException("Enumeration constant: " + val);
151 }
152
153
154 /***
155 * Perform collecting all element references and attributes. It's added into 'xe'
156 * parameter.
157 *
158 * @param me element whose references and attributes are collecting.
159 * @param xe attributes buffer where element references and attributes are added.
160 * @exception SAXException
161 * @author dida
162 */
163 protected void collectAttributes( MDFObject me, AttributesImpl xe ) throws SAXException
164 {
165 ru.novosoft.mdf.ext.MDFClass proxy = null;
166 if (me instanceof com.bonevich.erj.mof.interfaces.model.KeyConstraint)
167 {
168 processReferenceList(xe, "attributes", ((com.bonevich.erj.mof.interfaces.model.KeyConstraint)me).getAttributes() );
169 }
170 if (me instanceof com.bonevich.erj.mof.interfaces.model.ModelElement)
171 {
172 processString(xe, "name", ((com.bonevich.erj.mof.interfaces.model.ModelElement)me).getName() );
173 processString(xe, "identifier", ((com.bonevich.erj.mof.interfaces.model.ModelElement)me).getIdentifier() );
174 processString(xe, "description", ((com.bonevich.erj.mof.interfaces.model.ModelElement)me).getDescription() );
175 }
176 if (me instanceof com.bonevich.erj.mof.interfaces.model.ForeignKey)
177 {
178 processEnum(xe, "cardinality", ((com.bonevich.erj.mof.interfaces.model.ForeignKey)me).getCardinality() );
179 processReferenceList(xe, "referent", ((com.bonevich.erj.mof.interfaces.model.ForeignKey)me).getReferent() );
180 }
181 if (me instanceof com.bonevich.erj.mof.interfaces.model.Domain)
182 {
183 processEnum(xe, "defaultConstraint", ((com.bonevich.erj.mof.interfaces.model.Domain)me).getDefaultConstraint() );
184 }
185 if (me instanceof com.bonevich.erj.mof.interfaces.model.DataType)
186 {
187 processString(xe, "name", ((com.bonevich.erj.mof.interfaces.model.DataType)me).getName() );
188 processString(xe, "descriptor", ((com.bonevich.erj.mof.interfaces.model.DataType)me).getDescriptor() );
189 }
190 if (me instanceof com.bonevich.erj.mof.interfaces.model.Attribute)
191 {
192 processEnum(xe, "constraint", ((com.bonevich.erj.mof.interfaces.model.Attribute)me).getConstraint() );
193 processReference(xe, "type", ((com.bonevich.erj.mof.interfaces.model.Attribute)me).getType() );
194 }
195 }
196
197 /***
198 * Initialize string array 'vals' by two values: class uri and class name.
199 *
200 * @param cls class, information about whose must be contains in 'vals'
201 * after method performed.
202 * @param vals string array that must be initialized.
203 * @author dida
204 */
205 protected void getElementName(Class cls, String[] vals)
206 {
207 if (cls == com.bonevich.erj.mof.interfaces.model.KeyConstraint.class)
208 {
209 vals[0] = ErjInfoModel_NAMESPACE_URI;
210 vals[1] = "KeyConstraint";
211 return;
212 }
213 if (cls == com.bonevich.erj.mof.interfaces.model.Schema.class)
214 {
215 vals[0] = ErjInfoModel_NAMESPACE_URI;
216 vals[1] = "Schema";
217 return;
218 }
219 if (cls == com.bonevich.erj.mof.interfaces.model.ModelElement.class)
220 {
221 vals[0] = ErjInfoModel_NAMESPACE_URI;
222 vals[1] = "ModelElement";
223 return;
224 }
225 if (cls == com.bonevich.erj.mof.interfaces.model.AttributeType.class)
226 {
227 vals[0] = ErjInfoModel_NAMESPACE_URI;
228 vals[1] = "AttributeType";
229 return;
230 }
231 if (cls == com.bonevich.erj.mof.interfaces.model.ForeignKey.class)
232 {
233 vals[0] = ErjInfoModel_NAMESPACE_URI;
234 vals[1] = "ForeignKey";
235 return;
236 }
237 if (cls == com.bonevich.erj.mof.interfaces.model.Domain.class)
238 {
239 vals[0] = ErjInfoModel_NAMESPACE_URI;
240 vals[1] = "Domain";
241 return;
242 }
243 if (cls == com.bonevich.erj.mof.interfaces.model.Relation.class)
244 {
245 vals[0] = ErjInfoModel_NAMESPACE_URI;
246 vals[1] = "Relation";
247 return;
248 }
249 if (cls == com.bonevich.erj.mof.interfaces.model.UniqueKey.class)
250 {
251 vals[0] = ErjInfoModel_NAMESPACE_URI;
252 vals[1] = "UniqueKey";
253 return;
254 }
255 if (cls == com.bonevich.erj.mof.interfaces.model.PrimaryKey.class)
256 {
257 vals[0] = ErjInfoModel_NAMESPACE_URI;
258 vals[1] = "PrimaryKey";
259 return;
260 }
261 if (cls == com.bonevich.erj.mof.interfaces.model.DataType.class)
262 {
263 vals[0] = ErjInfoModel_NAMESPACE_URI;
264 vals[1] = "DataType";
265 return;
266 }
267 if (cls == com.bonevich.erj.mof.interfaces.model.Attribute.class)
268 {
269 vals[0] = ErjInfoModel_NAMESPACE_URI;
270 vals[1] = "Attribute";
271 return;
272 }
273 }
274
275
276 /***
277 * Processes structs.
278 *
279 * @param uri struct owner element uri
280 * @param localName struct name in form 'class_name.struct_name'
281 * @param qName full struct name in form 'prefix:local_name'
282 * @param arg struct value
283 * @exception SAXException
284 */
285 protected void processStruct( String uri, String localName, String qName, com.bonevich.erj.mof.interfaces.model.DefaultValue arg) throws SAXException
286 {
287 createStartFieldElement(uri, localName, qName);
288 processField( arg.getValue());
289 createEndFieldElement(uri, localName, qName);
290 }
291
292 public static final String ErjInfoModel_NAMESPACE_PREFIX = "ErjInfoModel";
293 public static final String ErjInfoModel_NAMESPACE_URI = "ErjInfoModel";
294
295 /***
296 * Returns element_prefix/element_uri string pair array. This values
297 * are given in the config.prp file and read from it as properties.
298 *
299 * @return prefix/uri string pair array.
300 * @author dida
301 */
302 protected String[][] forceNSInfo()
303 {
304 return new String[][]{
305 {ErjInfoModel_NAMESPACE_PREFIX, ErjInfoModel_NAMESPACE_URI}
306 };
307 }
308 }
This page was automatically generated by Maven