1 16 package org.apache.axis.wsdl.toJava; 17 18 import org.apache.axis.wsdl.gen.Generator; 19 import org.apache.axis.wsdl.symbolTable.SchemaUtils; 20 import org.apache.axis.wsdl.symbolTable.SymTabEntry; 21 import org.apache.axis.wsdl.symbolTable.SymbolTable; 22 import org.apache.axis.wsdl.symbolTable.Type; 23 import org.apache.axis.wsdl.symbolTable.TypeEntry; 24 import org.w3c.dom.Node ; 25 26 import javax.xml.namespace.QName ; 27 import java.io.IOException ; 28 import java.util.Vector ; 29 import java.util.Collections ; 30 31 35 public class JavaTypeWriter implements Generator { 36 37 38 public static final String HOLDER_IS_NEEDED = "Holder is needed"; 39 40 41 private Generator typeWriter = null; 42 43 44 private Generator holderWriter = null; 45 46 53 public JavaTypeWriter(Emitter emitter, TypeEntry type, 54 SymbolTable symbolTable) { 55 56 if (type.isReferenced() && !type.isOnlyLiteralReferenced()) { 57 58 Node node = type.getNode(); 61 62 boolean isSimpleList = SchemaUtils.isListWithItemType(node); 63 if (!type.getName().endsWith("[]") && !isSimpleList) { 65 66 Vector v = Utils.getEnumerationBaseAndValues(node, symbolTable); 68 69 if (v != null) { 70 typeWriter = getEnumTypeWriter(emitter, type, v); 71 } else { 72 TypeEntry base = 73 SchemaUtils.getComplexElementExtensionBase(node, 74 symbolTable); 75 76 if (base == null) { 77 base = SchemaUtils.getComplexElementRestrictionBase( 78 node, symbolTable); 79 } 80 81 if (base == null) { 82 QName baseQName = SchemaUtils.getSimpleTypeBase(node); 83 84 if (baseQName != null) { 85 base = symbolTable.getType(baseQName); 86 } 87 } 88 89 typeWriter = getBeanWriter(emitter, type, base); 90 } 91 } 92 93 if (holderIsNeeded(type)) { 96 holderWriter = getHolderWriter(emitter, type); 97 } 98 99 if (typeWriter != null && type instanceof Type) { 100 ((Type)type).setGenerated(true); 101 } 102 } 103 } 105 110 public void generate() throws IOException { 111 112 if (typeWriter != null) { 113 typeWriter.generate(); 114 } 115 116 if (holderWriter != null) { 117 holderWriter.generate(); 118 } 119 } 121 127 private boolean holderIsNeeded(SymTabEntry entry) { 128 129 Boolean holderIsNeeded = 130 (Boolean ) entry.getDynamicVar(HOLDER_IS_NEEDED); 131 132 return ((holderIsNeeded != null) && holderIsNeeded.booleanValue()); 133 } 135 143 protected JavaWriter getEnumTypeWriter(Emitter emitter, TypeEntry type, 144 Vector v) { 145 return new JavaEnumTypeWriter(emitter, type, v); 146 } 147 148 156 protected JavaWriter getBeanWriter(Emitter emitter, TypeEntry type, TypeEntry base) { Vector elements = type.getContainedElements(); 158 Vector attributes = type.getContainedAttributes(); 159 160 Boolean isComplexFault = (Boolean ) type.getDynamicVar( 164 JavaGeneratorFactory.COMPLEX_TYPE_FAULT); 165 166 if ((isComplexFault != null) && isComplexFault.booleanValue()) { 167 168 return new JavaBeanFaultWriter(emitter, type, elements, base, 169 attributes, 170 getBeanHelperWriter(emitter, type, elements, base, 171 attributes, true)); 172 } 173 174 return new JavaBeanWriter(emitter, type, elements, base, attributes, 175 getBeanHelperWriter(emitter, type, elements, base, 176 attributes, false)); 177 } 178 179 189 protected JavaWriter getBeanHelperWriter( 190 Emitter emitter, TypeEntry type, Vector elements, TypeEntry base, 191 Vector attributes, boolean forException) { 192 return new JavaBeanHelperWriter( 193 emitter, type, elements, base, attributes, 194 forException ? JavaBeanFaultWriter.RESERVED_PROPERTY_NAMES 195 : Collections.EMPTY_SET); 196 } 197 198 205 protected Generator getHolderWriter(Emitter emitter, TypeEntry type) { 206 return new JavaHolderWriter(emitter, type); 207 } 208 } | Popular Tags |