org.apache.activemq.artemis.utils.UUID.stringToBytes()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(119)

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

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());
   }
  }
}

相关文章