Cantaloop CGimlet - API Documentation, Version: 0.2.0, Date: 2002-05-13 21:30 CEST

org.cantaloop.cgimlet
Class ProjectGenerator

java.lang.Object
  |
  +--org.cantaloop.cgimlet.ProjectGenerator
All Implemented Interfaces:
Constants

public class ProjectGenerator
extends java.lang.Object
implements Constants

A ProjectGenerator is attached to every projectfile. It configures the handlers and calls them to generate their code.

Version:
0.2.0 ($Revision: 1.15 $)
Author:
David Leuschner, Stefan Heimann

Field Summary
static int LOG_DEFAULT
          Constant used with setLogLevel(int).
static int LOG_QUIET
          Constant used with setLogLevel(int).
static int LOG_VERBOSE
          Constant used with setLogLevel(int).
 
Fields inherited from interface org.cantaloop.cgimlet.Constants
LOGGER_TOPIC_PREFIX, PROJECT_NS, PROJECT_NS_URI, PROPERTY
 
Constructor Summary
protected ProjectGenerator(java.io.File prjFile)
           
 
Method Summary
 java.io.File getBaseDir()
          Get the base directory of the project.
 CodeWriter getCodeWriter(java.lang.String dirname, LanguageFactory lang)
          Returns a codewriter for the programming language lang that is configured with dirname as basedir.
 ComponentHandler getHandler(java.lang.String key)
          Get the handler with key key.
 java.lang.String getHandlerKey(java.lang.Class handlerType)
          Get the key that was used to register a handler of type handlerType.
 org.cantaloop.tools.logging.Logger getLogger(java.lang.Object obj)
          Get a logger for the given object that is preconfigured with the topic of the ProjectGenerator.
 java.lang.String getLoggerTopic()
          Return the topic the ProjectGenerator is logging on.
protected  org.dom4j.Document getProjectDocument()
          Get the document for the project file.
 java.util.Properties getProperties()
          Get the properties of this project
 java.util.Map getResultMap()
          Returns the results the handlers.
protected  void initHandlers(org.dom4j.Element root)
           
 void registerHandler(java.lang.String key, ComponentHandler handler)
          Register a handler.
 java.io.File resolveFilename(java.lang.String name)
          Resolves the abstract pathname name against the base directory of the project.
 void run()
          Run the codegeneration.
 void setDebug(boolean b)
           
 void setLogLevel(int level)
          Set the log level of the ProjectGenerator.
 void setPrettyPrinting(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_VERBOSE

public static final int LOG_VERBOSE
Constant used with setLogLevel(int).

LOG_DEFAULT

public static final int LOG_DEFAULT
Constant used with setLogLevel(int).

LOG_QUIET

public static final int LOG_QUIET
Constant used with setLogLevel(int).
Constructor Detail

ProjectGenerator

protected ProjectGenerator(java.io.File prjFile)
Method Detail

getBaseDir

public java.io.File getBaseDir()
Get the base directory of the project.
Returns:
a File value

resolveFilename

public java.io.File resolveFilename(java.lang.String name)
Resolves the abstract pathname name against the base directory of the project. name must use `/' as the directory separator symbol.
Parameters:
name - a String value
Returns:
a File value

getCodeWriter

public CodeWriter getCodeWriter(java.lang.String dirname,
                                LanguageFactory lang)
Returns a codewriter for the programming language lang that is configured with dirname as basedir. dirname is resolved against the base directory of the project.
Parameters:
dirname - the name of the base directory
lang - the language of the CodeWriter
Returns:
a Codewriter value

getProperties

public java.util.Properties getProperties()
Get the properties of this project
Returns:
a Properties value

run

public void run()
Run the codegeneration.

getResultMap

public java.util.Map getResultMap()
Returns the results the handlers. The return values of the generate method of every ComponentHandler are stored in a map, using the key that was given when registering the handler (if you don't know this key, you can ask the getHandlerKey(Class) method). For every handler you will find a List value. This list contains the values returned by the calls of generate.
Returns:
a Map value

registerHandler

public void registerHandler(java.lang.String key,
                            ComponentHandler handler)
Register a handler.
Parameters:
key - a String value
handler - a ComponentHandler value

getHandler

public ComponentHandler getHandler(java.lang.String key)
Get the handler with key key.
Parameters:
key - a String value
Returns:
a ComponentHandler value

getHandlerKey

public java.lang.String getHandlerKey(java.lang.Class handlerType)
Get the key that was used to register a handler of type handlerType.
Parameters:
handlerType - a Class value
Returns:
a String value

getLogger

public org.cantaloop.tools.logging.Logger getLogger(java.lang.Object obj)
Get a logger for the given object that is preconfigured with the topic of the ProjectGenerator.
Parameters:
obj - an Object value
Returns:
a Logger value

getLoggerTopic

public java.lang.String getLoggerTopic()
Return the topic the ProjectGenerator is logging on.
Returns:
a String value

setLogLevel

public void setLogLevel(int level)
Set the log level of the ProjectGenerator. level should be LOG_VERBOSE or LOG_DEFAULT or LOG_QUIET.
Parameters:
level - an int value

setPrettyPrinting

public void setPrettyPrinting(boolean b)

setDebug

public void setDebug(boolean b)

getProjectDocument

protected org.dom4j.Document getProjectDocument()
Get the document for the project file. Note:This method is only for testing purpose.

initHandlers

protected void initHandlers(org.dom4j.Element root)

Copyright 2001, 2002 Stefan Heimann, David Leuschner. All rights reserved.