org.apache.cocoon.components.language.programming
Interface ProgrammingLanguage

All Superinterfaces:
Component
All Known Implementing Classes:
AbstractProgrammingLanguage, CompiledJavascriptLanguage, CompiledProgrammingLanguage, JavaLanguage, JavascriptLanguage, PythonLanguage

public interface ProgrammingLanguage
extends Component

This interface states the functionality of a programming language processor

Version:
CVS $Id: ProgrammingLanguage.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Ricardo Rocha

Field Summary
static String ROLE
           
 
Method Summary
 CodeFormatter getCodeFormatter()
          Return the CodeFormatter associated with this programming language
 String getLanguageName()
          Get Language Name
 String getSourceExtension()
          Return the programming language's source file extension
 CompiledComponent instantiate(Program program)
          Create a new instance for the given program type
 Program load(String filename, File baseDirectory, String encoding)
          Load a program from a file
 Program preload(String filename, File baseDirectory, String encoding)
          Preload a program from a file
 String quoteString(String constant)
          Escape a String according to the programming language's string constant encoding rules.
 void setLanguageName(String name)
          Set Language Name
 void unload(Object program, String filename, File baseDirectory)
          Unload from memory and invalidate a given program
 

Field Detail

ROLE

static final String ROLE
Method Detail

getSourceExtension

String getSourceExtension()
Return the programming language's source file extension

Returns:
The canonical source file extension

preload

Program preload(String filename,
                File baseDirectory,
                String encoding)
                throws LanguageException
Preload a program from a file

Parameters:
filename - The program base file name
baseDirectory - The directory containing the program file
encoding - The encoding expected in the source file or null if it is the platform's default encoding
Returns:
The loaded program
Throws:
LanguageException - If an error occurs during loading

load

Program load(String filename,
             File baseDirectory,
             String encoding)
             throws LanguageException
Load a program from a file

Parameters:
filename - The program base file name
baseDirectory - The directory containing the program file
encoding - The encoding expected in the source file or null if it is the platform's default encoding
Returns:
The loaded program
Throws:
LanguageException - If an error occurs during loading

instantiate

CompiledComponent instantiate(Program program)
                              throws LanguageException
Create a new instance for the given program type

Parameters:
program - The program type
Returns:
A new program type instance
Throws:
LanguageException - If an instantiation error occurs

unload

void unload(Object program,
            String filename,
            File baseDirectory)
            throws LanguageException
Unload from memory and invalidate a given program

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

getCodeFormatter

CodeFormatter getCodeFormatter()
Return the CodeFormatter associated with this programming language

Returns:
The code formatter object or null if none is available

quoteString

String quoteString(String constant)
Escape a String according to the programming language's string constant encoding rules.

Parameters:
constant - The string to be escaped
Returns:
The escaped string

setLanguageName

void setLanguageName(String name)
Set Language Name

Parameters:
name - The name of the language

getLanguageName

String getLanguageName()
Get Language Name

Returns:
The name of the language


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.