ozone core API

org.ozoneDB.tools.OPP.srcgen.builder
Class FactoryBuilder

java.lang.Object
  extended byorg.ozoneDB.tools.OPP.srcgen.builder.FactoryBuilder
All Implemented Interfaces:
ClassBuilder

public class FactoryBuilder
extends java.lang.Object
implements ClassBuilder

Most of the code was lifted out of the FactoryGenerator written by Leo Mekenkamp. The FactoryGenerator was in turn based on the ProxyGenerator The FactoryBuilder is in fact half of the FactoryGenerate, the generating part. The rest of the FactoryGenerator had to do with browsing a class for constructors etc. That part is moved to a director, thus separating concerns.

Author:
SMB, Medium.net, Per Nyfelt, Leo Mekenkamp, Joakim Ohlrogge

Nested Class Summary
 
Nested classes inherited from class org.ozoneDB.tools.OPP.srcgen.ClassBuilder
ClassBuilder.Parameter
 
Field Summary
private  java.lang.String[] interfaces
           
private  MessageWriter msgWriter
           
private  java.io.PrintWriter out
           
private  OutputStreamFactory outputFactory
           
private  java.lang.String postfix
           
 
Constructor Summary
FactoryBuilder(OutputStreamFactory outputFactory, java.lang.String postfix)
           
 
Method Summary
 void beginClass(int modifer, java.lang.String fullName, java.lang.String superClass, java.lang.String[] interfaces)
          Called for each new class.
 void endClass()
          Called at the end of each generated class.
 void init(MessageWriter msgWriter)
          Initializes the builder for each new build.
 void makeConstructor(int modifier, ClassBuilder.Parameter[] parameters, java.lang.String[] exceptions)
          Called for each constructor in the current class
private  void makeCreateInternal(java.lang.String implementationClass, java.lang.String type)
           
private  void makeGlobalHeader(java.lang.String implementationClass)
           
private  void makeLocalHeader(java.lang.String simpleClassName)
           
 void makeMethod(int modifier, java.lang.String name, ClassBuilder.Parameter[] parameters, java.lang.String returnType, java.lang.String[] exceptions, int lockLevel)
          Called for each method in the current class
private  void makeObjectForHandle(java.lang.String type)
           
private  void makeObjectForName(java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputFactory

private OutputStreamFactory outputFactory

postfix

private java.lang.String postfix

out

private java.io.PrintWriter out

interfaces

private java.lang.String[] interfaces

msgWriter

private MessageWriter msgWriter
Constructor Detail

FactoryBuilder

public FactoryBuilder(OutputStreamFactory outputFactory,
                      java.lang.String postfix)
Method Detail

makeCreateInternal

private void makeCreateInternal(java.lang.String implementationClass,
                                java.lang.String type)

makeGlobalHeader

private void makeGlobalHeader(java.lang.String implementationClass)

makeLocalHeader

private void makeLocalHeader(java.lang.String simpleClassName)

makeObjectForHandle

private void makeObjectForHandle(java.lang.String type)

makeObjectForName

private void makeObjectForName(java.lang.String type)

init

public void init(MessageWriter msgWriter)
Description copied from interface: ClassBuilder
Initializes the builder for each new build. This method may be called several times during the lifetime of the builder but only once for each build. This method may be used reset any internal state that the builder may have.

Specified by:
init in interface ClassBuilder
Parameters:
msgWriter - The writer the builder should use to report messages.

beginClass

public void beginClass(int modifer,
                       java.lang.String fullName,
                       java.lang.String superClass,
                       java.lang.String[] interfaces)
                throws BuilderException
Description copied from interface: ClassBuilder
Called for each new class. May be called moore than once if the class has inner classes.

Specified by:
beginClass in interface ClassBuilder
Parameters:
modifer - The modifiers for this class
fullName - The full name including package path of this class
superClass - The full name including package pathh for this class
interfaces - The interfaces implemented by this class
Throws:
BuilderException

makeConstructor

public void makeConstructor(int modifier,
                            ClassBuilder.Parameter[] parameters,
                            java.lang.String[] exceptions)
                     throws BuilderException
Description copied from interface: ClassBuilder
Called for each constructor in the current class

Specified by:
makeConstructor in interface ClassBuilder
Parameters:
modifier - The modifier for this constructor
parameters - The parameters for this constructor
exceptions - The exceptions thrown by this constructor
Throws:
BuilderException

makeMethod

public void makeMethod(int modifier,
                       java.lang.String name,
                       ClassBuilder.Parameter[] parameters,
                       java.lang.String returnType,
                       java.lang.String[] exceptions,
                       int lockLevel)
                throws BuilderException
Description copied from interface: ClassBuilder
Called for each method in the current class

Specified by:
makeMethod in interface ClassBuilder
Parameters:
modifier - The modifiers for the method
name - The name of the method
parameters - The parameter list for the method
returnType - The return type of the method, use null for void
exceptions - The exceptions thrown by the method
lockLevel - The lock level for this method
Throws:
BuilderException

endClass

public void endClass()
              throws BuilderException
Description copied from interface: ClassBuilder
Called at the end of each generated class. Must be called once and once only for each beginClass.

Specified by:
endClass in interface ClassBuilder
Throws:
BuilderException

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.