Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.axis.wsdl.toJava
Class JavaClassWriter

    java.lang.Object
      |
      +--org.apache.axis.wsdl.toJava.JavaWriter
            |
            +--org.apache.axis.wsdl.toJava.JavaClassWriter

All Implemented Interfaces:
  Generator

Direct Known Subclasses:
  JavaBeanHelperWriter, JavaBeanWriter, JavaEnumTypeWriter, JavaFaultWriter, JavaHolderWriter, JavaImplWriter, JavaInterfaceWriter, JavaServiceIfaceWriter, JavaServiceImplWriter, JavaSkelWriter, JavaStubWriter, JavaTestCaseWriter

public abstract class JavaClassWriter
extends JavaWriter

Emitter knows about WSDL writers, one each for PortType, Binding, Service, Definition, Type. But for some of these WSDL types, Wsdl2java generates multiple files. Each of these files has a corresponding writer that extends JavaWriter. So the Java WSDL writers (JavaPortTypeWriter, JavaBindingWriter, etc.) each calls a file writer (JavaStubWriter, JavaSkelWriter, etc.) for each file that that WSDL generates.

For example, when Emitter calls JavaWriterFactory for a Binding Writer, it returns a JavaBindingWriter. JavaBindingWriter, in turn, contains a JavaStubWriter, JavaSkelWriter, and JavaImplWriter since a Binding may cause a stub, skeleton, and impl template to be generated.

Note that the writers that are given to Emitter by JavaWriterFactory DO NOT extend JavaWriter. They simply implement Writer and delegate the actual task of writing to extensions of JavaWriter.

All of Wsdl2java's Writer implementations follow a common behaviour. JavaWriter is the abstract base class that dictates this common behaviour. Many of the files generated are .java files, so this abstract class - JavaClassWriter - exists. It extends JavaWriter and adds a bit of Java- relative behaviour. This behaviour is primarily placed within the generate method. The generate method calls, in succession (note: the starred methods are the ones you are probably most interested in):

getFileName
  This method is abstract in JavaWriter, but JavaClassWriter implements this method. Subclasses should have no need to override it. It returns the fully-qualified file name based on the fully-qualified classname + ".java".
isFileGenerated(file)
  You should not need to override this method. It checks to see whether this file is in the List returned by emitter.getGeneratedFileNames.
registerFile(file)
  You should not need to override this method. It registers this file by calling emitter.getGeneratedFileInfo().add(...).
* verboseMessage(file)
  You may override this method if you want to provide more information. The generate method only calls verboseMessage if verbose is turned on.
getPrintWriter(file)
  You should not need to override this method. Given the file name, it creates a PrintWriter for it.
writeFileHeader(pw)
  JavaClassWriter implements this method, so you should not need to override it. This method generates a javadoc giving the filename and a comment stating that this file is generated by WSDL2Java, and it generates the class definition including the opening curly brace..
* writeFileBody(pw)
  This is an abstract method that must be implemented by the subclass. This is where the body of a file is generated.
* writeFileFooter(pw)
  JavaClassWriter implements this method, so you should not need to override it. It generates the closing curly brace for the class.
closePrintWriter(pw)
  You should not need to override this method. It simply closes the PrintWriter.

Additional behaviour that JavaClassWriter introduces beyond JavaWriter is related to the class header and definition:

writeHeaderComments
  Write the header comments, such as the file name and that the file was generated by WSDL2Java. You need not override this method unless you want a tailored comment.
writePackage
  Write the package statement, if necessary. You should not need to override this method.
getClassModifiers
  Modifiers, such as "public", "final", "abstract" would be returned by this method. The default implementation only generates "public ", so any subclass that needs more must override this method.
getClassText
  This simply returns "class ". If anything else is desired, for instance, JavaInterfaceWriter prefers "interface ", then this method must be overridden.
getExtendsText
  The default implementation returns "". If a subclass desires to list a set of classes this one extends, then this method must be overridden.
getImplementsText
  Same as getExtendsText except for the implements clause.

Field Summary
`protected java.lang.String` | `className`
`protected Namespaces` | `namespaces`
`protected java.lang.String` | `packageName`

