You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/10/26 09:50:41 UTC
[camel] 01/01: CAMEL-17505: camel-core - Propose a DSL for data formats
This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch CAMEL-17505/data-format-dsl
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ebb61cc0c2e1c260384b91657cc8f3e51f691f79
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Wed Oct 26 11:49:56 2022 +0200
CAMEL-17505: camel-core - Propose a DSL for data formats
---
.../camel/catalog/dataformats/univocityCsv.json | 2 +-
.../camel/catalog/dataformats/univocityFixed.json | 2 +-
.../camel/catalog/dataformats/univocityTsv.json | 2 +-
.../apache/camel/catalog/models/univocityCsv.json | 2 +-
.../camel/catalog/models/univocityFixed.json | 2 +-
.../apache/camel/catalog/models/univocityTsv.json | 2 +-
.../apache/camel/catalog/schemas/camel-spring.xsd | 2 +-
.../camel/dataformat/univocity/univocityCsv.json | 2 +-
.../camel/dataformat/univocity/univocityFixed.json | 2 +-
.../camel/dataformat/univocity/univocityTsv.json | 2 +-
.../camel/model/dataformat/univocityCsv.json | 2 +-
.../camel/model/dataformat/univocityFixed.json | 2 +-
.../camel/model/dataformat/univocityTsv.json | 2 +-
.../DataFormatBuilder.java} | 21 +-
.../camel/builder/DataFormatBuilderFactory.java | 349 +++++++++++++++++++++
.../org/apache/camel/builder/RouteBuilder.java | 21 ++
.../camel/model/dataformat/ASN1DataFormat.java | 50 +++
.../camel/model/dataformat/Any23DataFormat.java | 75 +++++
.../camel/model/dataformat/AvroDataFormat.java | 274 ++++++++++++++++
.../camel/model/dataformat/BarcodeDataFormat.java | 58 ++++
.../camel/model/dataformat/Base64DataFormat.java | 54 ++++
.../camel/model/dataformat/BindyDataFormat.java | 85 +++++
.../camel/model/dataformat/CBORDataFormat.java | 155 +++++++++
.../camel/model/dataformat/CryptoDataFormat.java | 113 +++++++
.../camel/model/dataformat/CsvDataFormat.java | 314 ++++++++++++++++++
.../camel/model/dataformat/CustomDataFormat.java | 29 ++
.../camel/model/dataformat/FhirDataformat.java | 279 ++++++++++++++++
.../camel/model/dataformat/FhirJsonDataFormat.java | 16 +
.../camel/model/dataformat/FhirXmlDataFormat.java | 16 +
.../camel/model/dataformat/FlatpackDataFormat.java | 103 ++++++
.../camel/model/dataformat/GrokDataFormat.java | 61 ++++
.../model/dataformat/GzipDeflaterDataFormat.java | 12 +
.../camel/model/dataformat/HL7DataFormat.java | 39 +++
.../camel/model/dataformat/IcalDataFormat.java | 28 ++
.../model/dataformat/JacksonXMLDataFormat.java | 229 ++++++++++++++
.../camel/model/dataformat/JaxbDataFormat.java | 224 +++++++++++++
.../camel/model/dataformat/JsonApiDataFormat.java | 38 +++
.../camel/model/dataformat/JsonDataFormat.java | 328 ++++++++++++++++++-
.../camel/model/dataformat/LZFDataFormat.java | 29 ++
.../model/dataformat/MimeMultipartDataFormat.java | 82 +++++
.../camel/model/dataformat/PGPDataFormat.java | 184 +++++++++++
.../camel/model/dataformat/ProtobufDataFormat.java | 284 +++++++++++++++++
.../camel/model/dataformat/RssDataFormat.java | 12 +
.../camel/model/dataformat/SoapDataFormat.java | 124 ++++++++
.../camel/model/dataformat/SwiftMtDataFormat.java | 40 +++
.../camel/model/dataformat/SwiftMxDataFormat.java | 91 ++++++
.../camel/model/dataformat/SyslogDataFormat.java | 13 +
.../camel/model/dataformat/TarFileDataFormat.java | 64 ++++
.../camel/model/dataformat/ThriftDataFormat.java | 53 ++++
.../model/dataformat/TidyMarkupDataFormat.java | 51 +++
.../dataformat/UniVocityAbstractDataFormat.java | 182 ++++++++++-
.../model/dataformat/UniVocityCsvDataFormat.java | 57 ++++
.../model/dataformat/UniVocityFixedDataFormat.java | 53 ++++
.../model/dataformat/UniVocityTsvDataFormat.java | 27 ++
.../model/dataformat/XMLSecurityDataFormat.java | 202 ++++++++++++
.../camel/model/dataformat/XStreamDataFormat.java | 175 ++++++++++-
.../camel/model/dataformat/YAMLDataFormat.java | 162 ++++++++++
.../model/dataformat/ZipDeflaterDataFormat.java | 30 ++
.../camel/model/dataformat/ZipFileDataFormat.java | 66 ++++
.../camel/impl/DataFormatFluentSyntaxTest.java} | 32 +-
60 files changed, 4962 insertions(+), 48 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityCsv.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityCsv.json
index 9c05e32d54d..cafa1b6ef8a 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityCsv.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityCsv.json
@@ -22,7 +22,7 @@
"quoteEscape": { "kind": "attribute", "displayName": "Quote Escape", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\"", "description": "The quote escape symbol" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityFixed.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityFixed.json
index 0f060ba3059..55b60d5afaf 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityFixed.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityFixed.json
@@ -21,7 +21,7 @@
"recordEndsOnNewline": { "kind": "attribute", "displayName": "Record Ends On Newline", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the record ends on new line. The default value is false" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityTsv.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityTsv.json
index 39c90738dfb..07bb5bba9b1 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityTsv.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/univocityTsv.json
@@ -19,7 +19,7 @@
"escapeChar": { "kind": "attribute", "displayName": "Escape Char", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\\", "description": "The escape character." },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityCsv.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityCsv.json
index e0047cac1bc..09ff79144ad 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityCsv.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityCsv.json
@@ -19,7 +19,7 @@
"quoteEscape": { "kind": "attribute", "displayName": "Quote Escape", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\"", "description": "The quote escape symbol" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityFixed.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityFixed.json
index 9fe2a46e659..9d1e322b9ae 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityFixed.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityFixed.json
@@ -18,7 +18,7 @@
"recordEndsOnNewline": { "kind": "attribute", "displayName": "Record Ends On Newline", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the record ends on new line. The default value is false" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityTsv.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityTsv.json
index 8819ce92c9b..0a1e87d208b 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityTsv.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/univocityTsv.json
@@ -16,7 +16,7 @@
"escapeChar": { "kind": "attribute", "displayName": "Escape Char", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\\", "description": "The escape character." },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 25db02dca09..9a333cd58c8 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -12321,7 +12321,7 @@ Default value: true
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[
-Whether or not the trailing white spaces must ignored. The default value is
+Whether or not the trailing white spaces must be ignored. The default value is
true. Default value: true
]]>
</xs:documentation>
diff --git a/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityCsv.json b/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityCsv.json
index 9c05e32d54d..cafa1b6ef8a 100644
--- a/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityCsv.json
+++ b/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityCsv.json
@@ -22,7 +22,7 @@
"quoteEscape": { "kind": "attribute", "displayName": "Quote Escape", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\"", "description": "The quote escape symbol" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityFixed.json b/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityFixed.json
index 0f060ba3059..55b60d5afaf 100644
--- a/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityFixed.json
+++ b/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityFixed.json
@@ -21,7 +21,7 @@
"recordEndsOnNewline": { "kind": "attribute", "displayName": "Record Ends On Newline", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the record ends on new line. The default value is false" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityTsv.json b/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityTsv.json
index 39c90738dfb..07bb5bba9b1 100644
--- a/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityTsv.json
+++ b/components/camel-univocity-parsers/src/generated/resources/org/apache/camel/dataformat/univocity/univocityTsv.json
@@ -19,7 +19,7 @@
"escapeChar": { "kind": "attribute", "displayName": "Escape Char", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\\", "description": "The escape character." },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityCsv.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityCsv.json
index e0047cac1bc..09ff79144ad 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityCsv.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityCsv.json
@@ -19,7 +19,7 @@
"quoteEscape": { "kind": "attribute", "displayName": "Quote Escape", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\"", "description": "The quote escape symbol" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityFixed.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityFixed.json
index 9fe2a46e659..9d1e322b9ae 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityFixed.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityFixed.json
@@ -18,7 +18,7 @@
"recordEndsOnNewline": { "kind": "attribute", "displayName": "Record Ends On Newline", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the record ends on new line. The default value is false" },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityTsv.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityTsv.json
index 8819ce92c9b..0a1e87d208b 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityTsv.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/univocityTsv.json
@@ -16,7 +16,7 @@
"escapeChar": { "kind": "attribute", "displayName": "Escape Char", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\\", "description": "The escape character." },
"nullValue": { "kind": "attribute", "displayName": "Null Value", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The string representation of a null value. The default value is null" },
"skipEmptyLines": { "kind": "attribute", "displayName": "Skip Empty Lines", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the empty lines must be ignored. The default value is true" },
- "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must ignored. The default value is true" },
+ "ignoreTrailingWhitespaces": { "kind": "attribute", "displayName": "Ignore Trailing Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the trailing white spaces must be ignored. The default value is true" },
"ignoreLeadingWhitespaces": { "kind": "attribute", "displayName": "Ignore Leading Whitespaces", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether or not the leading white spaces must be ignored. The default value is true" },
"headersDisabled": { "kind": "attribute", "displayName": "Headers Disabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which indicates that there is no header. The default value is false" },
"headerExtractionEnabled": { "kind": "attribute", "displayName": "Header Extraction Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the header must be read in the first line of the test document The default value is false" },
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilder.java
similarity index 63%
copy from core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
copy to core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilder.java
index 0aab050323a..ca0a6493f22 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilder.java
@@ -14,22 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.model.dataformat;
-
-import javax.xml.bind.annotation.XmlRootElement;
+package org.apache.camel.builder;
import org.apache.camel.model.DataFormatDefinition;
-import org.apache.camel.spi.Metadata;
/**
- * Compress and decompress messages using <code>java.util.zip.GZIP*Stream</code>.
+ * {@code DataFormatBuilder} defines the contract of a data format builder.
*/
-@Metadata(firstVersion = "2.0.0", label = "dataformat,transformation", title = "GZip Deflater")
-@XmlRootElement(name = "gzipDeflater")
-public class GzipDeflaterDataFormat extends DataFormatDefinition {
-
- public GzipDeflaterDataFormat() {
- super("gzipDeflater");
- }
+public interface DataFormatBuilder<T extends DataFormatDefinition> {
+ /**
+ * Ends the build of the data format.
+ *
+ * @return the data format fully built.
+ */
+ T end();
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java
new file mode 100644
index 00000000000..ef1b78cc86c
--- /dev/null
+++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder;
+
+import org.apache.camel.model.dataformat.ASN1DataFormat;
+import org.apache.camel.model.dataformat.Any23DataFormat;
+import org.apache.camel.model.dataformat.AvroDataFormat;
+import org.apache.camel.model.dataformat.BarcodeDataFormat;
+import org.apache.camel.model.dataformat.Base64DataFormat;
+import org.apache.camel.model.dataformat.BindyDataFormat;
+import org.apache.camel.model.dataformat.CBORDataFormat;
+import org.apache.camel.model.dataformat.CryptoDataFormat;
+import org.apache.camel.model.dataformat.CsvDataFormat;
+import org.apache.camel.model.dataformat.CustomDataFormat;
+import org.apache.camel.model.dataformat.FhirJsonDataFormat;
+import org.apache.camel.model.dataformat.FhirXmlDataFormat;
+import org.apache.camel.model.dataformat.FlatpackDataFormat;
+import org.apache.camel.model.dataformat.GrokDataFormat;
+import org.apache.camel.model.dataformat.GzipDeflaterDataFormat;
+import org.apache.camel.model.dataformat.HL7DataFormat;
+import org.apache.camel.model.dataformat.IcalDataFormat;
+import org.apache.camel.model.dataformat.JacksonXMLDataFormat;
+import org.apache.camel.model.dataformat.JaxbDataFormat;
+import org.apache.camel.model.dataformat.JsonApiDataFormat;
+import org.apache.camel.model.dataformat.JsonDataFormat;
+import org.apache.camel.model.dataformat.LZFDataFormat;
+import org.apache.camel.model.dataformat.MimeMultipartDataFormat;
+import org.apache.camel.model.dataformat.PGPDataFormat;
+import org.apache.camel.model.dataformat.ProtobufDataFormat;
+import org.apache.camel.model.dataformat.RssDataFormat;
+import org.apache.camel.model.dataformat.SoapDataFormat;
+import org.apache.camel.model.dataformat.SwiftMtDataFormat;
+import org.apache.camel.model.dataformat.SwiftMxDataFormat;
+import org.apache.camel.model.dataformat.SyslogDataFormat;
+import org.apache.camel.model.dataformat.TarFileDataFormat;
+import org.apache.camel.model.dataformat.ThriftDataFormat;
+import org.apache.camel.model.dataformat.TidyMarkupDataFormat;
+import org.apache.camel.model.dataformat.UniVocityCsvDataFormat;
+import org.apache.camel.model.dataformat.UniVocityFixedDataFormat;
+import org.apache.camel.model.dataformat.UniVocityTsvDataFormat;
+import org.apache.camel.model.dataformat.XMLSecurityDataFormat;
+import org.apache.camel.model.dataformat.XStreamDataFormat;
+import org.apache.camel.model.dataformat.YAMLDataFormat;
+import org.apache.camel.model.dataformat.ZipDeflaterDataFormat;
+import org.apache.camel.model.dataformat.ZipFileDataFormat;
+
+/**
+ * {@code DataFormatBuilderFactory} is a factory class of builder of all supported data formats.
+ */
+public class DataFormatBuilderFactory {
+
+ /**
+ * Uses the Any23 data format
+ */
+ public Any23DataFormat.Builder any23() {
+ return new Any23DataFormat.Builder();
+ }
+
+ /**
+ * Uses the ASN.1 file data format
+ */
+ public ASN1DataFormat.Builder asn1() {
+ return new ASN1DataFormat.Builder();
+ }
+
+ /**
+ * Uses the Avro data format
+ */
+ public AvroDataFormat.Builder avro() {
+ return new AvroDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Barcode data format
+ */
+ public BarcodeDataFormat.Builder barcode() {
+ return new BarcodeDataFormat.Builder();
+ }
+
+ /**
+ * Uses the base64 data format
+ */
+ public Base64DataFormat.Builder base64() {
+ return new Base64DataFormat.Builder();
+ }
+
+ /**
+ * Uses the Bindy data format
+ */
+ public BindyDataFormat.Builder bindy() {
+ return new BindyDataFormat.Builder();
+ }
+
+ /**
+ * Uses the CBOR data format
+ */
+ public CBORDataFormat.Builder cbor() {
+ return new CBORDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Crypto data format
+ */
+ public CryptoDataFormat.Builder crypto() {
+ return new CryptoDataFormat.Builder();
+ }
+
+ /**
+ * Uses the CSV data format
+ */
+ public CsvDataFormat.Builder csv() {
+ return new CsvDataFormat.Builder();
+ }
+
+ /**
+ * Uses the custom data format
+ */
+ public CustomDataFormat.Builder custom() {
+ return new CustomDataFormat.Builder();
+ }
+
+ /**
+ * Uses the FHIR JSON data format
+ */
+ public FhirJsonDataFormat.Builder fhirJson() {
+ return new FhirJsonDataFormat.Builder();
+ }
+
+ /**
+ * Uses the FHIR XML data format
+ */
+ public FhirXmlDataFormat.Builder fhirXml() {
+ return new FhirXmlDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Flatpack data format
+ */
+ public FlatpackDataFormat.Builder flatpack() {
+ return new FlatpackDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Grok data format
+ */
+ public GrokDataFormat.Builder grok() {
+ return new GrokDataFormat.Builder();
+ }
+
+ /**
+ * Uses the GZIP deflater data format
+ */
+ public GzipDeflaterDataFormat.Builder gzipDeflater() {
+ return new GzipDeflaterDataFormat.Builder();
+ }
+
+ /**
+ * Uses the HL7 data format
+ */
+ public HL7DataFormat.Builder hl7() {
+ return new HL7DataFormat.Builder();
+ }
+
+ /**
+ * Uses the iCal data format
+ */
+ public IcalDataFormat.Builder ical() {
+ return new IcalDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Jackson XML data format
+ */
+ public JacksonXMLDataFormat.Builder jacksonXml() {
+ return new JacksonXMLDataFormat.Builder();
+ }
+
+ /**
+ * Uses the JAXB data format
+ */
+ public JaxbDataFormat.Builder jaxb() {
+ return new JaxbDataFormat.Builder();
+ }
+
+ /**
+ * Uses the JSON API data format
+ */
+ public JsonApiDataFormat.Builder jsonApi() {
+ return new JsonApiDataFormat.Builder();
+ }
+
+ /**
+ * Uses the JSON data format using the Jackson library
+ */
+ public JsonDataFormat.Builder json() {
+ return new JsonDataFormat.Builder();
+ }
+
+ /**
+ * Uses the LZF deflater data format
+ */
+ public LZFDataFormat.Builder lzf() {
+ return new LZFDataFormat.Builder();
+ }
+
+ /**
+ * Uses the MIME Multipart data format
+ */
+ public MimeMultipartDataFormat.Builder mimeMultipart() {
+ return new MimeMultipartDataFormat.Builder();
+ }
+
+ /**
+ * Uses the PGP data format
+ */
+ public PGPDataFormat.Builder pgp() {
+ return new PGPDataFormat.Builder();
+ }
+
+ /**
+ * Uses the protobuf data format
+ */
+ public ProtobufDataFormat.Builder protobuf() {
+ return new ProtobufDataFormat.Builder();
+ }
+
+ /**
+ * Uses the RSS data format
+ */
+ public RssDataFormat.Builder rss() {
+ return new RssDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Soap v1.1 data format
+ */
+ public SoapDataFormat.Builder soap() {
+ return new SoapDataFormat.Builder();
+ }
+
+ /**
+ * Uses the SWIFT MX data format
+ */
+ public SwiftMxDataFormat.Builder swiftMx() {
+ return new SwiftMxDataFormat.Builder();
+ }
+
+ /**
+ * Uses the SWIFT MT data format
+ */
+ public SwiftMtDataFormat.Builder swiftMt() {
+ return new SwiftMtDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Syslog data format
+ */
+ public SyslogDataFormat.Builder syslog() {
+ return new SyslogDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Tar file data format
+ */
+ public TarFileDataFormat.Builder tarFile() {
+ return new TarFileDataFormat.Builder();
+ }
+
+ /**
+ * Uses the Thrift data format
+ */
+ public ThriftDataFormat.Builder thrift() {
+ return new ThriftDataFormat.Builder();
+ }
+
+ /**
+ * Return TidyMarkup in the default format as {@link org.w3c.dom.Node}
+ */
+ public TidyMarkupDataFormat.Builder tidyMarkup() {
+ return new TidyMarkupDataFormat.Builder();
+ }
+
+ /**
+ * Uses the UniVosity CSV data format
+ */
+ public UniVocityCsvDataFormat.Builder univocityCsv() {
+ return new UniVocityCsvDataFormat.Builder();
+ }
+
+ /**
+ * Uses the UniVosity Fixed data format
+ */
+ public UniVocityFixedDataFormat.Builder univocityFixed() {
+ return new UniVocityFixedDataFormat.Builder();
+ }
+
+ public UniVocityTsvDataFormat.Builder univocityTsv() {
+ return new UniVocityTsvDataFormat.Builder();
+ }
+
+ /**
+ * Uses the XML Security data format
+ */
+ public XMLSecurityDataFormat.Builder xmlSecurity() {
+ return new XMLSecurityDataFormat.Builder();
+ }
+
+ /**
+ * Uses the XStream data format.
+ */
+ public XStreamDataFormat.Builder xstream() {
+ return new XStreamDataFormat.Builder();
+ }
+
+ /**
+ * Uses the YAML data format
+ */
+ public YAMLDataFormat.Builder yaml() {
+ return new YAMLDataFormat.Builder();
+ }
+
+ /**
+ * Uses the ZIP deflater data format
+ */
+ public ZipDeflaterDataFormat.Builder zipDeflater() {
+ return new ZipDeflaterDataFormat.Builder();
+ }
+
+ /**
+ * Uses the ZIP file data format
+ */
+ public ZipFileDataFormat.Builder zipFile() {
+ return new ZipFileDataFormat.Builder();
+ }
+}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/builder/RouteBuilder.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/RouteBuilder.java
index 359bad8d584..7883924c46b 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/builder/RouteBuilder.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/RouteBuilder.java
@@ -220,6 +220,27 @@ public abstract class RouteBuilder extends BuilderSupport implements RoutesBuild
*/
public void bindToRegistry(String id, Class<?> type, Object bean) {
getContext().getRegistry().bind(id, type, bean);
+
+ }
+
+ /**
+ * A utility method allowing to build any data format using a fluent syntax, as shown in the next example:
+ *
+ * <pre>
+ * {@code
+ * from("jms:queue:orders)
+ * .marshal(
+ * dataFormat()
+ * .swiftMt()
+ * .writeInJson(true)
+ * .end()
+ * )
+ * .to("file:data"");
+ *
+ * @return an entry point to the builder of all supported data formats.
+ */
+ public DataFormatBuilderFactory dataFormat() {
+ return new DataFormatBuilderFactory();
}
/**
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ASN1DataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ASN1DataFormat.java
index 265cc952bab..cc4db1f2839 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ASN1DataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ASN1DataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -58,10 +59,18 @@ public class ASN1DataFormat extends DataFormatDefinition {
}
public ASN1DataFormat(Class<?> unmarshalType) {
+ this();
setUsingIterator(Boolean.toString(true));
this.unmarshalType = unmarshalType;
}
+ private ASN1DataFormat(Builder builder) {
+ this();
+ this.usingIterator = builder.usingIterator;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.unmarshalType = builder.unmarshalType;
+ }
+
public String getUsingIterator() {
return usingIterator;
}
@@ -95,4 +104,45 @@ public class ASN1DataFormat extends DataFormatDefinition {
public void setUnmarshalType(Class<?> unmarshalType) {
this.unmarshalType = unmarshalType;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link ASN1DataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<ASN1DataFormat> {
+
+ private Class<?> unmarshalType;
+ private String unmarshalTypeName;
+ private String usingIterator;
+
+ /**
+ * If the asn1 file has more than one entry, the setting this option to true, allows working with the splitter
+ * EIP, to split the data using an iterator in a streaming mode.
+ */
+ public Builder usingIterator(String usingIterator) {
+ this.usingIterator = usingIterator;
+ return this;
+ }
+
+ /**
+ * Class to use when unmarshalling.
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * Class to use when unmarshalling.
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ @Override
+ public ASN1DataFormat end() {
+ return new ASN1DataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Any23DataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Any23DataFormat.java
index aadb5c46784..9c7914f060a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Any23DataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Any23DataFormat.java
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.model.PropertyDefinition;
import org.apache.camel.spi.Metadata;
@@ -81,6 +82,14 @@ public class Any23DataFormat extends DataFormatDefinition {
this.extractors = extractors;
}
+ private Any23DataFormat(Builder builder) {
+ this(builder.baseUri);
+ this.outputFormat = builder.outputFormat;
+ this.configuration = builder.configuration;
+ this.configurations = builder.configurations;
+ this.extractors = builder.extractors;
+ }
+
public String getOutputFormat() {
return outputFormat;
}
@@ -154,4 +163,70 @@ public class Any23DataFormat extends DataFormatDefinition {
this.baseUri = baseUri;
}
+ /**
+ * {@code Builder} is a specific builder for {@link Any23DataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<Any23DataFormat> {
+
+ private String outputFormat = "RDF4JMODEL";
+ private String baseUri;
+ private List<PropertyDefinition> configuration;
+ private Map<String, String> configurations;
+ private List<String> extractors;
+
+ /**
+ * What RDF syntax to unmarshal as, can be: NTRIPLES, TURTLE, NQUADS, RDFXML, JSONLD, RDFJSON, RDF4JMODEL. It is
+ * by default: RDF4JMODEL.
+ */
+ public Builder outputFormat(String outputFormat) {
+ this.outputFormat = outputFormat;
+ return this;
+ }
+
+ /**
+ * Configurations for Apache Any23 as key-value pairs in order to customize the extraction process. The list of
+ * supported parameters can be found <a href=
+ * "https://github.com/apache/any23/blob/master/api/src/main/resources/default-configuration.properties">here</a>.
+ * If not provided, a default configuration is used.
+ */
+ public Builder configuration(List<PropertyDefinition> configuration) {
+ this.configuration = configuration;
+ return this;
+ }
+
+ /**
+ * Configurations for Apache Any23 as key-value pairs in order to customize the extraction process. The list of
+ * supported parameters can be found <a href=
+ * "https://github.com/apache/any23/blob/master/api/src/main/resources/default-configuration.properties">here</a>.
+ * If not provided, a default configuration is used.
+ */
+ public Builder configuration(Map<String, String> configurations) {
+ this.configurations = configurations;
+ return this;
+ }
+
+ /**
+ * The URI to use as base for building RDF entities if only relative paths are provided.
+ */
+ public Builder baseUri(String baseUri) {
+ this.baseUri = baseUri;
+ return this;
+ }
+
+ /**
+ * List of Any23 extractors to be used in the unmarshal operation. A list of the available extractors can be
+ * found here <a href="https://any23.apache.org/getting-started.html">here</a>. If not provided, all the
+ * available extractors are used.
+ */
+ public Builder extractors(List<String> extractors) {
+ this.extractors = extractors;
+ return this;
+ }
+
+ @Override
+ public Any23DataFormat end() {
+ return new Any23DataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java
index ea505f5c244..4ffe779bf1b 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -113,6 +114,34 @@ public class AvroDataFormat extends DataFormatDefinition {
setInstanceClassName(instanceClassName);
}
+ private AvroDataFormat(Builder builder) {
+ this();
+ this.unmarshalType = builder.unmarshalType;
+ this.jsonView = builder.jsonView;
+ this.collectionType = builder.collectionType;
+ this.schema = builder.schema;
+ this.instanceClassName = builder.instanceClassName;
+ this.library = builder.library;
+ this.objectMapper = builder.objectMapper;
+ this.useDefaultObjectMapper = builder.useDefaultObjectMapper;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.jsonViewTypeName = builder.jsonViewTypeName;
+ this.include = builder.include;
+ this.allowJmsType = builder.allowJmsType;
+ this.collectionTypeName = builder.collectionTypeName;
+ this.useList = builder.useList;
+ this.moduleClassNames = builder.moduleClassNames;
+ this.moduleRefs = builder.moduleRefs;
+ this.enableFeatures = builder.enableFeatures;
+ this.disableFeatures = builder.disableFeatures;
+ this.allowUnmarshallType = builder.allowUnmarshallType;
+ this.timezone = builder.timezone;
+ this.autoDiscoverObjectMapper = builder.autoDiscoverObjectMapper;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ this.schemaResolver = builder.schemaResolver;
+ this.autoDiscoverSchemaResolver = builder.autoDiscoverSchemaResolver;
+ }
+
public String getInstanceClassName() {
return instanceClassName;
}
@@ -491,4 +520,249 @@ public class AvroDataFormat extends DataFormatDefinition {
this.autoDiscoverObjectMapper = autoDiscoverObjectMapper;
return this;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link AvroDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<AvroDataFormat> {
+
+ private Class<?> unmarshalType;
+ private Class<?> jsonView;
+ private Class<?> collectionType;
+ private Object schema;
+ private String instanceClassName;
+ private AvroLibrary library = AvroLibrary.ApacheAvro;
+ private String objectMapper;
+ private String useDefaultObjectMapper = "true";
+ private String unmarshalTypeName;
+ private String jsonViewTypeName;
+ private String include;
+ private String allowJmsType;
+ private String collectionTypeName;
+ private String useList;
+ private String moduleClassNames;
+ private String moduleRefs;
+ private String enableFeatures;
+ private String disableFeatures;
+ private String allowUnmarshallType;
+ private String timezone;
+ private String autoDiscoverObjectMapper;
+ private String contentTypeHeader = "true";
+ private String schemaResolver;
+ private String autoDiscoverSchemaResolver = "true";
+
+ /**
+ * Class name to use for marshal and unmarshalling
+ */
+ public Builder instanceClassName(String instanceClassName) {
+ this.instanceClassName = instanceClassName;
+ return this;
+ }
+
+ public Builder schema(Object schema) {
+ this.schema = schema;
+ return this;
+ }
+
+ /**
+ * Which Avro library to use.
+ */
+ public Builder library(AvroLibrary library) {
+ this.library = library;
+ return this;
+ }
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ /**
+ * Lookup and use the existing ObjectMapper with the given id when using Jackson.
+ */
+ public Builder objectMapper(String objectMapper) {
+ this.objectMapper = objectMapper;
+ return this;
+ }
+
+ /**
+ * Whether to lookup and use default Jackson ObjectMapper from the registry.
+ */
+ public Builder useDefaultObjectMapper(String useDefaultObjectMapper) {
+ this.useDefaultObjectMapper = useDefaultObjectMapper;
+ return this;
+ }
+
+ /**
+ * Class name of the java type to use when unmarshalling
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * Class of the java type to use when unmarshalling
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonViewTypeName(String jsonViewTypeName) {
+ this.jsonViewTypeName = jsonViewTypeName;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonView(Class<?> jsonView) {
+ this.jsonView = jsonView;
+ return this;
+ }
+
+ /**
+ * If you want to marshal a pojo to JSON, and the pojo has some fields with null values. And you want to skip
+ * these null values, you can set this option to <tt>NON_NULL</tt>
+ */
+ public Builder include(String include) {
+ this.include = include;
+ return this;
+ }
+
+ /**
+ * Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to
+ * unmarshal to.
+ */
+ public Builder allowJmsType(String allowJmsType) {
+ this.allowJmsType = allowJmsType;
+ return this;
+ }
+
+ /**
+ * Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but
+ * allows to use different collection types than java.util.Collection based as default.
+ */
+ public Builder collectionTypeName(String collectionTypeName) {
+ this.collectionTypeName = collectionTypeName;
+ return this;
+ }
+
+ public Builder collectionType(Class<?> collectionType) {
+ this.collectionType = collectionType;
+ return this;
+ }
+
+ /**
+ * To unmarshal to a List of Map or a List of Pojo.
+ */
+ public Builder useList(String useList) {
+ this.useList = useList;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class
+ * names. Multiple classes can be separated by comma.
+ */
+ public Builder moduleClassNames(String moduleClassNames) {
+ this.moduleClassNames = moduleClassNames;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma.
+ */
+ public Builder moduleRefs(String moduleRefs) {
+ this.moduleRefs = moduleRefs;
+ return this;
+ }
+
+ /**
+ * Set of features to enable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder enableFeatures(String enableFeatures) {
+ this.enableFeatures = enableFeatures;
+ return this;
+ }
+
+ /**
+ * Set of features to disable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder disableFeatures(String disableFeatures) {
+ this.disableFeatures = disableFeatures;
+ return this;
+ }
+
+ /**
+ * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the
+ * unmarshalling.
+ * <p/>
+ * This should only be enabled when desired to be used.
+ */
+ public Builder allowUnmarshallType(String allowUnmarshallType) {
+ this.allowUnmarshallType = allowUnmarshallType;
+ return this;
+ }
+
+ /**
+ * If set then Jackson will use the Timezone when marshalling/unmarshalling.
+ */
+ public Builder timezone(String timezone) {
+ this.timezone = timezone;
+ return this;
+ }
+
+ /**
+ * If set to true then Jackson will lookup for an objectMapper into the registry
+ */
+ public Builder autoDiscoverObjectMapper(String autoDiscoverObjectMapper) {
+ this.autoDiscoverObjectMapper = autoDiscoverObjectMapper;
+ return this;
+ }
+
+ /**
+ * Optional schema resolver used to lookup schemas for the data in transit.
+ */
+ public Builder schemaResolver(String schemaResolver) {
+ this.schemaResolver = schemaResolver;
+ return this;
+ }
+
+ /**
+ * When not disabled, the SchemaResolver will be looked up into the registry
+ */
+ public Builder autoDiscoverSchemaResolver(String autoDiscoverSchemaResolver) {
+ this.autoDiscoverSchemaResolver = autoDiscoverSchemaResolver;
+ return this;
+ }
+
+ @Override
+ public AvroDataFormat end() {
+ return new AvroDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BarcodeDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BarcodeDataFormat.java
index 4fc0bad57df..c6365593517 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BarcodeDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BarcodeDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -47,6 +49,14 @@ public class BarcodeDataFormat extends DataFormatDefinition {
super("barcode");
}
+ private BarcodeDataFormat(Builder builder) {
+ this();
+ this.barcodeFormat = builder.barcodeFormat;
+ this.imageType = builder.imageType;
+ this.width = builder.width;
+ this.height = builder.height;
+ }
+
public String getWidth() {
return width;
}
@@ -91,4 +101,52 @@ public class BarcodeDataFormat extends DataFormatDefinition {
this.barcodeFormat = barcodeFormat;
}
+ /**
+ * {@code Builder} is a specific builder for {@link BarcodeDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<BarcodeDataFormat> {
+
+ private String barcodeFormat;
+ private String imageType;
+ private String width;
+ private String height;
+
+ /**
+ * Width of the barcode
+ */
+ public Builder width(String width) {
+ this.width = width;
+ return this;
+ }
+
+ /**
+ * Height of the barcode
+ */
+ public Builder height(String height) {
+ this.height = height;
+ return this;
+ }
+
+ /**
+ * Image type of the barcode such as png
+ */
+ public Builder imageType(String imageType) {
+ this.imageType = imageType;
+ return this;
+ }
+
+ /**
+ * Barcode format such as QR-Code
+ */
+ public Builder barcodeFormat(String barcodeFormat) {
+ this.barcodeFormat = barcodeFormat;
+ return this;
+ }
+
+ @Override
+ public BarcodeDataFormat end() {
+ return new BarcodeDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Base64DataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Base64DataFormat.java
index ca92777ef5e..e34a2ecac92 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Base64DataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/Base64DataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -46,6 +48,13 @@ public class Base64DataFormat extends DataFormatDefinition {
super("base64");
}
+ private Base64DataFormat(Builder builder) {
+ this();
+ this.lineLength = builder.lineLength;
+ this.lineSeparator = builder.lineSeparator;
+ this.urlSafe = builder.urlSafe;
+ }
+
public String getLineLength() {
return lineLength;
}
@@ -83,4 +92,49 @@ public class Base64DataFormat extends DataFormatDefinition {
public void setUrlSafe(String urlSafe) {
this.urlSafe = urlSafe;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link Base64DataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<Base64DataFormat> {
+
+ private String lineLength = "76";
+ private String lineSeparator;
+ private String urlSafe;
+
+ /**
+ * To specific a maximum line length for the encoded data.
+ * <p/>
+ * By default 76 is used.
+ */
+ public Builder lineLength(String lineLength) {
+ this.lineLength = lineLength;
+ return this;
+ }
+
+ /**
+ * The line separators to use.
+ * <p/>
+ * Uses new line characters (CRLF) by default.
+ */
+ public Builder lineSeparator(String lineSeparator) {
+ this.lineSeparator = lineSeparator;
+ return this;
+ }
+
+ /**
+ * Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode
+ * operations. Decoding seamlessly handles both modes. Is by default false.
+ */
+ public Builder urlSafe(String urlSafe) {
+ this.urlSafe = urlSafe;
+ return this;
+ }
+
+ @Override
+ public Base64DataFormat end() {
+ return new Base64DataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BindyDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BindyDataFormat.java
index 9080e8581f1..7c4f7d55dcc 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BindyDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/BindyDataFormat.java
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -58,6 +59,16 @@ public class BindyDataFormat extends DataFormatDefinition {
super("bindy");
}
+ private BindyDataFormat(Builder builder) {
+ this();
+ this.clazz = builder.clazz;
+ this.type = builder.type;
+ this.classType = builder.classType;
+ this.allowEmptyStream = builder.allowEmptyStream;
+ this.unwrapSingleInstance = builder.unwrapSingleInstance;
+ this.locale = builder.locale;
+ }
+
public String getType() {
return type;
}
@@ -209,4 +220,78 @@ public class BindyDataFormat extends DataFormatDefinition {
return this;
}
+ /**
+ * {@code Builder} is a specific builder for {@link BindyDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<BindyDataFormat> {
+
+ private Class<?> clazz;
+ private String type;
+ private String classType;
+ private String allowEmptyStream = "false";
+ private String unwrapSingleInstance = "true";
+ private String locale;
+
+ /**
+ * Whether to use Csv, Fixed, or KeyValue.
+ */
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder type(BindyType type) {
+ return type(type.name());
+ }
+
+ /**
+ * Name of model class to use.
+ */
+ public Builder classType(String classType) {
+ this.classType = classType;
+ return this;
+ }
+
+ /**
+ * Name of model class to use.
+ */
+ public Builder classType(Class<?> classType) {
+ this.clazz = classType;
+ return this;
+ }
+
+ /**
+ * To configure a default locale to use, such as <tt>us</tt> for united states.
+ * <p/>
+ * To use the JVM platform default locale then use the name <tt>default</tt>
+ */
+ public Builder locale(String locale) {
+ this.locale = locale;
+ return this;
+ }
+
+ /**
+ * When unmarshalling should a single instance be unwrapped and returned instead of wrapped in a
+ * <tt>java.util.List</tt>.
+ */
+ public Builder unwrapSingleInstance(String unwrapSingleInstance) {
+ this.unwrapSingleInstance = unwrapSingleInstance;
+ return this;
+ }
+
+ /**
+ * Whether to allow empty streams in the unmarshal process. If true, no exception will be thrown when a body
+ * without records is provided.
+ */
+ public Builder allowEmptyStream(String allowEmptyStream) {
+ this.allowEmptyStream = allowEmptyStream;
+ return this;
+ }
+
+ @Override
+ public BindyDataFormat end() {
+ return new BindyDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java
index f91533d4a3b..1525019da99 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -70,6 +71,22 @@ public class CBORDataFormat extends DataFormatDefinition {
super("cbor");
}
+ private CBORDataFormat(Builder builder) {
+ this();
+ this.collectionType = builder.collectionType;
+ this.unmarshalType = builder.unmarshalType;
+ this.objectMapper = builder.objectMapper;
+ this.useDefaultObjectMapper = builder.useDefaultObjectMapper;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.collectionTypeName = builder.collectionTypeName;
+ this.useList = builder.useList;
+ this.allowUnmarshallType = builder.allowUnmarshallType;
+ this.prettyPrint = builder.prettyPrint;
+ this.allowJmsType = builder.allowJmsType;
+ this.enableFeatures = builder.enableFeatures;
+ this.disableFeatures = builder.disableFeatures;
+ }
+
public String getObjectMapper() {
return objectMapper;
}
@@ -220,4 +237,142 @@ public class CBORDataFormat extends DataFormatDefinition {
this.disableFeatures = disableFeatures;
}
+ /**
+ * {@code Builder} is a specific builder for {@link CBORDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<CBORDataFormat> {
+
+ private Class<?> collectionType;
+ private Class<?> unmarshalType;
+ private String objectMapper;
+ private String useDefaultObjectMapper = "true";
+ private String unmarshalTypeName;
+ private String collectionTypeName;
+ private String useList = "false";
+ private String allowUnmarshallType = "false";
+ private String prettyPrint = "false";
+ private String allowJmsType = "false";
+ private String enableFeatures;
+ private String disableFeatures;
+
+ /**
+ * Lookup and use the existing CBOR ObjectMapper with the given id when using Jackson.
+ */
+ public Builder objectMapper(String objectMapper) {
+ this.objectMapper = objectMapper;
+ return this;
+ }
+
+ /**
+ * Whether to lookup and use default Jackson CBOR ObjectMapper from the registry.
+ */
+ public Builder useDefaultObjectMapper(String useDefaultObjectMapper) {
+ this.useDefaultObjectMapper = useDefaultObjectMapper;
+ return this;
+ }
+
+ /**
+ * Class name of the java type to use when unmarshalling
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * To enable pretty printing output nicely formatted.
+ * <p/>
+ * Is by default false.
+ */
+ public Builder prettyPrint(String prettyPrint) {
+ this.prettyPrint = prettyPrint;
+ return this;
+ }
+
+ /**
+ * Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to
+ * unmarshal to.
+ */
+ public Builder allowJmsType(String allowJmsType) {
+ this.allowJmsType = allowJmsType;
+ return this;
+ }
+
+ /**
+ * Class of the java type to use when unmarshalling
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ /**
+ * Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but
+ * allows to use different collection types than java.util.Collection based as default.
+ */
+ public Builder collectionTypeName(String collectionTypeName) {
+ this.collectionTypeName = collectionTypeName;
+ return this;
+ }
+
+ public Builder collectionType(Class<?> collectionType) {
+ this.collectionType = collectionType;
+ return this;
+ }
+
+ /**
+ * To unmarshal to a List of Map or a List of Pojo.
+ */
+ public Builder useList(String useList) {
+ this.useList = useList;
+ return this;
+ }
+
+ /**
+ * If enabled then Jackson CBOR is allowed to attempt to use the CamelCBORUnmarshalType header during the
+ * unmarshalling.
+ * <p/>
+ * This should only be enabled when desired to be used.
+ */
+ public Builder allowUnmarshallType(String allowUnmarshallType) {
+ this.allowUnmarshallType = allowUnmarshallType;
+ return this;
+ }
+
+ /**
+ * Set of features to enable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder enableFeatures(String enableFeatures) {
+ this.enableFeatures = enableFeatures;
+ return this;
+ }
+
+ /**
+ * Set of features to disable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder disableFeatures(String disableFeatures) {
+ this.disableFeatures = disableFeatures;
+ return this;
+ }
+
+ @Override
+ public CBORDataFormat end() {
+ return new CBORDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java
index 4a5423414c1..a7f9154a7f9 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -62,6 +64,19 @@ public class CryptoDataFormat extends DataFormatDefinition {
super("crypto");
}
+ private CryptoDataFormat(Builder builder) {
+ this();
+ this.algorithm = builder.algorithm;
+ this.keyRef = builder.keyRef;
+ this.cryptoProvider = builder.cryptoProvider;
+ this.initVectorRef = builder.initVectorRef;
+ this.algorithmParameterRef = builder.algorithmParameterRef;
+ this.bufferSize = builder.bufferSize;
+ this.macAlgorithm = builder.macAlgorithm;
+ this.shouldAppendHMAC = builder.shouldAppendHMAC;
+ this.inline = builder.inline;
+ }
+
public String getAlgorithm() {
return algorithm;
}
@@ -164,4 +179,102 @@ public class CryptoDataFormat extends DataFormatDefinition {
public void setInline(String inline) {
this.inline = inline;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link CryptoDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<CryptoDataFormat> {
+
+ private String algorithm;
+ private String keyRef;
+ private String cryptoProvider;
+ private String initVectorRef;
+ private String algorithmParameterRef;
+ private String bufferSize = "4096";
+ private String macAlgorithm = "HmacSHA1";
+ private String shouldAppendHMAC = "true";
+ private String inline = "false";
+
+ /**
+ * The JCE algorithm name indicating the cryptographic algorithm that will be used.
+ */
+ public Builder setAlgorithm(String algorithm) {
+ this.algorithm = algorithm;
+ return this;
+ }
+
+ /**
+ * The name of the JCE Security Provider that should be used.
+ */
+ public Builder setCryptoProvider(String cryptoProvider) {
+ this.cryptoProvider = cryptoProvider;
+ return this;
+ }
+
+ /**
+ * Refers to the secret key to lookup from the register to use.
+ */
+ public Builder setKeyRef(String keyRef) {
+ this.keyRef = keyRef;
+ return this;
+ }
+
+ /**
+ * Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher.
+ */
+ public Builder setInitVectorRef(String initVectorRef) {
+ this.initVectorRef = initVectorRef;
+ return this;
+ }
+
+ /**
+ * A JCE AlgorithmParameterSpec used to initialize the Cipher.
+ * <p/>
+ * Will lookup the type using the given name as a {@link java.security.spec.AlgorithmParameterSpec} type.
+ */
+ public Builder setAlgorithmParameterRef(String algorithmParameterRef) {
+ this.algorithmParameterRef = algorithmParameterRef;
+ return this;
+ }
+
+ /**
+ * The size of the buffer used in the signature process.
+ */
+ public Builder setBufferSize(String bufferSize) {
+ this.bufferSize = bufferSize;
+ return this;
+ }
+
+ /**
+ * The JCE algorithm name indicating the Message Authentication algorithm.
+ */
+ public Builder setMacAlgorithm(String macAlgorithm) {
+ this.macAlgorithm = macAlgorithm;
+ return this;
+ }
+
+ /**
+ * Flag indicating that a Message Authentication Code should be calculated and appended to the encrypted data.
+ */
+ public Builder setShouldAppendHMAC(String shouldAppendHMAC) {
+ this.shouldAppendHMAC = shouldAppendHMAC;
+ return this;
+ }
+
+ /**
+ * Flag indicating that the configured IV should be inlined into the encrypted data stream.
+ * <p/>
+ * Is by default false.
+ */
+ public Builder setInline(String inline) {
+ this.inline = inline;
+ return this;
+ }
+
+ @Override
+ public CryptoDataFormat end() {
+ return new CryptoDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java
index a881a58662d..86e3aa92073 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java
@@ -23,7 +23,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -136,6 +138,39 @@ public class CsvDataFormat extends DataFormatDefinition {
setLazyLoad(Boolean.toString(lazyLoad));
}
+ private CsvDataFormat(Builder builder) {
+ this();
+ this.formatRef = builder.formatRef;
+ this.formatName = builder.formatName;
+ this.commentMarkerDisabled = builder.commentMarkerDisabled;
+ this.commentMarker = builder.commentMarker;
+ this.delimiter = builder.delimiter;
+ this.escapeDisabled = builder.escapeDisabled;
+ this.escape = builder.escape;
+ this.headerDisabled = builder.headerDisabled;
+ this.header = builder.header;
+ this.allowMissingColumnNames = builder.allowMissingColumnNames;
+ this.ignoreEmptyLines = builder.ignoreEmptyLines;
+ this.ignoreSurroundingSpaces = builder.ignoreSurroundingSpaces;
+ this.nullStringDisabled = builder.nullStringDisabled;
+ this.nullString = builder.nullString;
+ this.quoteDisabled = builder.quoteDisabled;
+ this.quote = builder.quote;
+ this.recordSeparatorDisabled = builder.recordSeparatorDisabled;
+ this.recordSeparator = builder.recordSeparator;
+ this.skipHeaderRecord = builder.skipHeaderRecord;
+ this.quoteMode = builder.quoteMode;
+ this.ignoreHeaderCase = builder.ignoreHeaderCase;
+ this.trim = builder.trim;
+ this.trailingDelimiter = builder.trailingDelimiter;
+ this.marshallerFactoryRef = builder.marshallerFactoryRef;
+ this.lazyLoad = builder.lazyLoad;
+ this.useMaps = builder.useMaps;
+ this.useOrderedMaps = builder.useOrderedMaps;
+ this.recordConverterRef = builder.recordConverterRef;
+ this.captureHeaderRecord = builder.captureHeaderRecord;
+ }
+
/**
* Sets the implementation of the CsvMarshallerFactory interface which is able to customize
* marshalling/unmarshalling behavior by extending CsvMarshaller or creating it from scratch.
@@ -468,4 +503,283 @@ public class CsvDataFormat extends DataFormatDefinition {
public void setCaptureHeaderRecord(String captureHeaderRecord) {
this.captureHeaderRecord = captureHeaderRecord;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link CsvDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<CsvDataFormat> {
+ private String formatRef;
+ private String formatName = "DEFAULT";
+ private String commentMarkerDisabled;
+ private String commentMarker;
+ private String delimiter;
+ private String escapeDisabled;
+ private String escape;
+ private String headerDisabled;
+ private List<String> header;
+ private String allowMissingColumnNames;
+ private String ignoreEmptyLines;
+ private String ignoreSurroundingSpaces;
+ private String nullStringDisabled;
+ private String nullString;
+ private String quoteDisabled;
+ private String quote;
+ private String recordSeparatorDisabled;
+ private String recordSeparator;
+ private String skipHeaderRecord;
+ private String quoteMode;
+ private String ignoreHeaderCase;
+ private String trim;
+ private String trailingDelimiter;
+ private String marshallerFactoryRef;
+ private String lazyLoad;
+ private String useMaps;
+ private String useOrderedMaps;
+ private String recordConverterRef;
+ private String captureHeaderRecord;
+
+ /**
+ * Sets the implementation of the CsvMarshallerFactory interface which is able to customize
+ * marshalling/unmarshalling behavior by extending CsvMarshaller or creating it from scratch.
+ *
+ * @param marshallerFactoryRef the <code>CsvMarshallerFactory</code> reference.
+ */
+ public Builder marshallerFactoryRef(String marshallerFactoryRef) {
+ this.marshallerFactoryRef = marshallerFactoryRef;
+ return this;
+ }
+
+ /**
+ * The reference format to use, it will be updated with the other format options, the default value is
+ * CSVFormat.DEFAULT
+ */
+ public Builder formatRef(String formatRef) {
+ this.formatRef = formatRef;
+ return this;
+ }
+
+ /**
+ * The name of the format to use, the default value is CSVFormat.DEFAULT
+ */
+ public Builder formatName(String formatName) {
+ this.formatName = formatName;
+ return this;
+ }
+
+ /**
+ * Disables the comment marker of the reference format.
+ */
+ public Builder commentMarkerDisabled(String commentMarkerDisabled) {
+ this.commentMarkerDisabled = commentMarkerDisabled;
+ return this;
+ }
+
+ /**
+ * Sets the comment marker of the reference format.
+ */
+ public Builder commentMarker(String commentMarker) {
+ this.commentMarker = commentMarker;
+ return this;
+ }
+
+ /**
+ * Sets the delimiter to use.
+ * <p/>
+ * The default value is , (comma)
+ */
+ public Builder delimiter(String delimiter) {
+ this.delimiter = delimiter;
+ return this;
+ }
+
+ /**
+ * Use for disabling using escape character
+ */
+ public Builder escapeDisabled(String escapeDisabled) {
+ this.escapeDisabled = escapeDisabled;
+ return this;
+ }
+
+ /**
+ * Sets the escape character to use
+ */
+ public Builder escape(String escape) {
+ this.escape = escape;
+ return this;
+ }
+
+ public Builder headerDisabled(String headerDisabled) {
+ this.headerDisabled = headerDisabled;
+ return this;
+ }
+
+ /**
+ * To configure the CSV headers
+ */
+ public Builder header(List<String> header) {
+ this.header = header;
+ return this;
+ }
+
+ /**
+ * Whether to allow missing column names.
+ */
+ public Builder allowMissingColumnNames(String allowMissingColumnNames) {
+ this.allowMissingColumnNames = allowMissingColumnNames;
+ return this;
+ }
+
+ /**
+ * Whether to ignore empty lines.
+ */
+ public Builder ignoreEmptyLines(String ignoreEmptyLines) {
+ this.ignoreEmptyLines = ignoreEmptyLines;
+ return this;
+ }
+
+ /**
+ * Whether to ignore surrounding spaces
+ */
+ public Builder ignoreSurroundingSpaces(String ignoreSurroundingSpaces) {
+ this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
+ return this;
+ }
+
+ /**
+ * Used to disable null strings
+ */
+ public Builder nullStringDisabled(String nullStringDisabled) {
+ this.nullStringDisabled = nullStringDisabled;
+ return this;
+ }
+
+ /**
+ * Sets the null string
+ */
+ public Builder nullString(String nullString) {
+ this.nullString = nullString;
+ return this;
+ }
+
+ /**
+ * Used to disable quotes
+ */
+ public Builder quoteDisabled(String quoteDisabled) {
+ this.quoteDisabled = quoteDisabled;
+ return this;
+ }
+
+ /**
+ * Sets the quote which by default is "
+ */
+ public Builder quote(String quote) {
+ this.quote = quote;
+ return this;
+ }
+
+ /**
+ * Used for disabling record separator
+ */
+ public Builder recordSeparatorDisabled(String recordSeparatorDisabled) {
+ this.recordSeparatorDisabled = recordSeparatorDisabled;
+ return this;
+ }
+
+ /**
+ * Sets the record separator (aka new line) which by default is new line characters (CRLF)
+ */
+ public Builder recordSeparator(String recordSeparator) {
+ this.recordSeparator = recordSeparator;
+ return this;
+ }
+
+ /**
+ * Whether to skip the header record in the output
+ */
+ public Builder skipHeaderRecord(String skipHeaderRecord) {
+ this.skipHeaderRecord = skipHeaderRecord;
+ return this;
+ }
+
+ /**
+ * Sets the quote mode
+ */
+ public Builder quoteMode(String quoteMode) {
+ this.quoteMode = quoteMode;
+ return this;
+ }
+
+ /**
+ * Whether the unmarshalling should produce an iterator that reads the lines on the fly or if all the lines must
+ * be read at one.
+ */
+ public Builder lazyLoad(String lazyLoad) {
+ this.lazyLoad = lazyLoad;
+ return this;
+ }
+
+ /**
+ * Whether the unmarshalling should produce maps (HashMap)for the lines values instead of lists. It requires to
+ * have header (either defined or collected).
+ */
+ public Builder useMaps(String useMaps) {
+ this.useMaps = useMaps;
+ return this;
+ }
+
+ /**
+ * Whether the unmarshalling should produce ordered maps (LinkedHashMap) for the lines values instead of lists.
+ * It requires to have header (either defined or collected).
+ */
+ public Builder useOrderedMaps(String useOrderedMaps) {
+ this.useOrderedMaps = useOrderedMaps;
+ return this;
+ }
+
+ /**
+ * Refers to a custom <tt>CsvRecordConverter</tt> to lookup from the registry to use.
+ */
+ public Builder recordConverterRef(String recordConverterRef) {
+ this.recordConverterRef = recordConverterRef;
+ return this;
+ }
+
+ /**
+ * Sets whether or not to trim leading and trailing blanks.
+ */
+ public Builder trim(String trim) {
+ this.trim = trim;
+ return this;
+ }
+
+ /**
+ * Sets whether or not to ignore case when accessing header names.
+ */
+ public Builder ignoreHeaderCase(String ignoreHeaderCase) {
+ this.ignoreHeaderCase = ignoreHeaderCase;
+ return this;
+ }
+
+ /**
+ * Sets whether or not to add a trailing delimiter.
+ */
+ public Builder trailingDelimiter(String trailingDelimiter) {
+ this.trailingDelimiter = trailingDelimiter;
+ return this;
+ }
+
+ /**
+ * Whether the unmarshalling should capture the header record and store it in the message header
+ */
+ public Builder captureHeaderRecord(String captureHeaderRecord) {
+ this.captureHeaderRecord = captureHeaderRecord;
+ return this;
+ }
+
+ @Override
+ public CsvDataFormat end() {
+ return new CsvDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CustomDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CustomDataFormat.java
index 6b0a4ebd92f..16eee49556d 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CustomDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CustomDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -42,6 +44,11 @@ public class CustomDataFormat extends DataFormatDefinition {
this.ref = ref;
}
+ private CustomDataFormat(Builder builder) {
+ this();
+ this.ref = builder.ref;
+ }
+
/**
* Reference to the custom {@link org.apache.camel.spi.DataFormat} to lookup from the Camel registry.
*/
@@ -60,4 +67,26 @@ public class CustomDataFormat extends DataFormatDefinition {
public String toString() {
return "CustomDataFormat[" + ref + "]";
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link CustomDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<CustomDataFormat> {
+
+ private String ref;
+
+ /**
+ * Reference to the custom {@link org.apache.camel.spi.DataFormat} to lookup from the Camel registry.
+ */
+ public Builder ref(String ref) {
+ this.ref = ref;
+ return this;
+ }
+
+ @Override
+ public CustomDataFormat end() {
+ return new CustomDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java
index 49a04f86a08..065078b9e39 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java
@@ -22,6 +22,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -91,6 +92,28 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con
// This constructor is needed by jaxb for schema generation
}
+ protected FhirDataformat(String dataFormatName, AbstractBuilder<?, ?> builder) {
+ this(dataFormatName);
+ this.fhirContext = builder.fhirContext;
+ this.fhirVersion = builder.fhirVersion;
+ this.prettyPrint = builder.prettyPrint;
+ this.parserErrorHandler = builder.parserErrorHandler;
+ this.parserOptions = builder.parserOptions;
+ this.preferTypes = builder.preferTypes;
+ this.forceResourceId = builder.forceResourceId;
+ this.serverBaseUrl = builder.serverBaseUrl;
+ this.omitResourceId = builder.omitResourceId;
+ this.encodeElementsAppliesToChildResourcesOnly = builder.encodeElementsAppliesToChildResourcesOnly;
+ this.encodeElements = builder.encodeElements;
+ this.dontEncodeElements = builder.dontEncodeElements;
+ this.stripVersionsFromReferences = builder.stripVersionsFromReferences;
+ this.overrideResourceIdWithBundleEntryFullUrl = builder.overrideResourceIdWithBundleEntryFullUrl;
+ this.summaryMode = builder.summaryMode;
+ this.suppressNarratives = builder.suppressNarratives;
+ this.dontStripVersionsFromReferencesAtPaths = builder.dontStripVersionsFromReferencesAtPaths;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ }
+
public Object getFhirContext() {
return fhirContext;
}
@@ -371,4 +394,260 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con
this.contentTypeHeader = contentTypeHeader;
}
+ /**
+ * {@code Builder} is a specific builder for {@link FhirDataformat}.
+ */
+ @XmlTransient
+ @SuppressWarnings("unchecked")
+ abstract static class AbstractBuilder<T extends AbstractBuilder<T, F>, F extends FhirDataformat>
+ implements DataFormatBuilder<F> {
+
+ private Object fhirContext;
+ private String fhirVersion = "R4";
+ private String prettyPrint;
+ private Object parserErrorHandler;
+ private Object parserOptions;
+ private Object preferTypes;
+ private Object forceResourceId;
+ private String serverBaseUrl;
+ private String omitResourceId;
+ private String encodeElementsAppliesToChildResourcesOnly;
+ private Set<String> encodeElements;
+ private Set<String> dontEncodeElements;
+ private String stripVersionsFromReferences;
+ private String overrideResourceIdWithBundleEntryFullUrl;
+ private String summaryMode;
+ private String suppressNarratives;
+ private List<String> dontStripVersionsFromReferencesAtPaths;
+ private String contentTypeHeader = "true";
+
+ public T fhirContext(Object fhirContext) {
+ this.fhirContext = fhirContext;
+ return (T) this;
+ }
+
+ /**
+ * The version of FHIR to use. Possible values are: DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5
+ */
+ public T fhirVersion(String fhirVersion) {
+ this.fhirVersion = fhirVersion;
+ return (T) this;
+ }
+
+ /**
+ * Sets the "pretty print" flag, meaning that the parser will encode resources with human-readable spacing and
+ * newlines between elements instead of condensing output as much as possible.
+ *
+ * @param prettyPrint The flag
+ */
+ public T prettyPrint(String prettyPrint) {
+ this.prettyPrint = prettyPrint;
+ return (T) this;
+ }
+
+ /**
+ * Registers an error handler which will be invoked when any parse errors are found
+ *
+ * @param parserErrorHandler The error handler to set. Must not be null.
+ */
+ public T parserErrorHandler(Object parserErrorHandler) {
+ this.parserErrorHandler = parserErrorHandler;
+ return (T) this;
+ }
+
+ /**
+ * Sets the parser options object which will be used to supply default options to newly created parsers.
+ *
+ * @param parserOptions The parser options object
+ */
+ public T parserOptions(Object parserOptions) {
+ this.parserOptions = parserOptions;
+ return (T) this;
+ }
+
+ /**
+ * If set, when parsing resources the parser will try to use the given types when possible, in the order that
+ * they are provided (from highest to lowest priority). For example, if a custom type which declares to
+ * implement the Patient resource is passed in here, and the parser is parsing a Bundle containing a Patient
+ * resource, the parser will use the given custom type.
+ *
+ * @param preferTypes The preferred types, or <code>null</code>
+ */
+ public T preferTypes(Object preferTypes) {
+ this.preferTypes = preferTypes;
+ return (T) this;
+ }
+
+ /**
+ * When encoding, force this resource ID to be encoded as the resource ID
+ */
+ public T forceResourceId(Object forceResourceId) {
+ this.forceResourceId = forceResourceId;
+ return (T) this;
+ }
+
+ /**
+ * Sets the server's base URL used by this parser. If a value is set, resource references will be turned into
+ * relative references if they are provided as absolute URLs but have a base matching the given base.
+ *
+ * @param serverBaseUrl The base URL, e.g. "http://example.com/base"
+ */
+ public T serverBaseUrl(String serverBaseUrl) {
+ this.serverBaseUrl = serverBaseUrl;
+ return (T) this;
+ }
+
+ /**
+ * If set to <code>true</code> (default is <code>false</code>) the ID of any resources being encoded will not be
+ * included in the output. Note that this does not apply to contained resources, only to root resources. In
+ * other words, if this is set to <code>true</code>, contained resources will still have local IDs but the
+ * outer/containing ID will not have an ID.
+ *
+ * @param omitResourceId Should resource IDs be omitted
+ */
+ public T omitResourceId(String omitResourceId) {
+ this.omitResourceId = omitResourceId;
+ return (T) this;
+ }
+
+ /**
+ * If set to <code>true</code> (default is false), the values supplied to {@link #setEncodeElements(Set)} will
+ * not be applied to the root resource (typically a Bundle), but will be applied to any sub-resources contained
+ * within it (i.e. search result resources in that bundle)
+ */
+ public T encodeElementsAppliesToChildResourcesOnly(String encodeElementsAppliesToChildResourcesOnly) {
+ this.encodeElementsAppliesToChildResourcesOnly = encodeElementsAppliesToChildResourcesOnly;
+ return (T) this;
+ }
+
+ /**
+ * If provided, specifies the elements which should be encoded, to the exclusion of all others. Valid values for
+ * this field would include:
+ * <ul>
+ * <li><b>Patient</b> - Encode patient and all its children</li>
+ * <li><b>Patient.name</b> - Encode only the patient's name</li>
+ * <li><b>Patient.name.family</b> - Encode only the patient's family name</li>
+ * <li><b>*.text</b> - Encode the text element on any resource (only the very first position may contain a
+ * wildcard)</li>
+ * <li><b>*.(mandatory)</b> - This is a special case which causes any mandatory fields (min > 0) to be
+ * encoded</li>
+ * </ul>
+ *
+ * @param encodeElements The elements to encode
+ * @see #setDontEncodeElements(Set)
+ */
+ public T encodeElements(Set<String> encodeElements) {
+ this.encodeElements = encodeElements;
+ return (T) this;
+ }
+
+ /**
+ * If provided, specifies the elements which should NOT be encoded. Valid values for this field would include:
+ * <ul>
+ * <li><b>Patient</b> - Don't encode patient and all its children</li>
+ * <li><b>Patient.name</b> - Don't encode the patient's name</li>
+ * <li><b>Patient.name.family</b> - Don't encode the patient's family name</li>
+ * <li><b>*.text</b> - Don't encode the text element on any resource (only the very first position may contain a
+ * wildcard)</li>
+ * </ul>
+ * <p>
+ * DSTU2 note: Note that values including meta, such as <code>Patient.meta</code> will work for DSTU2 parsers,
+ * but values with subelements on meta such as <code>Patient.meta.lastUpdated</code> will only work in DSTU3+
+ * mode.
+ * </p>
+ *
+ * @param dontEncodeElements The elements to encode
+ * @see #setEncodeElements(Set)
+ */
+ public T dontEncodeElements(Set<String> dontEncodeElements) {
+ this.dontEncodeElements = dontEncodeElements;
+ return (T) this;
+ }
+
+ /**
+ * If set to <code>true<code> (which is the default), resource references containing a version
+ * will have the version removed when the resource is encoded. This is generally good behaviour because
+ * in most situations, references from one resource to another should be to the resource by ID, not
+ * by ID and version. In some cases though, it may be desirable to preserve the version in resource
+ * links. In that case, this value should be set to <code>false</code>.
+ * <p>
+ * This method provides the ability to globally disable reference encoding. If finer-grained control is needed,
+ * use {@link #setDontStripVersionsFromReferencesAtPaths(List)}
+ * </p>
+ *
+ * @param stripVersionsFromReferences Set this to
+ * <code>false<code> to prevent the parser from removing resource versions
+ * from references (or <code>null</code> to apply the default setting from
+ * the {@link #setParserOptions(Object)}
+ * @see #setDontStripVersionsFromReferencesAtPaths(List)
+ */
+ public T stripVersionsFromReferences(String stripVersionsFromReferences) {
+ this.stripVersionsFromReferences = stripVersionsFromReferences;
+ return (T) this;
+ }
+
+ /**
+ * If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the
+ * Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens when parsing the source
+ * data into a Bundle object. Set this to <code>false</code> if this is not the desired behavior (e.g. the
+ * client code wishes to perform additional validation checks between the fullUrl and the resource id).
+ *
+ * @param overrideResourceIdWithBundleEntryFullUrl Set this to <code>false</code> to prevent the parser from
+ * overriding resource ids with the Bundle.entry.fullUrl (or
+ * <code>null</code> to apply the default setting from the
+ * {@link #setParserOptions(Object)})
+ */
+ public T overrideResourceIdWithBundleEntryFullUrl(String overrideResourceIdWithBundleEntryFullUrl) {
+ this.overrideResourceIdWithBundleEntryFullUrl = overrideResourceIdWithBundleEntryFullUrl;
+ return (T) this;
+ }
+
+ /**
+ * If set to <code>true</code> (default is <code>false</code>) only elements marked by the FHIR specification as
+ * being "summary elements" will be included.
+ */
+ public T summaryMode(String summaryMode) {
+ this.summaryMode = summaryMode;
+ return (T) this;
+ }
+
+ /**
+ * If set to <code>true</code> (default is <code>false</code>), narratives will not be included in the encoded
+ * values.
+ */
+ public T suppressNarratives(String suppressNarratives) {
+ this.suppressNarratives = suppressNarratives;
+ return (T) this;
+ }
+
+ /**
+ * If supplied value(s), any resource references at the specified paths will have their resource versions
+ * encoded instead of being automatically stripped during the encoding process. This setting has no effect on
+ * the parsing process.
+ * <p>
+ * This method provides a finer-grained level of control than {@link #setStripVersionsFromReferences(String)}
+ * and any paths specified by this method will be encoded even if
+ * {@link #setStripVersionsFromReferences(String)} has been set to <code>true</code> (which is the default)
+ * </p>
+ *
+ * @param dontStripVersionsFromReferencesAtPaths A collection of paths for which the resource versions will not
+ * be removed automatically when serializing, e.g.
+ * "Patient.managingOrganization" or
+ * "AuditEvent.object.reference". Note that only resource name and
+ * field names with dots separating is allowed here (no repetition
+ * indicators, FluentPath expressions, etc.). Set to
+ * <code>null</code> to use the value set in the
+ * {@link #setParserOptions(Object)}
+ * @see #setStripVersionsFromReferences(String)
+ */
+ public T dontStripVersionsFromReferencesAtPaths(List<String> dontStripVersionsFromReferencesAtPaths) {
+ this.dontStripVersionsFromReferencesAtPaths = dontStripVersionsFromReferencesAtPaths;
+ return (T) this;
+ }
+
+ public T contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return (T) this;
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirJsonDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirJsonDataFormat.java
index 08e6d9d41dd..38beaf260ec 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirJsonDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirJsonDataFormat.java
@@ -19,6 +19,7 @@ package org.apache.camel.model.dataformat;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.spi.Metadata;
@@ -34,4 +35,19 @@ public class FhirJsonDataFormat extends FhirDataformat {
super("fhirJson");
}
+ private FhirJsonDataFormat(Builder builder) {
+ super("fhirJson", builder);
+ }
+
+ /**
+ * {@code Builder} is a specific builder for {@link FhirJsonDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder extends AbstractBuilder<Builder, FhirJsonDataFormat> {
+
+ @Override
+ public FhirJsonDataFormat end() {
+ return new FhirJsonDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirXmlDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirXmlDataFormat.java
index f1cad180d61..e2611a3a58d 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirXmlDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirXmlDataFormat.java
@@ -19,6 +19,7 @@ package org.apache.camel.model.dataformat;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.spi.Metadata;
@@ -34,4 +35,19 @@ public class FhirXmlDataFormat extends FhirDataformat {
super("fhirXml");
}
+ private FhirXmlDataFormat(Builder builder) {
+ super("fhirXml", builder);
+ }
+
+ /**
+ * {@code Builder} is a specific builder for {@link FhirXmlDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder extends AbstractBuilder<Builder, FhirXmlDataFormat> {
+
+ @Override
+ public FhirXmlDataFormat end() {
+ return new FhirXmlDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FlatpackDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FlatpackDataFormat.java
index 9436353a1f6..df28a29699c 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FlatpackDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FlatpackDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -61,6 +63,18 @@ public class FlatpackDataFormat extends DataFormatDefinition {
super("flatpack");
}
+ private FlatpackDataFormat(Builder builder) {
+ this();
+ this.definition = builder.definition;
+ this.fixed = builder.fixed;
+ this.delimiter = builder.delimiter;
+ this.ignoreFirstRecord = builder.ignoreFirstRecord;
+ this.allowShortLines = builder.allowShortLines;
+ this.ignoreExtraColumns = builder.ignoreExtraColumns;
+ this.textQualifier = builder.textQualifier;
+ this.parserFactoryRef = builder.parserFactoryRef;
+ }
+
public String getDefinition() {
return definition;
}
@@ -153,4 +167,93 @@ public class FlatpackDataFormat extends DataFormatDefinition {
this.parserFactoryRef = parserFactoryRef;
}
+ /**
+ * {@code Builder} is a specific builder for {@link FlatpackDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<FlatpackDataFormat> {
+
+ private String definition;
+ private String fixed;
+ private String delimiter = ",";
+ private String ignoreFirstRecord = "true";
+ private String allowShortLines;
+ private String ignoreExtraColumns;
+ private String textQualifier;
+ private String parserFactoryRef;
+
+ /**
+ * The flatpack pzmap configuration file. Can be omitted in simpler situations, but its preferred to use the
+ * pzmap.
+ */
+ public Builder definition(String definition) {
+ this.definition = definition;
+ return this;
+ }
+
+ /**
+ * Delimited or fixed. Is by default false = delimited
+ */
+ public Builder fixed(String fixed) {
+ this.fixed = fixed;
+ return this;
+ }
+
+ /**
+ * Whether the first line is ignored for delimited files (for the column headers).
+ * <p/>
+ * Is by default true.
+ */
+ public Builder ignoreFirstRecord(String ignoreFirstRecord) {
+ this.ignoreFirstRecord = ignoreFirstRecord;
+ return this;
+ }
+
+ /**
+ * If the text is qualified with a character.
+ * <p/>
+ * Uses quote character by default.
+ */
+ public Builder textQualifier(String textQualifier) {
+ this.textQualifier = textQualifier;
+ return this;
+ }
+
+ /**
+ * The delimiter char (could be ; , or similar)
+ */
+ public Builder delimiter(String delimiter) {
+ this.delimiter = delimiter;
+ return this;
+ }
+
+ /**
+ * Allows for lines to be shorter than expected and ignores the extra characters
+ */
+ public Builder allowShortLines(String allowShortLines) {
+ this.allowShortLines = allowShortLines;
+ return this;
+ }
+
+ /**
+ * Allows for lines to be longer than expected and ignores the extra characters.
+ */
+ public Builder ignoreExtraColumns(String ignoreExtraColumns) {
+ this.ignoreExtraColumns = ignoreExtraColumns;
+ return this;
+ }
+
+ /**
+ * References to a custom parser factory to lookup in the registry
+ */
+ public Builder parserFactoryRef(String parserFactoryRef) {
+ this.parserFactoryRef = parserFactoryRef;
+ return this;
+ }
+
+ @Override
+ public FlatpackDataFormat end() {
+ return new FlatpackDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GrokDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GrokDataFormat.java
index 3c176450648..ebd242d8d9e 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GrokDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GrokDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -49,6 +51,14 @@ public class GrokDataFormat extends DataFormatDefinition {
super("grok");
}
+ private GrokDataFormat(Builder builder) {
+ this();
+ this.pattern = builder.pattern;
+ this.flattened = builder.flattened;
+ this.allowMultipleMatchesPerLine = builder.allowMultipleMatchesPerLine;
+ this.namedOnly = builder.namedOnly;
+ }
+
public String getPattern() {
return pattern;
}
@@ -99,4 +109,55 @@ public class GrokDataFormat extends DataFormatDefinition {
public String toString() {
return "GrokDataFormat[" + pattern + ']';
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link GrokDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<GrokDataFormat> {
+
+ private String pattern;
+ private String flattened;
+ private String allowMultipleMatchesPerLine = "true";
+ private String namedOnly;
+
+ /**
+ * The grok pattern to match lines of input
+ */
+ public Builder pattern(String pattern) {
+ this.pattern = pattern;
+ return this;
+ }
+
+ /**
+ * Turns on flattened mode. In flattened mode the exception is thrown when there are multiple pattern matches
+ * with same key.
+ */
+ public Builder flattened(String flattened) {
+ this.flattened = flattened;
+ return this;
+ }
+
+ /**
+ * If false, every line of input is matched for pattern only once. Otherwise the line can be scanned multiple
+ * times when non-terminal pattern is used.
+ */
+ public Builder allowMultipleMatchesPerLine(String allowMultipleMatchesPerLine) {
+ this.allowMultipleMatchesPerLine = allowMultipleMatchesPerLine;
+ return this;
+ }
+
+ /**
+ * Whether to capture named expressions only or not (i.e. %{IP:ip} but not ${IP})
+ */
+ public Builder namedOnly(String namedOnly) {
+ this.namedOnly = namedOnly;
+ return this;
+ }
+
+ @Override
+ public GrokDataFormat end() {
+ return new GrokDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
index 0aab050323a..e3690745500 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
@@ -17,7 +17,9 @@
package org.apache.camel.model.dataformat;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -32,4 +34,14 @@ public class GzipDeflaterDataFormat extends DataFormatDefinition {
super("gzipDeflater");
}
+ /**
+ * {@code Builder} is a specific builder for {@link GzipDeflaterDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<GzipDeflaterDataFormat> {
+ @Override
+ public GzipDeflaterDataFormat end() {
+ return new GzipDeflaterDataFormat();
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/HL7DataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/HL7DataFormat.java
index 04d58e16a01..7f63be878b0 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/HL7DataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/HL7DataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -45,6 +46,12 @@ public class HL7DataFormat extends DataFormatDefinition {
super("hl7");
}
+ private HL7DataFormat(Builder builder) {
+ this();
+ this.parser = builder.parser;
+ this.validate = builder.validate;
+ }
+
public String getValidate() {
return validate;
}
@@ -69,4 +76,36 @@ public class HL7DataFormat extends DataFormatDefinition {
this.parser = parser;
}
+ /**
+ * {@code Builder} is a specific builder for {@link HL7DataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<HL7DataFormat> {
+
+ private Object parser;
+ private String validate = "true";
+
+ /**
+ * Whether to validate the HL7 message
+ * <p/>
+ * Is by default true.
+ */
+ public Builder validate(String validate) {
+ this.validate = validate;
+ return this;
+ }
+
+ /**
+ * To use a custom HL7 parser
+ */
+ public Builder parser(Object parser) {
+ this.parser = parser;
+ return this;
+ }
+
+ @Override
+ public HL7DataFormat end() {
+ return new HL7DataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/IcalDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/IcalDataFormat.java
index 29fd9b0f64a..bee04c10459 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/IcalDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/IcalDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -40,6 +42,11 @@ public class IcalDataFormat extends DataFormatDefinition {
super("ical");
}
+ private IcalDataFormat(Builder builder) {
+ this();
+ this.validating = builder.validating;
+ }
+
public String getValidating() {
return validating;
}
@@ -51,4 +58,25 @@ public class IcalDataFormat extends DataFormatDefinition {
this.validating = validating;
}
+ /**
+ * {@code Builder} is a specific builder for {@link IcalDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<IcalDataFormat> {
+
+ private String validating;
+
+ /**
+ * Whether to validate.
+ */
+ public Builder validating(String validating) {
+ this.validating = validating;
+ return this;
+ }
+
+ @Override
+ public IcalDataFormat end() {
+ return new IcalDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
index 888d3a74fe9..a9baa562819 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -90,6 +91,29 @@ public class JacksonXMLDataFormat extends DataFormatDefinition implements Conten
super("jacksonXml");
}
+ private JacksonXMLDataFormat(Builder builder) {
+ this();
+ this.unmarshalType = builder.unmarshalType;
+ this.jsonView = builder.jsonView;
+ this.collectionType = builder.collectionType;
+ this.xmlMapper = builder.xmlMapper;
+ this.prettyPrint = builder.prettyPrint;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.allowUnmarshallType = builder.allowUnmarshallType;
+ this.jsonViewTypeName = builder.jsonViewTypeName;
+ this.include = builder.include;
+ this.allowJmsType = builder.allowJmsType;
+ this.collectionTypeName = builder.collectionTypeName;
+ this.useList = builder.useList;
+ this.timezone = builder.timezone;
+ this.enableJaxbAnnotationModule = builder.enableJaxbAnnotationModule;
+ this.moduleClassNames = builder.moduleClassNames;
+ this.moduleRefs = builder.moduleRefs;
+ this.enableFeatures = builder.enableFeatures;
+ this.disableFeatures = builder.disableFeatures;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ }
+
public String getXmlMapper() {
return xmlMapper;
}
@@ -319,4 +343,209 @@ public class JacksonXMLDataFormat extends DataFormatDefinition implements Conten
this.timezone = timezone;
}
+ /**
+ * {@code Builder} is a specific builder for {@link JacksonXMLDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<JacksonXMLDataFormat> {
+
+ private Class<?> unmarshalType;
+ private Class<?> jsonView;
+ private Class<?> collectionType;
+ private String xmlMapper;
+ private String prettyPrint;
+ private String unmarshalTypeName;
+ private String allowUnmarshallType;
+ private String jsonViewTypeName;
+ private String include;
+ private String allowJmsType;
+ private String collectionTypeName;
+ private String useList;
+ private String timezone;
+ private String enableJaxbAnnotationModule;
+ private String moduleClassNames;
+ private String moduleRefs;
+ private String enableFeatures;
+ private String disableFeatures;
+ private String contentTypeHeader = "true";
+
+ /**
+ * Lookup and use the existing XmlMapper with the given id.
+ */
+ public Builder xmlMapper(String xmlMapper) {
+ this.xmlMapper = xmlMapper;
+ return this;
+ }
+
+ /**
+ * To enable pretty printing output nicely formatted.
+ * <p/>
+ * Is by default false.
+ */
+ public Builder prettyPrint(String prettyPrint) {
+ this.prettyPrint = prettyPrint;
+ return this;
+ }
+
+ /**
+ * Class name of the java type to use when unmarshalling
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * Class of the java type to use when unmarshalling
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonViewTypeName(String jsonViewTypeName) {
+ this.jsonViewTypeName = jsonViewTypeName;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonView(Class<?> jsonView) {
+ this.jsonView = jsonView;
+ return this;
+ }
+
+ /**
+ * If you want to marshal a pojo to JSON, and the pojo has some fields with null values. And you want to skip
+ * these null values, you can set this option to <tt>NON_NULL</tt>
+ */
+ public Builder include(String include) {
+ this.include = include;
+ return this;
+ }
+
+ /**
+ * Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to
+ * unmarshal to.
+ */
+ public Builder allowJmsType(String allowJmsType) {
+ this.allowJmsType = allowJmsType;
+ return this;
+ }
+
+ /**
+ * Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but
+ * allows to use different collection types than java.util.Collection based as default.
+ */
+ public Builder collectionTypeName(String collectionTypeName) {
+ this.collectionTypeName = collectionTypeName;
+ return this;
+ }
+
+ public Builder collectionType(Class<?> collectionType) {
+ this.collectionType = collectionType;
+ return this;
+ }
+
+ /**
+ * To unmarshal to a List of Map or a List of Pojo.
+ */
+ public Builder useList(String useList) {
+ this.useList = useList;
+ return this;
+ }
+
+ /**
+ * Whether to enable the JAXB annotations module when using jackson. When enabled then JAXB annotations can be
+ * used by Jackson.
+ */
+ public Builder enableJaxbAnnotationModule(String enableJaxbAnnotationModule) {
+ this.enableJaxbAnnotationModule = enableJaxbAnnotationModule;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class
+ * names. Multiple classes can be separated by comma.
+ */
+ public Builder moduleClassNames(String moduleClassNames) {
+ this.moduleClassNames = moduleClassNames;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma.
+ */
+ public Builder moduleRefs(String moduleRefs) {
+ this.moduleRefs = moduleRefs;
+ return this;
+ }
+
+ /**
+ * Set of features to enable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder enableFeatures(String enableFeatures) {
+ this.enableFeatures = enableFeatures;
+ return this;
+ }
+
+ /**
+ * Set of features to disable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder disableFeatures(String disableFeatures) {
+ this.disableFeatures = disableFeatures;
+ return this;
+ }
+
+ /**
+ * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the
+ * unmarshalling.
+ * <p/>
+ * This should only be enabled when desired to be used.
+ */
+ public Builder allowUnmarshallType(String allowUnmarshallType) {
+ this.allowUnmarshallType = allowUnmarshallType;
+ return this;
+ }
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ /**
+ * If set then Jackson will use the Timezone when marshalling/unmarshalling.
+ */
+ public Builder timezone(String timezone) {
+ this.timezone = timezone;
+ return this;
+ }
+
+ @Override
+ public JacksonXMLDataFormat end() {
+ return new JacksonXMLDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
index d113010b98f..6508d6b97e0 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -98,6 +100,29 @@ public class JaxbDataFormat extends DataFormatDefinition implements ContentTypeH
setPrettyPrint(Boolean.toString(prettyPrint));
}
+ private JaxbDataFormat(Builder builder) {
+ this();
+ this.contextPath = builder.contextPath;
+ this.contextPathIsClassName = builder.contextPathIsClassName;
+ this.schema = builder.schema;
+ this.schemaSeverityLevel = builder.schemaSeverityLevel;
+ this.prettyPrint = builder.prettyPrint;
+ this.objectFactory = builder.objectFactory;
+ this.ignoreJAXBElement = builder.ignoreJAXBElement;
+ this.mustBeJAXBElement = builder.mustBeJAXBElement;
+ this.filterNonXmlChars = builder.filterNonXmlChars;
+ this.encoding = builder.encoding;
+ this.fragment = builder.fragment;
+ this.partClass = builder.partClass;
+ this.partNamespace = builder.partNamespace;
+ this.namespacePrefixRef = builder.namespacePrefixRef;
+ this.xmlStreamWriterWrapper = builder.xmlStreamWriterWrapper;
+ this.schemaLocation = builder.schemaLocation;
+ this.noNamespaceSchemaLocation = builder.noNamespaceSchemaLocation;
+ this.jaxbProviderProperties = builder.jaxbProviderProperties;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ }
+
public String getContextPath() {
return contextPath;
}
@@ -322,4 +347,203 @@ public class JaxbDataFormat extends DataFormatDefinition implements ContentTypeH
this.contentTypeHeader = contentTypeHeader;
}
+ /**
+ * {@code Builder} is a specific builder for {@link JaxbDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<JaxbDataFormat> {
+
+ private String contextPath;
+ private String contextPathIsClassName;
+ private String schema;
+ private String schemaSeverityLevel = "0";
+ private String prettyPrint;
+ private String objectFactory;
+ private String ignoreJAXBElement;
+ private String mustBeJAXBElement;
+ private String filterNonXmlChars;
+ private String encoding;
+ private String fragment;
+ private String partClass;
+ private String partNamespace;
+ private String namespacePrefixRef;
+ private String xmlStreamWriterWrapper;
+ private String schemaLocation;
+ private String noNamespaceSchemaLocation;
+ private String jaxbProviderProperties;
+ private String contentTypeHeader = "true";
+
+ /**
+ * Package name where your JAXB classes are located.
+ */
+ public Builder contextPath(String contextPath) {
+ this.contextPath = contextPath;
+ return this;
+ }
+
+ /**
+ * This can be set to true to mark that the contextPath is referring to a classname and not a package name.
+ */
+ public Builder contextPathIsClassName(String contextPathIsClassName) {
+ this.contextPathIsClassName = contextPathIsClassName;
+ return this;
+ }
+
+ /**
+ * To validate against an existing schema. Your can use the prefix classpath:, file:* or *http: to specify how
+ * the resource should be resolved. You can separate multiple schema files by using the ',' character.
+ */
+ public Builder schema(String schema) {
+ this.schema = schema;
+ return this;
+ }
+
+ /**
+ * Sets the schema severity level to use when validating against a schema. This level determines the minimum
+ * severity error that triggers JAXB to stop continue parsing. The default value of 0 (warning) means that any
+ * error (warning, error or fatal error) will trigger JAXB to stop. There are the following three levels:
+ * 0=warning, 1=error, 2=fatal error.
+ */
+ public Builder schemaSeverityLevel(String schemaSeverityLevel) {
+ this.schemaSeverityLevel = schemaSeverityLevel;
+ return this;
+ }
+
+ /**
+ * To enable pretty printing output nicely formatted.
+ * <p/>
+ * Is by default false.
+ */
+ public Builder prettyPrint(String prettyPrint) {
+ this.prettyPrint = prettyPrint;
+ return this;
+ }
+
+ /**
+ * Whether to allow using ObjectFactory classes to create the POJO classes during marshalling. This only applies
+ * to POJO classes that has not been annotated with JAXB and providing jaxb.index descriptor files.
+ */
+ public Builder objectFactory(String objectFactory) {
+ this.objectFactory = objectFactory;
+ return this;
+ }
+
+ /**
+ * Whether to ignore JAXBElement elements - only needed to be set to false in very special use-cases.
+ */
+ public Builder ignoreJAXBElement(String ignoreJAXBElement) {
+ this.ignoreJAXBElement = ignoreJAXBElement;
+ return this;
+ }
+
+ /**
+ * Whether marhsalling must be java objects with JAXB annotations. And if not then it fails. This option can be
+ * set to false to relax that, such as when the data is already in XML format.
+ */
+ public Builder mustBeJAXBElement(String mustBeJAXBElement) {
+ this.mustBeJAXBElement = mustBeJAXBElement;
+ return this;
+ }
+
+ /**
+ * To turn on marshalling XML fragment trees. By default JAXB looks for @XmlRootElement annotation on given
+ * class to operate on whole XML tree. This is useful but not always - sometimes generated code does not
+ * have @XmlRootElement annotation, sometimes you need unmarshall only part of tree. In that case you can use
+ * partial unmarshalling. To enable this behaviours you need set property partClass. Camel will pass this class
+ * to JAXB's unmarshaler.
+ */
+ public Builder fragment(String fragment) {
+ this.fragment = fragment;
+ return this;
+ }
+
+ /**
+ * To ignore non xml characters and replace them with an empty space.
+ */
+ public Builder filterNonXmlChars(String filterNonXmlChars) {
+ this.filterNonXmlChars = filterNonXmlChars;
+ return this;
+ }
+
+ /**
+ * To overrule and use a specific encoding
+ */
+ public Builder encoding(String encoding) {
+ this.encoding = encoding;
+ return this;
+ }
+
+ /**
+ * Name of class used for fragment parsing.
+ * <p/>
+ * See more details at the fragment option.
+ */
+ public Builder partClass(String partClass) {
+ this.partClass = partClass;
+ return this;
+ }
+
+ /**
+ * XML namespace to use for fragment parsing.
+ * <p/>
+ * See more details at the fragment option.
+ */
+ public Builder partNamespace(String partNamespace) {
+ this.partNamespace = partNamespace;
+ return this;
+ }
+
+ /**
+ * When marshalling using JAXB or SOAP then the JAXB implementation will automatically assign namespace
+ * prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you to refer to a map which
+ * contains the desired mapping.
+ */
+ public Builder namespacePrefixRef(String namespacePrefixRef) {
+ this.namespacePrefixRef = namespacePrefixRef;
+ return this;
+ }
+
+ /**
+ * To use a custom xml stream writer.
+ */
+ public Builder xmlStreamWriterWrapper(String xmlStreamWriterWrapperRef) {
+ this.xmlStreamWriterWrapper = xmlStreamWriterWrapperRef;
+ return this;
+ }
+
+ /**
+ * To define the location of the schema
+ */
+ public Builder schemaLocation(String schemaLocation) {
+ this.schemaLocation = schemaLocation;
+ return this;
+ }
+
+ /**
+ * To define the location of the namespaceless schema
+ */
+ public Builder noNamespaceSchemaLocation(String schemaLocation) {
+ this.noNamespaceSchemaLocation = schemaLocation;
+ return this;
+ }
+
+ /**
+ * Refers to a custom java.util.Map to lookup in the registry containing custom JAXB provider properties to be
+ * used with the JAXB marshaller.
+ */
+ public Builder jaxbProviderProperties(String jaxbProviderProperties) {
+ this.jaxbProviderProperties = jaxbProviderProperties;
+ return this;
+ }
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ @Override
+ public JaxbDataFormat end() {
+ return new JaxbDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonApiDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonApiDataFormat.java
index faf85c49439..5337c692943 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonApiDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonApiDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -42,6 +44,12 @@ public class JsonApiDataFormat extends DataFormatDefinition {
super("jsonApi");
}
+ private JsonApiDataFormat(Builder builder) {
+ this();
+ this.dataFormatTypes = builder.dataFormatTypes;
+ this.mainFormatType = builder.mainFormatType;
+ }
+
public Class<?>[] getDataFormatTypes() {
return dataFormatTypes;
}
@@ -64,4 +72,34 @@ public class JsonApiDataFormat extends DataFormatDefinition {
this.mainFormatType = mainFormatType;
}
+ /**
+ * {@code Builder} is a specific builder for {@link JsonApiDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<JsonApiDataFormat> {
+
+ private Class<?>[] dataFormatTypes;
+ private Class<?> mainFormatType;
+
+ /**
+ * The classes to take into account for the marshalling
+ */
+ public Builder dataFormatTypes(Class<?>[] dataFormatTypes) {
+ this.dataFormatTypes = dataFormatTypes;
+ return this;
+ }
+
+ /**
+ * The classes to take into account while unmarshalling
+ */
+ public Builder mainFormatType(Class<?> mainFormatType) {
+ this.mainFormatType = mainFormatType;
+ return this;
+ }
+
+ @Override
+ public JsonApiDataFormat end() {
+ return new JsonApiDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
index b96a288823e..e210c1da6c1 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -116,9 +117,40 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
}
public JsonDataFormat(JsonLibrary library) {
+ this();
this.library = library;
}
+ private JsonDataFormat(Builder builder) {
+ this();
+ this.objectMapper = builder.objectMapper;
+ this.useDefaultObjectMapper = builder.useDefaultObjectMapper;
+ this.autoDiscoverObjectMapper = builder.autoDiscoverObjectMapper;
+ this.prettyPrint = builder.prettyPrint;
+ this.library = builder.library;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.unmarshalType = builder.unmarshalType;
+ this.jsonViewTypeName = builder.jsonViewTypeName;
+ this.jsonView = builder.jsonView;
+ this.include = builder.include;
+ this.allowJmsType = builder.allowJmsType;
+ this.collectionTypeName = builder.collectionTypeName;
+ this.collectionType = builder.collectionType;
+ this.useList = builder.useList;
+ this.moduleClassNames = builder.moduleClassNames;
+ this.moduleRefs = builder.moduleRefs;
+ this.enableFeatures = builder.enableFeatures;
+ this.disableFeatures = builder.disableFeatures;
+ this.permissions = builder.permissions;
+ this.allowUnmarshallType = builder.allowUnmarshallType;
+ this.timezone = builder.timezone;
+ this.dropRootNode = builder.dropRootNode;
+ this.schemaResolver = builder.schemaResolver;
+ this.autoDiscoverSchemaResolver = builder.autoDiscoverSchemaResolver;
+ this.namingStrategy = builder.namingStrategy;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ }
+
@Override
public String getDataFormatName() {
// json data format is special as the name can be from different bundles
@@ -366,12 +398,16 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
* @see #setPermissions(String)
*/
public void setPermissions(Class<?>... type) {
+ setPermissions(toString(type));
+ }
+
+ private static String toString(Class<?>[] type) {
StringJoiner permissionsBuilder = new StringJoiner(",");
for (Class<?> clazz : type) {
permissionsBuilder.add("+");
permissionsBuilder.add(clazz.getName());
}
- setPermissions(permissionsBuilder.toString());
+ return permissionsBuilder.toString();
}
public String getAllowUnmarshallType() {
@@ -600,4 +636,294 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
return this;
}
+ /**
+ * {@code Builder} is a specific builder for {@link JsonDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<JsonDataFormat> {
+
+ private String objectMapper;
+ private String useDefaultObjectMapper = "true";
+ private String autoDiscoverObjectMapper = "false";
+ private String prettyPrint;
+ private JsonLibrary library = JsonLibrary.Jackson;
+ private String unmarshalTypeName;
+ private Class<?> unmarshalType;
+ private String jsonViewTypeName;
+ private Class<?> jsonView;
+ private String include;
+ private String allowJmsType;
+ private String collectionTypeName;
+ private Class<?> collectionType;
+ private String useList;
+ private String moduleClassNames;
+ private String moduleRefs;
+ private String enableFeatures;
+ private String disableFeatures;
+ private String permissions;
+ private String allowUnmarshallType;
+ private String timezone;
+ private String dropRootNode = "false";
+ private String schemaResolver;
+ private String autoDiscoverSchemaResolver = "true";
+ private String namingStrategy;
+ private String contentTypeHeader = "true";
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ /**
+ * Lookup and use the existing ObjectMapper with the given id when using Jackson.
+ */
+ public Builder objectMapper(String objectMapper) {
+ this.objectMapper = objectMapper;
+ return this;
+ }
+
+ /**
+ * Whether to lookup and use default Jackson ObjectMapper from the registry.
+ */
+ public Builder useDefaultObjectMapper(String useDefaultObjectMapper) {
+ this.useDefaultObjectMapper = useDefaultObjectMapper;
+ return this;
+ }
+
+ /**
+ * To enable pretty printing output nicely formatted.
+ * <p/>
+ * Is by default false.
+ */
+ public Builder prettyPrint(String prettyPrint) {
+ this.prettyPrint = prettyPrint;
+ return this;
+ }
+
+ /**
+ * Class name of the java type to use when unmarshalling
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * Class of the java type to use when unmarshalling
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ /**
+ * Which json library to use.
+ */
+ public Builder library(JsonLibrary library) {
+ this.library = library;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonViewTypeName(String jsonViewTypeName) {
+ this.jsonViewTypeName = jsonViewTypeName;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonView(Class<?> jsonView) {
+ this.jsonView = jsonView;
+ return this;
+ }
+
+ /**
+ * If you want to marshal a pojo to JSON, and the pojo has some fields with null values. And you want to skip
+ * these null values, you can set this option to <tt>NON_NULL</tt>
+ */
+ public Builder include(String include) {
+ this.include = include;
+ return this;
+ }
+
+ /**
+ * Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to
+ * unmarshal to.
+ */
+ public Builder allowJmsType(String allowJmsType) {
+ this.allowJmsType = allowJmsType;
+ return this;
+ }
+
+ /**
+ * Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but
+ * allows using different collection types than java.util.Collection based as default.
+ */
+ public Builder collectionTypeName(String collectionTypeName) {
+ this.collectionTypeName = collectionTypeName;
+ return this;
+ }
+
+ public Builder collectionType(Class<?> collectionType) {
+ this.collectionType = collectionType;
+ return this;
+ }
+
+ /**
+ * To unmarshal to a List of Map or a List of Pojo.
+ */
+ public Builder useList(String useList) {
+ this.useList = useList;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class
+ * names. Multiple classes can be separated by comma.
+ */
+ public Builder moduleClassNames(String moduleClassNames) {
+ this.moduleClassNames = moduleClassNames;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma.
+ */
+ public Builder moduleRefs(String moduleRefs) {
+ this.moduleRefs = moduleRefs;
+ return this;
+ }
+
+ /**
+ * Set of features to enable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder enableFeatures(String enableFeatures) {
+ this.enableFeatures = enableFeatures;
+ return this;
+ }
+
+ /**
+ * Set of features to disable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder disableFeatures(String disableFeatures) {
+ this.disableFeatures = disableFeatures;
+ return this;
+ }
+
+ /**
+ * Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal
+ * from xml/json to Java beans.
+ * <p/>
+ * A permission must be configured either here or globally using a JVM system property. The permission can be
+ * specified in a syntax where a plus sign is allow, and minus sign is deny. <br/>
+ * Wildcards is supported by using <tt>.*</tt> as prefix. For example to allow <tt>com.foo</tt> and all
+ * subpackages then specfy <tt>+com.foo.*</tt>. Multiple permissions can be configured separated by comma, such
+ * as <tt>+com.foo.*,-com.foo.bar.MySecretBean</tt>. <br/>
+ * The following default permission is always included: <tt>"-*,java.lang.*,java.util.*"</tt> unless its
+ * overridden by specifying a JVM system property with they key <tt>org.apache.camel.xstream.permissions</tt>.
+ */
+ public Builder permissions(String permissions) {
+ this.permissions = permissions;
+ return this;
+ }
+
+ /**
+ * To add permission for the given pojo classes.
+ *
+ * @param type the pojo class(es) xstream should use as allowed permission
+ * @see #setPermissions(String)
+ */
+ public Builder permissions(Class<?>... type) {
+ return permissions(JsonDataFormat.toString(type));
+ }
+
+ /**
+ * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the
+ * unmarshalling.
+ * <p/>
+ * This should only be enabled when desired to be used.
+ */
+ public Builder allowUnmarshallType(String allowUnmarshallType) {
+ this.allowUnmarshallType = allowUnmarshallType;
+ return this;
+ }
+
+ /**
+ * If set then Jackson will use the Timezone when marshalling/unmarshalling. This option will have no effect on
+ * the others Json DataFormat, like gson, fastjson and xstream.
+ */
+ public Builder timezone(String timezone) {
+ this.timezone = timezone;
+ return this;
+ }
+
+ /**
+ * If set to true then Jackson will look for an objectMapper to use from the registry
+ */
+ public Builder autoDiscoverObjectMapper(String autoDiscoverObjectMapper) {
+ this.autoDiscoverObjectMapper = autoDiscoverObjectMapper;
+ return this;
+ }
+
+ /**
+ * Whether XStream will drop the root node in the generated JSon. You may want to enable this when using POJOs;
+ * as then the written object will include the class name as root node, which is often not intended to be
+ * written in the JSON output.
+ */
+ public Builder dropRootNode(String dropRootNode) {
+ this.dropRootNode = dropRootNode;
+ return this;
+ }
+
+ /**
+ * Optional schema resolver used to lookup schemas for the data in transit.
+ */
+ public Builder schemaResolver(String schemaResolver) {
+ this.schemaResolver = schemaResolver;
+ return this;
+ }
+
+ /**
+ * When not disabled, the SchemaResolver will be looked up into the registry
+ */
+ public Builder autoDiscoverSchemaResolver(String autoDiscoverSchemaResolver) {
+ this.autoDiscoverSchemaResolver = autoDiscoverSchemaResolver;
+ return this;
+ }
+
+ /**
+ * If set then Jackson will use the the defined Property Naming Strategy. Possible values are: LOWER_CAMEL_CASE,
+ * LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE
+ */
+ public Builder namingStrategy(String namingStrategy) {
+ this.namingStrategy = namingStrategy;
+ return this;
+ }
+
+ @Override
+ public JsonDataFormat end() {
+ return new JsonDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/LZFDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/LZFDataFormat.java
index 50a31dad490..8e950bf1391 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/LZFDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/LZFDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -40,6 +42,11 @@ public class LZFDataFormat extends DataFormatDefinition {
super("lzf");
}
+ private LZFDataFormat(Builder builder) {
+ this();
+ this.usingParallelCompression = builder.usingParallelCompression;
+ }
+
public String getUsingParallelCompression() {
return usingParallelCompression;
}
@@ -50,4 +57,26 @@ public class LZFDataFormat extends DataFormatDefinition {
public void setUsingParallelCompression(String usingParallelCompression) {
this.usingParallelCompression = usingParallelCompression;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link LZFDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<LZFDataFormat> {
+
+ private String usingParallelCompression;
+
+ /**
+ * Enable encoding (compress) using multiple processing cores.
+ */
+ public Builder usingParallelCompression(String usingParallelCompression) {
+ this.usingParallelCompression = usingParallelCompression;
+ return this;
+ }
+
+ @Override
+ public LZFDataFormat end() {
+ return new LZFDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/MimeMultipartDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/MimeMultipartDataFormat.java
index 892be960a9c..292e0cd579a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/MimeMultipartDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/MimeMultipartDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -51,6 +53,15 @@ public class MimeMultipartDataFormat extends DataFormatDefinition {
super("mimeMultipart");
}
+ private MimeMultipartDataFormat(Builder builder) {
+ this();
+ this.multipartSubType = builder.multipartSubType;
+ this.multipartWithoutAttachment = builder.multipartWithoutAttachment;
+ this.headersInline = builder.headersInline;
+ this.includeHeaders = builder.includeHeaders;
+ this.binaryContent = builder.binaryContent;
+ }
+
public String getMultipartSubType() {
return multipartSubType;
}
@@ -117,4 +128,75 @@ public class MimeMultipartDataFormat extends DataFormatDefinition {
public void setBinaryContent(String binaryContent) {
this.binaryContent = binaryContent;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link MimeMultipartDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<MimeMultipartDataFormat> {
+
+ private String multipartSubType = "mixed";
+ private String multipartWithoutAttachment;
+ private String headersInline;
+ private String includeHeaders;
+ private String binaryContent;
+
+ /**
+ * Specify the subtype of the MIME Multipart.
+ * <p>
+ * Default is mixed.
+ */
+ public Builder multipartSubType(String multipartSubType) {
+ this.multipartSubType = multipartSubType;
+ return this;
+ }
+
+ /**
+ * Defines whether a message without attachment is also marshaled into a MIME Multipart (with only one body
+ * part).
+ * <p>
+ * Default is false.
+ */
+ public Builder multipartWithoutAttachment(String multipartWithoutAttachment) {
+ this.multipartWithoutAttachment = multipartWithoutAttachment;
+ return this;
+ }
+
+ /**
+ * Defines whether the MIME-Multipart headers are part of the message body (true) or are set as Camel headers
+ * (false).
+ * <p>
+ * Default is false.
+ */
+ public Builder headersInline(String headersInline) {
+ this.headersInline = headersInline;
+ return this;
+ }
+
+ /**
+ * A regex that defines which Camel headers are also included as MIME headers into the MIME multipart. This will
+ * only work if headersInline is set to true.
+ * <p>
+ * Default is to include no headers
+ */
+ public Builder includeHeaders(String includeHeaders) {
+ this.includeHeaders = includeHeaders;
+ return this;
+ }
+
+ /**
+ * Defines whether the content of binary parts in the MIME multipart is binary (true) or Base-64 encoded (false)
+ * <p>
+ * Default is false.
+ */
+ public Builder binaryContent(String binaryContent) {
+ this.binaryContent = binaryContent;
+ return this;
+ }
+
+ @Override
+ public MimeMultipartDataFormat end() {
+ return new MimeMultipartDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/PGPDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/PGPDataFormat.java
index 20eb384f356..6600be9fa4d 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/PGPDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/PGPDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -69,6 +71,24 @@ public class PGPDataFormat extends DataFormatDefinition {
super("pgp");
}
+ private PGPDataFormat(Builder builder) {
+ this();
+ this.keyUserid = builder.keyUserid;
+ this.signatureKeyUserid = builder.signatureKeyUserid;
+ this.password = builder.password;
+ this.signaturePassword = builder.signaturePassword;
+ this.keyFileName = builder.keyFileName;
+ this.signatureKeyFileName = builder.signatureKeyFileName;
+ this.signatureKeyRing = builder.signatureKeyRing;
+ this.armored = builder.armored;
+ this.integrity = builder.integrity;
+ this.provider = builder.provider;
+ this.algorithm = builder.algorithm;
+ this.compressionAlgorithm = builder.compressionAlgorithm;
+ this.hashAlgorithm = builder.hashAlgorithm;
+ this.signatureVerificationOption = builder.signatureVerificationOption;
+ }
+
public String getSignatureKeyUserid() {
return signatureKeyUserid;
}
@@ -246,4 +266,168 @@ public class PGPDataFormat extends DataFormatDefinition {
public void setSignatureVerificationOption(String signatureVerificationOption) {
this.signatureVerificationOption = signatureVerificationOption;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link PGPDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<PGPDataFormat> {
+
+ private String keyUserid;
+ private String signatureKeyUserid;
+ private String password;
+ private String signaturePassword;
+ private String keyFileName;
+ private String signatureKeyFileName;
+ private String signatureKeyRing;
+ private String armored = "false";
+ private String integrity = "true";
+ private String provider;
+ private String algorithm;
+ private String compressionAlgorithm;
+ private String hashAlgorithm;
+ private String signatureVerificationOption;
+
+ /**
+ * User ID of the key in the PGP keyring used for signing (during encryption) or signature verification (during
+ * decryption). During the signature verification process the specified User ID restricts the public keys from
+ * the public keyring which can be used for the verification. If no User ID is specified for the signature
+ * verficiation then any public key in the public keyring can be used for the verification. Can also be only a
+ * part of a user ID. For example, if the user ID is "Test User <te...@camel.com>" then you can use the part
+ * "Test User" or "<te...@camel.com>" to address the User ID.
+ */
+ public Builder signatureKeyUserid(String signatureKeyUserid) {
+ this.signatureKeyUserid = signatureKeyUserid;
+ return this;
+ }
+
+ /**
+ * Password used when opening the private key used for signing (during encryption).
+ */
+ public Builder signaturePassword(String signaturePassword) {
+ this.signaturePassword = signaturePassword;
+ return this;
+ }
+
+ /**
+ * Filename of the keyring to use for signing (during encryption) or for signature verification (during
+ * decryption); must be accessible as a classpath resource (but you can specify a location in the file system by
+ * using the "file:" prefix).
+ */
+ public Builder signatureKeyFileName(String signatureKeyFileName) {
+ this.signatureKeyFileName = signatureKeyFileName;
+ return this;
+ }
+
+ /**
+ * Keyring used for signing/verifying as byte array. You can not set the signatureKeyFileName and
+ * signatureKeyRing at the same time.
+ */
+ public Builder signatureKeyRing(String signatureKeyRing) {
+ this.signatureKeyRing = signatureKeyRing;
+ return this;
+ }
+
+ /**
+ * Signature hash algorithm; possible values are defined in org.bouncycastle.bcpg.HashAlgorithmTags; for example
+ * 2 (= SHA1), 8 (= SHA256), 9 (= SHA384), 10 (= SHA512), 11 (=SHA224). Only relevant for signing.
+ */
+ public Builder hashAlgorithm(String hashAlgorithm) {
+ this.hashAlgorithm = hashAlgorithm;
+ return this;
+ }
+
+ /**
+ * This option will cause PGP to base64 encode the encrypted text, making it available for copy/paste, etc.
+ */
+ public Builder armored(String armored) {
+ this.armored = armored;
+ return this;
+ }
+
+ /**
+ * Adds an integrity check/sign into the encryption file.
+ * <p/>
+ * The default value is true.
+ */
+ public Builder integrity(String integrity) {
+ this.integrity = integrity;
+ return this;
+ }
+
+ /**
+ * Filename of the keyring; must be accessible as a classpath resource (but you can specify a location in the
+ * file system by using the "file:" prefix).
+ */
+ public Builder keyFileName(String keyFileName) {
+ this.keyFileName = keyFileName;
+ return this;
+ }
+
+ /**
+ * The user ID of the key in the PGP keyring used during encryption. Can also be only a part of a user ID. For
+ * example, if the user ID is "Test User <te...@camel.com>" then you can use the part "Test User" or
+ * "<te...@camel.com>" to address the user ID.
+ */
+ public Builder keyUserid(String keyUserid) {
+ this.keyUserid = keyUserid;
+ return this;
+ }
+
+ /**
+ * Symmetric key encryption algorithm; possible values are defined in
+ * org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags; for example 2 (= TRIPLE DES), 3 (= CAST5), 4 (= BLOWFISH), 6
+ * (= DES), 7 (= AES_128). Only relevant for encrypting.
+ */
+ public Builder algorithm(String algorithm) {
+ this.algorithm = algorithm;
+ return this;
+ }
+
+ /**
+ * Compression algorithm; possible values are defined in org.bouncycastle.bcpg.CompressionAlgorithmTags; for
+ * example 0 (= UNCOMPRESSED), 1 (= ZIP), 2 (= ZLIB), 3 (= BZIP2). Only relevant for encrypting.
+ */
+ public Builder compressionAlgorithm(String compressionAlgorithm) {
+ this.compressionAlgorithm = compressionAlgorithm;
+ return this;
+ }
+
+ /**
+ * Password used when opening the private key (not used for encryption).
+ */
+ public Builder password(String password) {
+ this.password = password;
+ return this;
+ }
+
+ /**
+ * Java Cryptography Extension (JCE) provider, default is Bouncy Castle ("BC"). Alternatively you can use, for
+ * example, the IAIK JCE provider; in this case the provider must be registered beforehand and the Bouncy Castle
+ * provider must not be registered beforehand. The Sun JCE provider does not work.
+ */
+ public Builder provider(String provider) {
+ this.provider = provider;
+ return this;
+ }
+
+ /**
+ * Controls the behavior for verifying the signature during unmarshaling. There are 4 values possible:
+ * "optional": The PGP message may or may not contain signatures; if it does contain signatures, then a
+ * signature verification is executed. "required": The PGP message must contain at least one signature; if this
+ * is not the case an exception (PGPException) is thrown. A signature verification is executed. "ignore":
+ * Contained signatures in the PGP message are ignored; no signature verification is executed.
+ * "no_signature_allowed": The PGP message must not contain a signature; otherwise an exception (PGPException)
+ * is thrown.
+ */
+ public Builder signatureVerificationOption(String signatureVerificationOption) {
+ this.signatureVerificationOption = signatureVerificationOption;
+ return this;
+ }
+
+ @Override
+ public PGPDataFormat end() {
+ return new PGPDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
index 7380e8d457c..47b2107a23d 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -121,6 +122,35 @@ public class ProtobufDataFormat extends DataFormatDefinition implements ContentT
setContentTypeFormat(contentTypeFormat);
}
+ private ProtobufDataFormat(Builder builder) {
+ this();
+ this.defaultInstance = builder.defaultInstance;
+ this.instanceClass = builder.instanceClass;
+ this.objectMapper = builder.objectMapper;
+ this.useDefaultObjectMapper = builder.useDefaultObjectMapper;
+ this.autoDiscoverObjectMapper = builder.autoDiscoverObjectMapper;
+ this.library = builder.library;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.unmarshalType = builder.unmarshalType;
+ this.jsonViewTypeName = builder.jsonViewTypeName;
+ this.jsonView = builder.jsonView;
+ this.include = builder.include;
+ this.allowJmsType = builder.allowJmsType;
+ this.collectionTypeName = builder.collectionTypeName;
+ this.collectionType = builder.collectionType;
+ this.useList = builder.useList;
+ this.moduleClassNames = builder.moduleClassNames;
+ this.moduleRefs = builder.moduleRefs;
+ this.enableFeatures = builder.enableFeatures;
+ this.disableFeatures = builder.disableFeatures;
+ this.allowUnmarshallType = builder.allowUnmarshallType;
+ this.timezone = builder.timezone;
+ this.schemaResolver = builder.schemaResolver;
+ this.autoDiscoverSchemaResolver = builder.autoDiscoverSchemaResolver;
+ this.contentTypeFormat = builder.contentTypeFormat;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ }
+
@Override
public String getDataFormatName() {
// protobuf data format is special as the name can be from different bundles
@@ -513,4 +543,258 @@ public class ProtobufDataFormat extends DataFormatDefinition implements ContentT
return this;
}
+ /**
+ * {@code Builder} is a specific builder for {@link ProtobufDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<ProtobufDataFormat> {
+ private Object defaultInstance;
+ private String instanceClass;
+ private String objectMapper;
+ private String useDefaultObjectMapper = "true";
+ private String autoDiscoverObjectMapper = "false";
+ private ProtobufLibrary library = ProtobufLibrary.GoogleProtobuf;
+ private String unmarshalTypeName;
+ private Class<?> unmarshalType;
+ private String jsonViewTypeName;
+ private Class<?> jsonView;
+ private String include;
+ private String allowJmsType;
+ private String collectionTypeName;
+ private Class<?> collectionType;
+ private String useList;
+ private String moduleClassNames;
+ private String moduleRefs;
+ private String enableFeatures;
+ private String disableFeatures;
+ private String allowUnmarshallType;
+ private String timezone;
+ private String schemaResolver;
+ private String autoDiscoverSchemaResolver = "true";
+ private String contentTypeFormat = "native";
+ private String contentTypeHeader = "true";
+
+ /**
+ * Name of class to use when unmarshalling
+ */
+ public Builder instanceClass(String instanceClass) {
+ this.instanceClass = instanceClass;
+ return this;
+ }
+
+ /**
+ * Defines a content type format in which protobuf message will be serialized/deserialized from(to) the Java
+ * been. The format can either be native or json for either native protobuf or json fields representation. The
+ * default value is native.
+ */
+ public Builder contentTypeFormat(String contentTypeFormat) {
+ this.contentTypeFormat = contentTypeFormat;
+ return this;
+ }
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ public Builder defaultInstance(Object defaultInstance) {
+ this.defaultInstance = defaultInstance;
+ return this;
+ }
+
+ /**
+ * Which Protobuf library to use.
+ */
+ public Builder library(ProtobufLibrary library) {
+ this.library = library;
+ return this;
+ }
+
+ /**
+ * Lookup and use the existing ObjectMapper with the given id when using Jackson.
+ */
+ public Builder objectMapper(String objectMapper) {
+ this.objectMapper = objectMapper;
+ return this;
+ }
+
+ /**
+ * Whether to lookup and use default Jackson ObjectMapper from the registry.
+ */
+ public Builder useDefaultObjectMapper(String useDefaultObjectMapper) {
+ this.useDefaultObjectMapper = useDefaultObjectMapper;
+ return this;
+ }
+
+ /**
+ * Class name of the java type to use when unmarshalling
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * Class of the java type to use when unmarshalling
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonViewTypeName(String jsonViewTypeName) {
+ this.jsonViewTypeName = jsonViewTypeName;
+ return this;
+ }
+
+ /**
+ * When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson
+ * you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView
+ * annotations
+ */
+ public Builder jsonView(Class<?> jsonView) {
+ this.jsonView = jsonView;
+ return this;
+ }
+
+ /**
+ * If you want to marshal a pojo to JSON, and the pojo has some fields with null values. And you want to skip
+ * these null values, you can set this option to <tt>NON_NULL</tt>
+ */
+ public Builder include(String include) {
+ this.include = include;
+ return this;
+ }
+
+ /**
+ * Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to
+ * unmarshal to.
+ */
+ public Builder allowJmsType(String allowJmsType) {
+ this.allowJmsType = allowJmsType;
+ return this;
+ }
+
+ /**
+ * Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but
+ * allows to use different collection types than java.util.Collection based as default.
+ */
+ public Builder collectionTypeName(String collectionTypeName) {
+ this.collectionTypeName = collectionTypeName;
+ return this;
+ }
+
+ public Builder collectionType(Class<?> collectionType) {
+ this.collectionType = collectionType;
+ return this;
+ }
+
+ /**
+ * To unmarshal to a List of Map or a List of Pojo.
+ */
+ public Builder useList(String useList) {
+ this.useList = useList;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class
+ * names. Multiple classes can be separated by comma.
+ */
+ public Builder moduleClassNames(String moduleClassNames) {
+ this.moduleClassNames = moduleClassNames;
+ return this;
+ }
+
+ /**
+ * To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma.
+ */
+ public Builder moduleRefs(String moduleRefs) {
+ this.moduleRefs = moduleRefs;
+ return this;
+ }
+
+ /**
+ * Set of features to enable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder enableFeatures(String enableFeatures) {
+ this.enableFeatures = enableFeatures;
+ return this;
+ }
+
+ /**
+ * Set of features to disable on the Jackson <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
+ * <p/>
+ * The features should be a name that matches a enum from
+ * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
+ * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
+ * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
+ * <p/>
+ * Multiple features can be separated by comma
+ */
+ public Builder disableFeatures(String disableFeatures) {
+ this.disableFeatures = disableFeatures;
+ return this;
+ }
+
+ /**
+ * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the
+ * unmarshalling.
+ * <p/>
+ * This should only be enabled when desired to be used.
+ */
+ public Builder allowUnmarshallType(String allowUnmarshallType) {
+ this.allowUnmarshallType = allowUnmarshallType;
+ return this;
+ }
+
+ /**
+ * If set then Jackson will use the Timezone when marshalling/unmarshalling.
+ */
+ public Builder timezone(String timezone) {
+ this.timezone = timezone;
+ return this;
+ }
+
+ /**
+ * If set to true then Jackson will lookup for an objectMapper into the registry
+ */
+ public Builder autoDiscoverObjectMapper(String autoDiscoverObjectMapper) {
+ this.autoDiscoverObjectMapper = autoDiscoverObjectMapper;
+ return this;
+ }
+
+ /**
+ * Optional schema resolver used to lookup schemas for the data in transit.
+ */
+ public Builder schemaResolver(String schemaResolver) {
+ this.schemaResolver = schemaResolver;
+ return this;
+ }
+
+ /**
+ * When not disabled, the SchemaResolver will be looked up into the registry
+ */
+ public Builder autoDiscoverSchemaResolver(String autoDiscoverSchemaResolver) {
+ this.autoDiscoverSchemaResolver = autoDiscoverSchemaResolver;
+ return this;
+ }
+
+ @Override
+ public ProtobufDataFormat end() {
+ return new ProtobufDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/RssDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/RssDataFormat.java
index 7081df94353..7b41fc60126 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/RssDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/RssDataFormat.java
@@ -19,7 +19,9 @@ package org.apache.camel.model.dataformat;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -35,4 +37,14 @@ public class RssDataFormat extends DataFormatDefinition {
super("rss");
}
+ /**
+ * {@code Builder} is a specific builder for {@link RssDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<RssDataFormat> {
+ @Override
+ public RssDataFormat end() {
+ return new RssDataFormat();
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SoapDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SoapDataFormat.java
index 11c16f00ac5..aad760a6f7c 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SoapDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SoapDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -72,6 +73,17 @@ public class SoapDataFormat extends DataFormatDefinition {
setElementNameStrategy(elementNameStrategy);
}
+ private SoapDataFormat(Builder builder) {
+ this();
+ this.contextPath = builder.contextPath;
+ this.encoding = builder.encoding;
+ this.elementNameStrategyRef = builder.elementNameStrategyRef;
+ this.elementNameStrategy = builder.elementNameStrategy;
+ this.version = builder.version;
+ this.namespacePrefixRef = builder.namespacePrefixRef;
+ this.schema = builder.schema;
+ }
+
/**
* Package name where your JAXB classes are located.
*/
@@ -186,4 +198,116 @@ public class SoapDataFormat extends DataFormatDefinition {
this.schema = schema;
}
+ /**
+ * {@code Builder} is a specific builder for {@link SoapDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<SoapDataFormat> {
+
+ private String contextPath;
+ private String encoding;
+ private String elementNameStrategyRef;
+ private Object elementNameStrategy;
+ private String version = "1.1";
+ private String namespacePrefixRef;
+ private String schema;
+
+ /**
+ * Package name where your JAXB classes are located.
+ */
+ public Builder contextPath(String contextPath) {
+ this.contextPath = contextPath;
+ return this;
+ }
+
+ /**
+ * To overrule and use a specific encoding
+ */
+ public Builder encoding(String encoding) {
+ this.encoding = encoding;
+ return this;
+ }
+
+ /**
+ * Refers to an element strategy to lookup from the registry.
+ * <p/>
+ * An element name strategy is used for two purposes. The first is to find a xml element name for a given object
+ * and soap action when marshaling the object into a SOAP message. The second is to find an Exception class for
+ * a given soap fault name.
+ * <p/>
+ * The following three element strategy class name is provided out of the box. QNameStrategy - Uses a fixed
+ * qName that is configured on instantiation. Exception lookup is not supported TypeNameStrategy - Uses the name
+ * and namespace from the @XMLType annotation of the given type. If no namespace is set then package-info is
+ * used. Exception lookup is not supported ServiceInterfaceStrategy - Uses information from a webservice
+ * interface to determine the type name and to find the exception class for a SOAP fault
+ * <p/>
+ * All three classes is located in the package name org.apache.camel.dataformat.soap.name
+ * <p/>
+ * If you have generated the web service stub code with cxf-codegen or a similar tool then you probably will
+ * want to use the ServiceInterfaceStrategy. In the case you have no annotated service interface you should use
+ * QNameStrategy or TypeNameStrategy.
+ */
+ public Builder elementNameStrategyRef(String elementNameStrategyRef) {
+ this.elementNameStrategyRef = elementNameStrategyRef;
+ return this;
+ }
+
+ /**
+ * SOAP version should either be 1.1 or 1.2.
+ * <p/>
+ * Is by default 1.1
+ */
+ public Builder version(String version) {
+ this.version = version;
+ return this;
+ }
+
+ /**
+ * Sets an element strategy instance to use.
+ * <p/>
+ * An element name strategy is used for two purposes. The first is to find a xml element name for a given object
+ * and soap action when marshaling the object into a SOAP message. The second is to find an Exception class for
+ * a given soap fault name.
+ * <p/>
+ * The following three element strategy class name is provided out of the box. QNameStrategy - Uses a fixed
+ * qName that is configured on instantiation. Exception lookup is not supported TypeNameStrategy - Uses the name
+ * and namespace from the @XMLType annotation of the given type. If no namespace is set then package-info is
+ * used. Exception lookup is not supported ServiceInterfaceStrategy - Uses information from a webservice
+ * interface to determine the type name and to find the exception class for a SOAP fault
+ * <p/>
+ * All three classes is located in the package name org.apache.camel.dataformat.soap.name
+ * <p/>
+ * If you have generated the web service stub code with cxf-codegen or a similar tool then you probably will
+ * want to use the ServiceInterfaceStrategy. In the case you have no annotated service interface you should use
+ * QNameStrategy or TypeNameStrategy.
+ */
+ public Builder elementNameStrategy(Object elementNameStrategy) {
+ this.elementNameStrategy = elementNameStrategy;
+ return this;
+ }
+
+ /**
+ * When marshalling using JAXB or SOAP then the JAXB implementation will automatic assign namespace prefixes,
+ * such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you to refer to a map which contains the
+ * desired mapping.
+ */
+ public Builder namespacePrefixRef(String namespacePrefixRef) {
+ this.namespacePrefixRef = namespacePrefixRef;
+ return this;
+ }
+
+ /**
+ * To validate against an existing schema. Your can use the prefix classpath:, file:* or *http: to specify how
+ * the resource should be resolved. You can separate multiple schema files by using the ',' character.
+ */
+ public Builder schema(String schema) {
+ this.schema = schema;
+ return this;
+ }
+
+ @Override
+ public SoapDataFormat end() {
+ return new SoapDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMtDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMtDataFormat.java
index 163cb85e40e..02452d6123a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMtDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMtDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -45,6 +47,11 @@ public class SwiftMtDataFormat extends DataFormatDefinition {
this.writeInJson = writeInJson;
}
+ private SwiftMtDataFormat(Builder builder) {
+ this();
+ this.writeInJson = builder.writeInJson;
+ }
+
public String getWriteInJson() {
return writeInJson;
}
@@ -58,4 +65,37 @@ public class SwiftMtDataFormat extends DataFormatDefinition {
this.writeInJson = writeInJson;
}
+ /**
+ * {@code Builder} is a specific builder for {@link SwiftMtDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<SwiftMtDataFormat> {
+
+ private String writeInJson;
+
+ /**
+ * The flag indicating that messages must be marshalled in a JSON format.
+ *
+ * @param writeInJson {@code true} if messages must be marshalled in a JSON format, {@code false} otherwise.
+ */
+ public Builder writeInJson(String writeInJson) {
+ this.writeInJson = writeInJson;
+ return this;
+ }
+
+ /**
+ * The flag indicating that messages must be marshalled in a JSON format.
+ *
+ * @param writeInJson {@code true} if messages must be marshalled in a JSON format, {@code false} otherwise.
+ */
+ public Builder writeInJson(boolean writeInJson) {
+ this.writeInJson = Boolean.toString(writeInJson);
+ return this;
+ }
+
+ @Override
+ public SwiftMtDataFormat end() {
+ return new SwiftMtDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMxDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMxDataFormat.java
index 63d06f30a13..133eb0113f8 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMxDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SwiftMxDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -85,6 +86,16 @@ public class SwiftMxDataFormat extends DataFormatDefinition {
this.readConfigRef = readConfigRef;
}
+ private SwiftMxDataFormat(Builder builder) {
+ this();
+ this.writeConfigRef = builder.writeConfigRef;
+ this.writeConfig = builder.writeConfig;
+ this.writeInJson = builder.writeInJson;
+ this.readMessageId = builder.readMessageId;
+ this.readConfigRef = builder.readConfigRef;
+ this.readConfig = builder.readConfig;
+ }
+
public Object getWriteConfig() {
return writeConfig;
}
@@ -153,4 +164,84 @@ public class SwiftMxDataFormat extends DataFormatDefinition {
public void setReadConfigRef(String readConfigRef) {
this.readConfigRef = readConfigRef;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link SwiftMxDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<SwiftMxDataFormat> {
+
+ private String writeConfigRef;
+ private Object writeConfig;
+ private String writeInJson;
+ private String readMessageId;
+ private String readConfigRef;
+ private Object readConfig;
+
+ /**
+ * The specific configuration to use when marshalling a message.
+ */
+ public Builder writeConfig(Object writeConfig) {
+ this.writeConfig = writeConfig;
+ return this;
+ }
+
+ /**
+ * The flag indicating that messages must be marshalled in a JSON format.
+ *
+ * @param writeInJson {@code true} if messages must be marshalled in a JSON format, {@code false} otherwise.
+ */
+ public Builder writeInJson(String writeInJson) {
+ this.writeInJson = writeInJson;
+ return this;
+ }
+
+ /**
+ * The flag indicating that messages must be marshalled in a JSON format.
+ *
+ * @param writeInJson {@code true} if messages must be marshalled in a JSON format, {@code false} otherwise.
+ */
+ public Builder writeInJson(boolean writeInJson) {
+ this.writeInJson = Boolean.toString(writeInJson);
+ return this;
+ }
+
+ /**
+ * The type of MX message to produce when unmarshalling an input stream. If not set, it will be automatically
+ * detected from the namespace used.
+ */
+ public Builder readMessageId(String readMessageId) {
+ this.readMessageId = readMessageId;
+ return this;
+ }
+
+ /**
+ * The specific configuration to use when unmarshalling an input stream.
+ */
+ public Builder readConfig(Object readConfig) {
+ this.readConfig = readConfig;
+ return this;
+ }
+
+ /**
+ * Refers to a specific configuration to use when marshalling a message to lookup from the registry.
+ */
+ public Builder writeConfigRef(String writeConfigRef) {
+ this.writeConfigRef = writeConfigRef;
+ return this;
+ }
+
+ /**
+ * Refers to a specific configuration to use when unmarshalling an input stream to lookup from the registry.
+ */
+ public Builder readConfigRef(String readConfigRef) {
+ this.readConfigRef = readConfigRef;
+ return this;
+ }
+
+ @Override
+ public SwiftMxDataFormat end() {
+ return new SwiftMxDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SyslogDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SyslogDataFormat.java
index 0127ce2bd25..5928cbca907 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SyslogDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SyslogDataFormat.java
@@ -19,7 +19,9 @@ package org.apache.camel.model.dataformat;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -34,4 +36,15 @@ public class SyslogDataFormat extends DataFormatDefinition {
public SyslogDataFormat() {
super("syslog");
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link SyslogDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<SyslogDataFormat> {
+ @Override
+ public SyslogDataFormat end() {
+ return new SyslogDataFormat();
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
index 92de50f94e9..76279d5e21a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -49,6 +51,13 @@ public class TarFileDataFormat extends DataFormatDefinition {
super("tarFile");
}
+ private TarFileDataFormat(Builder builder) {
+ this.usingIterator = builder.usingIterator;
+ this.allowEmptyDirectory = builder.allowEmptyDirectory;
+ this.preservePathElements = builder.preservePathElements;
+ this.maxDecompressedSize = builder.maxDecompressedSize;
+ }
+
public String getUsingIterator() {
return usingIterator;
}
@@ -100,4 +109,59 @@ public class TarFileDataFormat extends DataFormatDefinition {
this.maxDecompressedSize = maxDecompressedSize;
}
+ /**
+ * {@code Builder} is a specific builder for {@link TarFileDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<TarFileDataFormat> {
+
+ private String usingIterator;
+ private String allowEmptyDirectory;
+ private String preservePathElements;
+ private String maxDecompressedSize = "1073741824";
+
+ /**
+ * If the tar file has more than one entry, the setting this option to true, allows working with the splitter
+ * EIP, to split the data using an iterator in a streaming mode.
+ */
+ public Builder usingIterator(String usingIterator) {
+ this.usingIterator = usingIterator;
+ return this;
+ }
+
+ /**
+ * If the tar file has more than one entry, setting this option to true, allows to get the iterator even if the
+ * directory is empty
+ */
+ public Builder allowEmptyDirectory(String allowEmptyDirectory) {
+ this.allowEmptyDirectory = allowEmptyDirectory;
+ return this;
+ }
+
+ /**
+ * If the file name contains path elements, setting this option to true, allows the path to be maintained in the
+ * tar file.
+ */
+ public Builder preservePathElements(String preservePathElements) {
+ this.preservePathElements = preservePathElements;
+ return this;
+ }
+
+ /**
+ * Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to
+ * 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable
+ * setting a maximum decompressed size.
+ *
+ * @param maxDecompressedSize the maximum decompressed size of a tar file (in bytes)
+ */
+ public Builder maxDecompressedSize(String maxDecompressedSize) {
+ this.maxDecompressedSize = maxDecompressedSize;
+ return this;
+ }
+
+ @Override
+ public TarFileDataFormat end() {
+ return new TarFileDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ThriftDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ThriftDataFormat.java
index bf5c5c26cec..f65d14a4140 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ThriftDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ThriftDataFormat.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -62,6 +63,14 @@ public class ThriftDataFormat extends DataFormatDefinition implements ContentTyp
setContentTypeFormat(contentTypeFormat);
}
+ private ThriftDataFormat(Builder builder) {
+ this();
+ this.defaultInstance = builder.defaultInstance;
+ this.instanceClass = builder.instanceClass;
+ this.contentTypeFormat = builder.contentTypeFormat;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ }
+
public String getInstanceClass() {
return instanceClass;
}
@@ -102,4 +111,48 @@ public class ThriftDataFormat extends DataFormatDefinition implements ContentTyp
this.defaultInstance = defaultInstance;
}
+ /**
+ * {@code Builder} is a specific builder for {@link ThriftDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<ThriftDataFormat> {
+
+ private Object defaultInstance;
+ private String instanceClass;
+ private String contentTypeFormat = "binary";
+ private String contentTypeHeader = "true";
+
+ /**
+ * Name of class to use when unmarshalling
+ */
+ public Builder instanceClass(String instanceClass) {
+ this.instanceClass = instanceClass;
+ return this;
+ }
+
+ /**
+ * Defines a content type format in which thrift message will be serialized/deserialized from(to) the Java been.
+ * The format can either be native or json for either native binary thrift, json or simple json fields
+ * representation. The default value is binary.
+ */
+ public Builder contentTypeFormat(String contentTypeFormat) {
+ this.contentTypeFormat = contentTypeFormat;
+ return this;
+ }
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ public Builder defaultInstance(Object defaultInstance) {
+ this.defaultInstance = defaultInstance;
+ return this;
+ }
+
+ @Override
+ public ThriftDataFormat end() {
+ return new ThriftDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TidyMarkupDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TidyMarkupDataFormat.java
index 0d0334e03a5..fdf2e21d3f6 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TidyMarkupDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/TidyMarkupDataFormat.java
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlTransient;
import org.w3c.dom.Node;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -59,6 +60,13 @@ public class TidyMarkupDataFormat extends DataFormatDefinition {
this.setDataObjectType(dataObjectType);
}
+ private TidyMarkupDataFormat(Builder builder) {
+ this();
+ this.dataObjectType = builder.dataObjectType;
+ this.dataObjectTypeName = builder.dataObjectTypeName;
+ this.omitXmlDeclaration = builder.omitXmlDeclaration;
+ }
+
/**
* What data type to unmarshal as, can either be org.w3c.dom.Node or java.lang.String.
* <p/>
@@ -96,4 +104,47 @@ public class TidyMarkupDataFormat extends DataFormatDefinition {
this.omitXmlDeclaration = omitXmlDeclaration;
}
+ /**
+ * {@code Builder} is a specific builder for {@link TidyMarkupDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<TidyMarkupDataFormat> {
+
+ private Class<?> dataObjectType;
+ private String dataObjectTypeName = "org.w3c.dom.Node";
+ private String omitXmlDeclaration;
+
+ /**
+ * What data type to unmarshal as, can either be org.w3c.dom.Node or java.lang.String.
+ * <p/>
+ * Is by default org.w3c.dom.Node
+ */
+ public Builder dataObjectType(Class<?> dataObjectType) {
+ this.dataObjectType = dataObjectType;
+ return this;
+ }
+
+ /**
+ * What data type to unmarshal as, can either be org.w3c.dom.Node or java.lang.String.
+ * <p/>
+ * Is by default org.w3c.dom.Node
+ */
+ public Builder dataObjectTypeName(String dataObjectTypeName) {
+ this.dataObjectTypeName = dataObjectTypeName;
+ return this;
+ }
+
+ /**
+ * When returning a String, do we omit the XML declaration in the top.
+ */
+ public Builder omitXmlDeclaration(String omitXmlDeclaration) {
+ this.omitXmlDeclaration = omitXmlDeclaration;
+ return this;
+ }
+
+ @Override
+ public TidyMarkupDataFormat end() {
+ return new TidyMarkupDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityAbstractDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityAbstractDataFormat.java
index 6ee3d37d351..5a9ce8df80b 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityAbstractDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityAbstractDataFormat.java
@@ -22,7 +22,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -83,6 +85,24 @@ public abstract class UniVocityAbstractDataFormat extends DataFormatDefinition {
super(dataFormatName);
}
+ protected UniVocityAbstractDataFormat(String dataFormatName, AbstractBuilder<?, ?> builder) {
+ this(dataFormatName);
+ this.nullValue = builder.nullValue;
+ this.skipEmptyLines = builder.skipEmptyLines;
+ this.ignoreTrailingWhitespaces = builder.ignoreTrailingWhitespaces;
+ this.ignoreLeadingWhitespaces = builder.ignoreLeadingWhitespaces;
+ this.headersDisabled = builder.headersDisabled;
+ this.headers = builder.headers;
+ this.headerExtractionEnabled = builder.headerExtractionEnabled;
+ this.numberOfRecordsToRead = builder.numberOfRecordsToRead;
+ this.emptyValue = builder.emptyValue;
+ this.lineSeparator = builder.lineSeparator;
+ this.normalizedLineSeparator = builder.normalizedLineSeparator;
+ this.comment = builder.comment;
+ this.lazyLoad = builder.lazyLoad;
+ this.asMap = builder.asMap;
+ }
+
public String getNullValue() {
return nullValue;
}
@@ -114,7 +134,7 @@ public abstract class UniVocityAbstractDataFormat extends DataFormatDefinition {
}
/**
- * Whether or not the trailing white spaces must ignored.
+ * Whether or not the trailing white spaces must be ignored.
* <p/>
* The default value is true
*/
@@ -262,4 +282,164 @@ public abstract class UniVocityAbstractDataFormat extends DataFormatDefinition {
this.asMap = asMap;
}
+ /**
+ * {@code Builder} is a specific builder for {@link UniVocityAbstractDataFormat}.
+ */
+ @XmlTransient
+ @SuppressWarnings("unchecked")
+ abstract static class AbstractBuilder<T extends AbstractBuilder<T, F>, F extends UniVocityAbstractDataFormat>
+ implements DataFormatBuilder<F> {
+
+ private String nullValue;
+ private String skipEmptyLines = "true";
+ private String ignoreTrailingWhitespaces = "true";
+ private String ignoreLeadingWhitespaces = "true";
+ private String headersDisabled;
+ private List<UniVocityHeader> headers;
+ private String headerExtractionEnabled;
+ private String numberOfRecordsToRead;
+ private String emptyValue;
+ private String lineSeparator;
+ private String normalizedLineSeparator = "\\n";
+ private String comment = "#";
+ private String lazyLoad;
+ private String asMap;
+
+ /**
+ * The string representation of a null value.
+ * <p/>
+ * The default value is null
+ */
+ public T nullValue(String nullValue) {
+ this.nullValue = nullValue;
+ return (T) this;
+ }
+
+ /**
+ * Whether or not the empty lines must be ignored.
+ * <p/>
+ * The default value is true
+ */
+ public T skipEmptyLines(String skipEmptyLines) {
+ this.skipEmptyLines = skipEmptyLines;
+ return (T) this;
+ }
+
+ /**
+ * Whether or not the trailing white spaces must be ignored.
+ * <p/>
+ * The default value is true
+ */
+ public T ignoreTrailingWhitespaces(String ignoreTrailingWhitespaces) {
+ this.ignoreTrailingWhitespaces = ignoreTrailingWhitespaces;
+ return (T) this;
+ }
+
+ /**
+ * Whether or not the leading white spaces must be ignored.
+ * <p/>
+ * The default value is true
+ */
+ public T ignoreLeadingWhitespaces(String ignoreLeadingWhitespaces) {
+ this.ignoreLeadingWhitespaces = ignoreLeadingWhitespaces;
+ return (T) this;
+ }
+
+ /**
+ * Whether or not the headers are disabled. When defined, this option explicitly sets the headers as null which
+ * indicates that there is no header.
+ * <p/>
+ * The default value is false
+ */
+ public T headersDisabled(String headersDisabled) {
+ this.headersDisabled = headersDisabled;
+ return (T) this;
+ }
+
+ /**
+ * The headers to use.
+ */
+ public T headers(List<UniVocityHeader> headers) {
+ this.headers = headers;
+ return (T) this;
+ }
+
+ /**
+ * Whether or not the header must be read in the first line of the test document
+ * <p/>
+ * The default value is false
+ */
+ public T headerExtractionEnabled(String headerExtractionEnabled) {
+ this.headerExtractionEnabled = headerExtractionEnabled;
+ return (T) this;
+ }
+
+ /**
+ * The maximum number of record to read.
+ */
+ public T numberOfRecordsToRead(String numberOfRecordsToRead) {
+ this.numberOfRecordsToRead = numberOfRecordsToRead;
+ return (T) this;
+ }
+
+ /**
+ * The String representation of an empty value
+ */
+ public T emptyValue(String emptyValue) {
+ this.emptyValue = emptyValue;
+ return (T) this;
+ }
+
+ /**
+ * The line separator of the files
+ * <p/>
+ * The default value is to use the JVM platform line separator
+ */
+ public T lineSeparator(String lineSeparator) {
+ this.lineSeparator = lineSeparator;
+ return (T) this;
+ }
+
+ /**
+ * The normalized line separator of the files
+ * <p/>
+ * The default value is a new line character.
+ */
+ public T normalizedLineSeparator(String normalizedLineSeparator) {
+ this.normalizedLineSeparator = normalizedLineSeparator;
+ return (T) this;
+ }
+
+ /**
+ * The comment symbol.
+ * <p/>
+ * The default value is #
+ */
+ public T comment(String comment) {
+ this.comment = comment;
+ return (T) this;
+ }
+
+ /**
+ * Whether the unmarshalling should produce an iterator that reads the lines on the fly or if all the lines must
+ * be read at one.
+ * <p/>
+ * The default value is false
+ */
+ public T lazyLoad(String lazyLoad) {
+ this.lazyLoad = lazyLoad;
+ return (T) this;
+ }
+
+ /**
+ * Whether the unmarshalling should produce maps for the lines values instead of lists. It requires to have
+ * header (either defined or collected).
+ * <p/>
+ * The default value is false
+ */
+ public T asMap(String asMap) {
+ this.asMap = asMap;
+ return (T) this;
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityCsvDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityCsvDataFormat.java
index 55263878eed..14bc3d9f864 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityCsvDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityCsvDataFormat.java
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.spi.Metadata;
@@ -48,6 +49,14 @@ public class UniVocityCsvDataFormat extends UniVocityAbstractDataFormat {
super("univocityCsv");
}
+ private UniVocityCsvDataFormat(Builder builder) {
+ super("univocityCsv", builder);
+ this.delimiter = builder.delimiter;
+ this.quoteAllFields = builder.quoteAllFields;
+ this.quote = builder.quote;
+ this.quoteEscape = builder.quoteEscape;
+ }
+
public String getQuoteAllFields() {
return quoteAllFields;
}
@@ -92,4 +101,52 @@ public class UniVocityCsvDataFormat extends UniVocityAbstractDataFormat {
this.delimiter = delimiter;
}
+ /**
+ * {@code Builder} is a specific builder for {@link UniVocityCsvDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder extends AbstractBuilder<Builder, UniVocityCsvDataFormat> {
+
+ private String delimiter = ",";
+ private String quoteAllFields;
+ private String quote = "\"";
+ private String quoteEscape = "\"";
+
+ /**
+ * Whether or not all values must be quoted when writing them.
+ */
+ public Builder quoteAllFields(String quoteAllFields) {
+ this.quoteAllFields = quoteAllFields;
+ return this;
+ }
+
+ /**
+ * The quote symbol.
+ */
+ public Builder quote(String quote) {
+ this.quote = quote;
+ return this;
+ }
+
+ /**
+ * The quote escape symbol
+ */
+ public Builder quoteEscape(String quoteEscape) {
+ this.quoteEscape = quoteEscape;
+ return this;
+ }
+
+ /**
+ * The delimiter of values
+ */
+ public Builder delimiter(String delimiter) {
+ this.delimiter = delimiter;
+ return this;
+ }
+
+ @Override
+ public UniVocityCsvDataFormat end() {
+ return new UniVocityCsvDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityFixedDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityFixedDataFormat.java
index 86812bfe6b0..c2ccd5d5e72 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityFixedDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityFixedDataFormat.java
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.spi.Metadata;
@@ -44,6 +45,13 @@ public class UniVocityFixedDataFormat extends UniVocityAbstractDataFormat {
super("univocityFixed");
}
+ private UniVocityFixedDataFormat(Builder builder) {
+ super("univocityFixed", builder);
+ this.padding = builder.padding;
+ this.skipTrailingCharsUntilNewline = builder.skipTrailingCharsUntilNewline;
+ this.recordEndsOnNewline = builder.recordEndsOnNewline;
+ }
+
public String getSkipTrailingCharsUntilNewline() {
return skipTrailingCharsUntilNewline;
}
@@ -83,4 +91,49 @@ public class UniVocityFixedDataFormat extends UniVocityAbstractDataFormat {
this.padding = padding;
}
+ /**
+ * {@code Builder} is a specific builder for {@link UniVocityFixedDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder extends AbstractBuilder<Builder, UniVocityFixedDataFormat> {
+
+ private String padding;
+ private String skipTrailingCharsUntilNewline;
+ private String recordEndsOnNewline;
+
+ /**
+ * Whether or not the trailing characters until new line must be ignored.
+ * <p/>
+ * The default value is false
+ */
+ public Builder skipTrailingCharsUntilNewline(String skipTrailingCharsUntilNewline) {
+ this.skipTrailingCharsUntilNewline = skipTrailingCharsUntilNewline;
+ return this;
+ }
+
+ /**
+ * Whether or not the record ends on new line.
+ * <p/>
+ * The default value is false
+ */
+ public Builder recordEndsOnNewline(String recordEndsOnNewline) {
+ this.recordEndsOnNewline = recordEndsOnNewline;
+ return this;
+ }
+
+ /**
+ * The padding character.
+ * <p/>
+ * The default value is a space
+ */
+ public Builder padding(String padding) {
+ this.padding = padding;
+ return this;
+ }
+
+ @Override
+ public UniVocityFixedDataFormat end() {
+ return new UniVocityFixedDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityTsvDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityTsvDataFormat.java
index 19582dec26a..c9419c412a1 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityTsvDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/UniVocityTsvDataFormat.java
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.spi.Metadata;
@@ -39,6 +40,11 @@ public class UniVocityTsvDataFormat extends UniVocityAbstractDataFormat {
super("univocityTsv");
}
+ private UniVocityTsvDataFormat(Builder builder) {
+ super("univocityTsv", builder);
+ this.escapeChar = builder.escapeChar;
+ }
+
public String getEscapeChar() {
return escapeChar;
}
@@ -50,4 +56,25 @@ public class UniVocityTsvDataFormat extends UniVocityAbstractDataFormat {
this.escapeChar = escapeChar;
}
+ /**
+ * {@code Builder} is a specific builder for {@link UniVocityTsvDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder extends AbstractBuilder<Builder, UniVocityTsvDataFormat> {
+
+ private String escapeChar = "\\";
+
+ /**
+ * The escape character.
+ */
+ public Builder escapeChar(String escapeChar) {
+ this.escapeChar = escapeChar;
+ return this;
+ }
+
+ @Override
+ public UniVocityTsvDataFormat end() {
+ return new UniVocityTsvDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
index bff45667bb3..75d3c85d018 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.NamespaceAware;
@@ -79,6 +80,24 @@ public class XMLSecurityDataFormat extends DataFormatDefinition implements Names
super("xmlSecurity");
}
+ private XMLSecurityDataFormat(Builder builder) {
+ this();
+ this.xmlCipherAlgorithm = builder.xmlCipherAlgorithm;
+ this.passPhrase = builder.passPhrase;
+ this.passPhraseByte = builder.passPhraseByte;
+ this.secureTag = builder.secureTag;
+ this.secureTagContents = builder.secureTagContents;
+ this.keyCipherAlgorithm = builder.keyCipherAlgorithm;
+ this.recipientKeyAlias = builder.recipientKeyAlias;
+ this.keyOrTrustStoreParametersRef = builder.keyOrTrustStoreParametersRef;
+ this.keyPassword = builder.keyPassword;
+ this.digestAlgorithm = builder.digestAlgorithm;
+ this.mgfAlgorithm = builder.mgfAlgorithm;
+ this.addKeyValueForEncryptedKey = builder.addKeyValueForEncryptedKey;
+ this.keyOrTrustStoreParameters = builder.keyOrTrustStoreParameters;
+ this.namespaces = builder.namespaces;
+ }
+
public String getXmlCipherAlgorithm() {
return xmlCipherAlgorithm;
}
@@ -276,4 +295,187 @@ public class XMLSecurityDataFormat extends DataFormatDefinition implements Names
public Map<String, String> getNamespaces() {
return namespaces;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link XMLSecurityDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<XMLSecurityDataFormat> {
+
+ private String xmlCipherAlgorithm = "AES-256-GCM";
+ private String passPhrase;
+ private byte[] passPhraseByte;
+ private String secureTag;
+ private String secureTagContents;
+ private String keyCipherAlgorithm = "RSA_OAEP";
+ private String recipientKeyAlias;
+ private String keyOrTrustStoreParametersRef;
+ private String keyPassword;
+ private String digestAlgorithm = "SHA1";
+ private String mgfAlgorithm = "MGF1_SHA1";
+ private String addKeyValueForEncryptedKey = "true";
+ private KeyStoreParameters keyOrTrustStoreParameters;
+ private Map<String, String> namespaces;
+
+ /**
+ * The cipher algorithm to be used for encryption/decryption of the XML message content. The available choices
+ * are:
+ * <ul>
+ * <li>XMLCipher.TRIPLEDES</li>
+ * <li>XMLCipher.AES_128</li>
+ * <li>XMLCipher.AES_128_GCM</li>
+ * <li>XMLCipher.AES_192</li>
+ * <li>XMLCipher.AES_192_GCM</li>
+ * <li>XMLCipher.AES_256</li>
+ * <li>XMLCipher.AES_256_GCM</li>
+ * <li>XMLCipher.SEED_128</li>
+ * <li>XMLCipher.CAMELLIA_128</li>
+ * <li>XMLCipher.CAMELLIA_192</li>
+ * <li>XMLCipher.CAMELLIA_256</li>
+ * </ul>
+ * The default value is XMLCipher.AES_256_GCM
+ */
+ public Builder xmlCipherAlgorithm(String xmlCipherAlgorithm) {
+ this.xmlCipherAlgorithm = xmlCipherAlgorithm;
+ return this;
+ }
+
+ /**
+ * A String used as passPhrase to encrypt/decrypt content. The passPhrase has to be provided. The passPhrase
+ * needs to be put together in conjunction with the appropriate encryption algorithm. For example using
+ * TRIPLEDES the passPhase can be a "Only another 24 Byte key"
+ */
+ public Builder passPhrase(String passPhrase) {
+ this.passPhrase = passPhrase;
+ return this;
+ }
+
+ /**
+ * A byte[] used as passPhrase to encrypt/decrypt content. The passPhrase has to be provided. The passPhrase
+ * needs to be put together in conjunction with the appropriate encryption algorithm. For example using
+ * TRIPLEDES the passPhase can be a "Only another 24 Byte key"
+ */
+ public Builder passPhraseByte(byte[] passPhraseByte) {
+ this.passPhraseByte = passPhraseByte;
+ return this;
+ }
+
+ /**
+ * The XPath reference to the XML Element selected for encryption/decryption. If no tag is specified, the entire
+ * payload is encrypted/decrypted.
+ */
+ public Builder secureTag(String secureTag) {
+ this.secureTag = secureTag;
+ return this;
+ }
+
+ /**
+ * A boolean value to specify whether the XML Element is to be encrypted or the contents of the XML Element.
+ * false = Element Level. true = Element Content Level.
+ */
+ public Builder secureTagContents(String secureTagContents) {
+ this.secureTagContents = secureTagContents;
+ return this;
+ }
+
+ /**
+ * The cipher algorithm to be used for encryption/decryption of the asymmetric key. The available choices are:
+ * <ul>
+ * <li>XMLCipher.RSA_v1dot5</li>
+ * <li>XMLCipher.RSA_OAEP</li>
+ * <li>XMLCipher.RSA_OAEP_11</li>
+ * </ul>
+ * The default value is XMLCipher.RSA_OAEP
+ */
+ public Builder keyCipherAlgorithm(String keyCipherAlgorithm) {
+ this.keyCipherAlgorithm = keyCipherAlgorithm;
+ return this;
+ }
+
+ /**
+ * The key alias to be used when retrieving the recipient's public or private key from a KeyStore when
+ * performing asymmetric key encryption or decryption.
+ */
+ public Builder recipientKeyAlias(String recipientKeyAlias) {
+ this.recipientKeyAlias = recipientKeyAlias;
+ return this;
+ }
+
+ /**
+ * Refers to a KeyStore instance to lookup in the registry, which is used for configuration options for creating
+ * and loading a KeyStore instance that represents the sender's trustStore or recipient's keyStore.
+ */
+ public Builder keyOrTrustStoreParametersRef(String keyOrTrustStoreParametersRef) {
+ this.keyOrTrustStoreParametersRef = keyOrTrustStoreParametersRef;
+ return this;
+ }
+
+ /**
+ * Configuration options for creating and loading a KeyStore instance that represents the sender's trustStore or
+ * recipient's keyStore.
+ */
+ public Builder keyOrTrustStoreParameters(KeyStoreParameters keyOrTrustStoreParameters) {
+ this.keyOrTrustStoreParameters = keyOrTrustStoreParameters;
+ return this;
+ }
+
+ /**
+ * The password to be used for retrieving the private key from the KeyStore. This key is used for asymmetric
+ * decryption.
+ */
+ public Builder keyPassword(String keyPassword) {
+ this.keyPassword = keyPassword;
+ return this;
+ }
+
+ /**
+ * The digest algorithm to use with the RSA OAEP algorithm. The available choices are:
+ * <ul>
+ * <li>XMLCipher.SHA1</li>
+ * <li>XMLCipher.SHA256</li>
+ * <li>XMLCipher.SHA512</li>
+ * </ul>
+ * The default value is XMLCipher.SHA1
+ */
+ public Builder digestAlgorithm(String digestAlgorithm) {
+ this.digestAlgorithm = digestAlgorithm;
+ return this;
+ }
+
+ /**
+ * The MGF Algorithm to use with the RSA OAEP algorithm. The available choices are:
+ * <ul>
+ * <li>EncryptionConstants.MGF1_SHA1</li>
+ * <li>EncryptionConstants.MGF1_SHA256</li>
+ * <li>EncryptionConstants.MGF1_SHA512</li>
+ * </ul>
+ * The default value is EncryptionConstants.MGF1_SHA1
+ */
+ public Builder mgfAlgorithm(String mgfAlgorithm) {
+ this.mgfAlgorithm = mgfAlgorithm;
+ return this;
+ }
+
+ /**
+ * Whether to add the public key used to encrypt the session key as a KeyValue in the EncryptedKey structure or
+ * not.
+ */
+ public Builder addKeyValueForEncryptedKey(String addKeyValueForEncryptedKey) {
+ this.addKeyValueForEncryptedKey = addKeyValueForEncryptedKey;
+ return this;
+ }
+
+ public Builder setNamespaces(Map<String, String> nspaces) {
+ if (this.namespaces == null) {
+ this.namespaces = new HashMap<>();
+ }
+ this.namespaces.putAll(nspaces);
+ return this;
+ }
+
+ @Override
+ public XMLSecurityDataFormat end() {
+ return new XMLSecurityDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
index c376408fc32..9bc97483a3c 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
@@ -27,7 +27,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.model.PropertyDefinition;
import org.apache.camel.spi.Metadata;
@@ -77,6 +79,20 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
setEncoding(encoding);
}
+ private XStreamDataFormat(Builder builder) {
+ this();
+ this.permissions = builder.permissions;
+ this.encoding = builder.encoding;
+ this.driver = builder.driver;
+ this.driverRef = builder.driverRef;
+ this.mode = builder.mode;
+ this.contentTypeHeader = builder.contentTypeHeader;
+ this.converters = builder.converters;
+ this.aliases = builder.aliases;
+ this.omitFields = builder.omitFields;
+ this.implicitCollections = builder.implicitCollections;
+ }
+
@Override
public String getDataFormatName() {
return "json".equals(driver) ? "xstreamJson" : "xstream";
@@ -159,8 +175,13 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
}
public void setConverters(Map<String, String> converters) {
- this.converters = new ArrayList<>();
- converters.forEach((k, v) -> this.converters.add(new PropertyDefinition(k, v)));
+ setConverters(toList(converters));
+ }
+
+ private static List<PropertyDefinition> toList(Map<String, String> map) {
+ List<PropertyDefinition> result = new ArrayList<>(map.size());
+ map.forEach((k, v) -> result.add(new PropertyDefinition(k, v)));
+ return result;
}
public List<PropertyDefinition> getAliases() {
@@ -186,8 +207,7 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
}
public void setAliases(Map<String, String> aliases) {
- this.aliases = new ArrayList<>();
- aliases.forEach((k, v) -> this.aliases.add(new PropertyDefinition(k, v)));
+ setAliases(toList(aliases));
}
public List<PropertyDefinition> getOmitFields() {
@@ -203,8 +223,7 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
}
public void setOmitFields(Map<String, String> aliases) {
- this.omitFields = new ArrayList<>();
- aliases.forEach((k, v) -> this.omitFields.add(new PropertyDefinition(k, v)));
+ setOmitFields(toList(aliases));
}
public Map<String, String> getOmitFieldsAsMap() {
@@ -231,8 +250,7 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
}
public void setImplicitCollections(Map<String, String> implicitCollections) {
- this.implicitCollections = new ArrayList<>();
- implicitCollections.forEach((k, v) -> this.implicitCollections.add(new PropertyDefinition(k, v)));
+ setImplicitCollections(toList(implicitCollections));
}
public Map<String, String> getImplicitCollectionsAsMap() {
@@ -273,12 +291,16 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
* @see #setPermissions(String)
*/
public void setPermissions(Class<?>... type) {
+ setPermissions(toString(type));
+ }
+
+ private static String toString(Class<?>[] type) {
StringJoiner permissionsBuilder = new StringJoiner(",");
for (Class<?> clazz : type) {
permissionsBuilder.add("+");
permissionsBuilder.add(clazz.getName());
}
- setPermissions(permissionsBuilder.toString());
+ return permissionsBuilder.toString();
}
public String getContentTypeHeader() {
@@ -289,4 +311,139 @@ public class XStreamDataFormat extends DataFormatDefinition implements ContentTy
this.contentTypeHeader = contentTypeHeader;
}
+ /**
+ * {@code Builder} is a specific builder for {@link XStreamDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<XStreamDataFormat> {
+
+ private String permissions;
+ private String encoding;
+ private String driver;
+ private String driverRef;
+ private String mode;
+ private String contentTypeHeader = "true";
+ private List<PropertyDefinition> converters;
+ private List<PropertyDefinition> aliases;
+ private List<PropertyDefinition> omitFields;
+ private List<PropertyDefinition> implicitCollections;
+
+ /**
+ * Sets the encoding to use
+ */
+ public Builder encoding(String encoding) {
+ this.encoding = encoding;
+ return this;
+ }
+
+ /**
+ * To use a custom XStream driver. The instance must be of type
+ * com.thoughtworks.xstream.io.HierarchicalStreamDriver
+ */
+ public Builder driver(String driver) {
+ this.driver = driver;
+ return this;
+ }
+
+ /**
+ * To refer to a custom XStream driver to lookup in the registry. The instance must be of type
+ * com.thoughtworks.xstream.io.HierarchicalStreamDriver
+ */
+ public Builder driverRef(String driverRef) {
+ this.driverRef = driverRef;
+ return this;
+ }
+
+ /**
+ * Mode for dealing with duplicate references The possible values are:
+ * <ul>
+ * <li>NO_REFERENCES</li>
+ * <li>ID_REFERENCES</li>
+ * <li>XPATH_RELATIVE_REFERENCES</li>
+ * <li>XPATH_ABSOLUTE_REFERENCES</li>
+ * <li>SINGLE_NODE_XPATH_RELATIVE_REFERENCES</li>
+ * <li>SINGLE_NODE_XPATH_ABSOLUTE_REFERENCES</li>
+ * </ul>
+ */
+ public Builder mode(String mode) {
+ this.mode = mode;
+ return this;
+ }
+
+ /**
+ * List of class names for using custom XStream converters. The classes must be of type
+ * com.thoughtworks.xstream.converters.Converter
+ */
+ public Builder converters(List<PropertyDefinition> converters) {
+ this.converters = converters;
+ return this;
+ }
+
+ public Builder converters(Map<String, String> converters) {
+ return converters(XStreamDataFormat.toList(converters));
+ }
+
+ /**
+ * Prevents a field from being serialized. To omit a field you must always provide the declaring type and not
+ * necessarily the type that is converted. Multiple values can be separated by comma.
+ */
+ public Builder omitFields(List<PropertyDefinition> omitFields) {
+ this.omitFields = omitFields;
+ return this;
+ }
+
+ public Builder omitFields(Map<String, String> aliases) {
+ return omitFields(XStreamDataFormat.toList(aliases));
+ }
+
+ /**
+ * Adds a default implicit collection which is used for any unmapped XML tag. Multiple values can be separated
+ * by comma.
+ */
+ public Builder implicitCollections(List<PropertyDefinition> implicitCollections) {
+ this.implicitCollections = implicitCollections;
+ return this;
+ }
+
+ public Builder implicitCollections(Map<String, String> implicitCollections) {
+ return implicitCollections(XStreamDataFormat.toList(implicitCollections));
+ }
+
+ /**
+ * Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal
+ * from xml/json to Java beans.
+ * <p/>
+ * A permission must be configured either here or globally using a JVM system property. The permission can be
+ * specified in a syntax where a plus sign is allow, and minus sign is deny. <br/>
+ * Wildcards is supported by using <tt>.*</tt> as prefix. For example to allow <tt>com.foo</tt> and all
+ * subpackages then specify <tt>+com.foo.*</tt>. Multiple permissions can be configured separated by comma, such
+ * as <tt>+com.foo.*,-com.foo.bar.MySecretBean</tt>. <br/>
+ * The following default permission is always included: <tt>"-*,java.lang.*,java.util.*"</tt> unless its
+ * overridden by specifying a JVM system property with they key <tt>org.apache.camel.xstream.permissions</tt>.
+ */
+ public Builder permissions(String permissions) {
+ this.permissions = permissions;
+ return this;
+ }
+
+ /**
+ * To add permission for the given pojo classes.
+ *
+ * @param type the pojo class(es) xstream should use as allowed permission
+ * @see #setPermissions(String)
+ */
+ public Builder permissions(Class<?>... type) {
+ return permissions(XStreamDataFormat.toString(type));
+ }
+
+ public Builder contentTypeHeader(String contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ return this;
+ }
+
+ @Override
+ public XStreamDataFormat end() {
+ return new XStreamDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/YAMLDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/YAMLDataFormat.java
index 21ee1facfc7..8b5915cb9ca 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/YAMLDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/YAMLDataFormat.java
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -91,6 +92,24 @@ public class YAMLDataFormat extends DataFormatDefinition {
this.unmarshalType = unmarshalType;
}
+ private YAMLDataFormat(Builder builder) {
+ super(builder.dataFormatName == null ? YAMLLibrary.SnakeYAML.getDataFormatName() : builder.dataFormatName);
+ this.classLoader = builder.classLoader;
+ this.unmarshalType = builder.unmarshalType;
+ this.library = builder.library;
+ this.unmarshalTypeName = builder.unmarshalTypeName;
+ this.constructor = builder.constructor;
+ this.representer = builder.representer;
+ this.dumperOptions = builder.dumperOptions;
+ this.resolver = builder.resolver;
+ this.useApplicationContextClassLoader = builder.useApplicationContextClassLoader;
+ this.prettyFlow = builder.prettyFlow;
+ this.allowAnyType = builder.allowAnyType;
+ this.typeFilters = builder.typeFilters;
+ this.maxAliasesForCollections = builder.maxAliasesForCollections;
+ this.allowRecursiveKeys = builder.allowRecursiveKeys;
+ }
+
@Override
public String getDataFormatName() {
// yaml data format is special as the name can be from different bundles
@@ -253,4 +272,147 @@ public class YAMLDataFormat extends DataFormatDefinition {
public void setAllowRecursiveKeys(String allowRecursiveKeys) {
this.allowRecursiveKeys = allowRecursiveKeys;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link YAMLDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<YAMLDataFormat> {
+
+ private String dataFormatName;
+ private ClassLoader classLoader;
+ private Class<?> unmarshalType;
+ private YAMLLibrary library = YAMLLibrary.SnakeYAML;
+ private String unmarshalTypeName;
+ private String constructor;
+ private String representer;
+ private String dumperOptions;
+ private String resolver;
+ private String useApplicationContextClassLoader = "true";
+ private String prettyFlow;
+ private String allowAnyType;
+ private List<YAMLTypeFilterDefinition> typeFilters;
+ private String maxAliasesForCollections = "50";
+ private String allowRecursiveKeys;
+
+ /**
+ * Which yaml library to use.
+ * <p/>
+ * By default it is SnakeYAML
+ */
+ public Builder library(YAMLLibrary library) {
+ this.library = library;
+ this.dataFormatName = "yaml-" + library.name().toLowerCase();
+ return this;
+ }
+
+ /**
+ * Class of the object to be created
+ */
+ public Builder unmarshalType(Class<?> unmarshalType) {
+ this.unmarshalType = unmarshalType;
+ return this;
+ }
+
+ /**
+ * Class name of the java type to use when unmarshalling
+ */
+ public Builder unmarshalTypeName(String unmarshalTypeName) {
+ this.unmarshalTypeName = unmarshalTypeName;
+ return this;
+ }
+
+ /**
+ * Set a custom classloader
+ */
+ public Builder classLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ return this;
+ }
+
+ /**
+ * BaseConstructor to construct incoming documents.
+ */
+ public Builder constructor(String constructor) {
+ this.constructor = constructor;
+ return this;
+ }
+
+ /**
+ * Representer to emit outgoing objects.
+ */
+ public Builder representer(String representer) {
+ this.representer = representer;
+ return this;
+ }
+
+ /**
+ * DumperOptions to configure outgoing objects.
+ */
+ public Builder dumperOptions(String dumperOptions) {
+ this.dumperOptions = dumperOptions;
+ return this;
+ }
+
+ /**
+ * Resolver to detect implicit type
+ */
+ public Builder resolver(String resolver) {
+ this.resolver = resolver;
+ return this;
+ }
+
+ /**
+ * Use ApplicationContextClassLoader as custom ClassLoader
+ */
+ public Builder useApplicationContextClassLoader(String useApplicationContextClassLoader) {
+ this.useApplicationContextClassLoader = useApplicationContextClassLoader;
+ return this;
+ }
+
+ /**
+ * Force the emitter to produce a pretty YAML document when using the flow style.
+ */
+ public Builder prettyFlow(String prettyFlow) {
+ this.prettyFlow = prettyFlow;
+ return this;
+ }
+
+ /**
+ * Allow any class to be un-marshaled
+ */
+ public Builder allowAnyType(String allowAnyType) {
+ this.allowAnyType = allowAnyType;
+ return this;
+ }
+
+ /**
+ * Set the types SnakeYAML is allowed to un-marshall
+ */
+ public Builder typeFilters(List<YAMLTypeFilterDefinition> typeFilters) {
+ this.typeFilters = typeFilters;
+ return this;
+ }
+
+ /**
+ * Set the maximum amount of aliases allowed for collections.
+ */
+ public Builder maxAliasesForCollections(String maxAliasesForCollections) {
+ this.maxAliasesForCollections = maxAliasesForCollections;
+ return this;
+ }
+
+ /**
+ * Set whether recursive keys are allowed.
+ */
+ public Builder allowRecursiveKeys(String allowRecursiveKeys) {
+ this.allowRecursiveKeys = allowRecursiveKeys;
+ return this;
+ }
+
+ @Override
+ public YAMLDataFormat end() {
+ return new YAMLDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java
index 91af9010e63..681ef750265 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -40,6 +42,11 @@ public class ZipDeflaterDataFormat extends DataFormatDefinition {
super("zipDeflater");
}
+ private ZipDeflaterDataFormat(Builder builder) {
+ this();
+ this.compressionLevel = builder.compressionLevel;
+ }
+
public String getCompressionLevel() {
return compressionLevel;
}
@@ -51,4 +58,27 @@ public class ZipDeflaterDataFormat extends DataFormatDefinition {
public void setCompressionLevel(String compressionLevel) {
this.compressionLevel = compressionLevel;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link ZipDeflaterDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<ZipDeflaterDataFormat> {
+
+ private String compressionLevel = "-1";
+
+ /**
+ * To specify a specific compression between 0-9. -1 is default compression, 0 is no compression, and 9 is the
+ * best compression.
+ */
+ public Builder compressionLevel(String compressionLevel) {
+ this.compressionLevel = compressionLevel;
+ return this;
+ }
+
+ @Override
+ public ZipDeflaterDataFormat end() {
+ return new ZipDeflaterDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
index 41675a31a7b..74e72ea4d6a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
@@ -20,7 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.builder.DataFormatBuilder;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.Metadata;
@@ -49,6 +51,14 @@ public class ZipFileDataFormat extends DataFormatDefinition {
super("zipFile");
}
+ private ZipFileDataFormat(Builder builder) {
+ this();
+ this.usingIterator = builder.usingIterator;
+ this.allowEmptyDirectory = builder.allowEmptyDirectory;
+ this.preservePathElements = builder.preservePathElements;
+ this.maxDecompressedSize = builder.maxDecompressedSize;
+ }
+
public String getUsingIterator() {
return usingIterator;
}
@@ -99,4 +109,60 @@ public class ZipFileDataFormat extends DataFormatDefinition {
public void setMaxDecompressedSize(String maxDecompressedSize) {
this.maxDecompressedSize = maxDecompressedSize;
}
+
+ /**
+ * {@code Builder} is a specific builder for {@link ZipFileDataFormat}.
+ */
+ @XmlTransient
+ public static class Builder implements DataFormatBuilder<ZipFileDataFormat> {
+
+ private String usingIterator;
+ private String allowEmptyDirectory;
+ private String preservePathElements;
+ private String maxDecompressedSize = "1073741824";
+
+ /**
+ * If the zip file has more than one entry, the setting this option to true, allows working with the splitter
+ * EIP, to split the data using an iterator in a streaming mode.
+ */
+ public Builder usingIterator(String usingIterator) {
+ this.usingIterator = usingIterator;
+ return this;
+ }
+
+ /**
+ * If the zip file has more than one entry, setting this option to true, allows to get the iterator even if the
+ * directory is empty
+ */
+ public Builder allowEmptyDirectory(String allowEmptyDirectory) {
+ this.allowEmptyDirectory = allowEmptyDirectory;
+ return this;
+ }
+
+ /**
+ * If the file name contains path elements, setting this option to true, allows the path to be maintained in the
+ * zip file.
+ */
+ public Builder preservePathElements(String preservePathElements) {
+ this.preservePathElements = preservePathElements;
+ return this;
+ }
+
+ /**
+ * Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to
+ * 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable
+ * setting a maximum decompressed size.
+ *
+ * @param maxDecompressedSize the maximum decompressed size of a zip file (in bytes)
+ */
+ public Builder maxDecompressedSize(String maxDecompressedSize) {
+ this.maxDecompressedSize = maxDecompressedSize;
+ return this;
+ }
+
+ @Override
+ public ZipFileDataFormat end() {
+ return new ZipFileDataFormat(this);
+ }
+ }
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java b/core/camel-core/src/test/java/org/apache/camel/impl/DataFormatFluentSyntaxTest.java
similarity index 51%
copy from core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
copy to core/camel-core/src/test/java/org/apache/camel/impl/DataFormatFluentSyntaxTest.java
index 0aab050323a..28adfc4046d 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/GzipDeflaterDataFormat.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DataFormatFluentSyntaxTest.java
@@ -14,22 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.model.dataformat;
+package org.apache.camel.impl;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.model.DataFormatDefinition;
-import org.apache.camel.spi.Metadata;
+import org.apache.camel.builder.RouteBuilder;
/**
- * Compress and decompress messages using <code>java.util.zip.GZIP*Stream</code>.
+ * A unit test class ensuring that the fluent syntax to create data format works as expected.
*/
-@Metadata(firstVersion = "2.0.0", label = "dataformat,transformation", title = "GZip Deflater")
-@XmlRootElement(name = "gzipDeflater")
-public class GzipDeflaterDataFormat extends DataFormatDefinition {
+public class DataFormatFluentSyntaxTest extends RefDataFormatTest {
- public GzipDeflaterDataFormat() {
- super("gzipDeflater");
- }
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: e1
+ from("direct:a").marshal(
+ dataFormat().custom().ref("reverse").end()
+ ).to("mock:a");
+ from("direct:b").unmarshal(
+ dataFormat().custom().ref("reverse").end()
+ ).to("mock:b");
+ // END SNIPPET: e1
+ }
+ };
+ }
}