KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.List JavaDoc;
22 import java.util.Set JavaDoc;
23 import org.netbeans.modules.xml.axi.impl.AXIModelBuilder;
24 import org.netbeans.modules.xml.axi.impl.Util;
25 import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
26 import org.netbeans.modules.xml.schema.model.Form;
27 import org.netbeans.modules.xml.schema.model.GlobalElement;
28 import org.netbeans.modules.xml.schema.model.Schema;
29 import org.netbeans.modules.xml.schema.model.SchemaComponent;
30
31 /**
32  * Root of the AXI tree.
33  *
34  * @author Samaresh (Samaresh.Panda@Sun.Com)
35  */

36 public abstract class AXIDocument extends AXIComponent {
37     
38     /**
39      * Creates a new instance of AXIDocument.
40      */

41     public AXIDocument(AXIModel model) {
42         super(model);
43     }
44     
45     /**
46      * Creates a new instance of AXIDocument
47      */

48     public AXIDocument(AXIModel model, SchemaComponent schemaComponent) {
49         super(model, schemaComponent);
50     }
51         
52     /**
53      * Allow visitor.
54      */

55     public void accept(AXIVisitor visitor) {
56         visitor.visit(this);
57     }
58     
59     /**
60      * Convenient method to return the top level elements.
61      */

62     public List JavaDoc<Element> getElements() {
63         return getChildren(Element.class);
64     }
65     
66     /**
67      * Convenient method to return the top level attributes.
68      */

69     public List JavaDoc<Attribute> getAttributes() {
70         return getChildren(Attribute.class);
71     }
72     
73     /**
74      * Returns a list of ContentModels used in this schema document.
75      */

76     public List JavaDoc<ContentModel> getContentModels() {
77         return getChildren(ContentModel.class);
78     }
79     
80         
81     /**
82      * Adds a ContentModel to the document.
83      */

84     public void addContentModel(ContentModel contentModel) {
85         appendChild(ContentModel.PROP_CONTENT_MODEL, contentModel);
86     }
87         
88     /**
89      * Removes a ContentModel from the document.
90      */

91     public void removeContentModel(ContentModel contentModel) {
92         removeChild(ContentModel.PROP_CONTENT_MODEL, contentModel);
93     }
94     
95     /**
96      * Adds an Element as its child.
97      */

98     public void addElement(Element element) {
99         appendChild(Element.PROP_ELEMENT, element);
100     }
101         
102     /**
103      * Removes an Element.
104      */

105     public void removeElement(Element element) {
106         removeChild(Element.PROP_ELEMENT, element);
107     }
108
109     /**
110      * Returns the namespace, this component belongs to.
111      */

112     public String JavaDoc getTargetNamespace() {
113         return namespace;
114     }
115     
116     /**
117      * Sets the fixed value.
118      */

119     public void setTargetNamespace(String JavaDoc value) {
120         String JavaDoc oldValue = getTargetNamespace();
121         if( (oldValue == null && value == null) ||
122                 (oldValue != null && oldValue.equals(value)) ) {
123             return;
124         }
125         this.namespace = value;
126         firePropertyChangeEvent(PROP_TARGET_NAMESPACE, oldValue, value);
127     }
128         
129     public void setVersion(String JavaDoc value) {
130         String JavaDoc oldValue = getVersion();
131         if( (oldValue == null && value == null) ||
132                 (oldValue != null && oldValue.equals(value)) ) {
133             return;
134         }
135         this.version = value;
136         firePropertyChangeEvent(PROP_VERSION, oldValue, value);
137     }
138     
139     public String JavaDoc getVersion() {
140         return version;
141     }
142     
143     public void setLanguage(String JavaDoc value) {
144         String JavaDoc oldValue = getLanguage();
145         if( (oldValue == null && value == null) ||
146                 (oldValue != null && oldValue.equals(value)) ) {
147             return;
148         }
149         this.language = value;
150         firePropertyChangeEvent(PROP_LANGUAGE, oldValue, value);
151     }
152     
153     public String JavaDoc getLanguage() {
154         return language;
155     }
156     
157     //TODO
158
// public void setFinalDefault(Set<Final> value) {
159
// Set<Final> oldValue = getFinalDefault();
160
// if( (oldValue == null && value == null) ||
161
// (oldValue != null && oldValue.equals(value)) ) {
162
// return;
163
// }
164
// this.finalDefault = value;
165
// firePropertyChangeEvent(PROP_FINAL_DEFAULT, oldValue, value);
166
// }
167
//
168
// public Set<Final> getFinalDefault() {
169
// return finalDefault;
170
// }
171

172     public void setElementFormDefault(Form value) {
173         Form oldValue = getElementFormDefault();
174         if( (oldValue == null && value == null) ||
175                 (oldValue != null && oldValue.equals(value)) ) {
176             return;
177         }
178         this.elementFormDefault = value;
179         firePropertyChangeEvent(PROP_ELEMENT_FORM_DEFAULT, oldValue, value);
180     }
181     
182     public Form getElementFormDefault() {
183         return elementFormDefault;
184     }
185     
186     public void setAttributeFormDefault(Form value) {
187         Form oldValue = getAttributeFormDefault();
188         if( (oldValue == null && value == null) ||
189                 (oldValue != null && oldValue.equals(value)) ) {
190             return;
191         }
192         this.attributeFormDefault = value;
193         firePropertyChangeEvent(PROP_ATTRIBUTE_FORM_DEFAULT, oldValue, value);
194     }
195     
196     public Form getAttributeFormDefault() {
197         return attributeFormDefault;
198     }
199     
200     public void setSchemaDesignPattern(SchemaGenerator.Pattern value) {
201         SchemaGenerator.Pattern oldValue = getSchemaDesignPattern();
202         if( (oldValue == null && value == null) ||
203                 (oldValue != null && oldValue == value) ) {
204             return;
205         }
206         if(getModel() != null)
207             getModel().setSchemaDesignPattern(value);
208         firePropertyChangeEvent(PROP_SCHEMA_DESIGN_PATTERN, oldValue, value);
209     }
210     
211     public SchemaGenerator.Pattern getSchemaDesignPattern() {
212         return getModel()!=null?getModel().getSchemaDesignPattern():null;
213     }
214     
215     private String JavaDoc namespace;
216     private String JavaDoc version;
217     private String JavaDoc language;
218     private Form attributeFormDefault;
219     private Form elementFormDefault;
220     
221     public static final String JavaDoc PROP_TARGET_NAMESPACE = "targetNamespace"; // NOI18N
222
public static final String JavaDoc PROP_LANGUAGE = "language"; // NOI18N
223
public static final String JavaDoc PROP_VERSION = "version"; // NOI18N
224
public static final String JavaDoc PROP_ATTRIBUTE_FORM_DEFAULT = "attributeFormDefault"; // NOI18N
225
public static final String JavaDoc PROP_ELEMENT_FORM_DEFAULT = "elementFormDefault"; // NOI18N
226
public static final String JavaDoc PROP_SCHEMA_DESIGN_PATTERN = "schemaDesignPattern"; // NOI18N
227
}
228
Popular Tags