001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.builder;
018    
019    import java.util.Map;
020    import java.util.zip.Deflater;
021    
022    import org.w3c.dom.Node;
023    
024    import org.apache.camel.model.DataFormatDefinition;
025    import org.apache.camel.model.ProcessorDefinition;
026    import org.apache.camel.model.dataformat.AvroDataFormat;
027    import org.apache.camel.model.dataformat.Base64DataFormat;
028    import org.apache.camel.model.dataformat.BeanioDataFormat;
029    import org.apache.camel.model.dataformat.BindyDataFormat;
030    import org.apache.camel.model.dataformat.BindyType;
031    import org.apache.camel.model.dataformat.CastorDataFormat;
032    import org.apache.camel.model.dataformat.CsvDataFormat;
033    import org.apache.camel.model.dataformat.CustomDataFormat;
034    import org.apache.camel.model.dataformat.GzipDataFormat;
035    import org.apache.camel.model.dataformat.HL7DataFormat;
036    import org.apache.camel.model.dataformat.JaxbDataFormat;
037    import org.apache.camel.model.dataformat.JibxDataFormat;
038    import org.apache.camel.model.dataformat.JsonDataFormat;
039    import org.apache.camel.model.dataformat.JsonLibrary;
040    import org.apache.camel.model.dataformat.PGPDataFormat;
041    import org.apache.camel.model.dataformat.ProtobufDataFormat;
042    import org.apache.camel.model.dataformat.RssDataFormat;
043    import org.apache.camel.model.dataformat.SerializationDataFormat;
044    import org.apache.camel.model.dataformat.SoapJaxbDataFormat;
045    import org.apache.camel.model.dataformat.StringDataFormat;
046    import org.apache.camel.model.dataformat.SyslogDataFormat;
047    import org.apache.camel.model.dataformat.TidyMarkupDataFormat;
048    import org.apache.camel.model.dataformat.XMLBeansDataFormat;
049    import org.apache.camel.model.dataformat.XMLSecurityDataFormat;
050    import org.apache.camel.model.dataformat.XStreamDataFormat;
051    import org.apache.camel.model.dataformat.XmlJsonDataFormat;
052    import org.apache.camel.model.dataformat.ZipDataFormat;
053    import org.apache.camel.model.dataformat.ZipFileDataFormat;
054    import org.apache.camel.util.jsse.KeyStoreParameters;
055    
056    /**
057     * An expression for constructing the different possible {@link org.apache.camel.spi.DataFormat}
058     * options.
059     *
060     * @version 
061     */
062    public class DataFormatClause<T extends ProcessorDefinition<?>> {
063        private final T processorType;
064        private final Operation operation;
065    
066        /**
067         * {@link org.apache.camel.spi.DataFormat} operations.
068         */
069        public enum Operation {
070            Marshal, Unmarshal
071        }
072    
073        public DataFormatClause(T processorType, Operation operation) {
074            this.processorType = processorType;
075            this.operation = operation;
076        }
077    
078        /**
079         * Uses the Avro data format
080         */
081        public T avro() {
082            return dataFormat(new AvroDataFormat());
083        }
084    
085        public T avro(Object schema) {
086            AvroDataFormat dataFormat = new AvroDataFormat();
087            dataFormat.setSchema(schema);
088            return dataFormat(dataFormat);
089        }
090    
091        public T avro(String instanceClassName) {
092            return dataFormat(new AvroDataFormat(instanceClassName));
093        }
094    
095        /**
096         * Uses the base64 data format
097         */
098        public T base64() {
099            Base64DataFormat dataFormat = new Base64DataFormat();
100            return dataFormat(dataFormat);
101        }
102    
103        /**
104         * Uses the base64 data format
105         */
106        public T base64(int lineLength, String lineSeparator, boolean urlSafe) {
107            Base64DataFormat dataFormat = new Base64DataFormat();
108            dataFormat.setLineLength(lineLength);
109            dataFormat.setLineSeparator(lineSeparator);
110            dataFormat.setUrlSafe(urlSafe);
111            return dataFormat(dataFormat);
112        }
113    
114        /**
115         * Uses the beanio data format
116         */
117        public T beanio(String mapping, String streamName) {
118            BeanioDataFormat dataFormat = new BeanioDataFormat();
119            dataFormat.setMapping(mapping);
120            dataFormat.setStreamName(streamName);
121            return dataFormat(dataFormat);
122        }
123    
124        /**
125         * Uses the beanio data format
126         */
127        public T beanio(String mapping, String streamName, String encoding) {
128            BeanioDataFormat dataFormat = new BeanioDataFormat();
129            dataFormat.setMapping(mapping);
130            dataFormat.setStreamName(streamName);
131            dataFormat.setEncoding(encoding);
132            return dataFormat(dataFormat);
133        }
134    
135        /**
136         * Uses the beanio data format
137         */
138        public T beanio(String mapping, String streamName, String encoding,
139                        boolean ignoreUnidentifiedRecords, boolean ignoreUnexpectedRecords, boolean ignoreInvalidRecords) {
140            BeanioDataFormat dataFormat = new BeanioDataFormat();
141            dataFormat.setMapping(mapping);
142            dataFormat.setStreamName(streamName);
143            dataFormat.setEncoding(encoding);
144            dataFormat.setIgnoreInvalidRecords(ignoreInvalidRecords);
145            dataFormat.setIgnoreUnexpectedRecords(ignoreUnexpectedRecords);
146            dataFormat.setIgnoreInvalidRecords(ignoreInvalidRecords);
147            return dataFormat(dataFormat);
148        }
149    
150        /**
151         * Uses the Bindy data format
152         *
153         * @param type     the type of bindy data format to use
154         * @param packages packages to scan for Bindy annotated POJO classes
155         */
156        public T bindy(BindyType type, String... packages) {
157            BindyDataFormat bindy = new BindyDataFormat();
158            bindy.setType(type);
159            bindy.setPackages(packages);
160            return dataFormat(bindy);
161        }
162    
163        /**
164         * Uses the Bindy data format
165         *
166         * @param type      the type of bindy data format to use
167         * @param classType the POJO class type
168         */
169        public T bindy(BindyType type, Class<?> classType) {
170            BindyDataFormat bindy = new BindyDataFormat();
171            bindy.setType(type);
172            bindy.setClassType(classType);
173            return dataFormat(bindy);
174        }
175    
176        /**
177         * Uses the CSV data format
178         */
179        public T csv() {
180            return dataFormat(new CsvDataFormat());
181        }
182    
183        /**
184         * Uses the CSV data format for a huge file.
185         * Sequential access through an iterator.
186         */
187        public T csvLazyLoad() {
188            return dataFormat(new CsvDataFormat(true));
189        }
190    
191        /**
192         * Uses the custom data format
193         */
194        public T custom(String ref) {
195            return dataFormat(new CustomDataFormat(ref));
196        }
197    
198        /**
199         * Uses the Castor data format
200         */
201        public T castor() {
202            return dataFormat(new CastorDataFormat());
203        }
204    
205        /**
206         * Uses the Castor data format
207         *
208         * @param mappingFile name of mapping file to locate in classpath
209         */
210        public T castor(String mappingFile) {
211            CastorDataFormat castor = new CastorDataFormat();
212            castor.setMappingFile(mappingFile);
213            return dataFormat(castor);
214        }
215    
216        /**
217         * Uses the Castor data format
218         *
219         * @param mappingFile name of mapping file to locate in classpath
220         * @param validation  whether validation is enabled or not
221         */
222        public T castor(String mappingFile, boolean validation) {
223            CastorDataFormat castor = new CastorDataFormat();
224            castor.setMappingFile(mappingFile);
225            castor.setValidation(validation);
226            return dataFormat(castor);
227        }
228    
229        /**
230         * Uses the GZIP deflater data format
231         */
232        public T gzip() {
233            GzipDataFormat gzdf = new GzipDataFormat();
234            return dataFormat(gzdf);
235        }
236    
237        /**
238         * Uses the HL7 data format
239         */
240        public T hl7() {
241            return dataFormat(new HL7DataFormat());
242        }
243    
244        /**
245         * Uses the HL7 data format
246         */
247        public T hl7(boolean validate) {
248            HL7DataFormat hl7 = new HL7DataFormat();
249            hl7.setValidate(validate);
250            return dataFormat(hl7);
251        }
252        
253        /**
254         * Uses the HL7 data format
255         */
256        public T hl7(Object parser) {
257            HL7DataFormat hl7 = new HL7DataFormat();
258            hl7.setParser(parser);
259            return dataFormat(hl7);
260        }    
261    
262        /**
263         * Uses the PGP data format
264         */
265        public T pgp(String keyFileName, String keyUserid) {
266            PGPDataFormat pgp = new PGPDataFormat();
267            pgp.setKeyFileName(keyFileName);
268            pgp.setKeyUserid(keyUserid);
269            return dataFormat(pgp);
270        }
271    
272        /**
273         * Uses the PGP data format
274         */
275        public T pgp(String keyFileName, String keyUserid, String password) {
276            PGPDataFormat pgp = new PGPDataFormat();
277            pgp.setKeyFileName(keyFileName);
278            pgp.setKeyUserid(keyUserid);
279            pgp.setPassword(password);
280            return dataFormat(pgp);
281        }
282    
283        /**
284         * Uses the PGP data format
285         */
286        public T pgp(String keyFileName, String keyUserid, String password, boolean armored, boolean integrity) {
287            PGPDataFormat pgp = new PGPDataFormat();
288            pgp.setKeyFileName(keyFileName);
289            pgp.setKeyUserid(keyUserid);
290            pgp.setPassword(password);
291            pgp.setArmored(armored);
292            pgp.setIntegrity(integrity);
293            return dataFormat(pgp);
294        }
295    
296        /**
297         * Uses the JAXB data format
298         */
299        public T jaxb() {
300            return dataFormat(new JaxbDataFormat());
301        }
302    
303        /**
304         * Uses the JAXB data format with context path
305         */
306        public T jaxb(String contextPath) {
307            JaxbDataFormat dataFormat = new JaxbDataFormat();
308            dataFormat.setContextPath(contextPath);
309            return dataFormat(dataFormat);
310        }
311    
312        /**
313         * Uses the JAXB data format turning pretty printing on or off
314         */
315        public T jaxb(boolean prettyPrint) {
316            return dataFormat(new JaxbDataFormat(prettyPrint));
317        }
318    
319        /**
320         * Uses the JiBX data format.
321         */
322        public T jibx() {
323            return dataFormat(new JibxDataFormat());
324        }
325    
326        /**
327         * Uses the JiBX data format with unmarshall class.
328         */
329        public T jibx(Class<?> unmarshallClass) {
330            return dataFormat(new JibxDataFormat(unmarshallClass));
331        }
332    
333        /**
334         * Uses the JSON data format using the XStream json library
335         */
336        public T json() {
337            return dataFormat(new JsonDataFormat());
338        }
339    
340        /**
341         * Uses the JSON data format
342         *
343         * @param library the json library to use
344         */
345        public T json(JsonLibrary library) {
346            return dataFormat(new JsonDataFormat(library));
347        }
348    
349        /**
350         * Uses the JSON data format
351         *
352         * @param type          the json type to use
353         * @param unmarshalType unmarshal type for json jackson type
354         */
355        public T json(JsonLibrary type, Class<?> unmarshalType) {
356            JsonDataFormat json = new JsonDataFormat(type);
357            json.setUnmarshalType(unmarshalType);
358            return dataFormat(json);
359        }
360    
361        /**
362         * Uses the JSON data format
363         *
364         * @param type          the json type to use
365         * @param unmarshalType unmarshal type for json jackson type
366         * @param jsonView      the view type for json jackson type
367         */
368        public T json(Class<?> unmarshalType, Class<?> jsonView) {
369            JsonDataFormat json = new JsonDataFormat(JsonLibrary.Jackson);
370            json.setUnmarshalType(unmarshalType);
371            json.setJsonView(jsonView);
372            return dataFormat(json);
373        }
374    
375        /**
376         * Uses the protobuf data format
377         */
378        public T protobuf() {
379            return dataFormat(new ProtobufDataFormat());
380        }
381    
382        public T protobuf(Object defaultInstance) {
383            ProtobufDataFormat dataFormat = new ProtobufDataFormat();
384            dataFormat.setDefaultInstance(defaultInstance);
385            return dataFormat(dataFormat);
386        }
387    
388        public T protobuf(String instanceClassName) {
389            return dataFormat(new ProtobufDataFormat(instanceClassName));
390        }
391    
392        /**
393         * Uses the RSS data format
394         */
395        public T rss() {
396            return dataFormat(new RssDataFormat());
397        }
398    
399        /**
400         * Uses the Java Serialization data format
401         */
402        public T serialization() {
403            return dataFormat(new SerializationDataFormat());
404        }
405    
406        /**
407         * Uses the Soap 1.1 JAXB data format
408         */
409        public T soapjaxb() {
410            return dataFormat(new SoapJaxbDataFormat());
411        }
412    
413        /**
414         * Uses the Soap 1.1 JAXB data format
415         */
416        public T soapjaxb(String contextPath) {
417            return dataFormat(new SoapJaxbDataFormat(contextPath));
418        }
419    
420        /**
421         * Uses the Soap 1.1 JAXB data format
422         */
423        public T soapjaxb(String contextPath, String elementNameStrategyRef) {
424            return dataFormat(new SoapJaxbDataFormat(contextPath, elementNameStrategyRef));
425        }
426    
427        /**
428         * Uses the Soap 1.1 JAXB data format
429         */
430        public T soapjaxb(String contextPath, Object elementNameStrategy) {
431            return dataFormat(new SoapJaxbDataFormat(contextPath, elementNameStrategy));
432        }
433    
434        /**
435         * Uses the Soap 1.2 JAXB data format
436         */
437        public T soapjaxb12() {
438            SoapJaxbDataFormat soap = new SoapJaxbDataFormat();
439            soap.setVersion("1.2");
440            return dataFormat(soap);
441        }
442    
443        /**
444         * Uses the Soap 1.2 JAXB data format
445         */
446        public T soapjaxb12(String contextPath) {
447            SoapJaxbDataFormat soap = new SoapJaxbDataFormat(contextPath);
448            soap.setVersion("1.2");
449            return dataFormat(soap);
450        }
451    
452        /**
453         * Uses the Soap 1.2 JAXB data format
454         */
455        public T soapjaxb12(String contextPath, String elementNameStrategyRef) {
456            SoapJaxbDataFormat soap = new SoapJaxbDataFormat(contextPath, elementNameStrategyRef);
457            soap.setVersion("1.2");
458            return dataFormat(soap);
459        }
460    
461        /**
462         * Uses the Soap JAXB data format
463         */
464        public T soapjaxb12(String contextPath, Object elementNameStrategy) {
465            SoapJaxbDataFormat soap = new SoapJaxbDataFormat(contextPath, elementNameStrategy);
466            soap.setVersion("1.2");
467            return dataFormat(soap);
468        }
469    
470        /**
471         * Uses the String data format
472         */
473        public T string() {
474            return string(null);
475        }
476    
477        /**
478         * Uses the String data format supporting encoding using given charset
479         */
480        public T string(String charset) {
481            StringDataFormat sdf = new StringDataFormat();
482            sdf.setCharset(charset);
483            return dataFormat(sdf);
484        }
485    
486        /**
487         * Uses the Syslog data format
488         */
489        public T syslog() {
490            return dataFormat(new SyslogDataFormat());
491        }
492    
493        /**
494         * Return WellFormed HTML (an XML Document) either
495         * {@link java.lang.String} or {@link org.w3c.dom.Node}
496         */
497        public T tidyMarkup(Class<?> dataObjectType) {
498            return dataFormat(new TidyMarkupDataFormat(dataObjectType));
499        }
500    
501        /**
502         * Return TidyMarkup in the default format
503         * as {@link org.w3c.dom.Node}
504         */
505        public T tidyMarkup() {
506            return dataFormat(new TidyMarkupDataFormat(Node.class));
507        }
508    
509        /**
510         * Uses the XStream data format
511         */
512        public T xstream() {
513            return dataFormat(new XStreamDataFormat());
514        }
515    
516        /**
517         * Uses the xstream by setting the encoding
518         */
519        public T xstream(String encoding) {
520            return dataFormat(new XStreamDataFormat(encoding));
521        }
522    
523        /**
524         * Uses the XML Security data format
525         */
526        public T secureXML() {
527            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat();
528            return dataFormat(xsdf);
529        }
530    
531        /**
532         * Uses the XML Security data format
533         */
534        public T secureXML(String secureTag, boolean secureTagContents) {
535            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents);
536            return dataFormat(xsdf);
537        }
538        
539        /**
540         * Uses the XML Security data format
541         */
542        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents) {
543            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents);
544            return dataFormat(xsdf);
545        }
546    
547        /**
548         * Uses the XML Security data format
549         */
550        public T secureXML(String secureTag, boolean secureTagContents, String passPhrase) {
551            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, passPhrase);
552            return dataFormat(xsdf);
553        }
554        
555        /**
556         * Uses the XML Security data format
557         */
558        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String passPhrase) {
559            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, passPhrase);
560            return dataFormat(xsdf);
561        }
562        
563        /**
564         * Uses the XML Security data format
565         */
566        public T secureXML(String secureTag, boolean secureTagContents, String passPhrase, String xmlCipherAlgorithm) {
567            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, passPhrase, xmlCipherAlgorithm);
568            return dataFormat(xsdf);
569        }
570        
571        
572        /**
573         * Uses the XML Security data format
574         */
575        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String passPhrase, String xmlCipherAlgorithm) {
576            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, passPhrase, xmlCipherAlgorithm);
577            return dataFormat(xsdf);
578        }
579        
580        /**
581         * @deprecated Use {@link #secureXML(String, Map, boolean, String, String, String, String) instead.
582         * Uses the XML Security data format
583         */
584        @Deprecated
585        public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
586                String keyCipherAlgorithm) {
587            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, keyCipherAlgorithm);
588            return dataFormat(xsdf);
589        }
590        
591        /**
592         * Uses the XML Security data format
593         */
594        public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
595                String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
596            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
597                keyCipherAlgorithm, keyOrTrustStoreParametersId);
598            return dataFormat(xsdf);
599        }
600        
601        /**
602         * Uses the XML Security data format
603         */
604        public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
605                String keyCipherAlgorithm, String keyOrTrustStoreParametersId, String keyPassword) {
606            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
607                keyCipherAlgorithm, keyOrTrustStoreParametersId, keyPassword);
608            return dataFormat(xsdf);
609        }    
610        
611        /**
612         * Uses the XML Security data format
613         */
614        public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
615                String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
616            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
617                keyCipherAlgorithm, keyOrTrustStoreParameters);
618            return dataFormat(xsdf);
619        }
620        
621        /**
622         * Uses the XML Security data format
623         */
624        public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
625                String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters, String keyPassword) {
626            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
627                keyCipherAlgorithm, keyOrTrustStoreParameters, keyPassword);
628            return dataFormat(xsdf);
629        }    
630        
631        /**
632         * Uses the XML Security data format
633         */
634        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
635                String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
636            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
637                    keyCipherAlgorithm, keyOrTrustStoreParametersId);
638            return dataFormat(xsdf);
639        }
640        
641        /**
642         * Uses the XML Security data format
643         */
644        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
645                String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId, String keyPassword) {
646            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
647                    keyCipherAlgorithm, keyOrTrustStoreParametersId, keyPassword);
648            return dataFormat(xsdf);
649        }    
650        
651        /**
652         * Uses the XML Security data format
653         */
654        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
655                String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
656            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
657                    keyCipherAlgorithm, keyOrTrustStoreParameters);
658            return dataFormat(xsdf);
659        }
660        
661        /**
662         * Uses the XML Security data format
663         */
664        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
665                String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters, String keyPassword) {
666            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
667                    keyCipherAlgorithm, keyOrTrustStoreParameters, keyPassword);
668            return dataFormat(xsdf);
669        }   
670        
671        /**
672         * Uses the XML Security data format
673         */
674        public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
675                String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters, String keyPassword,
676                String digestAlgorithm) {
677            XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
678                    keyCipherAlgorithm, keyOrTrustStoreParameters, keyPassword, digestAlgorithm);
679            return dataFormat(xsdf);
680        }   
681        
682        /**
683         * Uses the xmlBeans data format
684         */
685        public T xmlBeans() {
686            return dataFormat(new XMLBeansDataFormat());
687        }
688    
689        /**
690         * Uses the xmljson dataformat, based on json-lib
691         */
692        public T xmljson() {
693            return dataFormat(new XmlJsonDataFormat());
694        }
695        
696        /**
697         * Uses the xmljson dataformat, based on json-lib, initializing custom options with a Map
698         */
699        public T xmljson(Map<String, String> options) {
700            return dataFormat(new XmlJsonDataFormat(options));
701        }
702        
703        /**
704         * Uses the ZIP deflater data format
705         */
706        public T zip() {
707            ZipDataFormat zdf = new ZipDataFormat(Deflater.DEFAULT_COMPRESSION);
708            return dataFormat(zdf);
709        }
710    
711        /**
712         * Uses the ZIP deflater data format
713         */
714        public T zip(int compressionLevel) {
715            ZipDataFormat zdf = new ZipDataFormat(compressionLevel);
716            return dataFormat(zdf);
717        }
718    
719        /**
720         * Uses the ZIP file data format
721         */
722        public T zipFile() {
723            ZipFileDataFormat zfdf = new ZipFileDataFormat();
724            return dataFormat(zfdf);
725        }
726    
727        @SuppressWarnings("unchecked")
728        private T dataFormat(DataFormatDefinition dataFormatType) {
729            switch (operation) {
730            case Unmarshal:
731                return (T) processorType.unmarshal(dataFormatType);
732            case Marshal:
733                return (T) processorType.marshal(dataFormatType);
734            default:
735                throw new IllegalArgumentException("Unknown DataFormat operation: " + operation);
736            }
737        }
738    }