KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > nodes > CreateSchemaComponentNodeVisitor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.ui.nodes;
21
22 import org.netbeans.modules.xml.schema.model.All;
23 import org.netbeans.modules.xml.schema.model.Annotation;
24 import org.netbeans.modules.xml.schema.model.AnyAttribute;
25 import org.netbeans.modules.xml.schema.model.AnyElement;
26 import org.netbeans.modules.xml.schema.model.AppInfo;
27 import org.netbeans.modules.xml.schema.model.AttributeGroupReference;
28 import org.netbeans.modules.xml.schema.model.AttributeReference;
29 import org.netbeans.modules.xml.schema.model.Choice;
30 import org.netbeans.modules.xml.schema.model.ComplexContent;
31 import org.netbeans.modules.xml.schema.model.ComplexContentRestriction;
32 import org.netbeans.modules.xml.schema.model.ComplexExtension;
33 import org.netbeans.modules.xml.schema.model.Documentation;
34 import org.netbeans.modules.xml.schema.model.ElementReference;
35 import org.netbeans.modules.xml.schema.model.Enumeration;
36 import org.netbeans.modules.xml.schema.model.Field;
37 import org.netbeans.modules.xml.schema.model.FractionDigits;
38 import org.netbeans.modules.xml.schema.model.GlobalAttribute;
39 import org.netbeans.modules.xml.schema.model.GlobalAttributeGroup;
40 import org.netbeans.modules.xml.schema.model.GlobalComplexType;
41 import org.netbeans.modules.xml.schema.model.GlobalElement;
42 import org.netbeans.modules.xml.schema.model.GlobalGroup;
43 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
44 import org.netbeans.modules.xml.schema.model.GroupReference;
45 import org.netbeans.modules.xml.schema.model.Import;
46 import org.netbeans.modules.xml.schema.model.Include;
47 import org.netbeans.modules.xml.schema.model.Key;
48 import org.netbeans.modules.xml.schema.model.KeyRef;
49 import org.netbeans.modules.xml.schema.model.Length;
50 import org.netbeans.modules.xml.schema.model.List;
51 import org.netbeans.modules.xml.schema.model.LocalAttribute;
52 import org.netbeans.modules.xml.schema.model.LocalComplexType;
53 import org.netbeans.modules.xml.schema.model.LocalElement;
54 import org.netbeans.modules.xml.schema.model.LocalSimpleType;
55 import org.netbeans.modules.xml.schema.model.MaxExclusive;
56 import org.netbeans.modules.xml.schema.model.MaxInclusive;
57 import org.netbeans.modules.xml.schema.model.MaxLength;
58 import org.netbeans.modules.xml.schema.model.MinExclusive;
59 import org.netbeans.modules.xml.schema.model.MinInclusive;
60 import org.netbeans.modules.xml.schema.model.MinLength;
61 import org.netbeans.modules.xml.schema.model.Notation;
62 import org.netbeans.modules.xml.schema.model.Pattern;
63 import org.netbeans.modules.xml.schema.model.Redefine;
64 import org.netbeans.modules.xml.schema.model.Schema;
65 import org.netbeans.modules.xml.schema.model.SchemaComponent;
66 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
67 import org.netbeans.modules.xml.schema.model.Selector;
68 import org.netbeans.modules.xml.schema.model.Sequence;
69 import org.netbeans.modules.xml.schema.model.SimpleContent;
70 import org.netbeans.modules.xml.schema.model.SimpleContentRestriction;
71 import org.netbeans.modules.xml.schema.model.SimpleExtension;
72 import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction;
73 import org.netbeans.modules.xml.schema.model.TotalDigits;
74 import org.netbeans.modules.xml.schema.model.Union;
75 import org.netbeans.modules.xml.schema.model.Unique;
76 import org.netbeans.modules.xml.schema.model.Whitespace;
77 import org.netbeans.modules.xml.schema.model.visitor.DefaultSchemaVisitor;
78 import org.openide.nodes.Node;
79
80 /**
81  *
82  * @author Ajit Bhate
83  */

