X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=zxingorg%2Fweb%2Fdecoderesult.jspx;h=b7002f3e5fcfee0f9779f7c750cf3a24987cd929;hp=40a0c482ec62864a508f18938d6cca72cabcb698;hb=5cc5a1cd29b034939d7545140454c869844ddfea;hpb=8c91e26190f4d312f0c5d000d676efadd352ef81 diff --git a/zxingorg/web/decoderesult.jspx b/zxingorg/web/decoderesult.jspx index 40a0c482..b7002f3e 100644 --- a/zxingorg/web/decoderesult.jspx +++ b/zxingorg/web/decoderesult.jspx @@ -16,10 +16,37 @@ --> + + + private static String arrayToString(byte[] bytes) { + int length = bytes.length; + StringBuilder result = new StringBuilder(length << 2); + int i = 0; + while (i < length) { + int max = Math.min(i + 8, length); + for (int j = i; j < max; j++) { + int value = bytes[j] & 0xFF; + result.append(Integer.toHexString(value / 16)); + result.append(Integer.toHexString(value % 16)); + result.append(' '); + } + result.append('\n'); + i += 8; + } + for (int j = i - 8; j < length; j++) { + result.append(Integer.toHexString(bytes[j] & 0xFF)); + result.append(' '); + } + return result.toString(); + } + response.setHeader("Cache-Control", "no-cache"); - - ]]> @@ -31,28 +58,60 @@ + + for (Result result : (List<Result>) request.getAttribute("results")) { + ParsedResult parsedResult = ResultParser.parseResult(result); + + String text = result.getText(); + if (text == null) { + text = "(Not applicable)"; + } else { + text = StringEscapeUtils.escapeXml(text); + text = text.replaceAll("\r?\n", "<br/>"); + } + + byte[] rawBytes = result.getRawBytes(); + String rawBytesString; + if (rawBytes == null) { + rawBytesString = "(Not applicable)"; + } else { + rawBytesString = arrayToString(rawBytes); + } + + String displayResult = parsedResult.getDisplayResult(); + if (displayResult == null) { + displayResult = "(Not applicable)"; + } else { + displayResult = StringEscapeUtils.escapeXml(displayResult); + displayResult = displayResult.replaceAll("\r?\n", "<br/>"); + } + - + - + - + - + - +
Raw textrequest.getAttribute("text")text
Raw bytesrequest.getAttribute("rawBytesString")rawBytesString
Barcode formatresult.getBarcodeFormat()
Parsed Result TypeparsedResult.getType()
Parsed Resultrequest.getAttribute("displayResult")displayResult
+
+ + } +