Class XMLFlow<T>
- java.lang.Object
-
- com.norconex.commons.lang.xml.flow.XMLFlow<T>
-
- Type Parameters:
T- type of the object to be submitted to the flow.
public final class XMLFlow<T> extends Object
Treats an XML block as being a mix of predicate and consumer classes to create an execution "flow". The XML syntax below can be used create conditional
Predicatestatements deciding whether to execute or notConsumerobjects.XML Syntax
<!-- Proceeds if condition is true. --> <if> <!-- A single XML "condition" or "conditions" (i.e., condition group). A condition group accepts an operator. Example: --> <conditions operator="[AND|OR]"> <!-- Unless you have a default implementation configured, "condition" expects a "class" attribute pointing to a Predicate implementation. E.g.: --> <condition class="(a Predicate implementation)"> <condition class="(a Predicate implementation)"> </conditions> <then> <!-- Holds one or more XML elements with a "class" attribute pointing to a Consumer implementation. Executed when above condition or condition group evaluates to true. Can also contain nested if/ifNot blocks. --> </then> <else> <!-- Optional. Same as "then" above, but triggered if the condition evaluates to false. Can also contain nested if/ifNot blocks. --> </else> </if> <!-- Proceed if condition is false. --> <ifNot> <!-- Same as "if" tag --> </ifNot>- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CONSUMERS_WRITE_TAG_NAME
-
Constructor Summary
Constructors Constructor Description XMLFlow()XMLFlow(Class<? extends IXMLFlowConsumerAdapter<T>> consumerAdapter, Class<? extends IXMLFlowPredicateAdapter<T>> predicateAdapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Class<? extends IXMLFlowConsumerAdapter<T>>getConsumerAdapter()Class<? extends IXMLFlowPredicateAdapter<T>>getPredicateAdapter()inthashCode()Consumer<T>parse(XML xml)StringtoString()voidwrite(XML xml, Consumer<T> consumer)Writes a flow previously constructed byparse(XML)to XML.
-
-
-
Field Detail
-
DEFAULT_CONSUMERS_WRITE_TAG_NAME
public static final String DEFAULT_CONSUMERS_WRITE_TAG_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMLFlow
public XMLFlow()
-
XMLFlow
public XMLFlow(Class<? extends IXMLFlowConsumerAdapter<T>> consumerAdapter, Class<? extends IXMLFlowPredicateAdapter<T>> predicateAdapter)
-
-
Method Detail
-
getConsumerAdapter
public Class<? extends IXMLFlowConsumerAdapter<T>> getConsumerAdapter()
-
getPredicateAdapter
public Class<? extends IXMLFlowPredicateAdapter<T>> getPredicateAdapter()
-
write
public void write(XML xml, Consumer<T> consumer)
Writes a flow previously constructed byparse(XML)to XML.- Parameters:
xml- the XML to write toconsumer- the consumer flow to write
-
-