本文整理汇总了Java中java.util.UUID.fromString方法的典型用法代码示例。如果您正苦于以下问题:Java UUID.fromString方法的具体用法?Java UUID.fromString怎么用?Java UUID.fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.UUID
的用法示例。
在下文中一共展示了UUID.fromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readDataNBT
import java.util.UUID; //导入方法依赖的package包/类
@Override
protected void readDataNBT(NBTTagCompound tag) {
cooldown = tag.getInteger("cooldown");
if (tag.hasKey("ritual"))
ritual = Ritual.REGISTRY.getValue(new ResourceLocation(tag.getString("ritual")));
if (tag.hasKey("player"))
entityPlayer = UUID.fromString(tag.getString("player"));
if (tag.hasKey("data"))
ritualData = tag.getCompoundTag("data");
if (tag.hasKey("entityList")) {
entityList = new ArrayList<Tuple<String, String>>();
tag.getTagList("entityList", NBT.TAG_STRING).forEach(nbts -> {
String[] names = ((NBTTagString) nbts).getString().split("!");
if (names.length == 2)
entityList.add(new Tuple<String, String>(names[0], names[1]));
});
}
}
示例2: func_152648_b
import java.util.UUID; //导入方法依赖的package包/类
private static GameProfile func_152648_b(JsonObject p_152648_0_)
{
if (p_152648_0_.has("uuid") && p_152648_0_.has("name"))
{
String s = p_152648_0_.get("uuid").getAsString();
UUID uuid;
try
{
uuid = UUID.fromString(s);
}
catch (Throwable var4)
{
return null;
}
return new GameProfile(uuid, p_152648_0_.get("name").getAsString());
}
else
{
return null;
}
}
示例3: toGameProfile
import java.util.UUID; //导入方法依赖的package包/类
/**
* Convert a {@linkplain com.google.gson.JsonObject JsonObject} into a {@linkplain com.mojang.authlib.GameProfile}.
* The json object must have {@code uuid} and {@code name} attributes or {@code null} will be returned.
*/
private static GameProfile toGameProfile(JsonObject json)
{
if (json.has("uuid") && json.has("name"))
{
String s = json.get("uuid").getAsString();
UUID uuid;
try
{
uuid = UUID.fromString(s);
}
catch (Throwable var4)
{
return null;
}
return new GameProfile(uuid, json.get("name").getAsString());
}
else
{
return null;
}
}
示例4: receive
import java.util.UUID; //导入方法依赖的package包/类
@Override
public void receive(String channel, String packet)
{
UUID player = UUID.fromString(packet);
JoinResponse response = manager.requestJoin(player, false);
if (!response.isAllowed())
{
TextComponent component = new TextComponent(response.getReason());
component.setColor(ChatColor.RED);
SamaGamesAPI.get().getPlayerManager().sendMessage(player, component);
} else
{
SamaGamesAPI.get().getPlayerManager().connectToServer(player, SamaGamesAPI.get().getServerName());
SamaGamesAPI.get().getGameManager().refreshArena();
}
}
示例5: read
import java.util.UUID; //导入方法依赖的package包/类
@Override
public UUID read(Unpacker u, UUID to, boolean required) throws IOException {
if (!required && u.trySkipNil()) {
return null;
}
String path = u.readString();
return UUID.fromString(path);
}
示例6: getOwner
import java.util.UUID; //导入方法依赖的package包/类
public EntityLivingBase getOwner()
{
try
{
UUID uuid = UUID.fromString(this.getOwnerId());
return uuid == null ? null : this.worldObj.getPlayerEntityByUUID(uuid);
}
catch (IllegalArgumentException var2)
{
return null;
}
}
示例7: readPacketData
import java.util.UUID; //导入方法依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
String s = buf.readStringFromBuffer(36);
String s1 = buf.readStringFromBuffer(16);
UUID uuid = UUID.fromString(s);
this.profile = new GameProfile(uuid, s1);
}
示例8: 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());
}
}
示例9: getCrime
import java.util.UUID; //导入方法依赖的package包/类
public Crime getCrime() {
String uuidString = getString(getColumnIndex(Cols.UUID));
String title = getString(getColumnIndex(Cols.TITLE));
long date = getLong(getColumnIndex(Cols.DATE));
int isSolved = getInt(getColumnIndex(Cols.SOLVED));
String suspect = getString(getColumnIndex(CrimeTable.Cols.SUSPECT));
Crime crime = new Crime(UUID.fromString(uuidString));
crime.setTitle(title);
crime.setDate(new Date(date));
crime.setSolved(isSolved != 0);
crime.setSuspect(suspect);
return crime;
}
示例10: parseStartTag
import java.util.UUID; //导入方法依赖的package包/类
@Override
public void parseStartTag(XmlPullParser parser) {
if (TAG_PROTECTION_HEADER.equals(parser.getName())) {
inProtectionHeader = true;
String uuidString = parser.getAttributeValue(null, KEY_SYSTEM_ID);
uuidString = stripCurlyBraces(uuidString);
uuid = UUID.fromString(uuidString);
}
}
示例11: getUserId
import java.util.UUID; //导入方法依赖的package包/类
@Override
@JsonIgnore
public UUID getUserId () {
try {
return UUID.fromString(this.user_id);
} catch (Exception e) {
return super.getUserId();
}
}
示例12: LuxometerProfile
import java.util.UUID; //导入方法依赖的package包/类
public LuxometerProfile(@NonNull Observable<RxBleConnection> conn) {
super(conn,
UUID.fromString(GattServ),
UUID.fromString(GattConf),
UUID.fromString(GattData),
UUID.fromString(GattPeri),
Bconf);
}
示例13: testResolveSubjectIdentity
import java.util.UUID; //导入方法依赖的package包/类
@Test
public void testResolveSubjectIdentity() {
UUID id = UUID.fromString("00000000-0000-0000-0000-000000000001");
SubjectIdentity identity = resolver.resolveSubjectIdentity(id);
assertTrue(identity instanceof SubjectIdentifier);
assertEquals(id, SubjectIdentifier.class.cast(identity).getGlobalID());
}
示例14: ensureItemInternal
import java.util.UUID; //导入方法依赖的package包/类
@Override
protected void ensureItemInternal(Item newItem)
{
ItemKey itemkey = params.getItemKey();
params.setItemPack(newPack);
String uuid = itemkey.getUuid();
if( uuid.length() == 0 )
{
uuid = UUID.randomUUID().toString();
}
else
{
// Make sure valid uuid
UUID.fromString(uuid);
}
itemkey = new ItemId(uuid, itemkey.getVersion());
params.setItemKey(itemkey, 0);
newItem.setId(0);
newItem.setUuid(uuid);
newItem.setVersion(itemkey.getVersion());
newItem.setDateCreated(new Date());
newItem.setItemDefinition(itemDefinitionService.get(newItem.getItemDefinition().getId()));
if( itemkey.getVersion() > 1 )
{
long collectionId = itemDao.getCollectionIdForUuid(itemkey.getUuid());
if( collectionId != 0 && newItem.getItemDefinition().getId() != collectionId )
{
throw new OperationException("com.tle.core.workflow.operations.editmeta.error.cannotchangecollection"); //$NON-NLS-1$
}
}
boolean noOwner = Check.isEmpty(newItem.getOwner());
if( noOwner )
{
newItem.setOwner(CurrentUser.getUserID());
}
newItem.setStatus(null);
newItem.setStatus(initialStatus);
relinkAttachments(newItem.getAttachments(), newItem.getTreeNodes());
createHistory(Type.contributed);
}
示例15: random
import java.util.UUID; //导入方法依赖的package包/类
@Override
public UUID random() {
return UUID.fromString("524e4f85-2d2f-4927-ab98-bd7a2f689773");
}