KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
23 import javax.swing.text.BadLocationException JavaDoc;
24 import org.netbeans.modules.xml.axi.impl.SchemaGeneratorFactoryImpl;
25 import org.netbeans.modules.xml.schema.model.SchemaModel;
26
27 /**
28  *
29  * @author Ayub Khan
30  */

31 public abstract class SchemaGeneratorFactory {
32     
33     public enum TransformHint{
34         OK,
35         SAME_DESIGN_PATTERN,
36         INVALID_SCHEMA,
37         NO_GLOBAL_ELEMENTS,
38         GLOBAL_ELEMENTS_HAVE_NO_CHILD_ELEMENTS,
39         GLOBAL_ELEMENTS_HAVE_NO_CHILD_ATTRIBUTES,
40         GLOBAL_ELEMENTS_HAVE_NO_CHILD_ELEMENTS_AND_ATTRIBUTES,
41         GLOBAL_ELEMENTS_HAVE_NO_GRAND_CHILDREN,
42         NO_ATTRIBUTES,
43         WILL_REMOVE_TYPES,
44         WILL_REMOVE_GLOBAL_ELEMENTS,
45         WILL_REMOVE_GLOBAL_ELEMENTS_AND_TYPES,
46         CANNOT_REMOVE_TYPES,
47         CANNOT_REMOVE_GLOBAL_ELEMENTS,
48         CANNOT_REMOVE_GLOBAL_ELEMENTS_AND_TYPES;
49     }
50     
51     private static SchemaGeneratorFactory instance;
52     
53     /** Creates a new instance of SchemaGeneratorFactory */
54     public static SchemaGeneratorFactory getDefault() {
55         if(instance == null)
56             instance = new SchemaGeneratorFactoryImpl();
57         return instance;
58     }
59     
60     /*
61      * infers design pattern
62      *
63      */

64     public abstract SchemaGenerator.Pattern inferDesignPattern(AXIModel am);
65     
66     /*
67      * Updates schema using a a particular design pattern
68      *
69      */

70     public abstract void updateSchema(SchemaModel sm,
71             SchemaGenerator.Pattern pattern) throws BadLocationException JavaDoc, IOException JavaDoc;
72     
73     /*
74      * returns list of all master axi global elements
75      *
76      * @param am - AXIModel
77      * @return ges - list of all master axi global elements
78      */

79     public abstract List JavaDoc<Element> findMasterGlobalElements(AXIModel am);
80     
81     /*
82      * can transforms schema using a a particular design pattern
83      *
84      * @param sm - SchemaModel
85      * @param currentPattern - if null then checks only if the schema is valid and well-formed for transform
86      * @param targetPattern - if null then checks only if the schema is valid and well-formed for transform
87      */

88     public abstract TransformHint canTransformSchema(SchemaModel sm,
89             SchemaGenerator.Pattern currentPattern, SchemaGenerator.Pattern targetPattern);
90     
91     /*
92      * can transforms schema using a a particular design pattern
93      *
94      * @param sm - SchemaModel
95      * @param currentPattern - if null then checks only if the schema is valid and well-formed for transform
96      * @param targetPattern - if null then checks only if the schema is valid and well-formed for transform
97      * @param ges - list of all master axi global elements
98      */

99     public abstract TransformHint canTransformSchema(SchemaModel sm,
100             SchemaGenerator.Pattern currentPattern, SchemaGenerator.Pattern targetPattern,
101             List JavaDoc<Element> ges);
102     
103     /*
104      * transforms schema using a a particular design pattern
105      *
106      */

107     public abstract void transformSchema(SchemaModel sm,
108             SchemaGenerator.Pattern targetPattern) throws IOException JavaDoc;
109 }
110
Popular Tags