本文整理汇总了Java中java.util.UUID.nameUUIDFromBytes方法的典型用法代码示例。如果您正苦于以下问题:Java UUID.nameUUIDFromBytes方法的具体用法?Java UUID.nameUUIDFromBytes怎么用?Java UUID.nameUUIDFromBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.UUID
的用法示例。
在下文中一共展示了UUID.nameUUIDFromBytes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createServer
import java.util.UUID; //导入方法依赖的package包/类
/**
* Creates a server from given values by getting the ServerPattern and copying the files<br>
* At this point it might be better to download the pattern from a webserver if you want to
* have multiple daemon instances with the same pattern, BUT I see it as not important atm.
*
* @param type The type of server (pattern)
* @param autoSave Auto-save on shutdown?
* @return The server
*/
public Server createServer(String type, boolean autoSave) {
ServerFolder pattern = getPattern(type, false);
if(pattern == null) {
Daemon.getInstance().getLogs().info("There is no pattern available with type='" + type + "'!");
return null;
}
File targetFolder = getServersFolder();
int id = IOUtil.getNextId(targetFolder, TYPE_COUNT_SPLIT, type);
File target2 = new File(targetFolder, pattern.getName() + TYPE_COUNT_SPLIT + id);
UUID uuid = UUID.nameUUIDFromBytes((type + ":" + id).getBytes());
pattern.copy(id, targetFolder);
return new Server(this, id, uuid, new File(targetFolder, target2.getName()), autoSave);
}
示例2: changeType
import java.util.UUID; //导入方法依赖的package包/类
/**
* Changes the data type of the source object to an UUID;
*/
@Override
protected UUID changeType(Class<?> sourceClass, Object source) {
if (byte[].class.isAssignableFrom(sourceClass))
return UUID.nameUUIDFromBytes((byte[]) source);
else
return super.changeType(sourceClass, source);
}
示例3: dataToUUID
import java.util.UUID; //导入方法依赖的package包/类
public static UUID dataToUUID(String... params) {
StringBuilder builder = new StringBuilder();
for (String param : params) {
builder.append(param);
}
return UUID.nameUUIDFromBytes(builder.toString().getBytes(StandardCharsets.UTF_8));
}
示例4: getUUID
import java.util.UUID; //导入方法依赖的package包/类
public static UUID getUUID(String username) {
if (JARCraftinator.getConfig().isOnlineMode()) {
return null;
} else {
//For now, we'll use offline UUIDs. Online mode will be implemented later.
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
}
}
示例5: convert
import java.util.UUID; //导入方法依赖的package包/类
@Override
public UUID convert(Object value) {
if (value == null) {
return null;
}
else
if (value instanceof UUID) {
return (UUID)value;
}
else
if (value instanceof String) {
return UUID.fromString((String)value);
}
else
if (value.getClass().isArray()) {
if (value.getClass().getComponentType() == Byte.TYPE) {
return UUID.nameUUIDFromBytes((byte[])value);
}
else
if (value.getClass().getComponentType() == Character.TYPE) {
return UUID.fromString(String.valueOf((char[])value));
}
else {
throw new IllegalArgumentException("Cannot convert to UUID "+
"from array of \""+
value.getClass().getComponentType()+"\"");
}
}
else {
return UUID.fromString(value.toString());
}
}
示例6: generateGuid
import java.util.UUID; //导入方法依赖的package包/类
/**
* Generates a GUID using a seed. This will generate the same GUID usign the same seed.
* @param seed The seed to use for generating the GUID
* @return A string representation of the GUID
*/
public static String generateGuid(String seed) {
UUID uuid;
try {
uuid = UUID.nameUUIDFromBytes(seed.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(String.format("UnsupportedEncodingException: %f", e.getMessage()));
}
return uuid.toString();
}
示例7: dataToUUID
import java.util.UUID; //导入方法依赖的package包/类
public static UUID dataToUUID(byte[]... params) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
for (byte[] param : params) {
try {
stream.write(param);
} catch (IOException e) {
break;
}
}
return UUID.nameUUIDFromBytes(stream.toByteArray());
}
示例8: getOfflineUUID
import java.util.UUID; //导入方法依赖的package包/类
public static UUID getOfflineUUID(String username)
{
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
示例9: getOfflineProfile
import java.util.UUID; //导入方法依赖的package包/类
protected GameProfile getOfflineProfile(GameProfile original)
{
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + original.getName()).getBytes(Charsets.UTF_8));
return new GameProfile(uuid, original.getName());
}
示例10: getUUID
import java.util.UUID; //导入方法依赖的package包/类
public static UUID getUUID(String name) {
return UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
}
示例11: getUUID
import java.util.UUID; //导入方法依赖的package包/类
protected static UUID getUUID(String existingServiceOfferingName) {
return UUID.nameUUIDFromBytes((existingServiceOfferingName + SERVICE_PLAN_ENDING).getBytes());
}
示例12: generateLegacyCfId
import java.util.UUID; //导入方法依赖的package包/类
/**
* Generates deterministic UUID from keyspace/columnfamily name pair.
* This is used to generate the same UUID for {@code C* version < 2.1}
*
* Since 2.1, this is only used for system columnfamilies and tests.
*/
public static UUID generateLegacyCfId(String ksName, String cfName)
{
return UUID.nameUUIDFromBytes(ArrayUtils.addAll(ksName.getBytes(), cfName.getBytes()));
}
示例13: createAuthToken
import java.util.UUID; //导入方法依赖的package包/类
/**
* This method will generate auth token based on name , source and timestamp
*
* @param name String
* @param source String
* @return String
*/
public static String createAuthToken(String name, String source) {
String data = name + source + System.currentTimeMillis();
UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8));
return authId.toString();
}