org.codehaus.jackson.JsonNode.getBinaryValue()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.codehaus.jackson.JsonNode.getBinaryValue()方法的一些代码示例,展示了JsonNode.getBinaryValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.getBinaryValue()方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:getBinaryValue

JsonNode.getBinaryValue介绍

[英]Method to use for accessing binary content of binary nodes (nodes for which #isBinary returns true); or for Text Nodes (ones for which #getTextValue returns non-null value), to read decoded base64 data. For other types of nodes, returns null.
[中]用于访问二进制节点(即#isBinary返回true的节点)的二进制内容的方法;或者对于文本节点(getTextValue返回非空值的节点),读取解码的base64数据。对于其他类型的节点,返回null。

代码示例

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public byte[] getBinaryValue(Base64Variant b64variant)
  throws IOException, JsonParseException
{
  // Multiple possibilities...
  JsonNode n = currentNode();
  if (n != null) { // binary node?
    byte[] data = n.getBinaryValue();
    // (or TextNode, which can also convert automatically!)
    if (data != null) {
      return data;
    }
    // Or maybe byte[] as POJO?
    if (n.isPojo()) {
      Object ob = ((POJONode) n).getPojo();
      if (ob instanceof byte[]) {
        return (byte[]) ob;
      }
    }
  }
  // otherwise return null to mark we have no binary content
  return null;
}

代码示例来源:origin: apache/nifi

return fieldNode.getBinaryValue();

代码示例来源:origin: apache/nifi

return fieldNode.getBinaryValue();

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public byte[] getBinaryValue(Base64Variant b64variant)
  throws IOException, JsonParseException
{
  // Multiple possibilities...
  JsonNode n = currentNode();
  if (n != null) { // binary node?
    byte[] data = n.getBinaryValue();
    // (or TextNode, which can also convert automatically!)
    if (data != null) {
      return data;
    }
    // Or maybe byte[] as POJO?
    if (n.isPojo()) {
      Object ob = ((POJONode) n).getPojo();
      if (ob instanceof byte[]) {
        return (byte[]) ob;
      }
    }
  }
  // otherwise return null to mark we have no binary content
  return null;
}

代码示例来源:origin: com.atlassian.jira/jira-core

public byte[] getBinaryValue() throws IOException
{
  return delegate.getBinaryValue();
}

代码示例来源:origin: klout/brickhouse

case BINARY:
  try {
    return jsonNode.getBinaryValue();
  } catch (IOException ioExc) {
    return jsonNode.toString();

代码示例来源:origin: NGDATA/hbase-indexer

public static byte[] getBinary(JsonNode node, String prop, byte[] defaultValue) throws JsonFormatException {
  if (node.get(prop) == null) {
    return defaultValue;
  }
  try {
    return node.get(prop).getBinaryValue();
  } catch (IOException e) {
    throw new JsonFormatException("Error reading binary data in property " + prop, e);
  }
}

代码示例来源:origin: com.cloudhopper/ch-mq

public byte[] keyFromString(String s) {
try {
  JsonNode node = mapper.readTree(s);
  return node.get("key").getBinaryValue();
} catch (Exception e) { 
  throw new IllegalArgumentException("Unparseable value "+s, e);
}
}

代码示例来源:origin: NGDATA/lilyproject

public static byte[] getBinary(JsonNode node, String prop, byte[] defaultValue) throws JsonFormatException {
  if (node.get(prop) == null) {
    return defaultValue;
  }
  try {
    return node.get(prop).getBinaryValue();
  } catch (IOException e) {
    throw new JsonFormatException("Error reading binary data in property " + prop, e);
  }
}

代码示例来源:origin: NGDATA/hbase-indexer

public static byte[] getBinary(JsonNode node, String prop) throws JsonFormatException {
  if (node.get(prop) == null) {
    throw new JsonFormatException("Missing required property: " + prop);
  }
  try {
    return node.get(prop).getBinaryValue();
  } catch (IOException e) {
    throw new JsonFormatException("Error reading binary data in property " + prop, e);
  }
}

代码示例来源:origin: NGDATA/lilyproject

public static byte[] getBinary(JsonNode node, String prop) throws JsonFormatException {
  if (node.get(prop) == null) {
    throw new JsonFormatException("Missing required property: " + prop);
  }
  try {
    return node.get(prop).getBinaryValue();
  } catch (IOException e) {
    throw new JsonFormatException("Error reading binary data in property " + prop, e);
  }
}

代码示例来源:origin: com.ngdata/hbase-indexer-common

public static byte[] getBinary(JsonNode node, String prop, byte[] defaultValue) throws JsonFormatException {
  if (node.get(prop) == null || node.get(prop).isNull()) {
    return defaultValue;
  }
  try {
    return node.get(prop).getBinaryValue();
  } catch (IOException e) {
    throw new JsonFormatException("Error reading binary data in property " + prop, e);
  }
}

代码示例来源:origin: com.ngdata/hbase-indexer-common

public static byte[] getBinary(JsonNode node, String prop) throws JsonFormatException {
  if (node.get(prop) == null || node.get(prop).isNull()) {
    throw new JsonFormatException("Missing required property: " + prop);
  }
  try {
    return node.get(prop).getBinaryValue();
  } catch (IOException e) {
    throw new JsonFormatException("Error reading binary data in property " + prop, e);
  }
}

代码示例来源:origin: OpenAttestation/OpenAttestation

@Override
public X509AttributeCertificate deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
  JsonNode node = jp.getCodec().readTree(jp);
  byte[] encodedBytes = node.get("encoded").getBinaryValue();
  return X509AttributeCertificate.valueOf(encodedBytes);
}

代码示例来源:origin: NGDATA/lilyproject

protected ByteArray readByteArray(ValueHandle handle, ReadContext context)
    throws JsonFormatException, RepositoryException, InterruptedException {
  if (!handle.node.isTextual()) {
    throw new JsonFormatException("Expected base64 encoded value for property '" + handle.prop + "'");
  }
  try {
    return new ByteArray(handle.node.getBinaryValue());
  } catch (IOException e) {
    throw new JsonFormatException("Could not read base64 value for property '" + handle.prop + "'", e);
  }
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

@Override
public byte[] getBinaryValue(Base64Variant b64variant)
  throws IOException, JsonParseException
{
  // Multiple possibilities...
  JsonNode n = currentNode();
  if (n != null) { // binary node?
    byte[] data = n.getBinaryValue();
    // (or TextNode, which can also convert automatically!)
    if (data != null) {
      return data;
    }
    // Or maybe byte[] as POJO?
    if (n.isPojo()) {
      Object ob = ((POJONode) n).getPojo();
      if (ob instanceof byte[]) {
        return (byte[]) ob;
      }
    }
  }
  // otherwise return null to mark we have no binary content
  return null;
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

@Override
public byte[] getBinaryValue(Base64Variant b64variant)
  throws IOException, JsonParseException
{
  // Multiple possibilities...
  JsonNode n = currentNode();
  if (n != null) { // binary node?
    byte[] data = n.getBinaryValue();
    // (or TextNode, which can also convert automatically!)
    if (data != null) {
      return data;
    }
    // Or maybe byte[] as POJO?
    if (n.isPojo()) {
      Object ob = ((POJONode) n).getPojo();
      if (ob instanceof byte[]) {
        return (byte[]) ob;
      }
    }
  }
  // otherwise return null to mark we have no binary content
  return null;
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

@Override
public byte[] getBinaryValue(Base64Variant b64variant)
  throws IOException, JsonParseException
{
  // Multiple possibilities...
  JsonNode n = currentNode();
  if (n != null) { // binary node?
    byte[] data = n.getBinaryValue();
    // (or TextNode, which can also convert automatically!)
    if (data != null) {
      return data;
    }
    // Or maybe byte[] as POJO?
    if (n.isPojo()) {
      Object ob = ((POJONode) n).getPojo();
      if (ob instanceof byte[]) {
        return (byte[]) ob;
      }
    }
  }
  // otherwise return null to mark we have no binary content
  return null;
}

代码示例来源:origin: de.mhus.lib/mhu-lib-core

public static Object getValue(JsonNode node, TransformHelper helper) {
  Object out = null;
  if (node == null) return null;
  try {
    if (node.isTextual())
      out = node.asText();
    else if (node.isNull())
      out = null;
    else if (node.isBigDecimal())
      out = node.getDecimalValue();
    else if (node.isBigInteger())
      out = node.getBigIntegerValue();
    else if (node.isBinary())
      out = node.getBinaryValue();
    else if (node.isBoolean())
      out = node.getBooleanValue();
    else if (node.isDouble())
      out = node.getDoubleValue();
    else if (node.isInt())
      out = node.getIntValue();
    else if (node.isLong())
      out = node.getLongValue();
    else if (node.isNumber())
      out = node.getNumberValue();
  } catch (IOException e) {}
  return out;
}

代码示例来源:origin: de.mhus.lib/mhu-lib-core

public static Object getValue(JsonNode node, TransformHelper helper) {
    Object out = null;
    if (node == null) return null;
    try {
      if (node.isTextual())
        out = node.asText();
      else if (node.isNull())
        out = null;
      else if (node.isBigDecimal())
        out = node.getDecimalValue();
      else if (node.isBigInteger())
        out = node.getBigIntegerValue();
      else if (node.isBinary())
        out = node.getBinaryValue();
      else if (node.isBoolean())
        out = node.getBooleanValue();
      else if (node.isDouble())
        out = node.getDoubleValue();
      else if (node.isInt())
        out = node.getIntValue();
      else if (node.isLong())
        out = node.getLongValue();
      else if (node.isNumber())
        out = node.getNumberValue();
    } catch (IOException e) {}
    return out;
  }
}

相关文章