|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.dv.sbu.filehandler.ftl.DefaultSourceParser
public class DefaultSourceParser
Parses a source file's text separating by METADATA, INLUDE, IGNORED content and render COMPONENT call sections. Each command is marked by an opening and a closing tag. The following example uses "<!--#" as opening and "-->" as closing tag. It demonstrates the structure of a source file.
<!--#sbu:metadata attributes={attribute1="value1" attribute2="value2"}
xml={<XML with one
root element - may span multiple lines>}-->
<!--#sbu:include-->
Some text content.
<!--#/sbu:include-->
ignored
<!--#sbu:include ftl="true"-->
Some FTL text content, e.g. 1 + 1 = ${1+1}.
The resource folder is the root for imports.
<!--#/sbu:include-->
<!--#sbu:component name="component 1" attributes={attribute1="value1"}
xml={<XML with one
root element - may span multiple lines>}-->
ignored
The METADATA tag is optional but must be the first one. Attributes and XML definitions are optional. They following additional FTL root map entries will be initialized per INCLUDE or COMPONENT part handling:
COMPONENT and FTL INCLUDE parts use the resource folder as root directory for FTL imports. Components must be registered and point to an initial FREEMARKER template.
Nested Class Summary | |
---|---|
(package private) class |
DefaultSourceParser.ComponentResult
Parsing result for a component tag. |
(package private) class |
DefaultSourceParser.DataResult
Wraps a attributes and XML information. |
(package private) class |
DefaultSourceParser.IncludeResult
Parsing result for an include opening tag. |
Field Summary | |
---|---|
static java.lang.String |
COMPONENT_ATTRIBUTES_NAME
Attribute data for the component attributes: 'componentattributes'. |
static java.lang.String |
COMPONENT_XML_NAME
XML data for the meta data XML content: 'componentxml'. |
static java.lang.String |
COMPONENTNAME_NAME
The name key: 'componentname'. |
static java.lang.String |
METADATA_ATTRIBUTES_NAME
Attribute data for the meta data attributes: 'attributes'. |
static java.lang.String |
METADATA_XML_NAME
XML data for the meta data XML content: 'xml'. |
Constructor Summary | |
---|---|
DefaultSourceParser()
|
Method Summary | |
---|---|
(package private) DefaultSourceParser.ComponentResult |
checkComponent(java.lang.String tagContent)
Checks the given tag content for being a component tag. |
(package private) boolean |
checkIncludeClose(java.lang.String tagContent)
Checks the given tag content for being an include close tag. |
(package private) DefaultSourceParser.IncludeResult |
checkIncludeOpen(java.lang.String tagContent)
Checks the given tag content for being an include open tag. |
(package private) DefaultSourceParser.DataResult |
checkMeta(java.lang.String tagContent)
Checks the given tag content for being a meta tag. |
(package private) DefaultSourceParser.DataResult |
extractAttributesAndXml(java.lang.String tagContent,
int beginIndex)
Extracts attributes and XML data from the given tag content. |
java.util.Map<java.lang.String,java.lang.String> |
getComponents()
Returns the registered render component as mapping from names to the related template paths (that are relative to the resource root). |
java.lang.String |
getIncludeBegin()
Returns the text to be inserted before an INCLUDE section. |
java.lang.String |
getIncludeEnd()
Returns the text to be inserted behind an INCLUDE section. |
java.lang.String |
getTagClose()
Returns the close marker tag. |
java.lang.String |
getTagOpen()
Returns the open marker tag. |
java.lang.String |
parse(java.io.Reader reader,
Configuration configuration,
java.util.Map<java.lang.String,java.lang.Object> rootMap)
Reads from a source file. |
void |
setComponents(java.util.Map<java.lang.String,java.lang.String> components)
Sets the available components. |
void |
setIncludeBegin(java.lang.String includeBegin)
Sets the INCLUDE prefix text. |
void |
setIncludeEnd(java.lang.String includeEnd)
Sets the INCLUDE suffix. |
void |
setTagClose(java.lang.String s)
Sets the tag closing text. |
void |
setTagOpen(java.lang.String s)
Sets the tag opening text. |
(package private) int |
skipWhitespacePosition(java.lang.String tagContent,
int beginIndex)
Returns the next non-whitespace index (maybe the text's length). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String METADATA_ATTRIBUTES_NAME
java.util.Map
.
public static final java.lang.String METADATA_XML_NAME
NodeModel
.
public static final java.lang.String COMPONENT_ATTRIBUTES_NAME
public static final java.lang.String COMPONENT_XML_NAME
NodeModel
.
public static final java.lang.String COMPONENTNAME_NAME
Constructor Detail |
---|
public DefaultSourceParser()
Method Detail |
---|
public java.lang.String getTagOpen()
public void setTagOpen(java.lang.String s) throws java.lang.NullPointerException
s
- The text to use.
java.lang.NullPointerException
- The argument is null
.public java.lang.String getTagClose()
public void setTagClose(java.lang.String s) throws java.lang.NullPointerException
s
- The text to use.
java.lang.NullPointerException
- The argument is null
.public java.lang.String getIncludeBegin()
public void setIncludeBegin(java.lang.String includeBegin) throws java.lang.NullPointerException
includeBegin
- The text to set.
java.lang.NullPointerException
- The text is null
.public java.lang.String getIncludeEnd()
public void setIncludeEnd(java.lang.String includeEnd) throws java.lang.NullPointerException
includeEnd
- The text to set.
java.lang.NullPointerException
- The text is null
.public java.util.Map<java.lang.String,java.lang.String> getComponents()
public void setComponents(java.util.Map<java.lang.String,java.lang.String> components) throws java.lang.NullPointerException
components
- The components to set.
java.lang.NullPointerException
- The argument is null
.public java.lang.String parse(java.io.Reader reader, Configuration configuration, java.util.Map<java.lang.String,java.lang.Object> rootMap) throws java.lang.Exception
parse
in interface ISourceParser
reader
- The reader consuming the related source file's text content.configuration
- The Freemarker configuration to use.rootMap
- The FTL root map. Might be modified.
java.lang.Exception
- Any exception.de.dv.sbu.filehandler.ftl.ISourceParser#parse(java.io.Reader, freemarker.template.Configuration, java.util.Map)
int skipWhitespacePosition(java.lang.String tagContent, int beginIndex)
tagContent
- The text to parse.beginIndex
- The beginning index.
DefaultSourceParser.DataResult extractAttributesAndXml(java.lang.String tagContent, int beginIndex)
tagContent
- The tag content to check.beginIndex
- The index offset.
null
on mismatch.boolean checkIncludeClose(java.lang.String tagContent)
tagContent
- The tag content to check.
true
if the tag content matches the INCLUDE close pattern.DefaultSourceParser.IncludeResult checkIncludeOpen(java.lang.String tagContent)
tagContent
- The tag content to check.
null
on mismatch.DefaultSourceParser.ComponentResult checkComponent(java.lang.String tagContent)
tagContent
- The tag content to check.
null
on mismatch.DefaultSourceParser.DataResult checkMeta(java.lang.String tagContent)
tagContent
- The tag content to check.
null
on mismatch.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |