Beispiel #1
0
    /**
     * Retrieves the OpenSocial ID associated with the instance. Returns an
     * empty string if no ID has been set.
     */
    public String getId()
    {
        OpenSocialField IDField = this.getField("id");

        if (IDField != null && !IDField.isComplex())
        {
            return(IDField.getStringValue());
        }

        return("");
    }
Beispiel #2
0
    /**
     * Retrieves the display name (typically given name followed by family name)
     * associated with the instance. Returns an empty string if no name has been
     * set.
     *
     * @throws OpenSocialException
     */
    public String getDisplayName()
    {
        OpenSocialField nicknameField = this.getField("nickname");
        OpenSocialField nameField     = this.getField("name");
        StringBuilder   name          = new StringBuilder();

        if (nameField != null)
        {
            if (nameField.isComplex())
            {
                OpenSocialObject nameObject = nameField.getValue();

                if (nameObject.hasField("givenName"))
                {
                    name.Append(nameObject.getField("givenName").getStringValue());
                }

                if (nameObject.hasField("givenName") &&
                    nameObject.hasField("familyName"))
                {
                    name.Append(" ");
                }

                if (nameObject.hasField("familyName"))
                {
                    name.Append(nameObject.getField("familyName").getStringValue());
                }
            }
            else
            {
                name.Append(nameField.getStringValue());
            }
        }
        else if (nicknameField != null)
        {
            if (!nicknameField.isComplex())
            {
                name.Append(nicknameField.getStringValue());
            }
        }

        return(name.ToString());
    }