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

All Superinterfaces:
org.apache.avalon.framework.component.Component
All Known Implementing Classes:
AbstractProgrammingLanguage, JavascriptLanguage

public interface ProgrammingLanguage
extends org.apache.avalon.framework.component.Component

This interface states the functionality of a programming language processor

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

Field Summary
static java.lang.String ROLE
           
 
Method Summary
 CodeFormatter getCodeFormatter()
          Return the CodeFormatter associated with this programming language
 java.lang.String getLanguageName()
          Get Language Name
 java.lang.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(java.lang.String filename, java.io.File baseDirectory, java.lang.String encoding)
          Load a program from a file
 Program preload(java.lang.String filename, java.io.File baseDirectory, java.lang.String encoding)
          Preload a program from a file
 java.lang.String quoteString(java.lang.String constant)
          Escape a String according to the programming language's string constant encoding rules.
 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
 

Field Detail

ROLE

public static final java.lang.String ROLE
Method Detail

getSourceExtension

public java.lang.String getSourceExtension()
Return the programming language's source file extension
Returns:
The canonical source file extension

preload

public Program preload(java.lang.String filename,
                       java.io.File baseDirectory,
                       java.lang.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

public Program load(java.lang.String filename,
                    java.io.File baseDirectory,
                    java.lang.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

public 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

public void unload(java.lang.Object program,
                   java.lang.String filename,
                   java.io.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

public CodeFormatter getCodeFormatter()
Return the CodeFormatter associated with this programming language
Returns:
The code formatter object or null if none is available

quoteString

public java.lang.String quoteString(java.lang.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

public void setLanguageName(java.lang.String name)
Set Language Name
Parameters:
name - The name of the language

getLanguageName

public java.lang.String getLanguageName()
Get Language Name
Returns:
The name of the language


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