If
Executes handlers conditionally when a condition evaluates to true.
Notes
A flow control wrapper that executes then handlers when the condition evaluates to true, and optional else handlers when the condition evaluates to false. Conditions can be nested to create complex conditional processing pipelines.
Examples
Rejects HTML documents and parses everything else.
- YAML
- JSON
- XML
handlers:
- if:
condition:
class: TextCondition
fieldMatcher:
pattern: Content-Type
valueMatcher:
pattern: text/html
then:
- handler:
class: Reject
else:
- handler:
class: DefaultParser
{
"handlers": [
{
"if": {
"condition": {
"class": "TextCondition",
"fieldMatcher": {
"pattern": "Content-Type"
},
"valueMatcher": {
"pattern": "text/html"
}
},
"then": [
{
"handler": {
"class": "Reject"
}
}
],
"else": [
{
"handler": {
"class": "DefaultParser"
}
}
]
}
}
]
}
<handlers>
<if>
<condition class="TextCondition">
<fieldMatcher>Content-Type</fieldMatcher>
<valueMatcher>text/html</valueMatcher>
</condition>
<then>
<handler class="Reject"/>
</then>
<else>
<handler class="DefaultParser"/>
</else>
</if>
</handlers>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
condition:
class: DateCondition
conditionZoneId: string
docZoneId: string
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
format: string
label: string
valueMatcher:
date: string
operator: gt
zoneId: string
valueMatcherRangeEnd:
date: string
operator: gt
zoneId: string
else: []
label: string
name: string
then: []
{
"condition": {
"class": "DateCondition",
"conditionZoneId": "string",
"docZoneId": "string",
"fieldMatcher": {
"ignoreCase": false,
"ignoreDiacritic": false,
"matchEmpty": false,
"method": "BASIC",
"negateMatches": false,
"partial": false,
"pattern": "string",
"replaceAll": false,
"trim": false
},
"format": "string",
"label": "string",
"valueMatcher": {
"date": "string",
"operator": "gt",
"zoneId": "string"
},
"valueMatcherRangeEnd": {
"date": "string",
"operator": "gt",
"zoneId": "string"
}
},
"else": [],
"label": "string",
"name": "string",
"then": []
}
<if>
<condition>
<class>DateCondition</class>
<conditionZoneId>string</conditionZoneId>
<docZoneId>string</docZoneId>
<fieldMatcher/>
<format>string</format>
<label>string</label>
<valueMatcher/>
<valueMatcherRangeEnd/>
</condition>
<else>
<entry/>
</else>
<label>string</label>
<name>string</name>
<then>
<entry/>
</then>
</if>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
condition | Condition | No | - |
else | DocHandler[] | No | - |
label | string | No | - |
name | string | No | if |
then | DocHandler[] | No | - |
Property Details
condition
The condition deciding which branch runs. Any condition component — TextCondition, DateCondition, BlankCondition, ScriptCondition, or one of the AllOf/AnyOf/NoneOf groupings for combining several.
else
The handler or list of handlers to apply when the condition evaluates to false. Optional — leave it out and documents failing the condition simply carry on to the next step.
label
An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.
name
The flow-control keyword identifying this step, if. It is set for you; there is no reason to change it.
then
The handler or list of handlers to apply when the associated condition evaluates to true.