KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > programming > ProgrammingLanguage


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.language.programming;
17
18 import org.apache.avalon.framework.component.Component;
19
20 import org.apache.cocoon.components.language.LanguageException;
21 import org.apache.cocoon.components.language.generator.CompiledComponent;
22
23 import java.io.File JavaDoc;
24
25 /**
26  * This interface states the functionality of a programming language processor
27  *
28  * @author <a HREF="mailto:ricardo@apache.org">Ricardo Rocha</a>
29  * @version CVS $Id: ProgrammingLanguage.java 30932 2004-07-29 17:35:38Z vgritsenko $
30  */

31 public interface ProgrammingLanguage extends Component {
32
33     String JavaDoc ROLE = ProgrammingLanguage.class.getName();
34
35     /**
36      * Return the programming language's source file extension
37      *
38      * @return The canonical source file extension
39      */

40     String JavaDoc getSourceExtension();
41
42     /**
43      * Preload a program from a file
44      *
45      * @param filename The program base file name
46      * @param baseDirectory The directory containing the program file
47      * @param encoding The encoding expected in the source file or
48      * <code>null</code> if it is the platform's default encoding
49      * @return The loaded program
50      * @exception LanguageException If an error occurs during loading
51      */

52     Program preload(String JavaDoc filename, File JavaDoc baseDirectory, String JavaDoc encoding)
53             throws LanguageException;
54
55     /**
56      * Load a program from a file
57      *
58      * @param filename The program base file name
59      * @param baseDirectory The directory containing the program file
60      * @param encoding The encoding expected in the source file or
61      * <code>null</code> if it is the platform's default encoding
62      * @return The loaded program
63      * @exception LanguageException If an error occurs during loading
64      */

65     Program load(String JavaDoc filename, File JavaDoc baseDirectory, String JavaDoc encoding)
66             throws LanguageException;
67
68     /**
69      * Create a new instance for the given program type
70      *
71      * @param program The program type
72      * @return A new program type instance
73      * @exception LanguageException If an instantiation error occurs
74      */

75     // FIXME(VG): Not used
76
CompiledComponent instantiate(Program program) throws LanguageException;
77
78     /**
79      * Unload from memory and invalidate a given program
80      *
81      * @param program The program
82      * @param filename The name of the file this program was loaded from
83      * @param baseDirectory The directory containing the program file
84      * @exception LanguageException If an error occurs
85      */

86     void unload(Object JavaDoc program, String JavaDoc filename, File JavaDoc baseDirectory) // unload(Program ?
87
throws LanguageException;
88
89     /**
90      * Return the <code>CodeFormatter</code> associated with this programming
91      * language
92      *
93      * @return The code formatter object or <code>null</code> if none is
94      * available
95      */

96     CodeFormatter getCodeFormatter();
97
98     /**
99      * Escape a <code>String</code> according to the programming language's
100      * string constant encoding rules.
101      *
102      * @param constant The string to be escaped
103      * @return The escaped string
104      */

105     String JavaDoc quoteString(String JavaDoc constant);
106
107     /**
108      * Set Language Name
109      *
110      * @param name The name of the language
111      */

112     void setLanguageName(String JavaDoc name);
113
114     /**
115      * Get Language Name
116      *
117      * @return The name of the language
118      */

119     String JavaDoc getLanguageName();
120 }
121
Popular Tags