Class SnippetContext
- java.lang.Object
-
- org.devacfr.maven.skins.reflow.snippet.SnippetContext
-
public class SnippetContext extends Object
- Version:
- 2.4
- Author:
- Christophe Friederich
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnippetContext.SnippetResourceRepresents a snippet resource.
-
Constructor Summary
Constructors Constructor Description SnippetContext(SnippetParser parser)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Component<?>create(org.jsoup.nodes.Element element, Component<?> parent)Create a component from element and component.Component<?>create(org.jsoup.nodes.Element element, ComponentToken startToken, ComponentToken endToken)Create a component from element and tokens.SnippetParsercreateChildParser()Create a child parser.protected static org.apache.velocity.tools.ToolManagercreateToolManaged()Creates a ToolManager with all generic tools configured.protected org.apache.velocity.context.ContextcreateVelocityContext(org.apache.velocity.context.Context contextParent)Creates a Velocity Context with all generic tools configured wit the site rendering context.org.jsoup.nodes.Elementdocument()Returns the html document.StringgenerateSnippetIdentifier()Generate a unique snippet identifier.ISkinConfiggetConfig()Returns the skin configuration.SnippetParsergetParser()Returns the current parser.Stringhtml()Returns the html source.protected voidmergeTemplate(SnippetComponent<?> component, org.apache.velocity.context.Context contextParent, Writer writer)Merges the template for the given component.protected voidrender(Component<?> component)Render the component.protected StringrenderComponent(SnippetComponent<?> component, org.apache.velocity.context.Context context)voidreset()Reset the context.voidsetConfig(ISkinConfig config)Sets the skin configuration.
-
-
-
Constructor Detail
-
SnippetContext
public SnippetContext(@Nonnull SnippetParser parser)
Constructor.- Parameters:
parser-
-
-
Method Detail
-
reset
public void reset()
Reset the context.
-
generateSnippetIdentifier
public String generateSnippetIdentifier()
Generate a unique snippet identifier.- Returns:
- a unique snippet identifier
-
getParser
public SnippetParser getParser()
Returns the current parser.- Returns:
- the current parser
-
getConfig
public ISkinConfig getConfig()
Returns the skin configuration.- Returns:
- the skin configuration
-
createChildParser
public SnippetParser createChildParser()
Create a child parser.- Returns:
- a new SnippetParser
-
setConfig
public void setConfig(ISkinConfig config)
Sets the skin configuration.- Parameters:
config- the skin configuration
-
html
public String html()
Returns the html source.- Returns:
- the html source
-
document
public org.jsoup.nodes.Element document()
Returns the html document.- Returns:
- the html document
-
create
@Nonnull public Component<?> create(@Nonnull org.jsoup.nodes.Element element, @Nonnull ComponentToken startToken, @Nullable ComponentToken endToken)
Create a component from element and tokens.- Parameters:
element- the html element to use.startToken- the start tokenendToken- the end token.- Returns:
- Returns a new
Componentrepresenting the snippet.
-
create
@Nonnull public Component<?> create(@Nonnull org.jsoup.nodes.Element element, Component<?> parent)
Create a component from element and component.- Parameters:
element- the html element to use.parent- the parent component.- Returns:
- Returns a new
SnippetComponentrepresenting the snippet.
-
render
protected void render(Component<?> component)
Render the component.- Parameters:
component- the component to render.
-
renderComponent
protected String renderComponent(SnippetComponent<?> component, org.apache.velocity.context.Context context)
-
mergeTemplate
protected void mergeTemplate(SnippetComponent<?> component, org.apache.velocity.context.Context contextParent, Writer writer)
Merges the template for the given component.- Parameters:
component- the snippet componentcontextParent- the velocity context parentwriter- the writer to use.
-
createVelocityContext
protected org.apache.velocity.context.Context createVelocityContext(org.apache.velocity.context.Context contextParent)
Creates a Velocity Context with all generic tools configured wit the site rendering context.- Parameters:
contextParent- velocity context parent- Returns:
- a Velocity tools managed context
-
createToolManaged
protected static org.apache.velocity.tools.ToolManager createToolManaged()
Creates a ToolManager with all generic tools configured.- Returns:
- a Velocity tools managed
-
-