JavaFaultWriterpublic class JavaFaultWriter extends JavaClassWriter This is Wsdl2java's Fault Writer. It writes the .java file.
NOTE: This only writes simple type faults, the JavaTypeWriter emits
faults that are complex types. |
Fields Summary |
---|
private javax.wsdl.Message | faultMessageField faultMessage | private org.apache.axis.wsdl.symbolTable.SymbolTable | symbolTableField symbolTable | private boolean | literalField literal | private String | faultNameField faultName |
Methods Summary |
---|
protected java.lang.String | getExtendsText()Return "extends org.apache.axis.AxisFault ".
return "extends org.apache.axis.AxisFault ";
| protected void | writeFileBody(java.io.PrintWriter pw)Write the body of the Fault file.
Vector params = new Vector();
symbolTable.getParametersFromParts(params,
faultMessage.getOrderedParts(null),
literal, faultName, null);
// Write data members of the exception and getter methods for them
for (int i = 0; i < params.size(); i++) {
Parameter param = (Parameter) params.get(i);
String type = param.getType().getName();
String variable = Utils.xmlNameToJava(param.getName());
pw.println(" public " + type + " " + variable + ";");
pw.println(" public " + type + " get"
+ Utils.capitalizeFirstChar(variable) + "() {");
pw.println(" return this." + variable + ";");
pw.println(" }");
}
// Default contructor
pw.println();
pw.println(" public " + className + "() {");
pw.println(" }");
pw.println();
// Additional contructors
pw.println(" public " + className + "(java.lang.Exception target) {");
pw.println(" super(target);");
pw.println(" }");
pw.println();
pw.println(" public " + className + "(java.lang.String message, java.lang.Throwable t) {");
pw.println(" super(message, t);");
pw.println(" }");
pw.println();
// contructor that initializes data
if (params.size() > 0) {
pw.print(" public " + className + "(");
for (int i = 0; i < params.size(); i++) {
if (i != 0) {
pw.print(", ");
}
Parameter param = (Parameter) params.get(i);
String type = param.getType().getName();
String variable = Utils.xmlNameToJava(param.getName());
pw.print(type + " " + variable);
}
pw.println(") {");
for (int i = 0; i < params.size(); i++) {
Parameter param = (Parameter) params.get(i);
String variable = Utils.xmlNameToJava(param.getName());
pw.println(" this." + variable + " = " + variable + ";");
}
pw.println(" }");
}
// Method that serializes exception data (writeDetail)
// The QName of the element is passed in by the runtime and is found
// via the fault meta-data in the WSDD.
// NOTE: This function is also written in JavaBeanFaultWriter.java
pw.println();
pw.println(" /**");
pw.println(" * Writes the exception data to the faultDetails");
pw.println(" */");
pw.println(
" public void writeDetails(javax.xml.namespace.QName qname, org.apache.axis.encoding.SerializationContext context) throws java.io.IOException {");
for (int i = 0; i < params.size(); i++) {
Parameter param = (Parameter) params.get(i);
String variable = Utils.xmlNameToJava(param.getName());
pw.println(" context.serialize(qname, null, "
+ Utils.wrapPrimitiveType(param.getType(), variable)
+ ");");
}
pw.println(" }");
|
|