camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/5] git commit: CAMEL-7870 re-optimize hints when setBarcodeFormat called
Date Sat, 27 Sep 2014 11:14:24 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/3ac01178
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3ac01178
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3ac01178

Branch: refs/heads/master
Commit: 3ac01178d181cc9cde0ef4b8d5ddae4e2678845e
Parents: 61f9e83
Author: Seiji Sogabe <s.sogabe@gmail.com>
Authored: Sun Sep 28 04:13:28 2014 +0900
Committer: Seiji Sogabe <s.sogabe@gmail.com>
Committed: Sun Sep 28 04:13:28 2014 +0900

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


http://git-wip-us.apache.org/repos/asf/camel/blob/3ac01178/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/3ac01178/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