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

The following are Jave code examples for showing how to use fromString() 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: Bewitchment   File: TileEntityGlyph.java   View Source Code Vote up 6 votes
@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]));
		});
	}
}
 
Example 2
Project: BaseClient   File: UserListBansEntry.java   View Source Code Vote up 6 votes
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;
    }
}
 
Example 3
Project: CustomWorldGen   File: UserListBansEntry.java   View Source Code Vote up 6 votes
/**
 * 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;
    }
}
 
Example 4
Project: SamaGamesCore   File: RegularJoinHandler.java   View Source Code Vote up 6 votes
@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();
    }
}
 
Example 5
Project: jsf-sdk   File: JSFUUIDTemplate.java   View Source Code Vote up 5 votes
@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);
}
 
Example 6
Project: DecompiledMinecraft   File: EntityTameable.java   View Source Code Vote up 5 votes
public EntityLivingBase getOwner()
{
    try
    {
        UUID uuid = UUID.fromString(this.getOwnerId());
        return uuid == null ? null : this.worldObj.getPlayerEntityByUUID(uuid);
    }
    catch (IllegalArgumentException var2)
    {
        return null;
    }
}
 
Example 7
Project: BaseClient   File: S02PacketLoginSuccess.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 8
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 9
Project: AndroidProgramming3e   File: CrimeCursorWrapper.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: CustomWorldGen   File: SPacketLoginSuccess.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 11
Project: PlusGram   File: SmoothStreamingManifestParser.java   View Source Code Vote up 5 votes
@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);
  }
}
 
Example 12
Project: vos_whatsapp   File: RequestGetMessages.java   View Source Code Vote up 5 votes
@Override
@JsonIgnore
public UUID getUserId () {

  try {

    return UUID.fromString(this.user_id);
  } catch (Exception e) {

    return super.getUserId();
  }
}
 
Example 13
Project: SensorTag2Testing   File: LuxometerProfile.java   View Source Code Vote up 5 votes
public LuxometerProfile(@NonNull Observable<RxBleConnection> conn) {
    super(conn,
            UUID.fromString(GattServ),
            UUID.fromString(GattConf),
            UUID.fromString(GattData),
            UUID.fromString(GattPeri),
            Bconf);
}
 
Example 14
Project: act-platform   File: PropertiesBasedIdentityResolverTest.java   View Source Code Vote up 5 votes
@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());
}
 
Example 15
Project: Equella   File: EditNewItemMetadataOperation.java   View Source Code Vote up 4 votes
@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);
}
 
Example 16
Project: openpaas-mailets   File: FakeUUIDGenerator.java   View Source Code Vote up 4 votes
@Override
public UUID random() {
    return UUID.fromString("524e4f85-2d2f-4927-ab98-bd7a2f689773");
}
 
Example 17
Project: scalable-coffee-shop   File: OrderBeansValidated.java   View Source Code Vote up 4 votes
public OrderBeansValidated(JsonObject jsonObject) {
    this(UUID.fromString(jsonObject.getString("orderId")), Instant.parse(jsonObject.getString("instant")));
}
 
Example 18
Project: OpenRPG   File: Main.java   View Source Code Vote up 4 votes
public UUID fromAddress(InetAddress address) {
    return UUID.fromString(this.addresses.get(new String(address.getAddress())).getAsString());
}
 
Example 19
Project: DecompiledMinecraft   File: PlayerProfileCache.java   View Source Code Vote up 4 votes
public PlayerProfileCache.ProfileEntry deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    if (p_deserialize_1_.isJsonObject())
    {
        JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
        JsonElement jsonelement = jsonobject.get("name");
        JsonElement jsonelement1 = jsonobject.get("uuid");
        JsonElement jsonelement2 = jsonobject.get("expiresOn");

        if (jsonelement != null && jsonelement1 != null)
        {
            String s = jsonelement1.getAsString();
            String s1 = jsonelement.getAsString();
            Date date = null;

            if (jsonelement2 != null)
            {
                try
                {
                    date = PlayerProfileCache.dateFormat.parse(jsonelement2.getAsString());
                }
                catch (ParseException var14)
                {
                    date = null;
                }
            }

            if (s1 != null && s != null)
            {
                UUID uuid;

                try
                {
                    uuid = UUID.fromString(s);
                }
                catch (Throwable var13)
                {
                    return null;
                }

                PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = PlayerProfileCache.this.new ProfileEntry(new GameProfile(uuid, s1), date);
                return playerprofilecache$profileentry;
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }
    }
    else
    {
        return null;
    }
}
 
Example 20
Project: neatle   File: ScanRecordTest.java   View Source Code Vote up 3 votes
@Test
public void testFitbitResponse() {
    String txt = "0201061106ba5689a6fabfa2bd01467d6eca36abad05160a180704696e34";
    byte[] scanRecord = parseHex(txt);
    ScanRecord record = ScanRecord.createFromBytes(scanRecord);


    UUID firstUUID = UUID.fromString("adab36ca-6e7d-4601-bda2-bffaa68956ba");


    Assert.assertTrue(record.getServiceUUIDs().contains(firstUUID));
}