Java Code Examples for java.util.UUID.nameUUIDFromBytes()

The following are Jave code examples for showing how to use nameUUIDFromBytes() of the java.util.UUID class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MooProject   File: DaemonInstance.java   View Source Code Vote up 6 votes
/**
 * 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);
}
 
Example 2
Project: jetfuel   File: UUIDAdapter.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 3
Project: Nukkit-Java9   File: Utils.java   View Source Code Vote up 5 votes
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));
}
 
Example 4
Project: JarCraftinator   File: UUIDManager.java   View Source Code Vote up 5 votes
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());
    }
}
 
Example 5
Project: Jenisys3   File: Utils.java   View Source Code Vote up 5 votes
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));
}
 
Example 6
Project: universal-graph-client   File: UUIDTypeConversion.java   View Source Code Vote up 5 votes
@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());
    }
}
 
Example 7
Project: Java-APIs   File: Utils.java   View Source Code Vote up 5 votes
/**
 * 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();
}
 
Example 8
Project: CoreX   File: Utils.java   View Source Code Vote up 5 votes
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));
}
 
Example 9
Project: CoreX   File: Utils.java   View Source Code Vote up 5 votes
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());
}
 
Example 10
Project: Jupiter   File: Utils.java   View Source Code Vote up 5 votes
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());
}
 
Example 11
Project: CustomWorldGen   File: EntityPlayer.java   View Source Code Vote up 4 votes
public static UUID getOfflineUUID(String username)
{
    return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
 
Example 12
Project: Backmemed   File: EntityPlayer.java   View Source Code Vote up 4 votes
public static UUID getOfflineUUID(String username)
{
    return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
 
Example 13
Project: BaseClient   File: EntityPlayer.java   View Source Code Vote up 4 votes
public static UUID getOfflineUUID(String username)
{
    return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
 
Example 14
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 4 votes
public static UUID getOfflineUUID(String username)
{
    return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
 
Example 15
Project: DecompiledMinecraft   File: NetHandlerLoginServer.java   View Source Code Vote up 4 votes
protected GameProfile getOfflineProfile(GameProfile original)
{
    UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + original.getName()).getBytes(Charsets.UTF_8));
    return new GameProfile(uuid, original.getName());
}
 
Example 16
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 4 votes
public static UUID getOfflineUUID(String username)
{
    return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
 
Example 17
Project: cf-mta-deploy-service   File: NameUtil.java   View Source Code Vote up 4 votes
public static UUID getUUID(String name) {
    return UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
}
 
Example 18
Project: cf-mta-deploy-service   File: ServiceCreatorTest.java   View Source Code Vote up 4 votes
protected static UUID getUUID(String existingServiceOfferingName) {
    return UUID.nameUUIDFromBytes((existingServiceOfferingName + SERVICE_PLAN_ENDING).getBytes());
}
 
Example 19
Project: sstable-adaptor   File: CFMetaData.java   View Source Code Vote up 2 votes
/**
 * 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()));
}
 
Example 20
Project: sunbird-utils   File: ProjectUtil.java   View Source Code Vote up 2 votes
/**
 * 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();
}