org.apache.cassandra.utils.Hex类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(121)

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

Hex介绍

暂无

代码示例

代码示例来源:origin: palantir/atlasdb

@Override
public String toString(Token token)
{
  AtlasBytesToken bytesToken = (AtlasBytesToken) token;
  return Hex.bytesToHex((byte[]) bytesToken.getTokenValue());
}

代码示例来源:origin: palantir/atlasdb

@Override
  public Token fromString(String string)
  {
    if (string.length() % 2 == 1)
      string = "0" + string;
    return new AtlasBytesToken(Hex.hexToBytes(string));
  }
};

代码示例来源:origin: org.apache.cassandra/cassandra-all

public static String bytesToHex(byte bytes[], int offset, int length)
{
  char[] c = new char[length * 2];
  for (int i = 0; i < length; i++)
  {
    int bint = bytes[i + offset];
    c[i * 2] = byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = byteToChar[bint & 0x0f];
  }
  return wrapCharArray(c);
}

代码示例来源:origin: org.apache.cassandra/cassandra-clientutil

public static String bytesToHex(ByteBuffer bytes)
{
  if (bytes.hasArray()) {
    return Hex.bytesToHex(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining());
  }
  final int offset = bytes.position();
  final int size = bytes.remaining();
  final char[] c = new char[size * 2];
  for (int i = 0; i < size; i++)
  {
    final int bint = bytes.get(i+offset);
    c[i * 2] = Hex.byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = Hex.byteToChar[bint & 0x0f];
  }
  return Hex.wrapCharArray(c);
}

代码示例来源:origin: Stratio/cassandra-lucene-index

private String base(String value) {
    try {
      byte[] bytes = Hex.hexToBytes(value.replaceFirst("0x", ""));
      return Hex.bytesToHex(bytes);
    } catch (NumberFormatException e) {
      throw new IndexException(e, "Field '{}' requires an hex string, but found '{}'", field, value);
    }
  }
}

代码示例来源:origin: jsevellec/cassandra-unit

public static String bytesToHex(ByteBuffer bytes)
{
  if (bytes.hasArray())
  {
    return Hex.bytesToHex(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining());
  }
  final int offset = bytes.position();
  final int size = bytes.remaining();
  final char[] c = new char[size * 2];
  for (int i = 0; i < size; i++)
  {
    final int bint = bytes.get(i+offset);
    c[i * 2] = Hex.byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = Hex.byteToChar[bint & 0x0f];
  }
  return Hex.wrapCharArray(c);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

public static String toString(byte[] hash)
{
  if (hash == null)
    return "null";
  return "[" + Hex.bytesToHex(hash) + "]";
}

代码示例来源:origin: palantir/atlasdb

@Override
public void validate(String token) throws ConfigurationException
{
  try
  {
    if (token.length() % 2 == 1)
      token = "0" + token;
    Hex.hexToBytes(token);
  }
  catch (NumberFormatException e)
  {
    throw new ConfigurationException("Token " + token + " contains non-hex digits");
  }
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

public static String bytesToHex(ByteBuffer bytes)
{
  if (bytes.hasArray())
  {
    return Hex.bytesToHex(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining());
  }
  final int offset = bytes.position();
  final int size = bytes.remaining();
  final char[] c = new char[size * 2];
  for (int i = 0; i < size; i++)
  {
    final int bint = bytes.get(i+offset);
    c[i * 2] = Hex.byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = Hex.byteToChar[bint & 0x0f];
  }
  return Hex.wrapCharArray(c);
}

代码示例来源:origin: jsevellec/cassandra-unit

public static String bytesToHex(byte bytes[], int offset, int length)
{
  char[] c = new char[length * 2];
  for (int i = 0; i < length; i++)
  {
    int bint = bytes[i + offset];
    c[i * 2] = byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = byteToChar[bint & 0x0f];
  }
  return wrapCharArray(c);
}

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

@Override
public String toString()
{
  return Hex.bytesToHex(token);
}

代码示例来源:origin: Impetus/Kundera

case MD5:
  authenticated = MessageDigest.isEqual(FBUtilities.threadLocalMD5Digest().digest(password.getBytes()),
      Hex.hexToBytes(props.getProperty(username)));
  break;
default:

代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra

public static String bytesToHex(ByteBuffer bytes)
{
  if (bytes.hasArray())
  {
    return Hex.bytesToHex(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining());
  }
  final int offset = bytes.position();
  final int size = bytes.remaining();
  final char[] c = new char[size * 2];
  for (int i = 0; i < size; i++)
  {
    final int bint = bytes.get(i+offset);
    c[i * 2] = Hex.byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = Hex.byteToChar[bint & 0x0f];
  }
  return Hex.wrapCharArray(c);
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public static String bytesToHex(byte bytes[], int offset, int length)
{
  char[] c = new char[length * 2];
  for (int i = 0; i < length; i++)
  {
    int bint = bytes[i + offset];
    c[i * 2] = byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = byteToChar[bint & 0x0f];
  }
  return wrapCharArray(c);
}

代码示例来源:origin: jsevellec/cassandra-unit

public String toString(Token token)
{
  BytesToken bytesToken = (BytesToken) token;
  return Hex.bytesToHex(bytesToken.token);
}

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

public static ByteBuffer hexToBytes(String str)
{
  return ByteBuffer.wrap(Hex.hexToBytes(str));
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public static String bytesToHex(ByteBuffer bytes)
{
  if (bytes.hasArray())
  {
    return Hex.bytesToHex(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining());
  }
  final int offset = bytes.position();
  final int size = bytes.remaining();
  final char[] c = new char[size * 2];
  for (int i = 0; i < size; i++)
  {
    final int bint = bytes.get(i+offset);
    c[i * 2] = Hex.byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = Hex.byteToChar[bint & 0x0f];
  }
  return Hex.wrapCharArray(c);
}

代码示例来源:origin: org.apache.cassandra/cassandra-clientutil

public static String bytesToHex(byte bytes[], int offset, int length)
{
  char[] c = new char[length * 2];
  for (int i = 0; i < length; i++)
  {
    int bint = bytes[i + offset];
    c[i * 2] = byteToChar[(bint & 0xf0) >> 4];
    c[1 + i * 2] = byteToChar[bint & 0x0f];
  }
  return wrapCharArray(c);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

@Override
  public String toString()
  {
    return Hex.bytesToHex(bytes);
  }
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public static ByteBuffer hexToBytes(String str)
{
  return ByteBuffer.wrap(Hex.hexToBytes(str));
}

相关文章