|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.components.language.markup.AbstractMarkupLanguage
public abstract class AbstractMarkupLanguage
Base implementation of MarkupLanguage
. This class uses
logicsheets as the only means of code generation. Code generation
should be decoupled from this context!!!
Nested Class Summary | |
---|---|
protected static class |
AbstractMarkupLanguage.LanguageDescriptor
This class holds transient information about a target programming language. |
class |
AbstractMarkupLanguage.TransformerChainBuilderFilter
An XMLFilter that build the chain of transformers on the fly. |
Field Summary | |
---|---|
static String |
ATTR_INTERPOLATION
Name "attr-interpolation" of boolean attribute to enable expression interpolation in attribute values. |
protected Map |
languages
The supported language table |
protected Store |
logicsheetCache
The code-generation logicsheet cache |
protected ServiceManager |
manager
The service manager |
protected String |
name
This language name |
static String |
TEXT_INTERPOLATION
Name "text-interpolation" of boolean attribute to enable expression interpolation inside text nodes. |
Fields inherited from interface org.apache.cocoon.components.language.markup.MarkupLanguage |
---|
ROLE |
Constructor Summary | |
---|---|
AbstractMarkupLanguage()
The default constructor. |
Method Summary | |
---|---|
protected abstract void |
addDependency(String location)
Add a dependency on an external file to the document for inclusion in generated code. |
protected void |
addLogicsheetsToGenerator(LogicsheetCodeGenerator codeGenerator)
Add logicsheet list to the code generator. |
protected void |
addLogicsheetToList(AbstractMarkupLanguage.LanguageDescriptor language,
String logicsheetLocation)
Add a logicsheet to the code generator. |
void |
configure(Configuration conf)
Process additional configuration. |
void |
dispose()
Release all resources. |
String |
generateCode(Source source,
String filename,
ProgrammingLanguage programmingLanguage)
Generate source code from the input document for the target ProgrammingLanguage . |
String |
getEncoding()
Return the source document's encoding. |
protected LogicsheetFilter |
getLogicsheetFilter()
Return the optional filter to prepocess logicsheets. |
String |
getName()
Return the markup language name. |
String |
getPrefix()
Returns the namespace prefix for this language. |
protected AbstractXMLPipe |
getPreprocessFilter(String filename,
AbstractXMLPipe filter,
ProgrammingLanguage language)
Prepare the input source for logicsheet processing and code generation with a preprocess filter. |
protected AbstractMarkupLanguage.TransformerChainBuilderFilter |
getTransformerChainBuilder(LogicsheetCodeGenerator logicsheetMarkupGenerator)
Returns a filter that chains on the fly the requested transformers for source code generation. |
String |
getURI()
Returns the namespace URI for this language. |
boolean |
hasAttrInterpolation()
Returns true if expansion of attribute expressions is enabled for this language. |
boolean |
hasTextInterpolation()
Returns true if expansion of expressions inside text nodes is enabled for this language. |
void |
recycle()
Recycle this component: clear logic sheet list and dependencies. |
void |
service(ServiceManager manager)
Set the global service manager. |
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 |
Field Detail |
---|
public static final String ATTR_INTERPOLATION
public static final String TEXT_INTERPOLATION
protected String name
protected Map languages
protected Store logicsheetCache
protected ServiceManager manager
Constructor Detail |
---|
public AbstractMarkupLanguage()
Method Detail |
---|
public void configure(Configuration conf) throws ConfigurationException
configure
in interface Configurable
conf
- The language configuration
ConfigurationException
- If an error occurs loading logichseetspublic void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
manager
- The sitemap-specified service manager
ServiceException
public void recycle()
recycle
in interface Recyclable
public void dispose()
dispose
in interface Disposable
public String getName()
public String getURI()
public String getPrefix()
public boolean hasAttrInterpolation()
public boolean hasTextInterpolation()
public String getEncoding()
null
for
the platform's default encoding. The default implementation returns
null
, but derived classes may override it if encoding applies to
their concrete languages.
FIXME: There should be a way to get the
XML document's encoding as seen by the parser; unfortunately, this
information is not returned by current DOM or SAX parsers...
getEncoding
in interface MarkupLanguage
protected AbstractMarkupLanguage.TransformerChainBuilderFilter getTransformerChainBuilder(LogicsheetCodeGenerator logicsheetMarkupGenerator)
logicsheetMarkupGenerator
- the logicsheet markup generator
protected AbstractXMLPipe getPreprocessFilter(String filename, AbstractXMLPipe filter, ProgrammingLanguage language)
XMLFilter
object is the first filter on the
transformer chain. The default implementation does nothing by
returning a identity filter, but derived classes should (at
least) use the passed programming language to quote
Strings
filename
- The source filenamelanguage
- The target programming language
protected abstract void addDependency(String location)
File
's
tested for change on each invocation; this information is used to assert whether regeneration is necessary.
location
- The file path of the dependent fileAbstractMarkupLanguage
,
ServerPagesGenerator
,
AbstractServerPage
public String generateCode(Source source, String filename, ProgrammingLanguage programmingLanguage) throws Exception
ProgrammingLanguage
. After preprocessing the input
document, this method applies logicsheets in the following
order:
generateCode
in interface MarkupLanguage
source
- The input sourcefilename
- The input document's original filenameprogrammingLanguage
- The target programming language
Exception
- If an error occurs during code generationprotected void addLogicsheetsToGenerator(LogicsheetCodeGenerator codeGenerator) throws MalformedURLException, IOException, SAXException, ProcessingException
codeGenerator
- The code generator
MalformedURLException
IOException
SAXException
ProcessingException
protected void addLogicsheetToList(AbstractMarkupLanguage.LanguageDescriptor language, String logicsheetLocation) throws IOException, SAXException, ProcessingException
language
- Target programming language of the logicsheetlogicsheetLocation
- Location of the logicsheet to be added
MalformedURLException
- If location is invalid
IOException
- IO Error
SAXException
- Logicsheet parse error
ProcessingException
protected LogicsheetFilter getLogicsheetFilter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |