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):
Additional behaviour that JavaClassWriter introduces beyond JavaWriter is
related to the class header and definition:
getClassModifiers
protected String getClassModifiers()
Return "public ". If more modifiers are needed, this method must be
overridden.
getClassName
protected String getClassName()
Returns the class name.
getClassText
protected String getClassText()
Return "class ". If "interface " is needed instead, this method must be
overridden.
getExtendsText
protected String getExtendsText()
Returns the appropriate extends clause. This default implementation
simply returns "", but if you want "extends "
then you must override this method.
getFileName
protected String getFileName()
Return the file name as a string of the form:
".java"
- getFileName in interface JavaWriter
getImplementsText
protected String getImplementsText()
Returns the appropriate implements clause. This default implementation
simply returns "", but if you want "implements " then
you must override this method.
getPackage
protected String getPackage()
Returns the package name.
registerFile
protected void registerFile(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.
- registerFile in interface JavaWriter
writeFileFooter
protected void writeFileFooter(PrintWriter pw)
throws IOException
Generate the closing curly brace.
- writeFileFooter in interface JavaWriter
writeFileHeader
protected void writeFileHeader(PrintWriter pw)
throws IOException
Write a common header, including the package name, the class
declaration, and the opening curly brace.
- writeFileHeader in interface JavaWriter
writeHeaderComments
protected void writeHeaderComments(PrintWriter pw)
throws IOException
Write the header comments.
writePackage
protected void writePackage(PrintWriter pw)
throws IOException
Write the package declaration statement.