@Override public ByteBuffer readFromJsonElement(JsonNode elem) { try { return ByteBuffer.wrap(elem.binaryValue()); } catch (IOException e) { throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e); } }
@Override public Object deserialize(JsonNode n, ObjectMapper mapper) { Object o = null; try { if (n.has("imageData")) { byte [] data = n.get("imageData").binaryValue(); o = Images.decode(data); } } catch (Exception e) { logger.error("exception deserializing ImageIcon ", e); } return o; }
@Override public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { // Multiple possibilities... JsonNode n = currentNode(); if (n != null) { // [databind#2096]: although `binaryValue()` works for real binary node // and embedded "POJO" node, coercion from TextNode may require variant, so: if (n instanceof TextNode) { return ((TextNode) n).getBinaryValue(b64variant); } return n.binaryValue(); } // otherwise return null to mark we have no binary content return null; }
private Object toValue(JsonNode node) throws IOException { if (node.isTextual()) { return node.asText(); } else if (node.isNumber()) { return node.numberValue(); } else if (node.isBoolean()) { return node.asBoolean(); } else if (node.isBinary()) { return node.binaryValue(); } else { throw new IllegalStateException("Unexpected range bound value: " + node); } } }
case BINARY: try { return read.binaryValue(); } catch (IOException e) { return null;
@Override public Any deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode root = p.getCodec().readTree(p); JsonNode type = root.get(JSON_TYPE); JsonNode value = root.get(JSON_VALUE); if (type == null || !type.isTextual()) { throw ctxt.reportMappingException("invalid '@type' field when deserializing ProtoBuf Any object"); } if (value == null || !value.isTextual()) { throw ctxt.reportMappingException("invalid '@value' field when deserializing ProtoBuf Any object"); } return Any.newBuilder() .setTypeUrl(type.textValue()) .setValue(ByteString.copyFrom(value.binaryValue())) .build(); } }
return wrap( json.binaryValue());
return wrap( json.binaryValue() );
@Override public TableRange deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode node = jp.readValueAsTree(); String tableName = node.get("table").textValue(); TableMetadata metadata = metadataCache.getMetadata(tableName); JsonNode optBatchSize = node.get("batch_size"); int batchSize = optBatchSize == null ? 2000 : optBatchSize.asInt(); Iterable<byte[]> columns = AtlasDeserializers.deserializeNamedCols(metadata.getColumns(), node.get("cols")); byte[] startRow = new byte[0]; byte[] endRow = new byte[0]; if (node.has("prefix")) { startRow = AtlasDeserializers.deserializeRowPrefix(metadata.getRowMetadata(), node.get("prefix")); endRow = RangeRequests.createEndNameForPrefixScan(startRow); } else { if (node.has("raw_start")) { startRow = node.get("raw_start").binaryValue(); } else if (node.has("start")) { startRow = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), node.get("start")); } if (node.has("raw_end")) { endRow = node.get("raw_end").binaryValue(); } else if (node.has("end")) { endRow = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), node.get("end")); } } return new TableRange(tableName, startRow, endRow, columns, batchSize); } }
@Override public ByteBuffer readFromJsonElement(JsonNode elem) { try { return ByteBuffer.wrap(elem.binaryValue()); } catch (IOException e) { throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e); } }
@Override public ByteBuffer readFromJsonElement(JsonNode elem) { try { return ByteBuffer.wrap(elem.binaryValue()); } catch (IOException e) { throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e); } }
@JsonIgnore public byte[] getBytesValue(int index) throws IOException { return value.get(index).binaryValue(); }
@Override public ByteBuffer readFromJsonElement(JsonNode elem) { try { return ByteBuffer.wrap(elem.binaryValue()); } catch (IOException e) { throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e); } }
private static List<X509Certificate> getX5c(JsonNode header) throws IOException, CertificateException { List<X509Certificate> result = new ArrayList<>(); for (JsonNode jsonNode : header.get("x5c")) { result.add(CertificateParser.parseDer(jsonNode.binaryValue())); } return result; } }
@Override public byte[] getBytes(int columnIndex) throws SQLException { JsonNode ret = getColumnValue(columnIndex); if (wasNull) { return null; } try { return ret.binaryValue(); } catch (IOException e) { throw new SQLException("error converting binary data", e); } }
@Override public PublicKey deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final ObjectCodec oc = jsonParser.getCodec(); final JsonNode node = oc.readTree(jsonParser); return new PublicKeyWithMechanism(node.get(PublicKeySerializer.KEY).binaryValue()).toJavaKey(); } }
@Override public Object fromJson(JsonNode node) { if (node == null || node instanceof NullNode) { return null; } else if (node.isValueNode()) { try { return node.binaryValue(); } catch (Exception e) { } } throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString()); }
@Override public Object fromJson(JsonNode node) { if (node == null || node instanceof NullNode) { return null; } else if (node.isValueNode()) { try { return node.binaryValue(); } catch (Exception e) { } } throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString()); }
@Override public Object fromJson(JsonNode node) { if (node.isValueNode()) { try { return node.binaryValue(); } catch (Exception e) { } } throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString()); }
private static ByteArray getResponseBytes(AttestationObject attestationObject) { final JsonNode response = attestationObject.getAttestationStatement().get("response"); if (response == null || !response.isBinary()) { throw new IllegalArgumentException("Property \"response\" of android-safetynet attestation statement must be a binary value, was: " + response); } try { return new ByteArray(response.binaryValue()); } catch (IOException ioe) { throw ExceptionUtil.wrapAndLog(log, "response.isBinary() was true but response.binaryValue failed: " + response, ioe); } }