KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
20 import org.apache.ws.jaxme.generator.sg.PropertySG;
21 import org.apache.ws.jaxme.generator.sg.PropertySGChain;
22 import org.apache.ws.jaxme.generator.sg.SimpleContentSG;
23 import org.apache.ws.jaxme.generator.sg.SimpleContentSGChain;
24 import org.apache.ws.jaxme.generator.sg.TypeSG;
25 import org.apache.ws.jaxme.xs.XSType;
26 import org.xml.sax.SAXException JavaDoc;
27
28
29 /**
30  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
31  */

32 public class JAXBSimpleContentTypeSG implements SimpleContentSGChain {
33   private XSType xsType;
34   private PropertySG propertySG;
35   private final TypeSG typeSG, contentTypeSG;
36
37   /** <p>Creates a new instance of JAXBSimpleContentSG.java.</p>
38    */

39   protected JAXBSimpleContentTypeSG(ComplexTypeSG pComplexTypeSG, XSType pType) throws SAXException JavaDoc {
40     xsType = pType;
41     typeSG = pComplexTypeSG.getTypeSG();
42     XSType theSimpleType = pType.getComplexType().getSimpleContent().getType();
43     contentTypeSG = typeSG.getFactory().getTypeSG(theSimpleType, pComplexTypeSG.getClassContext(), null);
44   }
45
46   public Object JavaDoc newPropertySGChain(SimpleContentSG pController) throws SAXException JavaDoc {
47     if (xsType == null) {
48       throw new IllegalStateException JavaDoc("A new PropertySG has already been created.");
49     }
50     PropertySGChain result = new JAXBPropertySG(typeSG, xsType);
51     xsType = null; // Make this available to garbage collection.
52
return result;
53   }
54
55   public void init(SimpleContentSG pController) throws SAXException JavaDoc {
56     PropertySGChain chain = (PropertySGChain) pController.newPropertySGChain();
57     propertySG = new PropertySGImpl(chain);
58     propertySG.init();
59   }
60
61   public PropertySG getPropertySG(SimpleContentSG pController) throws SAXException JavaDoc { return propertySG; }
62   public TypeSG getTypeSG(SimpleContentSG pController) throws SAXException JavaDoc { return typeSG; }
63   public TypeSG getContentTypeSG(SimpleContentSG pController) throws SAXException JavaDoc { return contentTypeSG; }
64 }
65
Popular Tags