1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.enums.Use; 58 import org.jboss.axis.wsdl.symbolTable.FaultInfo; 59 import org.jboss.axis.wsdl.symbolTable.Parameter; 60 import org.jboss.axis.wsdl.symbolTable.SymbolTable; 61 62 import javax.wsdl.Message; 63 import java.io.IOException ; 64 import java.io.PrintWriter ; 65 import java.util.Vector ; 66 67 73 public class JavaFaultWriter extends JavaClassWriter 74 { 75 private Message faultMessage; 76 private SymbolTable symbolTable; 77 private boolean literal; 78 private String faultName; 79 80 83 protected JavaFaultWriter(Emitter emitter, 84 SymbolTable symbolTable, 85 FaultInfo faultInfo) 86 { 87 super(emitter, Utils.getFullExceptionName(faultInfo.getMessage(), 88 symbolTable), "fault"); 89 this.literal = faultInfo.getUse().equals(Use.LITERAL); 90 this.faultMessage = faultInfo.getMessage(); 91 this.symbolTable = symbolTable; 92 } 94 97 protected String getExtendsText() 98 { 99 return "extends org.jboss.axis.AxisFault "; 100 } 102 105 protected void writeFileBody(PrintWriter pw) throws IOException 106 { 107 Vector params = new Vector (); 108 109 symbolTable.getParametersFromParts(params, 110 faultMessage.getOrderedParts(null), 111 literal, 112 faultName, 113 null); 114 115 for (int i = 0; i < params.size(); i++) 117 { 118 Parameter param = (Parameter)params.get(i); 119 String type = param.getType().getName(); 120 String variable = Utils.xmlNameToJava(param.getName()); 121 pw.println(" public " + type + " " + variable + ";"); 122 pw.println(" public " + type + " get" + Utils.capitalizeFirstChar(variable) + "() {"); 123 pw.println(" return this." + variable + ";"); 124 pw.println(" }"); 125 } 126 127 pw.println(); 129 pw.println(" public " + className + "() {"); 130 pw.println(" }"); 131 pw.println(); 132 133 if (params.size() > 0) 135 { 136 pw.print(" public " + className + "("); 137 for (int i = 0; i < params.size(); i++) 138 { 139 if (i != 0) pw.print(", "); 140 Parameter param = (Parameter)params.get(i); 141 String type = param.getType().getName(); 142 String variable = Utils.xmlNameToJava(param.getName()); 143 pw.print(type + " " + variable); 144 } 145 pw.println(") {"); 146 for (int i = 0; i < params.size(); i++) 147 { 148 Parameter param = (Parameter)params.get(i); 149 String variable = Utils.xmlNameToJava(param.getName()); 150 pw.println(" this." + variable + " = " + variable + ";"); 151 } 152 pw.println(" }"); 153 } 154 155 pw.println(); 160 pw.println(" /**"); 161 pw.println(" * Writes the exception data to the faultDetails"); 162 pw.println(" */"); 163 pw.println(" public void writeDetails(javax.xml.namespace.QName qname, org.jboss.axis.encoding.SerializationContext context) throws java.io.IOException {"); 164 for (int i = 0; i < params.size(); i++) 165 { 166 Parameter param = (Parameter)params.get(i); 167 String variable = Utils.xmlNameToJava(param.getName()); 168 pw.println(" context.serialize(qname, null, " + Utils.wrapPrimitiveType(param.getType(), variable) + ");"); 169 } 170 pw.println(" }"); 171 } 173 } | Popular Tags |