2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.modules.xml.axi;
43
import java.util.List;
45
import org.netbeans.modules.xml.axi.impl.AXIModelBuilder;
46
import org.netbeans.modules.xml.axi.impl.Util;
47
import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
48
import org.netbeans.modules.xml.schema.model.Form;
49
import org.netbeans.modules.xml.schema.model.GlobalElement;
50
import org.netbeans.modules.xml.schema.model.Schema;
51
import org.netbeans.modules.xml.schema.model.SchemaComponent;
54
* Root of the AXI tree.
56
* @author Samaresh (Samaresh.Panda@Sun.Com)
58
public abstract class AXIDocument extends AXIComponent {
61
* Creates a new instance of AXIDocument.
63
public AXIDocument(AXIModel model) {
68
* Creates a new instance of AXIDocument
70
public AXIDocument(AXIModel model, SchemaComponent schemaComponent) {
71
super(model, schemaComponent);
77
public void accept(AXIVisitor visitor) {
82
* Convenient method to return the top level elements.
84
public List<Element> getElements() {
85
return getChildren(Element.class);
89
* Convenient method to return the top level attributes.
91
public List<Attribute> getAttributes() {
92
return getChildren(Attribute.class);
96
* Returns a list of ContentModels used in this schema document.
98
public List<ContentModel> getContentModels() {
99
return getChildren(ContentModel.class);
104
* Adds a ContentModel to the document.
106
public void addContentModel(ContentModel contentModel) {
107
appendChild(ContentModel.PROP_CONTENT_MODEL, contentModel);
111
* Removes a ContentModel from the document.
113
public void removeContentModel(ContentModel contentModel) {
114
removeChild(ContentModel.PROP_CONTENT_MODEL, contentModel);
118
* Adds an Element as its child.
120
public void addElement(Element element) {
121
appendChild(Element.PROP_ELEMENT, element);
125
* Removes an Element.
127
public void removeElement(Element element) {
128
removeChild(Element.PROP_ELEMENT, element);
132
* Returns the namespace, this component belongs to.
134
public String getTargetNamespace() {
139
* Sets the fixed value.
141
public void setTargetNamespace(String value) {
142
String oldValue = getTargetNamespace();
143
if( (oldValue == null && value == null) ||
144
(oldValue != null && oldValue.equals(value)) ) {
147
this.namespace = value;
148
firePropertyChangeEvent(PROP_TARGET_NAMESPACE, oldValue, value);
151
public void setVersion(String value) {
152
String oldValue = getVersion();
153
if( (oldValue == null && value == null) ||
154
(oldValue != null && oldValue.equals(value)) ) {
157
this.version = value;
158
firePropertyChangeEvent(PROP_VERSION, oldValue, value);
161
public String getVersion() {
165
public void setLanguage(String value) {
166
String oldValue = getLanguage();
167
if( (oldValue == null && value == null) ||
168
(oldValue != null && oldValue.equals(value)) ) {
171
this.language = value;
172
firePropertyChangeEvent(PROP_LANGUAGE, oldValue, value);
175
public String getLanguage() {
180
// public void setFinalDefault(Set<Final> value) {
181
// Set<Final> oldValue = getFinalDefault();
182
// if( (oldValue == null && value == null) ||
183
// (oldValue != null && oldValue.equals(value)) ) {
186
// this.finalDefault = value;
187
// firePropertyChangeEvent(PROP_FINAL_DEFAULT, oldValue, value);
190
// public Set<Final> getFinalDefault() {
191
// return finalDefault;
194
public void setElementFormDefault(Form value) {
195
Form oldValue = getElementFormDefault();
196
if( (oldValue == null && value == null) ||
197
(oldValue != null && oldValue.equals(value)) ) {
200
this.elementFormDefault = value;
201
firePropertyChangeEvent(PROP_ELEMENT_FORM_DEFAULT, oldValue, value);
204
public Form getElementFormDefault() {
205
return elementFormDefault;
208
public void setAttributeFormDefault(Form value) {
209
Form oldValue = getAttributeFormDefault();
210
if( (oldValue == null && value == null) ||
211
(oldValue != null && oldValue.equals(value)) ) {
214
this.attributeFormDefault = value;
215
firePropertyChangeEvent(PROP_ATTRIBUTE_FORM_DEFAULT, oldValue, value);
218
public Form getAttributeFormDefault() {
219
return attributeFormDefault;
222
public void setSchemaDesignPattern(SchemaGenerator.Pattern value) {
223
SchemaGenerator.Pattern oldValue = getSchemaDesignPattern();
224
if( (oldValue == null && value == null) ||
225
(oldValue != null && oldValue == value) ) {
228
if(getModel() != null)
229
getModel().setSchemaDesignPattern(value);
230
firePropertyChangeEvent(PROP_SCHEMA_DESIGN_PATTERN, oldValue, value);
233
public SchemaGenerator.Pattern getSchemaDesignPattern() {
234
return getModel()!=null?getModel().getSchemaDesignPattern():null;
237
private String namespace;
238
private String version;
239
private String language;
240
private Form attributeFormDefault;
241
private Form elementFormDefault;
243
public static final String PROP_TARGET_NAMESPACE = "targetNamespace"; // NOI18N
244
public static final String PROP_LANGUAGE = "language"; // NOI18N
245
public static final String PROP_VERSION = "version"; // NOI18N
246
public static final String PROP_ATTRIBUTE_FORM_DEFAULT = "attributeFormDefault"; // NOI18N
247
public static final String PROP_ELEMENT_FORM_DEFAULT = "elementFormDefault"; // NOI18N
248
public static final String PROP_SCHEMA_DESIGN_PATTERN = "schemaDesignPattern"; // NOI18N