import DecodeHintType from './DecodeHintType' ; import Reader from './Reader' ; import Result from './Result' ; import BinaryBitmap from './BinaryBitmap' ; import BarcodeFormat from './BarcodeFormat' ; import QRCodeReader from './qrcode/QRCodeReader' ; import Exception from './Exception' ; author Sean Owen
 *  author dswitkin google export default class MultiFormatReader implements Reader { private hints : Map < DecodeHintType , any > | null ; private readers : Reader [ ] ; param image return throws param image param hints return throws public decode ( image , hints ? ) { this . setHints ( hints ) ; return this . decodeInternal ( image ) ; } param image return throws public decodeWithState ( image ) { if ( this . readers === null || this . readers === undefined ) { this . setHints ( null ) ; } return this . decodeInternal ( image ) ; } param hints public setHints ( hints ? ) { this . hints = hints ; const tryHarder = hints !== null && hints !== undefined && undefined !== hints . get ( DecodeHintType . TRY_HARDER ) ; const formats = hints === null || hints === undefined ? null : hints . get ( DecodeHintType . POSSIBLE_FORMATS ) ; const readers = new Array < Reader > ( ) ; if ( formats !== null && formats !== undefined ) { const addOneDReader = formats . contains ( BarcodeFormat . UPC_A ) || formats . contains ( BarcodeFormat . UPC_E ) || formats . contains ( BarcodeFormat . EAN_13 ) || formats . contains ( BarcodeFormat . EAN_8 ) || formats . contains ( BarcodeFormat . CODABAR ) || formats . contains ( BarcodeFormat . CODE_39 ) || formats . contains ( BarcodeFormat . CODE_93 ) || formats . contains ( BarcodeFormat . CODE_128 ) || formats . contains ( BarcodeFormat . ITF ) || formats . contains ( BarcodeFormat . RSS_14 ) || formats . contains ( BarcodeFormat . RSS_EXPANDED ) ; if ( formats . contains ( BarcodeFormat . QR_CODE ) ) { readers . push ( new QRCodeReader ( ) ) ; } } if ( readers . length === 0 ) { readers . push ( new QRCodeReader ( ) ) ; } this . readers = readers ; } public reset ( ) { if ( this . readers !== null ) { for ( let i = 0 , length = this . readers . length ; i !== length ; i ++ ) { const reader = this . readers [ i ] ; reader . reset ( ) ; } } } private decodeInternal ( image ) { if ( this . readers !== null ) { for ( let i = 0 , length = this . readers . length ; i !== length ; i ++ ) { const reader = this . readers [ i ] ; try { return reader . decode ( image , this . hints ) ; } catch ( re ) { if ( re . type === 'ReaderException' ) { continue ; } } } } throw new Exception ( Exception . NotFoundException ) ; } }