当前位置: 首页>>代码示例>>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;未经允许,请勿转载。