84 public class CreateSchemaComponentNodeVisitor extends DefaultSchemaVisitor
85 {
86     private Node result;
87     private SchemaNodeFactory factory;
88     /** Creates a new instance of CreateSchemaComponentNodeVisitor */
89     public CreateSchemaComponentNodeVisitor()
90     {
91     }
92
93     public <C extends SchemaComponent> Node createNode(SchemaNodeFactory factory,
94         C component)
95     {
96         this.result = null;
97         this.factory = factory;
98         component.accept(this);
99         return result;
100     }
101
102     public void visit(LocalSimpleType type)
103     {
104         SchemaComponentReference<LocalSimpleType> reference =
105                 SchemaComponentReference.create(type);
106         result = getFactory().createLocalSimpleTypeNode(reference);
107     }
108
109     public void visit(Union u)
110     {
111         SchemaComponentReference<Union> reference =
112                 SchemaComponentReference.create(u);
113         result = getFactory().createUnionNode(reference);
114     }
115
116     public void visit(AnyElement any)
117     {
118         SchemaComponentReference<AnyElement> reference =
119                 SchemaComponentReference.create(any);
120         result = getFactory().createAnyNode(reference);
121     }
122
123     public void visit(Enumeration e)
124     {
125         SchemaComponentReference<Enumeration> reference =
126                 SchemaComponentReference.create(e);
127         result = getFactory().createEnumerationNode(reference);
128     }
129
130     public void visit(AppInfo appinfo)
131     {
132         SchemaComponentReference<AppInfo> reference =
133                 SchemaComponentReference.create(appinfo);
134         result = getFactory().createAppInfoNode(reference);
135     }
136
137     public void visit(AttributeGroupReference agr)
138     {
139         SchemaComponentReference<AttributeGroupReference> reference =
140                 SchemaComponentReference.create(agr);
141         result = getFactory().createAttributeGroupReferenceNode(reference);
142     }
143
144     public void visit(GlobalAttributeGroup gag)
145     {
146         SchemaComponentReference<GlobalAttributeGroup> reference =
147                 SchemaComponentReference.create(gag);
148         result = getFactory().createGlobalAttributeGroupNode(reference);
149     }
150
151     public void visit(KeyRef kr)
152     {
153         SchemaComponentReference<KeyRef> reference =
154                 SchemaComponentReference.create(kr);
155         result = getFactory().createKeyRefNode(reference);
156     }
157
158     public void visit(GlobalSimpleType gst)
159     {
160         SchemaComponentReference<GlobalSimpleType> reference =
161                 SchemaComponentReference.create(gst);
162         result = getFactory().createGlobalSimpleTypeNode(reference);
163     }
164
165     public void visit(Include include)
166     {
167         SchemaComponentReference<Include> reference =
168                 SchemaComponentReference.create(include);
169         result = getFactory().createIncludeNode(reference);
170     }
171
172     public void visit(MinInclusive mi)
173     {
174         SchemaComponentReference<MinInclusive> reference =
175                 SchemaComponentReference.create(mi);
176         result = getFactory().createMinInclusiveNode(reference);
177     }
178
179     public void visit(Import im)
180     {
181         SchemaComponentReference<Import> reference =
182                 SchemaComponentReference.create(im);
183         result = getFactory().createImportNode(reference);
184     }
185
186     public void visit(Choice choice)
187     {
188         SchemaComponentReference<Choice> reference =
189                 SchemaComponentReference.create(choice);
190         result = getFactory().createChoiceNode(reference);
191     }
192
193     public void visit(Unique u)
194     {
195         SchemaComponentReference<Unique> reference =
196                 SchemaComponentReference.create(u);
197         result = getFactory().createUniqueNode(reference);
198     }
199
200     public void visit(MaxLength ml)
201     {
202         SchemaComponentReference<MaxLength> reference =
203                 SchemaComponentReference.create(ml);
204         result = getFactory().createMaxLengthNode(reference);
205     }
206
207     public void visit(Redefine rd)
208     {
209         SchemaComponentReference<Redefine> reference =
210                 SchemaComponentReference.create(rd);
211         result = getFactory().createRedefineNode(reference);
212     }
213
214     public void visit(SimpleContentRestriction scr)
215     {
216         SchemaComponentReference<SimpleContentRestriction> reference =
217                 SchemaComponentReference.create(scr);
218         result = getFactory().createSimpleContentRestrictionNode(reference);
219     }
220
221     public void visit(LocalElement le)
222     {
223         SchemaComponentReference<LocalElement> reference =
224                 SchemaComponentReference.create(le);
225         result = getFactory().createLocalElementNode(reference);
226     }
227
228     public void visit(Selector s)
229     {
230         SchemaComponentReference<Selector> reference =
231                 SchemaComponentReference.create(s);
232         result = getFactory().createSelectorNode(reference);
233     }
234
235     public void visit(Annotation ann)
236     {
237         SchemaComponentReference<Annotation> reference =
238                 SchemaComponentReference.create(ann);
239         result = getFactory().createAnnotationNode(reference);
240     }
241
242     public void visit(ComplexExtension ce)
243     {
244         SchemaComponentReference<ComplexExtension> reference =
245                 SchemaComponentReference.create(ce);
246         result = getFactory().createComplexExtensionNode(reference);
247     }
248
249     public void visit(FractionDigits fd)
250     {
251         SchemaComponentReference<FractionDigits> reference =
252                 SchemaComponentReference.create(fd);
253         result = getFactory().createFractionDigitsNode(reference);
254     }
255
256     public void visit(SimpleExtension se)
257     {
258         SchemaComponentReference<SimpleExtension> reference =
259                 SchemaComponentReference.create(se);
260         result = getFactory().createSimpleExtensionNode(reference);
261     }
262
263     public void visit(Whitespace ws)
264     {
265         SchemaComponentReference<Whitespace> reference =
266                 SchemaComponentReference.create(ws);
267         result = getFactory().createWhitespaceNode(reference);
268     }
269
270     public void visit(LocalComplexType type)
271     {
272         SchemaComponentReference<LocalComplexType> reference =
273                 SchemaComponentReference.create(type);
274         result = getFactory().createLocalComplexTypeNode(reference);
275     }
276
277     public void visit(TotalDigits td)
278     {
279         SchemaComponentReference<TotalDigits> reference =
280                 SchemaComponentReference.create(td);
281         result = getFactory().createTotalDigitsNode(reference);
282     }
283
284     public void visit(MaxExclusive me)
285     {
286         SchemaComponentReference<MaxExclusive> reference =
287                 SchemaComponentReference.create(me);
288         result = getFactory().createMaxExclusiveNode(reference);
289     }
290
291     public void visit(SimpleContent sc)
292     {
293         SchemaComponentReference<SimpleContent> reference =
294                 SchemaComponentReference.create(sc);
295         result = getFactory().createSimpleContentNode(reference);
296     }
297
298     public void visit(AnyAttribute anyAttr)
299     {
300         SchemaComponentReference<AnyAttribute> reference =
301                 SchemaComponentReference.create(anyAttr);
302         result = getFactory().createAnyAttributeNode(reference);
303     }
304
305     public void visit(GlobalAttribute ga)
306     {
307         SchemaComponentReference<GlobalAttribute> reference =
308                 SchemaComponentReference.create(ga);
309         result = getFactory().createGlobalAttributeNode(reference);
310     }
311
312     public void visit(All all)
313     {
314         SchemaComponentReference<All> reference =
315                 SchemaComponentReference.create(all);
316         result = getFactory().createAllNode(reference);
317     }
318
319     public void visit(ComplexContentRestriction ccr)
320     {
321         SchemaComponentReference<ComplexContentRestriction> reference =
322                 SchemaComponentReference.create(ccr);
323         result = getFactory().createComplexContentRestrictionNode(reference);
324     }
325
326     public void visit(GroupReference gr)
327     {
328         SchemaComponentReference<GroupReference> reference =
329                 SchemaComponentReference.create(gr);
330         result = getFactory().createGroupReferenceNode(reference);
331     }
332
333     public void visit(Key key)
334     {
335         SchemaComponentReference<Key> reference =
336                 SchemaComponentReference.create(key);
337         result = getFactory().createKeyNode(reference);
338     }
339
340     public void visit(List l)
341     {
342         SchemaComponentReference<List> reference =
343                 SchemaComponentReference.create(l);
344         result = getFactory().createListNode(reference);
345     }
346
347     public void visit(Pattern p)
348     {
349         SchemaComponentReference<Pattern> reference =
350                 SchemaComponentReference.create(p);
351         result = getFactory().createPatternNode(reference);
352     }
353
354     public void visit(Documentation d)
355     {
356         SchemaComponentReference<Documentation> reference =
357                 SchemaComponentReference.create(d);
358         result = getFactory().createDocumentationNode(reference);
359     }
360
361     public void visit(MinExclusive me)
362     {
363         SchemaComponentReference<MinExclusive> reference =
364                 SchemaComponentReference.create(me);
365         result = getFactory().createMinExclusiveNode(reference);
366     }
367
368     public void visit(MinLength ml)
369     {
370         SchemaComponentReference<MinLength> reference =
371                 SchemaComponentReference.create(ml);
372         result = getFactory().createMinLengthNode(reference);
373     }
374
375     public void visit(Schema s)
376     {
377         SchemaComponentReference<Schema> reference =
378                 SchemaComponentReference.create(s);
379         result = getFactory().createSchemaNode(reference);
380     }
381
382     public void visit(ElementReference er)
383     {
384         SchemaComponentReference<ElementReference> reference =
385                 SchemaComponentReference.create(er);
386         result = getFactory().createElementReferenceNode(reference);
387     }
388
389     public void visit(AttributeReference r)
390     {
391         SchemaComponentReference<AttributeReference> reference =
392                 SchemaComponentReference.create(r);
393         result = getFactory().createAttributeReferenceNode(reference);
394     }
395
396     public void visit(GlobalComplexType gct)
397     {
398         SchemaComponentReference<GlobalComplexType> reference =
399                 SchemaComponentReference.create(gct);
400         result = getFactory().createGlobalComplexTypeNode(reference);
401     }
402
403     public void visit(Sequence s)
404     {
405         SchemaComponentReference<Sequence> reference =
406                 SchemaComponentReference.create(s);
407         result = getFactory().createSequenceNode(reference);
408     }
409
410     public void visit(MaxInclusive mi)
411     {
412         SchemaComponentReference<MaxInclusive> reference =
413                 SchemaComponentReference.create(mi);
414         result = getFactory().createMaxInclusiveNode(reference);
415     }
416
417     public void visit(SimpleTypeRestriction str)
418     {
419         SchemaComponentReference<SimpleTypeRestriction> reference =
420                 SchemaComponentReference.create(str);
421         result = getFactory().createSimpleTypeRestrictionNode(reference);
422     }
423
424     public void visit(LocalAttribute la)
425     {
426         SchemaComponentReference<LocalAttribute> reference =
427                 SchemaComponentReference.create(la);
428         result = getFactory().createLocalAttributeNode(reference);
429     }
430
431     public void visit(Notation notation)
432     {
433         SchemaComponentReference<Notation> reference =
434                 SchemaComponentReference.create(notation);
435         result = getFactory().createNotationNode(reference);
436     }
437
438     public void visit(ComplexContent cc)
439     {
440         SchemaComponentReference<ComplexContent> reference =
441                 SchemaComponentReference.create(cc);
442         result = getFactory().createComplexContentNode(reference);
443     }
444
445     public void visit(GlobalElement ge)
446     {
447         SchemaComponentReference<GlobalElement> reference =
448                 SchemaComponentReference.create(ge);
449         result = getFactory().createGlobalElementNode(reference);
450     }
451
452     public void visit(Length length)
453     {
454         SchemaComponentReference<Length> reference =
455                 SchemaComponentReference.create(length);
456         result = getFactory().createLengthNode(reference);
457     }
458
459     public void visit(GlobalGroup gd)
460     {
461         SchemaComponentReference<GlobalGroup> reference =
462                 SchemaComponentReference.create(gd);
463         result = getFactory().createGlobalGroupNode(reference);
464     }
465
466     public void visit(Field f)
467     {
468         SchemaComponentReference<Field> reference =
469                 SchemaComponentReference.create(f);
470         result = getFactory().createFieldNode(reference);
471     }
472
473     protected SchemaNodeFactory getFactory()
474     {
475         return factory;
476     }
477     
478 }
479
Popular Tags