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
ConstructorsModifierConstructorDescriptionprotectedAbstractHtmlToJavaHtmlFlowNodeVisitor(Supplier<T> appendableSupplier, boolean indented) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidappendAttribute(org.jsoup.nodes.Attribute attribute, Class<?> nodeClass) Appends the attribute value and keyvoidAppends the footer of the Java class, i.e closes the method and the classvoidAppends the header of the Java class, i.e the imports, the declaration of the class, the declaration of the method, ...Converts the content of a Java string into a string that can be declared in a Java class passed as a method parameterfinal TReturns the appendable used to store the Java classClass<?>getClassFromNodeName(String nodeName) Returns the class of the node whose name is passed if any, otherwisenullgetMethodFromAttribute(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 Details
-
AbstractHtmlToJavaHtmlFlowNodeVisitor
Constructor- Parameters:
appendableSupplier- the supplier of the appendable, can create or get an appendableindented-trueif the generated HTML source code is indented, otherwisefalse
-
-
Method Details
-
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
Description 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
-
convertJavaStringContentToJavaDeclarableString
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
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
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 IOException Description 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
-