import ErrorCorrectionLevel from '../decoder/ErrorCorrectionLevel' ; import Mode from '../decoder/Mode' ; import Version from '../decoder/Version' ; import StringBuilder from '../../util/StringBuilder' ; import ByteMatrix from './ByteMatrix' ; author satorux google author dswitkin google export default class QRCode { public static NUM_MASK_PATTERNS = 8 ; private mode : Mode ; private ecLevel : ErrorCorrectionLevel ; private version : Version ; private maskPattern : number ; private matrix : ByteMatrix ; public constructor ( ) { this . maskPattern = - 1 ; } public getMode ( ) { return this . mode ; } public getECLevel ( ) { return this . ecLevel ; } public getVersion ( ) { return this . version ; } public getMaskPattern ( ) { return this . maskPattern ; } public getMatrix ( ) { return this . matrix ; } public toString ( ) { const result = new StringBuilder ( ) ; result . append ( '<<\n' ) ; result . append ( ' mode: ' ) ; result . append ( this . mode ? this . mode . toString ( ) : 'null' ) ; result . append ( '\n ecLevel: ' ) ; result . append ( this . ecLevel ? this . ecLevel . toString ( ) : 'null' ) ; result . append ( '\n version: ' ) ; result . append ( this . version ? this . version . toString ( ) : 'null' ) ; result . append ( '\n maskPattern: ' ) ; result . append ( this . maskPattern . toString ( ) ) ; if ( this . matrix ) { result . append ( '\n matrix:\n' ) ; result . append ( this . matrix . toString ( ) ) ; } else { result . append ( '\n matrix: null\n' ) ; } result . append ( '>>\n' ) ; return result . toString ( ) ; } public setMode ( value ) { this . mode = value ; } public setECLevel ( value ) { this . ecLevel = value ; } public setVersion ( version ) { this . version = version ; } public setMaskPattern ( value ) { this . maskPattern = value ; } public setMatrix ( value ) { this . matrix = value ; } public static isValidMaskPattern ( maskPattern ) { return maskPattern >= 0 && maskPattern < QRCode . NUM_MASK_PATTERNS ; } }