ch.sahits.codegen.generator
Class AbstractGenerator

java.lang.Object
  extended by ch.sahits.codegen.generator.AbstractGenerator
All Implemented Interfaces:
IBaseGenerator, IGenerator
Direct Known Subclasses:
ASTGenerator, JETGateway

public abstract class AbstractGenerator
extends java.lang.Object
implements IGenerator

Abstract superclass for the generators that handles the saving.

Since:
0.9.0
Author:
Andi Hotz

Constructor Summary
AbstractGenerator()
           
 
Method Summary
protected  IProgressMonitor createIfNull(IProgressMonitor monitor)
          Returns a non-null progress monitor.
protected  IContainer findOrCreateContainer(IProgressMonitor progressMonitor, java.lang.String targetDirectory, java.lang.String packageName)
          Find or create the container a package belongs to
 IJetGatewayConfiguration getConfig()
          Returns the Config object
 IFile save(IProgressMonitor monitor, byte[] contents)
          Saves the specified contents to a location specified by the Config settings.
 void setConfig(IJetGatewayConfiguration config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.sahits.codegen.generator.IGenerator
cleanup, getWorkload, init, setMonitor
 
Methods inherited from interface ch.sahits.codegen.generator.IBaseGenerator
generate, init, isInitialized
 

Constructor Detail

AbstractGenerator

public AbstractGenerator()
Method Detail

save

public final IFile save(IProgressMonitor monitor,
                        byte[] contents)
                 throws CoreException
Saves the specified contents to a location specified by the Config settings. The location of the file to save is found by finding or creating the container (folder) for the Config 's package in the Config's target folder. The name of the file to save is the Config's target file.

Specified by:
save in interface IGenerator
Parameters:
monitor - the progress monitor to use. May be null.
contents - the byte contents of the file to save
Returns:
IFile instance of the saved contents
Throws:
CoreException

findOrCreateContainer

protected final IContainer findOrCreateContainer(IProgressMonitor progressMonitor,
                                                 java.lang.String targetDirectory,
                                                 java.lang.String packageName)
                                          throws CoreException
Find or create the container a package belongs to

Parameters:
progressMonitor - Monitor
targetDirectory - Base directory relative to the workspace
packageName - name of the package
Returns:
Container resource
Throws:
CoreException

getConfig

public final IJetGatewayConfiguration getConfig()
Returns the Config object

Specified by:
getConfig in interface IGenerator
Returns:
the Config object

createIfNull

protected IProgressMonitor createIfNull(IProgressMonitor monitor)
Returns a non-null progress monitor.

Parameters:
monitor - an existing progress monitor
Returns:
a new NullProgressMonitor if the specified monitor is null, or the existing monitor otherwise

setConfig

public final void setConfig(IJetGatewayConfiguration config)
Parameters:
config - the mConfig to set