com.objectwave.tools
Class GenerateTemplateInto

java.lang.Object
  |
  +--com.objectwave.tools.GenerateTemplateInto

public class GenerateTemplateInto
extends java.lang.Object

Used to add the method signatures from one class to another class.

Version:
$Id: GenerateTemplateInto.java,v 2.2 2001/10/19 14:21:00 dave_hoag Exp $
Author:
Dave Hoag

Constructor Summary
GenerateTemplateInto()
           
 
Method Summary
protected static java.lang.String[] cleanupArgs(java.lang.String[] args)
          Sometimes I pass -D arguments on the command line by mistake
protected  java.io.Reader createReaderFromClassFile(java.io.File file)
           
 void generateTemplates(MergeTemplate[] templateName, java.lang.String targetClassName)
           
 void generateTemplates(MergeTemplate[] templateName, java.lang.String targetPackageName, java.lang.String targetClassName, java.lang.String fileName)
          Generate the templates into the body or header of the target class.
 java.lang.String getMiscData()
          Gets the MiscData attribute of the GenerateTemplateInto object
protected  java.io.Reader getReader(java.lang.String fileName, java.lang.String targetPackageName)
          Return a 'reader' that will be able to read Character values that will be in the form of a valid java source code file.
protected  java.io.Reader getReaderForClass(java.lang.Class clazz, java.lang.String targetPackageName)
          Use reflection to create the source necessary to create a new file.
protected  java.io.Reader getReaderForClass(java.lang.String className, java.lang.String targetPackageName)
          Use reflection to create the source necessary to create a new file.
protected  JavaClassDef getTargetDef(ClassElement[] els, java.lang.String targetClassName)
           
protected  TokenProvider getTokenProvider()
           
 void init(java.lang.String fileName)
          Load in the templates from the specified file name.
 void initFromXml(java.lang.String xmlFileName)
           
static void main(java.lang.String[] args)
          Defaults to using JavaClassDef.dat file for template source.
 void setInitialized(boolean initialized)
          If this is true, ignore any calls to the init methods.
 void setMiscData(java.lang.String str)
          MiscData is the value used for the %MISC% token in the ClassInformation object.
protected  void setTemplates(KnownTemplates temps)
          Sets the Templates attribute of the GenerateTemplateInto object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenerateTemplateInto

public GenerateTemplateInto()
Method Detail

main

public static void main(java.lang.String[] args)
Defaults to using JavaClassDef.dat file for template source.

Parameters:
args - java.lang.String[]

cleanupArgs

protected static java.lang.String[] cleanupArgs(java.lang.String[] args)
Sometimes I pass -D arguments on the command line by mistake

Parameters:
args -
Returns:

setInitialized

public void setInitialized(boolean initialized)
If this is true, ignore any calls to the init methods.

Parameters:
initialized - The new Initialized value

setMiscData

public void setMiscData(java.lang.String str)
MiscData is the value used for the %MISC% token in the ClassInformation object.

Parameters:
str - The new MiscData value

setTemplates

protected void setTemplates(KnownTemplates temps)
Sets the Templates attribute of the GenerateTemplateInto object

Parameters:
temps - The new Templates value

getMiscData

public java.lang.String getMiscData()
Gets the MiscData attribute of the GenerateTemplateInto object

Returns:
The MiscData value

getReaderForClass

protected java.io.Reader getReaderForClass(java.lang.String className,
                                           java.lang.String targetPackageName)
                                    throws java.io.IOException
Use reflection to create the source necessary to create a new file. All we can do is copy the method signature.

Parameters:
className -
targetPackageName -
Returns:
The ReaderForClass value
Throws:
java.io.IOException

getReaderForClass

protected java.io.Reader getReaderForClass(java.lang.Class clazz,
                                           java.lang.String targetPackageName)
                                    throws java.io.IOException
Use reflection to create the source necessary to create a new file. All we can do is copy the method signature.

Parameters:
clazz -
targetPackageName -
Returns:
The ReaderForClass value
Throws:
java.io.IOException

getReader

protected java.io.Reader getReader(java.lang.String fileName,
                                   java.lang.String targetPackageName)
                            throws java.io.IOException,
                                   java.lang.Exception
Return a 'reader' that will be able to read Character values that will be in the form of a valid java source code file. If the provided file is a '.class' file, then we will create a fake '.java' file that will be parsed into it's component pieces.

Parameters:
fileName -
targetPackageName -
Returns:
The Reader value
Throws:
java.io.IOException
java.lang.Exception
See Also:
classFile.ClassFile

getTargetDef

protected JavaClassDef getTargetDef(ClassElement[] els,
                                    java.lang.String targetClassName)
                             throws java.io.IOException,
                                    java.io.FileNotFoundException
Parameters:
els -
targetClassName -
Returns:
The TargetDef value
Throws:
java.io.IOException
java.io.FileNotFoundException

getTokenProvider

protected TokenProvider getTokenProvider()
Returns:
The TokenProvider value

init

public void init(java.lang.String fileName)
          throws java.lang.Exception
Load in the templates from the specified file name. This will look for a local file. If no file is found, it will look for the file as a resource.

Parameters:
fileName -
Throws:
java.lang.Exception

generateTemplates

public void generateTemplates(MergeTemplate[] templateName,
                              java.lang.String targetPackageName,
                              java.lang.String targetClassName,
                              java.lang.String fileName)
                       throws java.io.FileNotFoundException,
                              java.io.IOException,
                              java.lang.Exception
Generate the templates into the body or header of the target class.

Parameters:
templateName - java.lang.String
targetPackageName -
targetClassName -
fileName -
Throws:
java.io.FileNotFoundException
java.io.IOException
java.lang.Exception

generateTemplates

public void generateTemplates(MergeTemplate[] templateName,
                              java.lang.String targetClassName)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Parameters:
templateName -
targetClassName -
Throws:
java.io.FileNotFoundException
java.io.IOException

initFromXml

public void initFromXml(java.lang.String xmlFileName)
                 throws java.net.MalformedURLException,
                        ConfigurationException,
                        java.io.IOException
Parameters:
xmlFileName -
Throws:
java.net.MalformedURLException
ConfigurationException
java.io.IOException

createReaderFromClassFile

protected java.io.Reader createReaderFromClassFile(java.io.File file)
                                            throws java.io.IOException,
                                                   java.lang.Exception
Parameters:
file -
Returns:
Throws:
java.io.IOException
java.lang.Exception