當前位置: 首頁>>代碼示例>>Java>>正文


Java UUID.nameUUIDFromBytes方法代碼示例

本文整理匯總了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);
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:26,代碼來源:DaemonInstance.java

示例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);
}
 
開發者ID:EixoX,項目名稱:jetfuel,代碼行數:11,代碼來源:UUIDAdapter.java

示例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));
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:8,代碼來源:Utils.java

示例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());
    }
}
 
開發者ID:Clout-Team,項目名稱:JarCraftinator,代碼行數:9,代碼來源:UUIDManager.java

示例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());
    }
}
 
開發者ID:intuit,項目名稱:universal-graph-client,代碼行數:33,代碼來源:UUIDTypeConversion.java

示例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();
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:15,代碼來源:Utils.java

示例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());
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:12,代碼來源:Utils.java

示例8: getOfflineUUID

import java.util.UUID; //導入方法依賴的package包/類
public static UUID getOfflineUUID(String username)
{
    return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:5,代碼來源:EntityPlayer.java

示例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());
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:6,代碼來源:NetHandlerLoginServer.java

示例10: getUUID

import java.util.UUID; //導入方法依賴的package包/類
public static UUID getUUID(String name) {
    return UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:4,代碼來源:NameUtil.java

示例11: getUUID

import java.util.UUID; //導入方法依賴的package包/類
protected static UUID getUUID(String existingServiceOfferingName) {
    return UUID.nameUUIDFromBytes((existingServiceOfferingName + SERVICE_PLAN_ENDING).getBytes());
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:4,代碼來源:ServiceCreatorTest.java

示例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()));
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:11,代碼來源:CFMetaData.java

示例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();
}
 
開發者ID:project-sunbird,項目名稱:sunbird-utils,代碼行數:13,代碼來源:ProjectUtil.java


注:本文中的java.util.UUID.nameUUIDFromBytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。