Add minimal support for FNC1 mode in QR Code
[zxing.git] / core / src / com / google / zxing / qrcode / decoder / Mode.java
index 7f1d2f9..9e9947b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2007 ZXing authors
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,8 @@ final class Mode {
   static final Mode BYTE = new Mode(new int[]{8, 16, 16});
   static final Mode ECI = new Mode(null); // character counts don't apply
   static final Mode KANJI = new Mode(new int[]{8, 10, 12});
+  static final Mode FNC1_FIRST_POSITION = new Mode(null);
+  static final Mode FNC1_SECOND_POSITION = new Mode(null);
 
   private final int[] characterCountBitsForVersions;
 
@@ -56,12 +58,16 @@ final class Mode {
         return ALPHANUMERIC;
       case 0x4:
         return BYTE;
+      case 0x5:
+        return FNC1_FIRST_POSITION;
       case 0x7:
         return ECI;
       case 0x8:
         return KANJI;
+      case 0x9:
+        return FNC1_SECOND_POSITION;
       default:
-        throw new ReaderException("Illegal mode bits: " + bits);
+        throw new ReaderException("Unsupported mode bits: " + bits);
     }
   }
 
@@ -71,8 +77,8 @@ final class Mode {
    *         count of characters that will follow encoded in this {@link Mode}
    */
   int getCharacterCountBits(Version version) {
-    if (this == ECI) {
-      throw new UnsupportedOperationException("Character count doesn't apply to ECI mode");
+    if (characterCountBitsForVersions == null) {
+      throw new IllegalArgumentException("Character count doesn't apply to this mode");
     }
     int number = version.getVersionNumber();
     int offset;