KickJava   Java API By Example, From Geeks To Geeks.

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


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.xml.*;
20
21
22 /** <p>Implementation of <code>xs:simpleContent</code>,
23  * as specified by the following:
24  * <pre>
25  * &lt;xs:element name="simpleContent" id="simpleContent"&gt;
26  * &lt;xs:annotation&gt;
27  * &lt;xs:documentation source="http://www.w3.org/TR/xmlschema-1/#element-simpleContent"/&gt;
28  * &lt;/xs:annotation&gt;
29  * &lt;xs:complexType&gt;
30  * &lt;xs:complexContent&gt;
31  * &lt;xs:extension base="xs:annotated"&gt;
32  * &lt;xs:choice&gt;
33  * &lt;xs:element name="restriction" type="xs:simpleRestrictionType"/&gt;
34  * &lt;xs:element name="extension" type="xs:simpleExtensionType"/&gt;
35  * &lt;/xs:choice&gt;
36  * &lt;/xs:extension&gt;
37  * &lt;/xs:complexContent&gt;
38  * &lt;/xs:complexType&gt;
39  * &lt;/xs:element&gt;
40  * </pre></p>
41  *
42  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
43  */

44 public class XsESimpleContentImpl extends XsTAnnotatedImpl implements XsESimpleContent {
45   private XsTSimpleRestrictionType restriction;
46   private XsTSimpleExtensionType extension;
47
48   protected XsESimpleContentImpl(XsObject pParent) {
49     super(pParent);
50   }
51
52   public XsTSimpleRestrictionType createRestriction() {
53     if (restriction != null) {
54       throw new IllegalStateException JavaDoc("Multiple 'restriction' elements are forbidden.");
55     }
56     if (extension != null) {
57       throw new IllegalStateException JavaDoc("The 'restriction' and 'extension' child elements are mutually exclusive.");
58     }
59     return restriction = getObjectFactory().newXsTSimpleRestrictionType(this);
60   }
61
62   public XsTSimpleRestrictionType getRestriction() {
63     return restriction;
64   }
65
66   public XsTSimpleExtensionType createExtension() {
67     if (extension != null) {
68       throw new IllegalStateException JavaDoc("Multiple 'extension' elements are forbidden.");
69     }
70     if (restriction != null) {
71       throw new IllegalStateException JavaDoc("The 'restriction' and 'extension' child elements are mutually exclusive.");
72     }
73     return extension = getObjectFactory().newXsTSimpleExtensionType(this);
74   }
75
76   public XsTSimpleExtensionType getExtension() {
77     return extension;
78   }
79
80   public void validate() {
81     if (extension == null && restriction == null) {
82       throw new IllegalStateException JavaDoc("You must set either of the 'extension' or 'restriction' child elements.");
83     }
84   }
85 }
86
Popular Tags