KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > axi > SchemaGenerator


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 package org.netbeans.modules.xml.axi;
20
21 import java.io.IOException JavaDoc;
22 import java.util.Map JavaDoc;
23 import java.util.Set JavaDoc;
24 import javax.swing.text.BadLocationException JavaDoc;
25 import org.netbeans.modules.xml.axi.datatype.Datatype;
26 import org.netbeans.modules.xml.axi.visitor.*;
27 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
28 import org.netbeans.modules.xml.schema.model.SchemaComponent;
29 import org.netbeans.modules.xml.schema.model.SchemaModel;
30
31 /**
32  *
33  * @author Ayub Khan
34  */

35 public abstract class SchemaGenerator extends DefaultVisitor {
36     
37     private SchemaGenerator.Mode mode;
38     
39     public static SchemaGenerator.Pattern DEFAULT_DESIGN_PATTERN = Pattern.RUSSIAN_DOLL;
40     
41     public enum Pattern {
42         RUSSIAN_DOLL,
43         VENITIAN_BLIND,
44         GARDEN_OF_EDEN,
45         SALAMI_SLICE,
46         MIXED;
47     }
48     
49     public enum Mode {
50         TRANSFORM,
51         UPDATE;
52     }
53     
54     /**
55      * Creates a new instance of SchemaGenerator
56      */

57     public SchemaGenerator(Mode mode) {
58         super();
59         this.mode = mode;
60     }
61     
62     /*
63      * returns mode
64      *
65      */

66     public Mode getMode() {
67         return mode;
68     }
69     
70     /*
71      * Updates schema using a a particular design pattern
72      *
73      */

74     public abstract void updateSchema(SchemaModel sm) throws BadLocationException JavaDoc, IOException JavaDoc;
75     
76     /*
77      * Transforms schema using a particular design pattern
78      *
79      */

80     public abstract void transformSchema(SchemaModel sm) throws IOException JavaDoc;
81     
82     public void visit(Element element) {
83         visitChildren(element);
84     }
85     
86     public void visit(Attribute attribute) {
87         visitChildren(attribute);
88     }
89     
90     public void visit(Compositor compositor) {
91         visitChildren(compositor);
92     }
93     
94     protected void visitChildren(AXIComponent component) {
95         for(AXIComponent child: component.getChildren()) {
96             child.accept(this);
97         }
98     }
99     
100     public static interface UniqueId {
101         int nextId();
102     }
103     
104     public static interface PrimitiveCart {
105         void add(Datatype d, SchemaComponent referer);
106         Set JavaDoc<Map.Entry JavaDoc<SchemaComponent, Datatype>> getEntries();
107         GlobalSimpleType getDefaultPrimitive();
108         public GlobalSimpleType getPrimitiveType(String JavaDoc typeName);
109     }
110 }
111
Popular Tags