/*
- * 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.
static final Mode NUMERIC = new Mode(new int[]{10, 12, 14});
static final Mode ALPHANUMERIC = new Mode(new int[]{9, 11, 13});
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 int[] characterCountBitsForVersions;
+ private final int[] characterCountBitsForVersions;
private Mode(int[] characterCountBitsForVersions) {
this.characterCountBitsForVersions = characterCountBitsForVersions;
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);
}
}
* count of characters that will follow encoded in this {@link Mode}
*/
int getCharacterCountBits(Version version) {
+ if (characterCountBitsForVersions == null) {
+ throw new IllegalArgumentException("Character count doesn't apply to this mode");
+ }
int number = version.getVersionNumber();
int offset;
if (number <= 9) {