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

JavaTypeWriter

public class JavaTypeWriter extends Object implements org.apache.axis.wsdl.gen.Generator
This is Wsdl2java's Type Writer. It writes the following files, as appropriate: .java, Holder.java.

Fields Summary
public static final String
HOLDER_IS_NEEDED
Field HOLDER_IS_NEEDED
private org.apache.axis.wsdl.gen.Generator
typeWriter
Field typeWriter
private org.apache.axis.wsdl.gen.Generator
holderWriter
Field holderWriter
Constructors Summary
public JavaTypeWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.TypeEntry type, org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Constructor.

param
emitter
param
type
param
symbolTable


                               
        
                            

        if (type.isReferenced() && !type.isOnlyLiteralReferenced()) {

            // Determine what sort of type this is and instantiate
            // the appropriate Writer.
            Node node = type.getNode();

            boolean isSimpleList = SchemaUtils.isListWithItemType(node);
            // If it's an array, don't emit a class
            if (!type.getName().endsWith("[]") && !isSimpleList) {
                
                // Generate the proper class for either "complex" or "enumeration" types
                Vector v = Utils.getEnumerationBaseAndValues(node, symbolTable);

                if (v != null) {
                    typeWriter = getEnumTypeWriter(emitter, type, v);
                } else {
                    TypeEntry base =
                            SchemaUtils.getComplexElementExtensionBase(node,
                                    symbolTable);

                    if (base == null) {
                        base = SchemaUtils.getComplexElementRestrictionBase(
                                node, symbolTable);
                    }

                    if (base == null) {
                        QName baseQName = SchemaUtils.getSimpleTypeBase(node);

                        if (baseQName != null) {
                            base = symbolTable.getType(baseQName);
                        }
                    }

                    typeWriter = getBeanWriter(emitter, type, base);
                }
            }

            // If the holder is needed (ie., something uses this type as an out or inout
            // parameter), instantiate the holder writer.
            if (holderIsNeeded(type)) {
                holderWriter = getHolderWriter(emitter, type);
            }
            
            if (typeWriter != null && type instanceof Type) {
                ((Type)type).setGenerated(true);
            }
        }
    
Methods Summary
public voidgenerate()
Write all the service bindnigs: service and testcase.

throws
IOException


        if (typeWriter != null) {
            typeWriter.generate();
        }

        if (holderWriter != null) {
            holderWriter.generate();
        }
    
protected JavaWritergetBeanHelperWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.TypeEntry type, java.util.Vector elements, org.apache.axis.wsdl.symbolTable.TypeEntry base, java.util.Vector attributes, boolean forException)
getHelperWriter

param
emitter
param
type
param
elements
param
base
param
attributes
return

        return new JavaBeanHelperWriter(
                emitter, type, elements, base, attributes,
                forException  ?  JavaBeanFaultWriter.RESERVED_PROPERTY_NAMES
                              :  Collections.EMPTY_SET);
    
protected JavaWritergetBeanWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.TypeEntry type, org.apache.axis.wsdl.symbolTable.TypeEntry base)
getBeanWriter

param
emitter
param
type
param
base
return

   // CONTAINED_ELEM_AND_ATTR
        Vector elements = type.getContainedElements();
        Vector attributes = type.getContainedAttributes();
        
        // If this complexType is referenced in a
        // fault context, emit a bean-like exception
        // class
        Boolean isComplexFault = (Boolean) type.getDynamicVar(
                JavaGeneratorFactory.COMPLEX_TYPE_FAULT);

        if ((isComplexFault != null) && isComplexFault.booleanValue()) {

            return new JavaBeanFaultWriter(emitter, type, elements, base,
                attributes,
                getBeanHelperWriter(emitter, type, elements, base,
                                    attributes, true));
        }

        return new JavaBeanWriter(emitter, type, elements, base, attributes,
                getBeanHelperWriter(emitter, type, elements, base,
                                    attributes, false));
    
protected JavaWritergetEnumTypeWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.TypeEntry type, java.util.Vector v)
getEnumWriter

param
emitter
param
type
param
v
return

        return new JavaEnumTypeWriter(emitter, type, v);
    
protected org.apache.axis.wsdl.gen.GeneratorgetHolderWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.TypeEntry type)
getHolderWriter

param
emitter
param
type
return

        return new JavaHolderWriter(emitter, type);
    
private booleanholderIsNeeded(org.apache.axis.wsdl.symbolTable.SymTabEntry entry)
Does anything use this type as an inout/out parameter? Query the Type dynamicVar

param
entry
return


        Boolean holderIsNeeded =
                (Boolean) entry.getDynamicVar(HOLDER_IS_NEEDED);

        return ((holderIsNeeded != null) && holderIsNeeded.booleanValue());