@Override public void handle(FacesContext context) throws IOException { Map<String, String> params = context.getExternalContext().getRequestParameterMap(); ExternalContext externalContext = context.getExternalContext(); String sessionKey = params.get(Constants.DYNAMIC_CONTENT_PARAM); Map<String, Object> session = externalContext.getSessionMap(); Map<String, String> barcodeMapping = (Map) session.get(Constants.BARCODE_MAPPING); String value = barcodeMapping.get(sessionKey); if (value != null) { boolean cache = Boolean.parseBoolean(params.get(Constants.DYNAMIC_CONTENT_CACHE_PARAM)); externalContext.setResponseStatus(200); externalContext.setResponseContentType("image/png"); handleCache(externalContext, cache); ErrorCorrectionLevel ecl = ErrorCorrectionLevel.L; String errorCorrection = params.get("qrec"); if (!LangUtils.isValueBlank(errorCorrection)) { ecl = ErrorCorrectionLevel.valueOf(errorCorrection); } QRCode.from(value).to(ImageType.PNG).withErrorCorrection(ecl).withCharset("UTF-8") .writeTo(externalContext.getResponseOutputStream()); externalContext.responseFlushBuffer(); context.responseComplete(); } }
private FormatInformation(int formatInfo) { // Bits 3,4 errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); // Bottom 3 bits dataMask = (byte) (formatInfo & 0x07); }
private Version(int versionNumber, int[] alignmentPatternCenters, ECBlocks... ecBlocks) { this.versionNumber = versionNumber; this.alignmentPatternCenters = alignmentPatternCenters; this.ecBlocks = ecBlocks; int total = 0; int ecCodewords = ecBlocks[0].getECCodewordsPerBlock(); ECB[] ecbArray = ecBlocks[0].getECBlocks(); for (ECB ecBlock : ecbArray) { total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); } this.totalCodewords = total; }
/** * @return true if the number of input bits will fit in a code with the specified version and * error correction level. */ private static boolean willFit(int numInputBits, Version version, ErrorCorrectionLevel ecLevel) { // In the following comments, we use numbers of Version 7-H. // numBytes = 196 int numBytes = version.getTotalCodewords(); // getNumECBytes = 130 Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); int numEcBytes = ecBlocks.getTotalECCodewords(); // getNumDataBytes = 196 - 130 = 66 int numDataBytes = numBytes - numEcBytes; int totalInputBytes = (numInputBits + 7) / 8; return numDataBytes >= totalInputBytes; }
/** * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state. */ void remask() { if (parsedFormatInfo == null) { return; // We have no format information, and have no data mask } DataMask dataMask = DataMask.values()[parsedFormatInfo.getDataMask()]; int dimension = bitMatrix.getHeight(); dataMask.unmaskBitMatrix(bitMatrix, dimension); }
public int getNumBlocks() { int total = 0; for (ECB ecBlock : ecBlocks) { total += ecBlock.getCount(); } return total; }
@Override public int hashCode() { return (errorCorrectionLevel.ordinal() << 3) | dataMask; }
public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException { return decode(bits, null); }
try { qrCode = Encoder.encode(contentsToEncode, level, hints); patternCenters = qrCode.getVersion().getAlignmentPatternCenters();
private Version(int versionNumber, int[] alignmentPatternCenters, ECBlocks... ecBlocks) { this.versionNumber = versionNumber; this.alignmentPatternCenters = alignmentPatternCenters; this.ecBlocks = ecBlocks; int total = 0; int ecCodewords = ecBlocks[0].getECCodewordsPerBlock(); ECB[] ecbArray = ecBlocks[0].getECBlocks(); for (ECB ecBlock : ecbArray) { total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); } this.totalCodewords = total; }
/** * @return true if the number of input bits will fit in a code with the specified version and * error correction level. */ private static boolean willFit(int numInputBits, Version version, ErrorCorrectionLevel ecLevel) { // In the following comments, we use numbers of Version 7-H. // numBytes = 196 int numBytes = version.getTotalCodewords(); // getNumECBytes = 130 Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); int numEcBytes = ecBlocks.getTotalECCodewords(); // getNumDataBytes = 196 - 130 = 66 int numDataBytes = numBytes - numEcBytes; int totalInputBytes = (numInputBits + 7) / 8; return numDataBytes >= totalInputBytes; }
/** * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state. */ void remask() { if (parsedFormatInfo == null) { return; // We have no format information, and have no data mask } DataMask dataMask = DataMask.values()[parsedFormatInfo.getDataMask()]; int dimension = bitMatrix.getHeight(); dataMask.unmaskBitMatrix(bitMatrix, dimension); }
private FormatInformation(int formatInfo) { // Bits 3,4 errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); // Bottom 3 bits dataMask = (byte) (formatInfo & 0x07); }
public int getNumBlocks() { int total = 0; for (int i = 0; i < ecBlocks.length; i++) { total += ecBlocks[i].getCount(); } return total; }
@Override public int hashCode() { return (errorCorrectionLevel.ordinal() << 3) | dataMask; }
public DecoderResult decode(boolean[][] image) throws ChecksumException, FormatException, NotFoundException { return decode(image, null); }
private FormatInformation(int formatInfo) { // Bits 3,4 errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); // Bottom 3 bits dataMask = (byte) (formatInfo & 0x07); }
public int getNumBlocks() { int total = 0; for (ECB ecBlock : ecBlocks) { total += ecBlock.getCount(); } return total; }
private FormatInformation(int formatInfo) { // Bits 3,4 errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); // Bottom 3 bits dataMask = (byte) (formatInfo & 0x07); }
public int getNumBlocks() { int total = 0; for (int i = 0; i < ecBlocks.length; i++) { total += ecBlocks[i].getCount(); } return total; }