Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.cantaloop.cgimlet
Class ProjectGenerator  view ProjectGenerator download ProjectGenerator.java

java.lang.Object
  extended byorg.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:
@version@ ($Revision: 1.15 $)

Field Summary
private static java.lang.String CONFIGURE
           
private static java.lang.String GENERATE
           
static int LOG_DEFAULT
          Constant used with setLogLevel(int) 55 .
static int LOG_QUIET
          Constant used with setLogLevel(int) 55 .
static int LOG_VERBOSE
          Constant used with setLogLevel(int) 55 .
private  java.io.File m_baseDir
           
private  org.dom4j.Document m_doc
          the project document.
private  java.util.Map m_handlerKeyMap
           
private  java.util.Map m_handlerMap
           
private  int m_level
           
private  org.cantaloop.tools.logging.Logger m_log
           
private  java.lang.String m_loggerTopic
           
private  org.cantaloop.tools.logging.LoggingManager m_loggingManager
           
private  PropertyParser m_parser
           
private  boolean m_prettyPrinting
           
private  java.io.File m_prjFile
           
private  java.util.Map m_resultMap
           
 
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
private  void adjustBaseDir(java.lang.String baseStr)
           
private  void callHandler(org.dom4j.Element root, java.lang.String action)
           
 java.io.File getBaseDir()
          Get the base directory of the project.
 org.cantaloop.cgimlet.lang.CodeWriter getCodeWriter(java.lang.String dirname, org.cantaloop.cgimlet.lang.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) 55 .

See Also:
Constant Field Values

LOG_DEFAULT

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

See Also:
Constant Field Values

LOG_QUIET

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

See Also:
Constant Field Values

m_prjFile

private java.io.File m_prjFile

m_baseDir

private java.io.File m_baseDir

m_parser

private PropertyParser m_parser

m_doc

private org.dom4j.Document m_doc
the project document.


m_handlerMap

private java.util.Map m_handlerMap

m_handlerKeyMap

private java.util.Map m_handlerKeyMap

m_resultMap

private java.util.Map m_resultMap

m_level

private int m_level

m_prettyPrinting

private boolean m_prettyPrinting

m_loggerTopic

private java.lang.String m_loggerTopic

m_log

private org.cantaloop.tools.logging.Logger m_log

m_loggingManager

private org.cantaloop.tools.logging.LoggingManager m_loggingManager

CONFIGURE

private static final java.lang.String CONFIGURE
See Also:
Constant Field Values

GENERATE

private static final java.lang.String GENERATE
See Also:
Constant Field Values
Constructor Detail

ProjectGenerator

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

getBaseDir

public java.io.File getBaseDir()
Get the base directory of the project.


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.


getCodeWriter

public org.cantaloop.cgimlet.lang.CodeWriter getCodeWriter(java.lang.String dirname,
                                                           org.cantaloop.cgimlet.lang.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.


getProperties

public java.util.Properties getProperties()
Get the properties of this project


run

public void run()
Run the codegeneration.


callHandler

private void callHandler(org.dom4j.Element root,
                         java.lang.String action)

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) 55 method). For every handler you will find a List value. This list contains the values returned by the calls of generate.


registerHandler

public void registerHandler(java.lang.String key,
                            ComponentHandler handler)
Register a handler.


getHandler

public ComponentHandler getHandler(java.lang.String key)
Get the handler with key key.


getHandlerKey

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


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.


getLoggerTopic

public java.lang.String getLoggerTopic()
Return the topic the ProjectGenerator is logging on.


setLogLevel

public void setLogLevel(int level)
Set the log level of the ProjectGenerator. level should be LOG_VERBOSE or LOG_DEFAULT or LOG_QUIET.


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)

adjustBaseDir

private void adjustBaseDir(java.lang.String baseStr)