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

    java.lang.Object
      org.apache.axis.wsdl.toJava.JavaWriter

All Implemented Interfaces:
  Generator

Direct Known Subclasses:
  JavaBuildFileWriter, JavaClassWriter, JavaDeployWriter, JavaUndeployWriter

public abstract class JavaWriter
extends java.lang.Object
implements Generator

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. 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 is an abstract method that must be implemented by the subclass. It returns the fully-qualified file name.
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)
  You may want to override this method. The default implementation generates nothing.
* 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)
  You may want to override this method. The default implementation generates nothing.
closePrintWriter(pw)
  You should not need to override this method. It simply closes the PrintWriter.

Field Summary
`protected Emitter` `emitter` Field emitter
`protected static int` `LINE_LENGTH` This controls how many characters per line for javadoc comments
`protected java.lang.String` `type` Field type

Constructor Summary
`protected` `JavaWriter(Emitter emitter, java.lang.String type)` Constructor.

Method Summary
`protected void` `closePrintWriter(java.io.PrintWriter pw)` Close the print writer.
`void` `generate()` Generate a file.
`protected abstract java.lang.String` `getFileName()` This method must be implemented by a subclass.
`protected java.lang.String` `getJavadocDescriptionPart(java.lang.String documentation, boolean addTab)` Takes out new lines and wraps at Javadoc tags
`protected java.io.PrintWriter` `getPrintWriter(java.lang.String filename)` You should not need to override this method.
`protected boolean` `isFileGenerated(java.lang.String file)` You should not need to override this method.
`protected void` `registerFile(java.lang.String file)` You should not need to override this method.
`protected java.lang.String` `verboseMessage(java.lang.String file)` Return the string: "Generating <file>".
`protected void` `writeComment(java.io.PrintWriter pw, org.w3c.dom.Element element)` Output a documentation element as a Java comment.
`protected void` `writeComment(java.io.PrintWriter pw, org.w3c.dom.Element element, boolean addTab)` Output a documentation element as a Java comment.
`protected abstract void` `writeFileBody(java.io.PrintWriter pw)` This method must be implemented by a subclass.
`protected void` `writeFileFooter(java.io.PrintWriter pw)` You may want to override this method.
`protected void` `writeFileHeader(java.io.PrintWriter pw)` This method is intended to be overridden as necessary to generate file header information.

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

Field Detail

### LINE_LENGTH

    protected static final int LINE_LENGTH

  This controls how many characters per line for javadoc comments

  See Also:
    Constant Field Values

### emitter

    protected Emitter emitter

  Field emitter

### type

    protected java.lang.String type

  Field type

Constructor Detail

### JavaWriter

    protected JavaWriter(Emitter emitter,
                         java.lang.String type)

  Constructor.

Parameters:
  `emitter` -
  `type` -

Method Detail

### generate

    public void generate()
                  throws java.io.IOException

  Generate a file.

  Specified by:
    `generate` in interface `Generator`
  Throws:
    `java.io.IOException`

### getFileName

    protected abstract java.lang.String getFileName()

  This method must be implemented by a subclass. It returns the fully-qualified name of the file to be generated.

  Returns:

### isFileGenerated

    protected boolean isFileGenerated(java.lang.String file)

  You should not need to override this method. It checks to see whether the given file is in the List returned by emitter.getGeneratedFileNames.

  Parameters:
    `file` -
  Returns:

### 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(...).

  Parameters:
    `file` -

### verboseMessage

    protected java.lang.String verboseMessage(java.lang.String file)

  Return the string: "Generating <file>". Override this method if you want to provide more information.

  Parameters:
    `file` -
  Returns:

### getPrintWriter

    protected java.io.PrintWriter getPrintWriter(java.lang.String filename)
                                          throws java.io.IOException

  You should not need to override this method. Given the file name, it creates a PrintWriter for it.

  Parameters:
    `filename` -
  Returns:
  Throws:
    `java.io.IOException`

### writeFileHeader

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

  This method is intended to be overridden as necessary to generate file header information. This default implementation does nothing.

  Parameters:
    `pw` -
  Throws:
    `java.io.IOException`

### writeFileBody

    protected abstract void writeFileBody(java.io.PrintWriter pw)
                                   throws java.io.IOException

  This method must be implemented by a subclass. This is where the body of a file is generated.

  Parameters:
    `pw` -
  Throws:
    `java.io.IOException`

### writeFileFooter

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

  You may want to override this method. This default implementation generates nothing.

  Parameters:
    `pw` -
  Throws:
    `java.io.IOException`

### closePrintWriter

    protected void closePrintWriter(java.io.PrintWriter pw)

  Close the print writer.

  Parameters:
    `pw` -

### getJavadocDescriptionPart

    protected java.lang.String getJavadocDescriptionPart(java.lang.String documentation,
                                                         boolean addTab)

  Takes out new lines and wraps at Javadoc tags

  Parameters:
    `documentation` - the raw comments from schema
    `addTab` - if true adds a tab character when wrapping (methods)

### writeComment

    protected void writeComment(java.io.PrintWriter pw,
                                org.w3c.dom.Element element)

  Output a documentation element as a Java comment.

  Parameters:
    `pw` -
    `element` -

### writeComment

    protected void writeComment(java.io.PrintWriter pw,
                                org.w3c.dom.Element element,
                                boolean addTab)

  Output a documentation element as a Java comment.

  Parameters:
    `pw` -
    `element` -
    `addTab` -

Copyright © 2005 Apache Web Services Project. All Rights Reserved.