本文整理匯總了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();
}