English | Site Directory

opensocial.Enum (v0.7)

 SUMMARY     DETAIL

Class opensocial.Enum

Base interface for all enum objects. This class allows containers to use constants for fields that are usually have a common set of values. There are two main ways to use this class.

If your gadget just wants to display how much of a smoker someone is, it can simply use:

html = "This person smokes: " + person.getField('smoker').getValue();

This value field will be correctly set up by the container. This is a place where the container can even localize the value for the gadget so that it always shows the right thing.

If your gadget wants to have some logic around the smoker field it can use:

if (person.getField('smoker').getKey() != "NO") { //gadget logic here }

Note: The key may be null if the person's smoker field cannot be coerced into one of the standard enum types. The value, on the other hand, is never null.

Method Summary

 String getDisplayValue()
The value of this enum.
 String getKey()
Use this for logic within your gadget.
 

Method Detail

getDisplayValue

String getDisplayValue()
    The value of this enum. This will be a user displayable string. If the container supports localization, the string will be localized.
    Returns:
      String The enum's value.

getKey

String getKey()
    Use this for logic within your gadget. If they key is null then the value does not fit in the defined enums.
    Returns:
      String The enum's key. This should be one of the defined enums below.

Documentation generated by JsDoc Toolkit 1.3.3