com.objectwave.sourceGenerator
Class ClassBodyGenerator

java.lang.Object
  |
  +--com.objectwave.sourceGenerator.ClassBodyGenerator

public class ClassBodyGenerator
extends java.lang.Object

Manipulates java class info objects to include the various methods generated via the templates. This class is only capable of generating a template and adding those class elements to a JavaClassInfo object. This functionality is good for attributes, inner Classes, methods, static initializers ....

Version:
$Id: ClassBodyGenerator.java,v 2.0 2001/06/11 15:54:25 dave_hoag Exp $
Author:
Dave Hoag

Constructor Summary
ClassBodyGenerator(JavaClassInfo anInfo)
           
 
Method Summary
 void generateBody(java.lang.String tempName, ClassSpec aSpec)
           
 void generateClose(java.lang.String tempName, ClassSpec aSpec, boolean overwrite)
          Generate the supplied template.
 void generateHeader(MergeTemplate temp, ClassSpec aSpec)
          Generate the supplied template.
 void generateHeader(java.lang.String tempName, ClassSpec aSpec)
          Generate the supplied template.
 void generateStubs(MethodDef[] els, boolean overwrite)
          This can be used to basically 'clone' a class.
 void generateTemplate(MergeTemplate template, boolean overwrite)
           
 void generateTemplate(MergeTemplate temp, ClassSpec aSpec, boolean overwrite)
          Generate the supplied template.
 void generateTemplate(java.lang.String tempName)
           
 void generateTemplate(java.lang.String tempName, boolean overwrite)
          This is expecting that the template in question will generate a method.
 void generateTemplate(java.lang.String tempName, ClassSpec aSpec)
          Generate the supplied template.
 void generateTemplate(java.lang.String tempName, ClassSpec aSpec, boolean overwrite)
          Generate the supplied template.
 java.util.Vector getGeneratedElements(java.lang.String tempName, ClassSpec aSpec)
          Generate the code, but don't update the object.
protected  java.io.StringReader getGeneratedSourceReader(java.lang.String tempName, ClassSpec aSpec)
          This method will not instantiate an output stream.
 java.lang.String getMiscData()
           
 void setMiscData(java.lang.String val)
           
 void setRemoveMode(boolean aValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassBodyGenerator

public ClassBodyGenerator(JavaClassInfo anInfo)
Parameters:
anInfo -
Method Detail

setMiscData

public void setMiscData(java.lang.String val)
Parameters:
val - The new MiscData value

setRemoveMode

public void setRemoveMode(boolean aValue)
Parameters:
aValue - The new RemoveMode value

getGeneratedElements

public java.util.Vector getGeneratedElements(java.lang.String tempName,
                                             ClassSpec aSpec)
Generate the code, but don't update the object. Purely a utility method. Should not be used by any of the generation routines.

Parameters:
tempName -
aSpec -
Returns:
The GeneratedElements value

getMiscData

public java.lang.String getMiscData()
Returns:
The MiscData value

generateBody

public void generateBody(java.lang.String tempName,
                         ClassSpec aSpec)
Parameters:
tempName -
aSpec -

generateClose

public void generateClose(java.lang.String tempName,
                          ClassSpec aSpec,
                          boolean overwrite)
                   throws java.io.IOException
Generate the supplied template. This method will not instantiate an output stream. It is necessary to have called generate method header first. The template in question may generate more than just methods.

Parameters:
tempName - Name of MergeTemplate to generate.
aSpec - The 'class' to use for information while generating the template. it is important to note, however, that the actual changes will occur on the class provided when this class was created.
overwrite - If true, overwrite class elements with the same signature.
Throws:
java.io.IOException
See Also:
classBuilder.sourceGeneration.MergeTemplate, #generateMethodHeader

generateHeader

public void generateHeader(java.lang.String tempName,
                           ClassSpec aSpec)
Generate the supplied template. Used in conjunction with generateMethodClose. In general, these methods are not used by external programs. For the most part these are used by some of the other methods within this class.

Parameters:
tempName - Name of SourceCodeTemplate to generate.
aSpec -

generateHeader

public void generateHeader(MergeTemplate temp,
                           ClassSpec aSpec)
Generate the supplied template. Used in conjunction with generateMethodClose. In general, these methods are not used by external programs. For the most part these are used by some of the other methods within this class.

Parameters:
temp - The MergeTemplate to generate.
aSpec - The 'class' to use for information while generating the template. it is important to note, however, that the actual changes will occur on the class provided when this class was created.
See Also:
com.objectwave.sourceModel.MergeTemplate, #generateMethodBody, #generateMethodClose

generateStubs

public void generateStubs(MethodDef[] els,
                          boolean overwrite)
This can be used to basically 'clone' a class. All of the methods declared in the in the collection of ClassElements will be created a stubs in the class that is the subject of this method generator.

Parameters:
els -
overwrite -

generateTemplate

public void generateTemplate(MergeTemplate template,
                             boolean overwrite)
                      throws java.io.IOException
Parameters:
template -
overwrite -
Throws:
java.io.IOException

generateTemplate

public void generateTemplate(java.lang.String tempName)
                      throws java.io.IOException
Parameters:
tempName -
Throws:
java.io.IOException

generateTemplate

public void generateTemplate(java.lang.String tempName,
                             ClassSpec aSpec)
                      throws java.io.IOException
Generate the supplied template.

Parameters:
tempName - Name of MergeTemplate to generate.
aSpec - The 'class' to use for information while generating the template. it is important to note, however, that the actual changes will occur on the class provided when this class was created.
Throws:
java.io.IOException
See Also:
classBuilder.sourceGeneration.MergeTemplate

generateTemplate

public void generateTemplate(java.lang.String tempName,
                             ClassSpec aSpec,
                             boolean overwrite)
                      throws java.io.IOException
Generate the supplied template.

Parameters:
tempName - Name of MergeTemplate to generate.
aSpec -
overwrite -
Throws:
java.io.IOException

generateTemplate

public void generateTemplate(MergeTemplate temp,
                             ClassSpec aSpec,
                             boolean overwrite)
                      throws java.io.IOException
Generate the supplied template.

Parameters:
temp - The MergeTemplate to generate.
aSpec - The 'class' to use for information while generating the template. it is important to note, however, that the actual changes will occur on the class provided when this class was created.
overwrite -
Throws:
java.io.IOException
See Also:
classBuilder.sourceGeneration.MergeTemplate

generateTemplate

public void generateTemplate(java.lang.String tempName,
                             boolean overwrite)
                      throws java.io.IOException
This is expecting that the template in question will generate a method. If not, well, source won't generate correctly.

Parameters:
tempName -
overwrite -
Throws:
java.io.IOException

getGeneratedSourceReader

protected java.io.StringReader getGeneratedSourceReader(java.lang.String tempName,
                                                        ClassSpec aSpec)
This method will not instantiate an output stream. It is necessary to have called generate method header first. May, or may not, do any source code generation. It will only generate if a template is provided. The default will probably by a null value for both parameters.

Parameters:
tempName -
aSpec -
Returns:
The GeneratedSourceReader value