KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > generator > sg > impl > SimpleTypeRestrictionSG


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.generator.sg.impl;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.ws.jaxme.generator.sg.AtomicTypeSG;
23 import org.apache.ws.jaxme.generator.sg.Facet;
24 import org.apache.ws.jaxme.generator.sg.SimpleTypeSG;
25 import org.apache.ws.jaxme.generator.sg.SimpleTypeSGChain;
26 import org.apache.ws.jaxme.xs.XSEnumeration;
27 import org.apache.ws.jaxme.xs.XSSimpleType;
28 import org.apache.ws.jaxme.xs.XSType;
29 import org.xml.sax.SAXException JavaDoc;
30
31
32 /**
33  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
34  */

35 public class SimpleTypeRestrictionSG extends SimpleTypeSGChainImpl {
36   private XSSimpleType simpleType;
37   private XSType xsType;
38   private Facet[] facets;
39   private final AtomicTypeSG atomicTypeSG;
40
41   /** <p>Creates a new instance of SimpleTypeRestrictionSG.</p>
42    */

43   public SimpleTypeRestrictionSG(SimpleTypeSGChain o, XSType pType, XSSimpleType pSimpleType) {
44     super(o);
45     simpleType = pSimpleType;
46     if (pSimpleType.isAtomic()) {
47       atomicTypeSG = new AtomicTypeSGImpl(pSimpleType.getAtomicType());
48     } else {
49       atomicTypeSG = null;
50     }
51   }
52
53   public void init(SimpleTypeSG pController) throws SAXException JavaDoc {
54     super.init(pController);
55     List JavaDoc myFacets = new ArrayList JavaDoc();
56
57     XSEnumeration[] enumerations = simpleType.getEnumerations();
58     if (enumerations.length > 0) {
59       Facet f = new FacetImpl(xsType, enumerations);
60       myFacets.add(f);
61     }
62
63     simpleType = null; // Make this available for garbage collection
64
xsType = null; // Make this available for garbage collection
65
facets = (Facet[]) myFacets.toArray(new Facet[myFacets.size()]);
66   }
67
68   public Facet[] getFacets(SimpleTypeSG pController) {
69     return facets;
70   }
71
72   public AtomicTypeSG getAtomicType(SimpleTypeSG pController) {
73     if (atomicTypeSG == null) {
74       return super.getAtomicType(pController);
75     } else {
76       return atomicTypeSG;
77     }
78   }
79 }
80
Popular Tags