KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.ws.jaxme.xs.xml.*;
23
24
25 /** <p>Implementation of the <code>xs:typeDefParticle</code> group,
26  * as specified by the following:
27  * <pre>
28  * <xs:group name="typeDefParticle">
29  * <xs:annotation>
30  * <xs:documentation>
31  * 'complexType' uses this
32  * </xs:documentation>
33  * </xs:annotation>
34  * <xs:choice>
35  * <xs:element name="group" type="xs:groupRef"/>
36  * <xs:element ref="xs:all"/>
37  * <xs:element ref="xs:choice"/>
38  * <xs:element ref="xs:sequence"/>
39  * </xs:choice>
40  * </xs:group>
41  * </pre></p>
42  *
43  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
44  */

45 public class XsGParticleImpl implements XsGParticle {
46   private final XsObject owner;
47   private List JavaDoc particles;
48
49   protected XsGParticleImpl(XsObject pOwner) {
50     owner = pOwner;
51   }
52
53   protected void addParticle(XsTParticle pParticle) {
54     if (particles == null) {
55       particles = new ArrayList JavaDoc();
56     }
57     particles.add(pParticle);
58   }
59
60   public XsTLocalElement createElement() {
61     XsTLocalElement element = owner.getObjectFactory().newXsTLocalElement(owner);
62     addParticle(element);
63     return element;
64   }
65
66   public XsTGroupRef createGroup() {
67     XsTGroupRef groupRef = owner.getObjectFactory().newXsTGroupRef(owner);
68     addParticle(groupRef);
69     return groupRef;
70   }
71
72   public XsTAll createAll() {
73     XsTAll all = owner.getObjectFactory().newXsTAll(owner);
74     addParticle(all);
75     return all;
76   }
77
78   public XsESequence createSequence() {
79     XsESequence sequence = owner.getObjectFactory().newXsESequence(owner);
80     addParticle(sequence);
81     return sequence;
82   }
83
84   public XsEChoice createChoice() {
85     XsEChoice choice = owner.getObjectFactory().newXsEChoice(owner);
86     addParticle(choice);
87     return choice;
88   }
89
90   public XsEAny createAny() {
91     XsEAny any = owner.getObjectFactory().newXsEAny(owner);
92     addParticle(any);
93     return any;
94   }
95
96   public XsTParticle[] getParticles() {
97     if (particles == null) {
98       return new XsTParticle[0];
99     } else {
100       return (XsTParticle[]) particles.toArray(new XsTParticle[particles.size()]);
101     }
102   }
103 }
104
Popular Tags