本文整理了Java中org.apache.activemq.artemis.utils.UUID.stringToBytes()
方法的一些代码示例,展示了UUID.stringToBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UUID.stringToBytes()
方法的具体详情如下:
包路径:org.apache.activemq.artemis.utils.UUID
类名称:UUID
方法名:stringToBytes
[英]Creates a 128bit number from the String representation of UUID.
[中]从UUID的字符串表示形式创建一个128位的数字。
代码示例来源:origin: apache/activemq-artemis
private UUID rawReadNodeId() throws SQLException {
final PreparedStatement preparedStatement = this.readNodeId;
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (!resultSet.next()) {
return null;
} else {
final String nodeId = resultSet.getString(1);
if (nodeId != null) {
return new UUID(UUID.TYPE_TIME_BASED, UUID.stringToBytes(nodeId));
} else {
return null;
}
}
}
}
代码示例来源:origin: apache/activemq-artemis
/**
* Sets the nodeID.
* <p>
* Only used by replicating backups.
*
* @param nodeID
*/
public void setNodeID(String nodeID) {
synchronized (nodeIDGuard) {
this.nodeID = new SimpleString(nodeID);
this.uuid = new UUID(UUID.TYPE_TIME_BASED, UUID.stringToBytes(nodeID));
}
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void testStringToUuidConversion() {
UUIDGenerator gen = UUIDGenerator.getInstance();
for (int i = 0; i < MANY_TIMES; i++) {
final UUID uuid = gen.generateUUID();
final String uuidString = uuid.toString();
byte[] data2 = UUID.stringToBytes(uuidString);
final UUID uuid2 = new UUID(UUID.TYPE_TIME_BASED, data2);
assertEqualsByteArrays(uuid.asBytes(), data2);
assertEquals(uuidString, uuid, uuid2);
assertEquals(uuidString, uuidString, uuid2.toString());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!