org.apache.cocoon.components.language.programming.python
Class PythonLanguage

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
          extended by org.apache.cocoon.components.language.programming.python.PythonLanguage
All Implemented Interfaces:
Component, LogEnabled, Parameterizable, ProgrammingLanguage

public class PythonLanguage
extends AbstractProgrammingLanguage
implements ProgrammingLanguage

The interpreted Python programming language. Program in Python must have comment line as first line of file:

 """ $Cocoon extends: org.apache.cocoon.components.language.xsp.JSGenerator$ """
 
The class specified will be used as a Java wrapper interpreting javascript program.

Version:
CVS $Id: PythonLanguage.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Vadim Gritsenko

Field Summary
 
Fields inherited from class org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
codeFormatter, languageName
 
Fields inherited from interface org.apache.cocoon.components.language.programming.ProgrammingLanguage
ROLE
 
Constructor Summary
PythonLanguage()
           
 
Method Summary
protected  void doUnload(Object program, String filename, File baseDir)
          Unload a previously loaded program
 String getSourceExtension()
          Return the language's canonical source file extension.
 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.
 
Methods inherited from class org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
getCodeFormatter, getLanguageName, instantiate, parameterize, setLanguageName, unload
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, 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
getCodeFormatter, getLanguageName, instantiate, setLanguageName, unload
 

Constructor Detail

PythonLanguage

public PythonLanguage()
Method Detail

preload

public Program preload(String filename,
                       File baseDirectory,
                       String encoding)
                throws LanguageException
Description copied from interface: ProgrammingLanguage
Preload a program from a file

Specified by:
preload in interface ProgrammingLanguage
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(String filename,
                    File baseDirectory,
                    String encoding)
             throws LanguageException
Description copied from interface: ProgrammingLanguage
Load a program from a file

Specified by:
load in interface ProgrammingLanguage
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

doUnload

protected void doUnload(Object program,
                        String filename,
                        File baseDir)
                 throws LanguageException
Description copied from class: AbstractProgrammingLanguage
Unload a previously loaded program

Specified by:
doUnload in class AbstractProgrammingLanguage
Parameters:
program - A previously loaded object program
Throws:
LanguageException - If an error occurs during unloading

quoteString

public String quoteString(String constant)
Description copied from interface: ProgrammingLanguage
Escape a String according to the programming language's string constant encoding rules.

Specified by:
quoteString in interface ProgrammingLanguage
Parameters:
constant - The string to be escaped
Returns:
The escaped string

getSourceExtension

public String getSourceExtension()
Return the language's canonical source file extension.

Specified by:
getSourceExtension in interface ProgrammingLanguage
Returns:
The source file extension


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