Class SnippetParser
- java.lang.Object
-
- org.devacfr.maven.skins.reflow.snippet.SnippetParser
-
public class SnippetParser extends Object
- Version:
- 2.4
- Author:
- Christophe Friederich
-
-
Constructor Summary
Constructors Constructor Description SnippetParser()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SnippetParseraddResourcePath(String... path)Add a resource path.protected ComponentTokencurrentToken()SnippetContextgetSnippetContext()List<String>getSnippetPaths()protected Map<String,SnippetContext.SnippetResource>getSnippetResources()protected List<String>getSnippets()org.apache.velocity.context.ContextgetVelocityContext()booleanhasIncludedSnippetComponent(org.jsoup.nodes.Element document)Check if the document contains at least one snippet component.SnippetParserinsertResourcePath(int index, String path)Insert a resource path at the given index.booleanisSnippet(String nodeName)booleanisSnippet(org.jsoup.nodes.Node node)protected voidparse()Parse the current element.SnippetContextparse(ISkinConfig config, String htmlSource)Parse the given HTML source.protected voidparse(ComponentToken token)protected ComponentTokenpop()protected voidpush(ComponentToken token)Push a component token onto the stack.SnippetParserrefreshParser()Refresh the parser by reloading snippet resources.
-
-
-
Method Detail
-
getSnippetResources
@Nonnull protected Map<String,SnippetContext.SnippetResource> getSnippetResources()
- Returns:
- Returns the snippet resources.
-
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 addindex- 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
trueif the node is a snippet component.
-
isSnippet
public boolean isSnippet(String nodeName)
- Parameters:
nodeName- the Jsoup node name to use- Returns:
- Returns
trueif 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
trueif the document contains at least one snippet component.
-
parse
public SnippetContext parse(ISkinConfig config, @Nullable String htmlSource) throws IOException
Parse the given HTML source.- Parameters:
config- the skin confightmlSource- the HTML source to parse- Returns:
- Returns the snippet context.
- Throws:
IOException- if an I/O error occurs.
-
parse
protected void parse()
Parse the current element.
-
parse
protected void parse(ComponentToken token)
-
currentToken
protected ComponentToken currentToken()
-
pop
protected ComponentToken pop()
-
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()
-
-