KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > jaxb > impl > JAXBSchemaBindingsImpl


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.jaxb.impl;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.ws.jaxme.xs.jaxb.JAXBJavadoc;
23 import org.apache.ws.jaxme.xs.jaxb.JAXBSchemaBindings;
24 import org.apache.ws.jaxme.xs.jaxb.JAXBXsObjectFactory;
25 import org.apache.ws.jaxme.xs.xml.XsObject;
26 import org.apache.ws.jaxme.xs.xml.impl.XsObjectImpl;
27
28
29 /** <p>Implementation of the SchemaBindings interface.</p>
30  *
31  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
32  * @version $Id: JAXBSchemaBindingsImpl.java,v 1.3 2004/02/22 00:52:34 jochen Exp $
33  */

34 public class JAXBSchemaBindingsImpl extends JAXBXsObjectImpl implements JAXBSchemaBindings {
35   private Package JavaDoc myPackage;
36   private List JavaDoc nameXmlTransforms;
37
38   public static class PackageImpl extends JAXBXsObjectImpl implements JAXBSchemaBindings.Package {
39     /** <p>Creates a new instance of JAXBSchemaBindingsImpl.</p>
40      */

41     protected PackageImpl(XsObject pParent) {
42       super(pParent);
43     }
44
45     private String JavaDoc name;
46     private JAXBJavadoc javadoc;
47
48     public void setName(String JavaDoc pName) {
49       name = pName;
50     }
51
52     public String JavaDoc getName() {
53       return name;
54     }
55
56     public JAXBJavadoc createJavadoc() {
57       if (javadoc != null) {
58         throw new IllegalStateException JavaDoc("Multiple javadoc elements are not supported.");
59       }
60       javadoc = getJAXBXsObjectFactory().newJAXBJavadoc(this);
61       return javadoc;
62     }
63
64     public JAXBJavadoc getJavadoc() {
65       return javadoc;
66     }
67   }
68
69   public static class NameXmlTransformImpl extends XsObjectImpl
70       implements JAXBSchemaBindings.NameXmlTransform {
71     public static class NameTransformationImpl extends XsObjectImpl
72         implements JAXBSchemaBindings.NameTransformation {
73       /** <p>Creates a new instance of JAXBSchemaBindingsImpl.</p>
74        */

75       protected NameTransformationImpl(XsObject pParent) {
76         super(pParent);
77       }
78
79       private String JavaDoc suffix, prefix;
80
81       public void setSuffix(String JavaDoc pSuffix) {
82         suffix = pSuffix;
83       }
84
85       public String JavaDoc getSuffix() {
86         return suffix;
87       }
88
89       public void setPrefix(String JavaDoc pPrefix) {
90         prefix = pPrefix;
91       }
92
93       public String JavaDoc getPrefix() {
94         return prefix;
95       }
96     }
97
98     /** <p>Creates a new instance of JAXBSchemaBindingsImpl.</p>
99      */

100     protected NameXmlTransformImpl(XsObject pParent) {
101       super(pParent);
102     }
103
104     private NameTransformation typeName, elementName, modelGroupName, anonymousTypeName;
105
106     public NameTransformation createTypeName() {
107       if (typeName != null) {
108         throw new IllegalStateException JavaDoc("Multiple instances of typeName are not supported.");
109       }
110       typeName = ((JAXBXsObjectFactory) getObjectFactory()).newNameTransformation(this);
111       return typeName;
112     }
113
114     public NameTransformation getTypeName() {
115       return typeName;
116     }
117
118     public NameTransformation createElementName() {
119       if (elementName != null) {
120         throw new IllegalStateException JavaDoc("Multiple instances of elementName are not supported.");
121       }
122       elementName = ((JAXBXsObjectFactory) getObjectFactory()).newNameTransformation(this);
123       return elementName;
124     }
125
126     public NameTransformation getElementName() {
127       return elementName;
128     }
129
130     public NameTransformation createModelGroupName() {
131       if (modelGroupName != null) {
132         throw new IllegalStateException JavaDoc("Multiple instances of modelGroupName are not supported.");
133       }
134       modelGroupName = ((JAXBXsObjectFactory) getObjectFactory()).newNameTransformation(this);
135       return modelGroupName;
136     }
137
138     public NameTransformation getModelGroupName() {
139       return modelGroupName;
140     }
141
142     public NameTransformation createAnonymousTypeName() {
143       if (anonymousTypeName != null) {
144         throw new IllegalStateException JavaDoc("Multiple instances of anonymousTypeName are not supported.");
145       }
146       anonymousTypeName = ((JAXBXsObjectFactory) getObjectFactory()).newNameTransformation(this);
147       return anonymousTypeName;
148     }
149
150     public NameTransformation getAnonymousTypeName() {
151       return anonymousTypeName;
152     }
153   }
154
155   /** <p>Creates a new instance of SchemaBindings with the given
156    * GlobalBindings.</p>
157    */

158   protected JAXBSchemaBindingsImpl(XsObject pParent) {
159     super(pParent);
160   }
161
162   /** <p>Creates a new Package implementation.</p>
163    */

164   public Package JavaDoc createPackage() {
165     if (myPackage != null) {
166       throw new IllegalStateException JavaDoc("Multiple package declarations are not supported.");
167     }
168     myPackage = ((JAXBXsObjectFactory) getObjectFactory()).newPackage(this);
169     return myPackage;
170   }
171
172   public Package JavaDoc getPackage() {
173     return myPackage;
174   }
175
176   /** <p>Creates a new NameXmlTransform implementation.</p>
177    */

178   public NameXmlTransform createNameXmlTransform() {
179     if (nameXmlTransforms == null) {
180       nameXmlTransforms = new ArrayList JavaDoc();
181     }
182     NameXmlTransform result = ((JAXBXsObjectFactory) getObjectFactory()).newNameXmlTransform(this);
183     nameXmlTransforms.add(result);
184     return result;
185   }
186
187   private static final NameXmlTransform[] DEFAULT_NAME_XML_TRANSFORMATION = new NameXmlTransform[0];
188   public NameXmlTransform[] getNameXmlTransform() {
189     if (nameXmlTransforms == null) {
190       return DEFAULT_NAME_XML_TRANSFORMATION;
191     } else {
192       return (NameXmlTransform[]) nameXmlTransforms.toArray(new NameXmlTransform[nameXmlTransforms.size()]);
193     }
194   }
195 }
196
Popular Tags