KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > xml > impl > XsTSimpleTypeImpl


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.xs.xml.impl;
18
19 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
20 import org.apache.ws.jaxme.xs.xml.*;
21 import org.xml.sax.SAXException JavaDoc;
22
23
24 /** <p>Implementation of the following specification for
25  * <code>xs:simpleType</code>:
26  * <pre>
27  * &lt;xs:complexType name="simpleType" abstract="true"&gt;
28  * &lt;xs:complexContent&gt;
29  * &lt;xs:extension base="xs:annotated"&gt;
30  * &lt;xs:group ref="xs:simpleDerivation"/&gt;
31  * &lt;xs:attribute name="final" type="xs:simpleDerivationSet"/&gt;
32  * &lt;xs:attribute name="name" type="xs:NCName"&gt;
33  * &lt;xs:annotation&gt;
34  * &lt;xs:documentation&gt;
35  * Can be restricted to required or forbidden
36  * &lt;/xs:documentation&gt;
37  * &lt;/xs:annotation&gt;
38  * &lt;/xs:attribute&gt;
39  * &lt;/xs:extension&gt;
40  * &lt;/xs:complexContent&gt;
41  * &lt;/xs:complexType&gt;
42  *
43  * &lt;xs:group name="simpleDerivation"&gt;
44  * &lt;xs:choice&gt;
45  * &lt;xs:element ref="xs:restriction"/&gt;
46  * &lt;xs:element ref="xs:list"/&gt;
47  * &lt;xs:element ref="xs:union"/&gt;
48  * &lt;/xs:choice&gt;
49  * &lt;/xs:group&gt;
50  * </pre></p>
51  *
52  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
53  */

54 public class XsTSimpleTypeImpl extends XsTAnnotatedImpl implements XsTSimpleType {
55   private XsERestriction restriction;
56   private XsEList list;
57   private XsEUnion union;
58   private XsSimpleDerivationSet finalSet;
59   private XsNCName name;
60
61   protected XsTSimpleTypeImpl(XsObject pParent) {
62     super(pParent);
63   }
64
65   public XsERestriction createRestriction() throws SAXException {
66     if (restriction != null || list != null || union != null) {
67       throw new LocSAXException("Only one 'restriction', 'list', or 'union' child element is allowed.", getLocator());
68     }
69     return restriction = getObjectFactory().newXsERestriction(this);
70   }
71
72   public XsERestriction getRestriction() {
73     return restriction;
74   }
75
76   public XsEList createList() throws SAXException {
77     if (restriction != null || list != null || union != null) {
78       throw new LocSAXException("Only one 'restriction', 'list', or 'union' child element is allowed.", getLocator());
79     }
80     return list = getObjectFactory().newXsEList(this);
81   }
82
83   public XsEList getList() {
84     return list;
85   }
86
87   public XsEUnion createUnion() throws SAXException {
88     if (restriction != null || list != null || union != null) {
89       throw new LocSAXException("Only one 'restriction', 'list', or 'union' child element is allowed.", getLocator());
90     }
91     return union = getObjectFactory().newXsEUnion(this);
92   }
93
94   public XsEUnion getUnion() {
95     return union;
96   }
97
98   public void setFinal(XsSimpleDerivationSet pSet) throws SAXException {
99     finalSet = pSet;
100   }
101
102   public XsSimpleDerivationSet getFinal() {
103     return finalSet;
104   }
105
106   public void setName(XsNCName pName) throws SAXException {
107     name = pName;
108   }
109
110   public XsNCName getName() {
111     return name;
112   }
113
114   public void validate() throws SAXException {
115     super.validate();
116     if (restriction == null && list == null && union == null) {
117       throw new LocSAXException("Expected either of 'restriction', 'list' or 'union' child element.", getLocator());
118     }
119   }
120 }
121
Popular Tags