Fields inherited from class org.apache.axis.wsdl.toJava.JavaWriter
`emitter, type`

Constructor Summary
`protected` | `JavaClassWriter(Emitter emitter, java.lang.String fullClassName, java.lang.String type)` Constructor.

Method Summary
`protected java.lang.String` | `getClassModifiers()` Return "public ".
`protected java.lang.String` | `getClassName()` Returns the class name.
`protected java.lang.String` | `getClassText()` Return "class ".
`protected java.lang.String` | `getExtendsText()` Returns the appropriate extends clause.
`protected java.lang.String` | `getFileName()` Return the file name as a string of the form: ".java"
`protected java.lang.String` | `getImplementsText()` Returns the appropriate implements clause.
`protected java.lang.String` | `getPackage()` Returns the package name.
`protected void` | `registerFile(java.lang.String file)` You should not need to override this method.
`protected void` | `writeFileFooter(java.io.PrintWriter pw)` Generate the closing curly brace.
`protected void` | `writeFileHeader(java.io.PrintWriter pw)` Write a common header, including the package name, the class declaration, and the opening curly brace.
`protected void` | `writeHeaderComments(java.io.PrintWriter pw)` Write the header comments.
`protected void` | `writePackage(java.io.PrintWriter pw)` Write the package declaration statement.

Methods inherited from class org.apache.axis.wsdl.toJava.JavaWriter
`closePrintWriter, generate, getPrintWriter, isFileGenerated, verboseMessage, writeComment, writeFileBody`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### namespaces

    protected Namespaces namespaces

### className

    protected java.lang.String className

### packageName

    protected java.lang.String packageName

Constructor Detail

### JavaClassWriter

    protected JavaClassWriter(Emitter emitter,
                              java.lang.String fullClassName,
                              java.lang.String type)

  Constructor.
  Parameters:
    `emitter` - The emitter instance
    `fullClassName` - The fully qualified class name of the class to be generated.
    `type` -

Method Detail

### getFileName

    protected java.lang.String getFileName()

  Return the file name as a string of the form: ".java"
  Overrides:
    `getFileName` in class `JavaWriter`

### registerFile

    protected void registerFile(java.lang.String file)

  You should not need to override this method. It registers the given file by calling emitter.getGeneratedFileInfo().add(...). JavaClassWriter overrides this method from JavaWriter because it add class name to the registration information.
  Overrides:
    `registerFile` in class `JavaWriter`

### writeFileHeader

    protected void writeFileHeader(java.io.PrintWriter pw)
                            throws java.io.IOException

  Write a common header, including the package name, the class declaration, and the opening curly brace.
  Overrides:
    `writeFileHeader` in class `JavaWriter`

### writeHeaderComments

    protected void writeHeaderComments(java.io.PrintWriter pw)
                                throws java.io.IOException

  Write the header comments.

### writePackage

    protected void writePackage(java.io.PrintWriter pw)
                         throws java.io.IOException

  Write the package declaration statement.

### getClassModifiers

    protected java.lang.String getClassModifiers()

  Return "public ". If more modifiers are needed, this method must be overridden.

### getClassText

    protected java.lang.String getClassText()

  Return "class ". If "interface " is needed instead, this method must be overridden.

### getExtendsText

    protected java.lang.String getExtendsText()

  Returns the appropriate extends clause. This default implementation simply returns "", but if you want "extends " then you must override this method.
  Returns:
    ""

### getImplementsText

    protected java.lang.String getImplementsText()

  Returns the appropriate implements clause. This default implementation simply returns "", but if you want "implements " then you must override this method.
  Returns:
    ""

### getPackage

    protected java.lang.String getPackage()

  Returns the package name.

### getClassName

    protected java.lang.String getClassName()

  Returns the class name.

### writeFileFooter

    protected void writeFileFooter(java.io.PrintWriter pw)
                            throws java.io.IOException

  Generate the closing curly brace.
  Overrides:
    `writeFileFooter` in class `JavaWriter`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache XML Project. All Rights Reserved.