import Exception from './../../Exception' ; import Version from './Version' ; export const enum ModeValues { TERMINATOR , NUMERIC , ALPHANUMERIC , STRUCTURED_APPEND , BYTE , ECI , KANJI , FNC1_FIRST_POSITION , FNC1_SECOND_POSITION , /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */ HANZI } author Sean Owen
  export default class Mode { private static FOR_BITS = new Map < number , Mode > ( ) ; private static FOR_VALUE = new Map < ModeValues , Mode > ( ) ; public static TERMINATOR = new Mode ( ModeValues . TERMINATOR , "TERMINATOR" , Int32Array . from ( [ 0 , 0 , 0 ] ) , 0x00 ) ; public static NUMERIC = new Mode ( ModeValues . NUMERIC , "NUMERIC" , Int32Array . from ( [ 10 , 12 , 14 ] ) , 0x01 ) ; public static ALPHANUMERIC = new Mode ( ModeValues . ALPHANUMERIC , "ALPHANUMERIC" , Int32Array . from ( [ 9 , 11 , 13 ] ) , 0x02 ) ; public static STRUCTURED_APPEND = new Mode ( ModeValues . STRUCTURED_APPEND , "STRUCTURED_APPEND" , Int32Array . from ( [ 0 , 0 , 0 ] ) , 0x03 ) ; public static BYTE = new Mode ( ModeValues . BYTE , "BYTE" , Int32Array . from ( [ 8 , 16 , 16 ] ) , 0x04 ) ; public static ECI = new Mode ( ModeValues . ECI , "ECI" , Int32Array . from ( [ 0 , 0 , 0 ] ) , 0x07 ) ; public static KANJI = new Mode ( ModeValues . KANJI , "KANJI" , Int32Array . from ( [ 8 , 10 , 12 ] ) , 0x08 ) ; public static FNC1_FIRST_POSITION = new Mode ( ModeValues . FNC1_FIRST_POSITION , "FNC1_FIRST_POSITION" , Int32Array . from ( [ 0 , 0 , 0 ] ) , 0x05 ) ; public static FNC1_SECOND_POSITION = new Mode ( ModeValues . FNC1_SECOND_POSITION , "FNC1_SECOND_POSITION" , Int32Array . from ( [ 0 , 0 , 0 ] ) , 0x09 ) ; /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */ public static HANZI = new Mode ( ModeValues . HANZI , "HANZI" , Int32Array . from ( [ 8 , 10 , 12 ] ) , 0x0D ) ; private constructor ( private value , private stringValue , private characterCountBitsForVersions , private bits ) { Mode . FOR_BITS . set ( bits , this ) ; Mode . FOR_VALUE . set ( value , this ) ; } param bits return throws public static forBits ( bits ) { const mode = Mode . FOR_BITS . get ( bits ) ; if ( undefined === mode ) { throw new Exception ( Exception . IllegalArgumentException ) ; } return mode ; } param version return number of bits used, in this QR Code symbol  Version , to encode the
     *         count of characters that will follow encoded in this Mode
      public getCharacterCountBits ( version ) { const number = version . getVersionNumber ( ) ; let offset ; if ( number <= 9 ) { offset = 0 ; } else if ( number <= 26 ) { offset = 1 ; } else { offset = 2 ; } return this . characterCountBitsForVersions [ offset ] ; } public getValue ( ) { return this . value ; } public getBits ( ) { return this . bits ; } public equals ( o ) { if ( ! ( o instanceof Mode ) ) { return false ; } const other = < Mode > o ; return this . value === other . value ; } public toString ( ) { return this . stringValue ; } }