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


Java UUID.fromString方法代碼示例

本文整理匯總了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]));
		});
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:19,代碼來源:TileEntityGlyph.java

示例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;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:UserListBansEntry.java

示例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;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:28,代碼來源:UserListBansEntry.java

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

示例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);
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:9,代碼來源:JSFUUIDTemplate.java

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

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

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

示例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;
}
 
開發者ID:rsippl,項目名稱:AndroidProgramming3e,代碼行數:16,代碼來源:CrimeCursorWrapper.java

示例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);
  }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:10,代碼來源:SmoothStreamingManifestParser.java

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

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

示例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());
}
 
開發者ID:mnemonic-no,項目名稱:act-platform,代碼行數:8,代碼來源:PropertiesBasedIdentityResolverTest.java

示例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);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:48,代碼來源:EditNewItemMetadataOperation.java

示例15: random

import java.util.UUID; //導入方法依賴的package包/類
@Override
public UUID random() {
    return UUID.fromString("524e4f85-2d2f-4927-ab98-bd7a2f689773");
}
 
開發者ID:linagora,項目名稱:openpaas-mailets,代碼行數:5,代碼來源:FakeUUIDGenerator.java


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