org.apache.cocoon.components.language.programming
Class AbstractProgrammingLanguage

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.framework.parameters.Parameterizable, ProgrammingLanguage
Direct Known Subclasses:
CompiledProgrammingLanguage, JavascriptLanguage

public abstract class AbstractProgrammingLanguage
extends org.apache.avalon.framework.logger.AbstractLoggable
implements ProgrammingLanguage, org.apache.avalon.framework.parameters.Parameterizable

Base implementation of ProgrammingLanguage. This class sets the CodeFormatter instance and deletes source program files after unloading.

Version:
CVS $Id: AbstractProgrammingLanguage.java,v 1.7 2002/03/29 20:32:01 vgritsenko Exp $
Author:
Ricardo Rocha, Vadim Gritsenko

Field Summary
protected  java.lang.Class codeFormatter
          The source code formatter
protected  java.lang.String languageName
           
 
Fields inherited from interface org.apache.cocoon.components.language.programming.ProgrammingLanguage
ROLE
 
Constructor Summary
AbstractProgrammingLanguage()
           
 
Method Summary
protected abstract  void doUnload(java.lang.Object program, java.lang.String filename, java.io.File baseDirectory)
          Unload a previously loaded program
 CodeFormatter getCodeFormatter()
          Return this language's source code formatter.
 java.lang.String getLanguageName()
          Get Language Name
 CompiledComponent instantiate(Program program)
          Create a new instance for the given class
 void parameterize(org.apache.avalon.framework.parameters.Parameters params)
          Set the configuration parameters.
 void setLanguageName(java.lang.String name)
          Set Language Name
 void unload(java.lang.Object program, java.lang.String filename, java.io.File baseDirectory)
          Unload from memory and invalidate a given program
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.components.language.programming.ProgrammingLanguage
getSourceExtension, load, preload, quoteString
 

Field Detail

codeFormatter

protected java.lang.Class codeFormatter
The source code formatter

languageName

protected java.lang.String languageName
Constructor Detail

AbstractProgrammingLanguage

public AbstractProgrammingLanguage()
Method Detail

parameterize

public void parameterize(org.apache.avalon.framework.parameters.Parameters params)
                  throws org.apache.avalon.framework.parameters.ParameterException
Set the configuration parameters. This method instantiates the sitemap-specified source code formatter
Specified by:
parameterize in interface org.apache.avalon.framework.parameters.Parameterizable
Parameters:
params - The configuration parameters
Throws:
org.apache.avalon.framework.parameters.ParameterException - If the language compiler cannot be loaded

getCodeFormatter

public CodeFormatter getCodeFormatter()
Return this language's source code formatter. A new formatter instance is created on each invocation.
Specified by:
getCodeFormatter in interface ProgrammingLanguage
Returns:
The language source code formatter

doUnload

protected abstract void doUnload(java.lang.Object program,
                                 java.lang.String filename,
                                 java.io.File baseDirectory)
                          throws LanguageException
Unload a previously loaded program
Parameters:
program - A previously loaded object program
Throws:
LanguageException - If an error occurs during unloading

unload

public final void unload(java.lang.Object program,
                         java.lang.String filename,
                         java.io.File baseDirectory)
                  throws LanguageException
Description copied from interface: ProgrammingLanguage
Unload from memory and invalidate a given program
Specified by:
unload in interface ProgrammingLanguage
Following copied from interface: org.apache.cocoon.components.language.programming.ProgrammingLanguage
Parameters:
program - The program
filename - The name of the file this program was loaded from
baseDirectory - The directory containing the program file
Throws:
LanguageException - If an error occurs

setLanguageName

public final void setLanguageName(java.lang.String name)
Description copied from interface: ProgrammingLanguage
Set Language Name
Specified by:
setLanguageName in interface ProgrammingLanguage
Following copied from interface: org.apache.cocoon.components.language.programming.ProgrammingLanguage
Parameters:
name - The name of the language

getLanguageName

public final java.lang.String getLanguageName()
Description copied from interface: ProgrammingLanguage
Get Language Name
Specified by:
getLanguageName in interface ProgrammingLanguage
Following copied from interface: org.apache.cocoon.components.language.programming.ProgrammingLanguage
Returns:
The name of the language

instantiate

public CompiledComponent instantiate(Program program)
                              throws LanguageException
Create a new instance for the given class
Specified by:
instantiate in interface ProgrammingLanguage
Parameters:
program - The Java class
Returns:
A new class instance
Throws:
LanguageException - If an instantiation error occurs


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.