|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shale.clay.config.ClayTemplateParser
public class ClayTemplateParser
This class is responsible for loading an HTML template into a graph of
ComponentBean
's that represents a JSF component tree. It is used by
TemplateConfigBean
, a subclass of
ComponentConfigBean
.
Constructor Summary | |
---|---|
ClayTemplateParser()
|
Method Summary | |
---|---|
protected ComponentBean |
generateElement(URL templateURL,
String templateName)
Loads the template file and parses it into a composition of metadata that's used by the Clay
component. |
Builder |
getBuilder(Node node)
Returns the Builder that
is assigned the task of converting the html node to a corresponding component
metadata used to construct a JSF resource. |
String |
getCharacterEncoding(URL templateURL)
Returns the encoding type used to open the templateURL . |
ConfigBean |
getConfig()
Returns an object pool for HTML template configuration files. |
void |
loadConfigFile(URL templateURL,
String templateName)
Loads the templateURL identified by the
templateName into a graph of ComponentBean 's. |
StringBuffer |
loadTemplate(URL templateURL)
Loads the template file respecting the encoding type. |
void |
setConfig(ConfigBean config)
Sets an object pool for HTML template configuration files. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClayTemplateParser()
Method Detail |
---|
public void setConfig(ConfigBean config)
Sets an object pool for HTML template configuration files.
setConfig
in interface ClayConfigParser
config
- handlerpublic ConfigBean getConfig()
Returns an object pool for HTML template configuration files.
getConfig
in interface ClayConfigParser
public void loadConfigFile(URL templateURL, String templateName) throws IOException, SAXException
Loads the templateURL
identified by the
templateName
into a graph of ComponentBean
's.
loadConfigFile
in interface ClayConfigParser
templateURL
- template filetemplateName
- jsfid
SAXException
- XML parse error
IOException
- XML parse errorprotected ComponentBean generateElement(URL templateURL, String templateName) throws IOException
Loads the template file and parses it into a composition of metadata
that's used by the Clay
component. This metadata is used to construct a JSF subtree within target
view.
templateURL
- template filetemplateName
- jsfid
IOException
- loading template filepublic StringBuffer loadTemplate(URL templateURL) throws IOException
Loads the template file respecting the encoding type.
The file encoding type is determined by calling
the getCharacterEncoding()
method.
templateURL
- target template to load
IOException
- error loading the templatepublic String getCharacterEncoding(URL templateURL) throws IOException
Returns the encoding type used to open the templateURL
.
The template encoding type is resolved using three overrides. The first
step is to look in the target template for a comment token that defines
the charset. The first 512 chars of the templateURL
are read
and scanned for a special comment token.
For example: <-- ### clay:page charset="UTF-8" /### -->
If the Clay page directive is not found, the next override is an
initialization parameter in the web.xml. The value of this parameter
is a global override for all templates.
For example:
<context-param>
<param-name>org.apache.shale.clay.HTML_TEMPLATE_CHARSET
</param-name>
<param-value>UTF-8</param-value>
</context-param>
Otherwise, the defaut is the VM's "file.encoding
"
system parameter.
templateURL
- template URL
IOException
- unable to read the template documentpublic Builder getBuilder(Node node)
Returns the Builder
that
is assigned the task of converting the html node to a corresponding component
metadata used to construct a JSF resource.
node
- markup node
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |