KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 package org.netbeans.modules.xml.schema.model.impl;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.List JavaDoc;
25 import org.netbeans.modules.xml.schema.model.Annotation;
26 import org.netbeans.modules.xml.schema.model.AnyAttribute;
27 import org.netbeans.modules.xml.schema.model.AttributeGroupReference;
28 import org.netbeans.modules.xml.schema.model.Attribute;
29 import org.netbeans.modules.xml.schema.model.GlobalType;
30 import org.netbeans.modules.xml.schema.model.SimpleRestriction;
31 import org.netbeans.modules.xml.schema.model.Enumeration;
32 import org.netbeans.modules.xml.schema.model.FractionDigits;
33 import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
34 import org.netbeans.modules.xml.schema.model.Length;
35 import org.netbeans.modules.xml.schema.model.LocalSimpleType;
36 import org.netbeans.modules.xml.schema.model.MaxExclusive;
37 import org.netbeans.modules.xml.schema.model.MaxInclusive;
38 import org.netbeans.modules.xml.schema.model.MaxLength;
39 import org.netbeans.modules.xml.schema.model.MinExclusive;
40 import org.netbeans.modules.xml.schema.model.MinInclusive;
41 import org.netbeans.modules.xml.schema.model.MinLength;
42 import org.netbeans.modules.xml.schema.model.Pattern;
43 import org.netbeans.modules.xml.schema.model.SchemaComponent;
44 import org.netbeans.modules.xml.schema.model.TotalDigits;
45 import org.netbeans.modules.xml.schema.model.Whitespace;
46 import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
47 import org.w3c.dom.Element JavaDoc;
48
49 /**
50  *
51  * @author rico
52  */

