com.datastax.driver.core.utils.Bytes.toHexString()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(115)

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

Bytes.toHexString介绍

[英]Converts a blob to its CQL hex string representation.

A CQL blob string representation consist of the hexadecimal representation of the blob bytes prefixed by "0x".
[中]将blob转换为其CQL十六进制字符串表示形式。
CQL blob字符串表示法由前缀为“0x”的blob字节的十六进制表示法组成。

代码示例

代码示例来源:origin: kaaproject/kaa

/**
 * Convert key hash to string.
 *
 * @param endpointKeyHash is key hash to convert
 * @return string
 */
public static String convertKeyHashToString(byte[] endpointKeyHash) {
 String id = null;
 if (endpointKeyHash != null) {
  id = Bytes.toHexString(endpointKeyHash);
 }
 return id;
}

代码示例来源:origin: kaaproject/kaa

/**
 * This method convert ByteBuffer object to string representation,
 * if endpointKeyHash eq null, than return null.
 *
 * @return the String representation of endpoint key hash
 */
public static String convertKeyHashToString(ByteBuffer endpointKeyHash) {
 String id = null;
 if (endpointKeyHash != null) {
  id = Bytes.toHexString(endpointKeyHash);
 }
 return id;
}

代码示例来源:origin: kaaproject/kaa

/**
 * Generate new id using <code>endpointKeyHash</code> and <code>lastModifyTime</code>.
 *
 * @return id
 */
public String generateId() {
 String id = null;
 if (endpointKeyHash != null) {
  StringBuilder builder = new StringBuilder(Bytes.toHexString(endpointKeyHash));
  builder.append(CassandraModelConstants.KEY_DELIMITER).append(lastModifyTime.getTime());
  id = builder.toString();
 }
 return id;
}

代码示例来源:origin: prestodb/presto

private static String objectToString(Object object, CassandraType elemType)
{
  switch (elemType) {
    case ASCII:
    case TEXT:
    case VARCHAR:
    case UUID:
    case TIMEUUID:
    case TIMESTAMP:
    case INET:
    case VARINT:
      return CassandraCqlUtils.quoteStringLiteralForJson(object.toString());
    case BLOB:
    case CUSTOM:
      return CassandraCqlUtils.quoteStringLiteralForJson(Bytes.toHexString((ByteBuffer) object));
    case INT:
    case BIGINT:
    case COUNTER:
    case BOOLEAN:
    case DOUBLE:
    case FLOAT:
    case DECIMAL:
      return object.toString();
    default:
      throw new IllegalStateException("Handling of type " + elemType + " is not implemented");
  }
}

代码示例来源:origin: prestodb/presto

case BLOB:
case CUSTOM:
  return Bytes.toHexString(row.getBytesUnsafe(i));
default:
  throw new IllegalStateException("Handling of type " + cassandraType

代码示例来源:origin: kaaproject/kaa

@Test
public void testBytesToStringConversation() {
 byte[] array = new byte[]{-16, 7, 51, -98, -75, -19, -82, 119, -51, 122, -125, -14, 22, 44, -28, -56, 26, 111, 115, 2};
 String hash = Bytes.toHexString(array);
 LOG.info("---> hash is {}", hash);
 byte[] converted = Bytes.fromHexString(hash).array();
 Assert.assertArrayEquals(array, converted);
 Assert.assertEquals(hash, Bytes.toHexString(converted));
}

代码示例来源:origin: prestodb/presto

assertEquals(Bytes.toHexString(cursor.getSlice(columnIndex.get("typebytes")).getBytes()), String.format("0x%08X", rowId));

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
public String format(ByteBuffer value) {
 if (value == null) return "NULL";
 return Bytes.toHexString(value);
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
public String format(ByteBuffer value) {
 if (value == null) return "NULL";
 return Bytes.toHexString(value);
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public String toString() {
  return Bytes.toHexString(value);
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public String toString() {
  return Bytes.toHexString(bytes);
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Converts a blob to its CQL hex string representation.
 *
 * <p>A CQL blob string representation consist of the hexadecimal representation of the blob bytes
 * prefixed by "0x".
 *
 * @param byteArray the blob/bytes array to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes} is {@code null}, this
 *     method returns {@code null}.
 */
public static String toHexString(byte[] byteArray) {
 return toHexString(ByteBuffer.wrap(byteArray));
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

sb.append(s);
} else {
 sb.append(Bytes.toHexString(v));

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

@Override
public String format(ByteBuffer value) {
  if (value == null)
    return "NULL";
  return Bytes.toHexString(value);
}

代码示例来源:origin: com.yugabyte/cassandra-driver-core

@Override
public String format(ByteBuffer value) {
  if (value == null)
    return "NULL";
  return Bytes.toHexString(value);
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

@Override
public String format(ByteBuffer value) {
  if (value == null)
    return "NULL";
  return Bytes.toHexString(value);
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

@Override
  public String toString() {
    return Bytes.toHexString(bytes);
  }
}

代码示例来源:origin: com.yugabyte/cassandra-driver-core

@Override
  public String toString() {
    return Bytes.toHexString(value);
  }
}

代码示例来源:origin: io.zipkin/zipkin-cassandra-core

private String debugInsertSpan(long traceId, long timestamp, String spanName, ByteBuffer span, int ttl) {
  return insertSpan.getQueryString()
      .replace(":trace_id", String.valueOf(traceId))
      .replace(":ts", String.valueOf(timestamp))
      .replace(":span_name", spanName)
      .replace(":span", Bytes.toHexString(span))
      .replace(":ttl_", String.valueOf(ttl));
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

LOGGER.warn(
  "Failed to deserialize INITCOND value: {}; getInitCond() will return the raw bytes instead.",
  Bytes.toHexString(rawInitCond));
initCond = rawInitCond;

相关文章