本文整理了Java中com.datastax.driver.core.utils.Bytes.fromRawHexString()
方法的一些代码示例,展示了Bytes.fromRawHexString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.fromRawHexString()
方法的具体详情如下:
包路径:com.datastax.driver.core.utils.Bytes
类名称:Bytes
方法名:fromRawHexString
[英]Converts a CQL hex string representation into a byte array.
A CQL blob string representation consist of the hexadecimal representation of the blob bytes.
[中]将CQL十六进制字符串表示形式转换为字节数组。
CQL blob字符串表示法由blob字节的十六进制表示法组成。
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Parse an hex string representing a CQL blob.
*
* <p>The input should be a valid representation of a CQL blob, i.e. it must start by "0x"
* followed by the hexadecimal representation of the blob bytes.
*
* @param str the CQL blob string representation to parse.
* @return the bytes corresponding to {@code str}. If {@code str} is {@code null}, this method
* returns {@code null}.
* @throws IllegalArgumentException if {@code str} is not a valid CQL blob string.
*/
public static ByteBuffer fromHexString(String str) {
if ((str.length() & 1) == 1)
throw new IllegalArgumentException(
"A CQL blob string must have an even length (since one byte is always 2 hexadecimal character)");
if (str.charAt(0) != '0' || str.charAt(1) != 'x')
throw new IllegalArgumentException("A CQL blob string must start with \"0x\"");
return ByteBuffer.wrap(fromRawHexString(str, 2));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Create a PagingState object from a string previously generated with {@link #toString()}.
*
* @param string the string value.
* @return the PagingState object created.
* @throws PagingStateException if the string does not have the correct format.
*/
public static PagingState fromString(String string) {
try {
byte[] complete = Bytes.fromRawHexString(string, 0);
return new PagingState(complete);
} catch (Exception e) {
throw new PagingStateException(
"Cannot deserialize paging state, invalid format. "
+ "The serialized form was corrupted, or not initially generated from a PagingState object.",
e);
}
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
/**
* Parse an hex string representing a CQL blob.
* <p/>
* The input should be a valid representation of a CQL blob, i.e. it
* must start by "0x" followed by the hexadecimal representation of the
* blob bytes.
*
* @param str the CQL blob string representation to parse.
* @return the bytes corresponding to {@code str}. If {@code str}
* is {@code null}, this method returns {@code null}.
* @throws IllegalArgumentException if {@code str} is not a valid CQL
* blob string.
*/
public static ByteBuffer fromHexString(String str) {
if ((str.length() & 1) == 1)
throw new IllegalArgumentException("A CQL blob string must have an even length (since one byte is always 2 hexadecimal character)");
if (str.charAt(0) != '0' || str.charAt(1) != 'x')
throw new IllegalArgumentException("A CQL blob string must start with \"0x\"");
return ByteBuffer.wrap(fromRawHexString(str, 2));
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
/**
* Parse an hex string representing a CQL blob.
* <p/>
* The input should be a valid representation of a CQL blob, i.e. it
* must start by "0x" followed by the hexadecimal representation of the
* blob bytes.
*
* @param str the CQL blob string representation to parse.
* @return the bytes corresponding to {@code str}. If {@code str}
* is {@code null}, this method returns {@code null}.
* @throws IllegalArgumentException if {@code str} is not a valid CQL
* blob string.
*/
public static ByteBuffer fromHexString(String str) {
if ((str.length() & 1) == 1)
throw new IllegalArgumentException("A CQL blob string must have an even length (since one byte is always 2 hexadecimal character)");
if (str.charAt(0) != '0' || str.charAt(1) != 'x')
throw new IllegalArgumentException("A CQL blob string must start with \"0x\"");
return ByteBuffer.wrap(fromRawHexString(str, 2));
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Parse an hex string representing a CQL blob.
* <p/>
* The input should be a valid representation of a CQL blob, i.e. it
* must start by "0x" followed by the hexadecimal representation of the
* blob bytes.
*
* @param str the CQL blob string representation to parse.
* @return the bytes corresponding to {@code str}. If {@code str}
* is {@code null}, this method returns {@code null}.
* @throws IllegalArgumentException if {@code str} is not a valid CQL
* blob string.
*/
public static ByteBuffer fromHexString(String str) {
if ((str.length() & 1) == 1)
throw new IllegalArgumentException("A CQL blob string must have an even length (since one byte is always 2 hexadecimal character)");
if (str.charAt(0) != '0' || str.charAt(1) != 'x')
throw new IllegalArgumentException("A CQL blob string must start with \"0x\"");
return ByteBuffer.wrap(fromRawHexString(str, 2));
}
代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core
/**
* Parse an hex string representing a CQL blob.
* <p>
* The input should be a valid representation of a CQL blob, i.e. it
* must start by "0x" followed by the hexadecimal representation of the
* blob bytes.
*
* @param str the CQL blob string representation to parse.
* @return the bytes corresponding to {@code str}. If {@code str}
* is {@code null}, this method returns {@code null}.
*
* @throws IllegalArgumentException if {@code str} is not a valid CQL
* blob string.
*/
public static ByteBuffer fromHexString(String str) {
if ((str.length() & 1) == 1)
throw new IllegalArgumentException("A CQL blob string must have an even length (since one byte is always 2 hexadecimal character)");
if (str.charAt(0) != '0' || str.charAt(1) != 'x')
throw new IllegalArgumentException("A CQL blob string must start with \"0x\"");
return ByteBuffer.wrap(fromRawHexString(str, 2));
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
/**
* Create a PagingState object from a string previously generated with {@link #toString()}.
*
* @param string the string value.
* @return the PagingState object created.
* @throws PagingStateException if the string does not have the correct format.
*/
public static PagingState fromString(String string) {
try {
byte[] complete = Bytes.fromRawHexString(string, 0);
return new PagingState(complete);
} catch (Exception e) {
throw new PagingStateException("Cannot deserialize paging state, invalid format. "
+ "The serialized form was corrupted, or not initially generated from a PagingState object.", e);
}
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
/**
* Create a PagingState object from a string previously generated with {@link #toString()}.
*
* @param string the string value.
* @return the PagingState object created.
* @throws PagingStateException if the string does not have the correct format.
*/
public static PagingState fromString(String string) {
try {
byte[] complete = Bytes.fromRawHexString(string, 0);
return new PagingState(complete);
} catch (Exception e) {
throw new PagingStateException("Cannot deserialize paging state, invalid format. "
+ "The serialized form was corrupted, or not initially generated from a PagingState object.", e);
}
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Create a PagingState object from a string previously generated with {@link #toString()}.
*
* @param string the string value.
* @return the PagingState object created.
* @throws PagingStateException if the string does not have the correct format.
*/
public static PagingState fromString(String string) {
try {
byte[] complete = Bytes.fromRawHexString(string, 0);
return new PagingState(complete);
} catch (Exception e) {
throw new PagingStateException("Cannot deserialize paging state, invalid format. "
+ "The serialized form was corrupted, or not initially generated from a PagingState object.", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!