KickJava   Java API By Example, From Geeks To Geeks.

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


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 a named top-level group, with the following
23  * specification:
24  * <pre>
25  * &lt;xs:complexType name="namedGroup"&gt;
26  * &lt;xs:annotation&gt;
27  * &lt;xs:documentation&gt;
28  * Should derive this from realGroup, but too complicated for now
29  * &lt;/xs:documentation&gt;
30  * &lt;/xs:annotation&gt;
31  * &lt;xs:sequence&gt;
32  * &lt;xs:element ref="xs:annotation" minOccurs="0"/&gt;
33  * &lt;xs:choice minOccurs="1" maxOccurs="1"&gt;
34  * &lt;xs:element name="all"&gt;
35  * &lt;xs:complexType&gt;
36  * &lt;xs:complexContent&gt;
37  * &lt;xs:restriction base="xs:all"&gt;
38  * &lt;xs:group ref="xs:allModel"/&gt;
39  * &lt;xs:attribute name="minOccurs" use="prohibited"/&gt;
40  * &lt;xs:attribute name="maxOccurs" use="prohibited"/&gt;
41  * &lt;/xs:restriction&gt;
42  * &lt;/xs:complexContent&gt;
43  * &lt;/xs:complexType&gt;
44  * &lt;/xs:element&gt;
45  * &lt;xs:element name="choice" type="xs:simpleExplicitGroup"/&gt;
46  * &lt;xs:element name="sequence" type="xs:simpleExplicitGroup"/&gt;
47  * &lt;/xs:choice&gt;
48  * &lt;/xs:sequence&gt;
49  * &lt;xs:attribute name="name" use="required" type="xs:NCName"/&gt;
50  * &lt;xs:attribute name="ref" use="prohibited"/&gt;
51  * &lt;xs:attribute name="minOccurs" use="prohibited"/&gt;
52  * &lt;xs:attribute name="maxOccurs" use="prohibited"/&gt;
53  * &lt;/xs:complexType&gt;
54  * &lt;/pre>&lt;/p>
55  *
56  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
57  */

58 public class XsTNamedGroupImpl extends XsTAnnotatedImpl implements XsTNamedGroup {
59   private XsGAllModel all;
60   private XsTSimpleExplicitGroup sequence, choice;
61   private XsNCName name;
62
63   protected XsTNamedGroupImpl(XsObject pParent) {
64     super(pParent);
65   }
66
67   public void setName(XsNCName pName) {
68     name = pName;
69   }
70
71   public XsNCName getName() {
72     return name;
73   }
74
75   public XsGAllModel createAll() {
76     if (all != null) {
77       throw new IllegalStateException JavaDoc("Multiple 'all' child elements are forbidden.");
78     }
79     if (choice != null) {
80       throw new IllegalStateException JavaDoc("The 'choice' and 'all' child elements are mutually exclusive.");
81     }
82     if (sequence != null) {
83       throw new IllegalStateException JavaDoc("The 'sequence' and 'all' child elements are mutually exclusive.");
84     }
85     return all = getObjectFactory().newXsGAllModel(this);
86   }
87
88   public XsGAllModel getAll() {
89     return all;
90   }
91
92   public XsTSimpleExplicitGroup createSequence() {
93     if (sequence != null) {
94       throw new IllegalStateException JavaDoc("Multiple 'sequence' child elements are forbidden.");
95     }
96     if (all != null) {
97       throw new IllegalStateException JavaDoc("The 'all' and 'sequence' child elements are mutually exclusive.");
98     }
99     if (choice != null) {
100       throw new IllegalStateException JavaDoc("The 'all' and 'sequence' child elements are mutually exclusive.");
101     }
102     return sequence = getObjectFactory().newXsTSimpleExplicitGroup(this);
103   }
104
105   public XsTSimpleExplicitGroup getSequence() {
106     return sequence;
107   }
108
109   public XsTSimpleExplicitGroup createChoice() {
110     if (choice != null) {
111       throw new IllegalStateException JavaDoc("Multiple 'choice' elements are forbidden.");
112     }
113     if (sequence != null) {
114       throw new IllegalStateException JavaDoc("The 'sequence' and 'choice' elements are mutually exclusive.");
115     }
116     if (all != null) {
117       throw new IllegalStateException JavaDoc("The 'all' and 'choice' elements are mutually exclusive.");
118     }
119     return choice = getObjectFactory().newXsTSimpleExplicitGroup(this);
120   }
121
122   public XsTSimpleExplicitGroup getChoice() {
123     return choice;
124   }
125
126   public void validate() {
127     XsGAllModel myAll = getAll();
128     if (myAll == null) {
129       XsTSimpleExplicitGroup mySequence = getSequence();
130       if (mySequence == null) {
131         XsTSimpleExplicitGroup myChoice = getChoice();
132         if (myChoice == null) {
133           throw new NullPointerException JavaDoc("Neither of the 'all', 'choice', or 'sequence' elements are given.");
134         } else {
135         }
136       } else {
137       }
138     } else {
139     }
140   }
141 }
142
Popular Tags