Package htmlflow.flowifier
Class AbstractHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>
- java.lang.Object
-
- htmlflow.flowifier.AbstractHtmlToJavaHtmlFlowNodeVisitor<T>
-
- Type Parameters:
T- the type of appendable used to store the Java source code
- All Implemented Interfaces:
HtmlToJavaHtmlFlowNodeVisitor<T>,org.jsoup.select.NodeVisitor
- Direct Known Subclasses:
DefaultHtmlToJavaHtmlFlowNodeVisitor
public abstract class AbstractHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable> extends Object implements HtmlToJavaHtmlFlowNodeVisitor<T>
Defines most of the implementation for a typical visitor of a JSoup node that converts the HTML source code into a Java class except the storage managed by the appendable- Author:
- Julien Gouesse
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHtmlToJavaHtmlFlowNodeVisitor(Supplier<T> appendableSupplier, boolean indented)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendAttribute(org.jsoup.nodes.Attribute attribute, Class<?> nodeClass)Appends the attribute value and keyvoidappendFooter()Appends the footer of the Java class, i.e closes the method and the classvoidappendHeader()Appends the header of the Java class, i.e the imports, the declaration of the class, the declaration of the method, ...StringconvertJavaStringContentToJavaDeclarableString(String unescaped)Converts the content of a Java string into a string that can be declared in a Java class passed as a method parameterTgetAppendable()Returns the appendable used to store the Java classClass<?>getClassFromNodeName(String nodeName)Returns the class of the node whose name is passed if any, otherwisenullMethodgetMethodFromAttribute(Class<?> nodeClass, org.jsoup.nodes.Attribute attribute)Returns the method of the class node that matches with the attribute if any, otherwisenullvoidhead(org.jsoup.nodes.Node node, int depth)booleanisUncloseable(org.jsoup.nodes.Node node)Tells whether a JSoup node cannot be closedvoidtail(org.jsoup.nodes.Node node, int depth)
-
-
-
Constructor Detail
-
AbstractHtmlToJavaHtmlFlowNodeVisitor
protected AbstractHtmlToJavaHtmlFlowNodeVisitor(Supplier<T> appendableSupplier, boolean indented)
Constructor- Parameters:
appendableSupplier- the supplier of the appendable, can create or get an appendableindented-trueif the generated HTML source code is indented, otherwisefalse
-
-
Method Detail
-
getAppendable
public final T getAppendable()
Description copied from interface:HtmlToJavaHtmlFlowNodeVisitorReturns the appendable used to store the Java class- Specified by:
getAppendablein interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Returns:
- the appendable used to store the Java class
-
appendHeader
public void appendHeader() throws IOExceptionDescription copied from interface:HtmlToJavaHtmlFlowNodeVisitorAppends the header of the Java class, i.e the imports, the declaration of the class, the declaration of the method, ...- Specified by:
appendHeaderin interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Throws:
IOException- thrown when something wrong occurs while appending the Java source code
-
appendFooter
public void appendFooter() throws IOExceptionDescription copied from interface:HtmlToJavaHtmlFlowNodeVisitorAppends the footer of the Java class, i.e closes the method and the class- Specified by:
appendFooterin interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Throws:
IOException- thrown when something wrong occurs while appending the Java source code
-
convertJavaStringContentToJavaDeclarableString
public String convertJavaStringContentToJavaDeclarableString(String unescaped)
Description copied from interface:HtmlToJavaHtmlFlowNodeVisitorConverts the content of a Java string into a string that can be declared in a Java class passed as a method parameter- Specified by:
convertJavaStringContentToJavaDeclarableStringin interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Parameters:
unescaped- the content of a Java string- Returns:
- a string that can be declared in a Java class passed as a method parameter
-
isUncloseable
public boolean isUncloseable(org.jsoup.nodes.Node node)
Description copied from interface:HtmlToJavaHtmlFlowNodeVisitorTells whether a JSoup node cannot be closed- Specified by:
isUncloseablein interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Parameters:
node- the JSoup node- Returns:
trueif the JSoup node cannot be closed, otherwisefalse
-
getClassFromNodeName
public Class<?> getClassFromNodeName(String nodeName)
Description copied from interface:HtmlToJavaHtmlFlowNodeVisitorReturns the class of the node whose name is passed if any, otherwisenull- Specified by:
getClassFromNodeNamein interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Parameters:
nodeName- the node name- Returns:
- the class of the node whose name is passed if any, otherwise
null
-
getMethodFromAttribute
public Method getMethodFromAttribute(Class<?> nodeClass, org.jsoup.nodes.Attribute attribute)
Description copied from interface:HtmlToJavaHtmlFlowNodeVisitorReturns the method of the class node that matches with the attribute if any, otherwisenull- Specified by:
getMethodFromAttributein interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Parameters:
nodeClass- the class of the nodeattribute- the attribute- Returns:
- the method of the class node that matches with the attribute if
any, otherwise
null
-
head
public void head(org.jsoup.nodes.Node node, int depth)- Specified by:
headin interfaceorg.jsoup.select.NodeVisitor
-
appendAttribute
public void appendAttribute(org.jsoup.nodes.Attribute attribute, Class<?> nodeClass) throws IOExceptionDescription copied from interface:HtmlToJavaHtmlFlowNodeVisitorAppends the attribute value and key- Specified by:
appendAttributein interfaceHtmlToJavaHtmlFlowNodeVisitor<T extends Appendable>- Parameters:
attribute- the attributenodeClass- the class of the node- Throws:
IOException- thrown when something wrong occurs while appending the Java source code
-
tail
public void tail(org.jsoup.nodes.Node node, int depth)- Specified by:
tailin interfaceorg.jsoup.select.NodeVisitor
-
-