Class SnippetContext


  • public class SnippetContext
    extends Object
    Version:
    2.4
    Author:
    Christophe Friederich
    • 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,
                                   Component<?> parent)
        Create a component from element and component.
        Parameters:
        element - the html element to use.
        parent - the parent component.
        Returns:
        Returns a new SnippetComponent representing 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 component
        contextParent - the velocity context parent
        writer - 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