camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/5] git commit: CAMEL-7870 re-optimize hints when setBarcodeFormat called
Date Sat, 27 Sep 2014 11:14:23 GMT
CAMEL-7870 re-optimize hints when setBarcodeFormat called


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/49dccc13
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/49dccc13
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/49dccc13

Branch: refs/heads/camel-2.14.x
Commit: 49dccc13d09adddcd025e79f37beb5d299b06f28
Parents: c492777
Author: Seiji Sogabe <s.sogabe@gmail.com>
Authored: Sun Sep 28 04:13:28 2014 +0900
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Sep 27 13:14:08 2014 +0200

----------------------------------------------------------------------
 .../dataformat/barcode/BarcodeDataFormat.java   |  5 ++++
 .../barcode/BarcodeDataFormatTest.java          | 24 ++++++++++++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/49dccc13/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
index fe347ec..7639eaf 100644
--- a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
@@ -186,6 +186,10 @@ public class BarcodeDataFormat implements DataFormat {
      * Sets hints optimized for different barcode types.
      */
     protected final void optimizeHints() {
+        // clear hints for re-optimization
+        this.writerHintMap.clear();
+        this.readerHintMap.clear();
+
         // writer hints
         this.writerHintMap
                 .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
@@ -357,6 +361,7 @@ public class BarcodeDataFormat implements DataFormat {
     
     public void setBarcodeFormat(BarcodeFormat format) {
         this.params.setFormat(format);
+        this.optimizeHints();
     }
     
     public void setWidth(Integer width) {

http://git-wip-us.apache.org/repos/asf/camel/blob/49dccc13/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
index dad9387..8420625 100644
--- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
@@ -134,6 +134,30 @@ public class BarcodeDataFormatTest {
     }
 
     /**
+     * Test re-optimize hints.
+     */
+    @Test
+    public final void testReOptimizeHints() {
+        // DATA-MATRIX
+        BarcodeDataFormat instance = new BarcodeDataFormat(BarcodeFormat.DATA_MATRIX);
+        assertTrue(instance.getWriterHintMap()
+                        .containsKey(EncodeHintType.ERROR_CORRECTION));
+        assertTrue(instance.getWriterHintMap()
+                        .containsKey(EncodeHintType.DATA_MATRIX_SHAPE));
+        assertTrue(instance.getReaderHintMap()
+                        .containsKey(DecodeHintType.TRY_HARDER));
+
+        // -> QR-CODE
+        instance.setBarcodeFormat(BarcodeFormat.QR_CODE);
+        assertTrue(instance.getWriterHintMap()
+                        .containsKey(EncodeHintType.ERROR_CORRECTION));
+        assertFalse(instance.getWriterHintMap()
+                        .containsKey(EncodeHintType.DATA_MATRIX_SHAPE));
+        assertTrue(instance.getReaderHintMap()
+                        .containsKey(DecodeHintType.TRY_HARDER));
+    }
+
+    /**
      * Test of addToHintMap method, of class BarcodeDataFormat.
      */
     @Test


Mime
View raw message