53 public abstract class CommonSimpleRestrictionImpl extends SchemaComponentImpl implements SimpleRestriction{
54     
55     /** Creates a new instance of CommonSimpleRestrictionImpl */
56     public CommonSimpleRestrictionImpl(SchemaModelImpl model, Element JavaDoc el) {
57         super(model, el);
58     }
59     
60     public void addEnumeration(Enumeration fd) {
61         addBefore(ENUMERATION_PROPERTY, fd, getAttributeClasses());
62     }
63     
64     public void removeEnumeration(Enumeration fd) {
65         removeChild(ENUMERATION_PROPERTY, fd);
66     }
67     
68     public Collection JavaDoc<Enumeration> getEnumerations() {
69         return getChildren(Enumeration.class);
70     }
71     
72     public void removePattern(Pattern p) {
73         removeChild(PATTERN_PROPERTY, p);
74     }
75     
76     public void addPattern(Pattern p) {
77         addBefore(PATTERN_PROPERTY, p, getAttributeClasses());
78     }
79     
80     public Collection JavaDoc<Pattern> getPatterns() {
81         return getChildren(Pattern.class);
82     }
83     
84     public void removeMinExclusive(MinExclusive me) {
85         removeChild(MIN_EXCLUSIVE_PROPERTY, me);
86     }
87     
88     public void addMinExclusive(MinExclusive me) {
89         addBefore(MIN_EXCLUSIVE_PROPERTY, me, getAttributeClasses());
90     }
91     
92     public Collection JavaDoc<MinExclusive> getMinExclusives() {
93         return getChildren(MinExclusive.class);
94     }
95     
96     public void removeMinLength(MinLength ml) {
97         removeChild(MIN_LENGTH_PROPERTY, ml);
98     }
99     
100     public void addMinLength(MinLength ml) {
101         addBefore(MIN_LENGTH_PROPERTY, ml, getAttributeClasses());
102     }
103     
104     public Collection JavaDoc<MinLength> getMinLengths() {
105         return getChildren(MinLength.class);
106     }
107     
108     public void removeMaxLength(MaxLength ml) {
109         removeChild(MAX_LENGTH_PROPERTY, ml);
110     }
111     
112     public void addMaxLength(MaxLength ml) {
113         addBefore(MAX_LENGTH_PROPERTY, ml, getAttributeClasses());
114     }
115     
116     public Collection JavaDoc<MaxLength> getMaxLengths() {
117         return getChildren(MaxLength.class);
118     }
119     
120     public void removeFractionDigits(FractionDigits fd) {
121         removeChild(FRACTION_DIGITS_PROPERTY, fd);
122     }
123     
124     public void addFractionDigits(FractionDigits fd) {
125         addBefore(FRACTION_DIGITS_PROPERTY, fd, getAttributeClasses());
126     }
127     
128     public Collection JavaDoc<FractionDigits> getFractionDigits() {
129         return getChildren(FractionDigits.class);
130     }
131     
132     public void removeWhitespace(Whitespace me) {
133         removeChild(WHITESPACE_PROPERTY, me);
134     }
135     
136     public void addWhitespace(Whitespace me) {
137         addBefore(WHITESPACE_PROPERTY, me, getAttributeClasses());
138     }
139     
140     public Collection JavaDoc<Whitespace> getWhitespaces() {
141         return getChildren(Whitespace.class);
142     }
143     
144     
145     public void removeMaxInclusive(MaxInclusive me) {
146         removeChild(MAX_INCLUSIVE_PROPERTY, me);
147     }
148     
149     public void addMaxInclusive(MaxInclusive me) {
150         addBefore(MAX_INCLUSIVE_PROPERTY, me, getAttributeClasses());
151     }
152     
153     public Collection JavaDoc<MaxInclusive> getMaxInclusives() {
154         return getChildren(MaxInclusive.class);
155     }
156     
157     public void removeTotalDigit(TotalDigits td) {
158         removeChild(TOTAL_DIGITS_PROPERTY, td);
159     }
160     
161     public void addTotalDigit(TotalDigits td) {
162         addBefore(TOTAL_DIGITS_PROPERTY, td, getAttributeClasses());
163     }
164     
165     public Collection JavaDoc<TotalDigits> getTotalDigits() {
166         return getChildren(TotalDigits.class);
167     }
168     
169     public void removeLength(Length me) {
170         removeChild(LENGTH_PROPERTY , me);
171     }
172     
173     public void addLength(Length me) {
174         addBefore(LENGTH_PROPERTY, me, getAttributeClasses());
175     }
176     
177     public Collection JavaDoc<Length> getLengths() {
178         return getChildren(Length.class);
179     }
180     
181     public void removeMinInclusive(MinInclusive me) {
182         removeChild(MIN_INCLUSIVE_PROPERTY, me);
183     }
184     
185     public void addMinInclusive(MinInclusive me) {
186         addBefore(MIN_INCLUSIVE_PROPERTY, me, getAttributeClasses());
187     }
188     
189     public Collection JavaDoc<MinInclusive> getMinInclusives() {
190         return getChildren(MinInclusive.class);
191     }
192     
193     public void removeMaxExclusive(MaxExclusive me) {
194         removeChild(MAX_EXCLUSIVE_PROPERTY, me);
195     }
196     
197     public void addMaxExclusive(MaxExclusive me) {
198         addBefore(MAX_EXCLUSIVE_PROPERTY, me, getAttributeClasses());
199     }
200     
201     public Collection JavaDoc<MaxExclusive> getMaxExclusives() {
202         return getChildren(MaxExclusive.class);
203     }
204     
205     public void setInlineType(LocalSimpleType aSimpleType) {
206         List JavaDoc<java.lang.Class JavaDoc<? extends SchemaComponent>> list = new ArrayList JavaDoc<java.lang.Class JavaDoc<? extends SchemaComponent>>();
207         list.add(Annotation.class);
208         setChild(LocalSimpleType.class, INLINETYPE_PROPERTY, aSimpleType, list);
209     }
210     
211     public LocalSimpleType getInlineType() {
212         Collection JavaDoc<LocalSimpleType> elements = getChildren(LocalSimpleType.class);
213         if(!elements.isEmpty()){
214             return elements.iterator().next();
215         }
216         return null;
217     }
218     
219     private List JavaDoc<Class JavaDoc<? extends SchemaComponent>> getAttributeClasses(){
220         List JavaDoc<java.lang.Class JavaDoc<? extends SchemaComponent>> list = new ArrayList JavaDoc<java.lang.Class JavaDoc<? extends SchemaComponent>>();
221         list.add(Attribute.class);
222         list.add(AttributeGroupReference.class);
223         list.add(AnyAttribute.class);
224         
225         return list;
226     }
227 }
228
Popular Tags