ch.oscg.jreleaseinfo
Class SourceGenerator

java.lang.Object
  extended bych.oscg.jreleaseinfo.SourceGenerator
All Implemented Interfaces:
SourceGeneratorIF
Direct Known Subclasses:
SourceGeneratorApp

public class SourceGenerator
extends java.lang.Object
implements SourceGeneratorIF

The SourceGenerator is a simple implementation of the SourceGeneratorIF interface. In this class the code to be generated is hard coded.
Other implementation may provide extensions (like SourceGeneratorApp) or other mechanism (like using a template engine, etc).

Version:
$Revision: 1.3 $ ($Date: 2005/08/06 14:12:36 $ / $Author: tcotting $)
Author:
Thomas Cotting, Tangarena Engineering AG, Luzern

Field Summary
protected  java.lang.String className
          ClassName of version file to be created.
protected  java.util.Date newDate
          Date for test purposes.
protected  java.lang.String packageName
          PackageName of version file to be created, 'null' means default package.
protected  java.util.Map props
          Membervariables for created class.
 
Constructor Summary
SourceGenerator()
          Default constructor.
 
Method Summary
protected  void createClassFooter(java.lang.StringBuffer buf)
          Utility method to write the class footer code to a StringBuffer.
protected  void createClassHeader(java.lang.StringBuffer buf)
          Utility method to write the class header code to a StringBuffer.
protected  void createClassInfoHeader(java.lang.StringBuffer buf)
          Utility method to write the class header code to a StringBuffer.
 java.lang.String createCode()
          Utility method to write the class java code to a String.
protected  void createMethods(java.lang.StringBuffer buf)
          Utility method to write the class method code to a StringBuffer.
 void setClassName(java.lang.String className)
          Set the classname.
 void setPackageName(java.lang.String packageName)
          Set the packagename.
 void setProperties(java.util.Map props)
          Set the property map.
protected  void writeDateMethod(java.lang.StringBuffer buf, java.lang.String type, java.lang.String name, java.util.Date date)
          Utility method to write java code for an date method to a StringBuffer.
protected  void writeln(java.lang.StringBuffer buf)
          Utility method to write an empty line to the StringBuffer.
protected  void writeln(java.lang.StringBuffer buf, java.lang.String line)
          Utility method to write a line to the StringBuffer and append a line break.
protected  void writeMethodDeclaration(java.lang.StringBuffer buf, java.lang.String type, java.lang.String methodName, java.lang.String name, java.lang.String value, java.lang.String preset)
          Utility method to write a method declaration
protected  void writeObjectDeclaration(java.lang.StringBuffer buf, java.lang.String type, java.lang.String lName, java.lang.String value)
          Utility method to write a method declaration
protected  void writeObjectMethod(java.lang.StringBuffer buf, java.lang.String type, java.lang.String name, java.lang.String value)
          Utility method to write java code for an object method to a StringBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

className

protected java.lang.String className
ClassName of version file to be created.


packageName

protected java.lang.String packageName
PackageName of version file to be created, 'null' means default package.


props

protected java.util.Map props
Membervariables for created class.


newDate

protected java.util.Date newDate
Date for test purposes.

Constructor Detail

SourceGenerator

public SourceGenerator()
Default constructor.

Method Detail

setPackageName

public void setPackageName(java.lang.String packageName)
Set the packagename.

Specified by:
setPackageName in interface SourceGeneratorIF
Parameters:
packageName -

setClassName

public void setClassName(java.lang.String className)
Set the classname.

Specified by:
setClassName in interface SourceGeneratorIF
Parameters:
className -

setProperties

public void setProperties(java.util.Map props)
Set the property map.

Specified by:
setProperties in interface SourceGeneratorIF

createCode

public java.lang.String createCode()
Utility method to write the class java code to a String.

Specified by:
createCode in interface SourceGeneratorIF
Returns:
the created java class in a string

createClassInfoHeader

protected void createClassInfoHeader(java.lang.StringBuffer buf)
Utility method to write the class header code to a StringBuffer.

Parameters:
buf - StringBuffer to write into

createClassHeader

protected void createClassHeader(java.lang.StringBuffer buf)
Utility method to write the class header code to a StringBuffer.

Parameters:
buf - StringBuffer to write into

createClassFooter

protected void createClassFooter(java.lang.StringBuffer buf)
Utility method to write the class footer code to a StringBuffer.

Parameters:
buf - StringBuffer to write into

createMethods

protected void createMethods(java.lang.StringBuffer buf)
Utility method to write the class method code to a StringBuffer.

Parameters:
buf - StringBuffer to write into

writeObjectMethod

protected void writeObjectMethod(java.lang.StringBuffer buf,
                                 java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String value)
Utility method to write java code for an object method to a StringBuffer.

Parameters:
buf - StringBuffer to write into
type - must be one of the TYPE_OBJ_xxx Strings
name - of Property
value - ReturnValue of Property

writeDateMethod

protected void writeDateMethod(java.lang.StringBuffer buf,
                               java.lang.String type,
                               java.lang.String name,
                               java.util.Date date)
Utility method to write java code for an date method to a StringBuffer.

Parameters:
buf - StringBuffer to write into
type - must be TYPE_OBJ_DATE
name - of Property

writeObjectDeclaration

protected void writeObjectDeclaration(java.lang.StringBuffer buf,
                                      java.lang.String type,
                                      java.lang.String lName,
                                      java.lang.String value)
Utility method to write a method declaration

Parameters:
buf - StringBuffer to write into
type - String return type

writeMethodDeclaration

protected void writeMethodDeclaration(java.lang.StringBuffer buf,
                                      java.lang.String type,
                                      java.lang.String methodName,
                                      java.lang.String name,
                                      java.lang.String value,
                                      java.lang.String preset)
Utility method to write a method declaration

Parameters:
buf - StringBuffer to write into
type - String return type

writeln

protected void writeln(java.lang.StringBuffer buf,
                       java.lang.String line)
Utility method to write a line to the StringBuffer and append a line break.

Parameters:
buf - StringBuffer to write into
line - String to append to buf

writeln

protected void writeln(java.lang.StringBuffer buf)
Utility method to write an empty line to the StringBuffer.

Parameters:
buf - StringBuffer to write into


Copyright © 2005 Open Source Competence Group (OSCG). All Rights Reserved.