FileDocCategorySizeDatePackage
JavaImplWriter.javaAPI DocApache Axis 1.45781Sat Apr 22 18:57:28 BST 2006org.apache.axis.wsdl.toJava

JavaImplWriter

public class JavaImplWriter extends JavaClassWriter
This is Wsdl2java's implementation template writer. It writes the Impl.java file which contains the Impl class.

Fields Summary
protected javax.wsdl.Binding
binding
Field binding
protected org.apache.axis.wsdl.symbolTable.SymbolTable
symbolTable
Field symbolTable
protected org.apache.axis.wsdl.symbolTable.BindingEntry
bEntry
Field bEntry
Constructors Summary
protected JavaImplWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.BindingEntry bEntry, org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Constructor.

param
emitter
param
bEntry
param
symbolTable

        super(emitter, ( emitter.getImplementationClassName() == null ? 
        		bEntry.getName() + "Impl" :
				emitter.getImplementationClassName()), "templateImpl");
		
		this.binding = bEntry.getBinding();
        this.symbolTable = symbolTable;
        this.bEntry = bEntry;
    
Methods Summary
protected java.lang.StringgetImplementsText()
Returns the appropriate implements text

return
" implements "


        String portTypeName =
                (String) bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME);
        String implementsText = "implements " + portTypeName;

        return implementsText;
    
protected voidwriteFileBody(java.io.PrintWriter pw)
Write the body of the binding's stub file.

param
pw
throws
IOException


        List operations = binding.getBindingOperations();

        for (int i = 0; i < operations.size(); ++i) {
            BindingOperation operation = (BindingOperation) operations.get(i);
            Operation ptOperation = operation.getOperation();
            OperationType type = ptOperation.getStyle();
            Parameters parameters =
                    bEntry.getParameters(operation.getOperation());

            // These operation types are not supported.  The signature
            // will be a string stating that fact.
            if ((OperationType.NOTIFICATION.equals(type))
                    || (OperationType.SOLICIT_RESPONSE.equals(type))) {
                pw.println(parameters.signature);
                pw.println();
            } else {
                writeOperation(pw, parameters);
            }
        }
    
protected voidwriteOperation(java.io.PrintWriter pw, org.apache.axis.wsdl.symbolTable.Parameters parms)
Write the implementation template for the given operation.

param
pw
param
parms
throws
IOException


        pw.println(parms.signature + " {");

        // Fill in any out parameter holders
        Iterator iparam = parms.list.iterator();

        while (iparam.hasNext()) {
            Parameter param = (Parameter) iparam.next();

            if (param.getMode() == Parameter.OUT) {

                // write a constructor for each of the parameters
                BooleanHolder bThrow = new BooleanHolder(false);
                String constructorString =
                        Utils.getConstructorForParam(param, symbolTable, bThrow);

                if (bThrow.value) {
                    pw.println("        try {");
                }

                pw.println("        " + Utils.xmlNameToJava(param.getName())
                        + ".value = " + constructorString + ";");

                if (bThrow.value) {
                    pw.println("        } catch (Exception e) {");
                    pw.println("        }");
                }
            }
        }

        // Print the return statement
        Parameter returnParam = parms.returnParam;
        if (returnParam != null) {
            TypeEntry returnType = returnParam.getType();

            pw.print("        return ");

            if (!returnParam.isOmittable() &&
                    Utils.isPrimitiveType(returnType)) {
                String returnString = returnType.getName();

                if ("boolean".equals(returnString)) {
                    pw.println("false;");
                } else if ("byte".equals(returnString)) {
                    pw.println("(byte)-3;");
                } else if ("short".equals(returnString)) {
                    pw.println("(short)-3;");
                } else {
                    pw.println("-3;");
                }
            } else {
                pw.println("null;");
            }
        }

        pw.println("    }");
        pw.println();