KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > model > impl > RedefineImpl


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.schema.model.impl;
20
21 import org.netbeans.modules.xml.schema.model.GlobalAttributeGroup;
22 import org.netbeans.modules.xml.schema.model.GlobalComplexType;
23 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
24 import org.netbeans.modules.xml.schema.model.GlobalGroup;
25 import org.netbeans.modules.xml.schema.model.Redefine;
26 import org.netbeans.modules.xml.schema.model.SchemaComponent;
27 import org.netbeans.modules.xml.schema.model.SchemaModel;
28 import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
29 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor;
30 import org.netbeans.modules.xml.xam.Model;
31 import org.netbeans.modules.xml.xam.locator.CatalogModelException;
32 import org.netbeans.modules.xml.xam.ModelSource;
33 import org.openide.util.NbBundle;
34 import org.w3c.dom.Element JavaDoc;
35
36 /**
37  *
38  * @author Vidhya Narayanan
39  */

40 public class RedefineImpl extends SchemaComponentImpl implements Redefine {
41     
42         public RedefineImpl(SchemaModelImpl model) {
43             this(model,createNewComponent(SchemaElements.REDEFINE,model));
44         }
45     /**
46      * Creates a new instance of RedefineImpl
47      */

48     public RedefineImpl(SchemaModelImpl model, Element JavaDoc el) {
49         super(model, el);
50     }
51
52     /**
53      *
54      *
55      */

56     public Class JavaDoc<? extends SchemaComponent> getComponentType() {
57         return Redefine.class;
58     }
59     
60     /**
61      *
62      */

63     public void setSchemaLocation(String JavaDoc uri) {
64         setAttribute(SCHEMA_LOCATION_PROPERTY, SchemaAttributes.SCHEMA_LOCATION, uri);
65     }
66     
67     /**
68      *
69      */

70     public void addComplexType(GlobalComplexType type) {
71         appendChild(COMPLEX_TYPE_PROPERTY, type);
72     }
73     
74     /**
75      *
76      */

77     public void removeComplexType(GlobalComplexType type) {
78         removeChild(COMPLEX_TYPE_PROPERTY, type);
79     }
80     
81     /**
82      *
83      */

84     public void addAttributeGroup(GlobalAttributeGroup group) {
85         appendChild(ATTRIBUTE_GROUP_PROPERTY, group);
86     }
87     
88     /**
89      *
90      */

91     public void removeAttributeGroup(GlobalAttributeGroup group) {
92         removeChild(ATTRIBUTE_GROUP_PROPERTY, group);
93     }
94     
95     /**
96      *
97      */

98     public void removeSimpleType(GlobalSimpleType type) {
99         removeChild(SIMPLE_TYPE_PROPERTY, type);
100     }
101     
102     /**
103      *
104      */

105     public void addSimpleType(GlobalSimpleType type) {
106         appendChild(SIMPLE_TYPE_PROPERTY, type);
107     }
108     
109     /**
110      *
111      */

112     public void accept(SchemaVisitor visitor) {
113         visitor.visit(this);
114     }
115     
116     /**
117      *
118      */

119     public void addGroupDefinition(GlobalGroup def) {
120         appendChild(GROUP_DEFINITION_PROPERTY, def);
121     }
122     
123     /**
124      *
125      */

126     public void removeGroupDefinition(GlobalGroup def) {
127         removeChild(GROUP_DEFINITION_PROPERTY, def);
128     }
129     
130     /**
131      *
132      */

133     public java.util.Collection JavaDoc<GlobalAttributeGroup> getAttributeGroups() {
134         return getChildren(GlobalAttributeGroup.class);
135     }
136     
137     /**
138      *
139      */

140     public java.util.Collection JavaDoc<GlobalComplexType> getComplexTypes() {
141         return getChildren(GlobalComplexType.class);
142     }
143     
144     /**
145      *
146      */

147     public java.util.Collection JavaDoc<GlobalGroup> getGroupDefinitions() {
148         return getChildren(GlobalGroup.class);
149     }
150     
151     /**
152      *
153      */

154     public String JavaDoc getSchemaLocation() {
155            return getAttribute(SchemaAttributes.SCHEMA_LOCATION);
156     }
157     
158     /**
159      *
160      */

161     public java.util.Collection JavaDoc<GlobalSimpleType> getSimpleTypes() {
162         return getChildren(GlobalSimpleType.class);
163     }
164     
165     public SchemaModel resolveReferencedModel() throws CatalogModelException {
166         ModelSource ms = resolveModel(getSchemaLocation());
167         return SchemaModelFactory.getDefault().getModel(ms);
168     }
169 }
170
Popular Tags