Class SnippetParser


  • public class SnippetParser
    extends Object
    Version:
    2.4
    Author:
    Christophe Friederich
    • Constructor Detail

      • SnippetParser

        public SnippetParser()
        Constructor.
    • Method Detail

      • getSnippets

        @Nonnull
        protected List<String> getSnippets()
        Returns:
        Returns the snippet names.
      • getSnippetPaths

        @Nonnull
        public List<String> getSnippetPaths()
        Returns:
        Returns the snippet resource paths.
      • insertResourcePath

        public SnippetParser insertResourcePath​(int index,
                                                @Nonnull
                                                String path)
        Insert a resource path at the given index.
        Parameters:
        path - the resource path to add
        index - the index where to insert the path
        Returns:
        Returns this parser.
      • addResourcePath

        public SnippetParser addResourcePath​(@Nonnull
                                             String... path)
        Add a resource path.
        Parameters:
        path - the resource path to add
        Returns:
        Returns this parser.
      • refreshParser

        public SnippetParser refreshParser()
        Refresh the parser by reloading snippet resources.
        Returns:
        Returns this parser.
      • isSnippet

        public boolean isSnippet​(org.jsoup.nodes.Node node)
        Parameters:
        node - the Jsoup node to use
        Returns:
        Returns true if the node is a snippet component.
      • isSnippet

        public boolean isSnippet​(String nodeName)
        Parameters:
        nodeName - the Jsoup node name to use
        Returns:
        Returns true if the node name is a snippet component.
      • hasIncludedSnippetComponent

        public boolean hasIncludedSnippetComponent​(org.jsoup.nodes.Element document)
        Check if the document contains at least one snippet component.
        Parameters:
        document - the Jsoup element to use
        Returns:
        Returns true if the document contains at least one snippet component.
      • parse

        protected void parse()
        Parse the current element.
      • push

        protected void push​(ComponentToken token)
        Push a component token onto the stack.
        Parameters:
        token - the component token to push
      • getSnippetContext

        public SnippetContext getSnippetContext()
        Returns:
        Returns the snippet context.
      • getVelocityContext

        public org.apache.velocity.context.Context getVelocityContext()