KickJava   Java API By Example, From Geeks To Geeks.

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


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 the <code>xs:typeDefParticle</code> group,
23  * as specified by the following:
24  * <pre>
25  * <xs:group name="typeDefParticle">
26  * <xs:annotation>
27  * <xs:documentation>
28  * 'complexType' uses this
29  * </xs:documentation>
30  * </xs:annotation>
31  * <xs:choice>
32  * <xs:element name="group" type="xs:groupRef"/>
33  * <xs:element ref="xs:all"/>
34  * <xs:element ref="xs:choice"/>
35  * <xs:element ref="xs:sequence"/>
36  * </xs:choice>
37  * </xs:group>
38  * </pre></p>
39  *
40  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
41  */

42 public class XsGTypeDefParticleImpl implements XsGTypeDefParticle {
43   private final XsObject owner;
44   private XsTTypeDefParticle particle;
45
46   protected XsGTypeDefParticleImpl(XsObject pOwner) {
47     owner = pOwner;
48   }
49
50   protected void setTypeDefParticle(XsTTypeDefParticle pParticle) {
51     if (particle != null) {
52       throw new IllegalStateException JavaDoc("Only a single child element of 'all', 'group', 'choice', or 'sequence' is allowed.");
53     }
54     particle = pParticle;
55   }
56
57
58   public XsTTypeDefParticle getTypeDefParticle() {
59     return particle;
60   }
61
62   public XsTGroupRef createGroup() {
63     XsTGroupRef group = owner.getObjectFactory().newXsTGroupRef(owner);
64     setTypeDefParticle(group);
65     return group;
66   }
67
68   public XsTAll createAll() {
69     XsTAll all = owner.getObjectFactory().newXsTAll(owner);
70     setTypeDefParticle(all);
71     return all;
72   }
73
74   public XsESequence createSequence() {
75     XsESequence sequence = owner.getObjectFactory().newXsESequence(owner);
76     setTypeDefParticle(sequence);
77     return sequence;
78   }
79
80   public XsEChoice createChoice() {
81     XsEChoice choice = owner.getObjectFactory().newXsEChoice(owner);
82     setTypeDefParticle(choice);
83     return choice;
84   }
85 }
86
Popular Tags