forBits static method

Mode forBits(
  1. int bits
)

@param bits four bits encoding a QR Code data mode @return Mode encoded by these bits @throws IllegalArgumentException if bits do not correspond to a known mode

Implementation

static Mode forBits(int bits) {
  switch (bits) {
    case 0x0:
      return terminator;
    case 0x1:
      return numeric;
    case 0x2:
      return alphanumeric;
    case 0x3:
      return structuredAppend;
    case 0x4:
      return byte;
    case 0x5:
      return fnc1FirstPosition;
    case 0x7:
      return eci;
    case 0x8:
      return kanji;
    case 0x9:
      return fnc1SecondPosition;
    case 0xD:
      // 0xD is defined in GBT 18284-2000, may not be supported in foreign country
      return hanzi;
    default:
      throw ArgumentError();
  }
}