1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.wsdl.gen.Generator; 58 import org.jboss.axis.wsdl.symbolTable.SchemaUtils; 59 import org.jboss.axis.wsdl.symbolTable.SymTabEntry; 60 import org.jboss.axis.wsdl.symbolTable.SymbolTable; 61 import org.jboss.axis.wsdl.symbolTable.TypeEntry; 62 import org.w3c.dom.Node ; 63 64 import javax.xml.namespace.QName ; 65 import java.io.IOException ; 66 import java.util.Vector ; 67 68 72 public class JavaTypeWriter implements Generator 73 { 74 public static final String HOLDER_IS_NEEDED = "Holder is needed"; 75 76 private Generator typeWriter = null; 77 private Generator holderWriter = null; 78 79 82 public JavaTypeWriter(Emitter emitter, 83 TypeEntry type, 84 SymbolTable symbolTable) 85 { 86 87 if (type.isReferenced() && !type.isOnlyLiteralReferenced()) 88 { 89 90 Node node = type.getNode(); 93 94 if (!type.getName().endsWith("[]")) 96 { 97 98 Vector v = Utils.getEnumerationBaseAndValues(node, symbolTable); 100 if (v != null) 101 { 102 typeWriter = getEnumTypeWriter(emitter, type, v); 103 } 104 else 105 { 106 TypeEntry base = SchemaUtils.getComplexElementExtensionBase(node, symbolTable); 107 if (base == null) 108 { 109 QName baseQName = SchemaUtils.getSimpleTypeBase(node); 110 if (baseQName != null) 111 { 112 base = symbolTable.getType(baseQName); 113 } 114 } 115 116 typeWriter = getBeanWriter(emitter, 117 type, 118 SchemaUtils.getContainedElementDeclarations(node, 119 symbolTable), 120 base, 121 SchemaUtils.getContainedAttributeTypes(node, 122 symbolTable)); 123 } 124 } 125 126 if (holderIsNeeded(type)) 129 { 130 holderWriter = getHolderWriter(emitter, type); 131 } 132 } 133 } 135 138 public void generate() throws IOException 139 { 140 if (typeWriter != null) 141 { 142 typeWriter.generate(); 143 } 144 if (holderWriter != null) 145 { 146 holderWriter.generate(); 147 } 148 } 150 153 private boolean holderIsNeeded(SymTabEntry entry) 154 { 155 Boolean holderIsNeeded = 156 (Boolean )entry.getDynamicVar(HOLDER_IS_NEEDED); 157 return (holderIsNeeded != null && holderIsNeeded.booleanValue()); 158 } 160 163 protected JavaWriter getEnumTypeWriter(Emitter emitter, TypeEntry type, Vector v) 164 { 165 return new JavaEnumTypeWriter(emitter, type, v); 166 } 167 168 171 protected JavaWriter getBeanWriter(Emitter emitter, TypeEntry type, 172 Vector elements, TypeEntry base, 173 Vector attributes) 174 { 175 JavaWriter helperWriter = getBeanHelperWriter(emitter, type, elements, base, 176 attributes); 177 Boolean isComplexFault = (Boolean ) 181 type.getDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT); 182 if (isComplexFault != null && 183 isComplexFault.booleanValue()) 184 { 185 return new JavaBeanFaultWriter(emitter, type, 186 elements, base, attributes, 187 helperWriter); 188 } 189 return new JavaBeanWriter(emitter, type, 190 elements, base, attributes, 191 helperWriter); 192 } 193 194 197 protected JavaWriter getBeanHelperWriter(Emitter emitter, TypeEntry type, 198 Vector elements, TypeEntry base, 199 Vector attributes) 200 { 201 return new JavaBeanHelperWriter(emitter, type, elements, base, attributes); 202 } 203 204 207 protected Generator getHolderWriter(Emitter emitter, TypeEntry type) 208 { 209 return new JavaHolderWriter(emitter, type); 210 } 211 } | Popular Tags |