JOnASTypeWriter.java

00001 /*
00002  * Copyright 2001-2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 package org.objectweb.jonas_ws.wsgen.generator.ews.wsdltoj2ee.writer;
00017 
00018 import java.io.IOException;
00019 import java.util.Vector;
00020 
00021 import javax.xml.namespace.QName;
00022 
00023 import org.w3c.dom.Node;
00024 
00025 import org.apache.axis.wsdl.gen.Generator;
00026 import org.apache.axis.wsdl.symbolTable.SchemaUtils;
00027 import org.apache.axis.wsdl.symbolTable.SymbolTable;
00028 import org.apache.axis.wsdl.symbolTable.Type;
00029 import org.apache.axis.wsdl.symbolTable.TypeEntry;
00030 import org.apache.axis.wsdl.toJava.Emitter;
00031 import org.apache.axis.wsdl.toJava.JavaGeneratorFactory;
00032 import org.apache.axis.wsdl.toJava.JavaTypeWriter;
00033 import org.apache.axis.wsdl.toJava.Utils;
00034 
00039 public class JOnASTypeWriter extends JavaTypeWriter implements Generator {
00040 
00042     private Generator jonasTypeWriter = null;
00043 
00051     public JOnASTypeWriter(Emitter emitter, TypeEntry type,
00052                           SymbolTable symbolTable) {
00053         super(emitter,type,symbolTable);
00054         if (type.isReferenced() && !type.isOnlyLiteralReferenced() && type instanceof Type) {
00055 
00056             // Determine what sort of type this is and instantiate
00057             // the appropriate Writer.
00058             Node node = type.getNode();
00059 
00060             boolean isSimpleList = SchemaUtils.isListWithItemType(node);
00061             // If it's an array, don't emit a class
00062             if (!type.getName().endsWith("[]") && !isSimpleList) {
00063                 
00064                 // Generate the proper class for either "complex" or "enumeration" types
00065                 Vector v = Utils.getEnumerationBaseAndValues(node, symbolTable);
00066 
00067                 if (v != null) {
00068                     //typeWriter = getEnumTypeWriter(emitter, type, v);
00069                 } else {
00070                     TypeEntry base =
00071                             SchemaUtils.getComplexElementExtensionBase(node,
00072                                     symbolTable);
00073 
00074                     if (base == null) {
00075                         base = SchemaUtils.getComplexElementRestrictionBase(
00076                                 node, symbolTable);
00077                     }
00078 
00079                     if (base == null) {
00080                         QName baseQName = SchemaUtils.getSimpleTypeBase(node);
00081 
00082                         if (baseQName != null) {
00083                             base = symbolTable.getType(baseQName);
00084                         }
00085                     }
00086                     Vector elements = type.getContainedElements();
00087                     Vector attributes = type.getContainedAttributes();
00088                     
00089                     // If this complexType is referenced in a
00090                     // fault context, emit a bean-like exception
00091                     // class
00092                     Boolean isComplexFault = (Boolean) type.getDynamicVar(
00093                             JavaGeneratorFactory.COMPLEX_TYPE_FAULT);
00094 
00095                     if ((isComplexFault != null) && isComplexFault.booleanValue()) {
00096 
00097                         jonasTypeWriter = getBeanHelperWriter(emitter, type, elements, base, attributes, true);
00098                     } else {
00099                         jonasTypeWriter = getBeanHelperWriter(emitter, type, elements, base, attributes, false) ;
00100                     }
00101                 }
00102             }
00103         }
00104     }    // ctor
00105 
00111     public void generate() throws IOException {
00112 
00113         if (jonasTypeWriter != null) {
00114             jonasTypeWriter.generate();
00115         }
00116     }    
00117  
00118 }    // class JavaTypeWriter

Generated on Tue Feb 15 15:06:02 2005 for JOnAS by  doxygen 1.3.9.1