Language

public class Language implements Serializable, Listable

Represents a language that may be spoken by users. It may be included as part of the definition of a Network or as an attribute of a User, for example.

Fields

language_id

public long language_id

Unique identifier for the language and the PrimaryKey for databases

name

public String name

Name of the language, as used by the API.

numSpeakers

public int numSpeakers

The number of Culturemesh users who speak the language

Constructors

Language

public Language(long id, String name, int numSpeakers)

Create a new Language object with the provided properties

Parameters:
  • id – Unique identifier for the language. The same ID must be used everywhere
  • name – Human-readable name of the language. This will be displayed to users. It must also be unique, as it is passed in API calls.
  • numSpeakers – The number of Culturemesh users who speak the language

Language

public Language(JSONObject json)

Create a new Language from the JSON produced by an API call. The JSON must conform to the following format:

{
          "lang_id": 0,
          "name": "string",
          "num_speakers": 0,
          "added": 0
        }

Note that the added key is not used and therefore optional.

Parameters:
  • json – JSON representation of the language to create.
Throws:
  • JSONException – May be thrown for an improperly formatted JSON

Language

public Language()

Empty constructor solely for storing Language objects in a database. Never use this!

Methods

getListableName

public String getListableName()

Get a descriptive representation of the language suitable for display to user

Returns:Name of the language, abbreviated to be at most Listable.MAX_CHARS characters long.

getNumUsers

public long getNumUsers()

Get the number of users who speak the language

Returns:Number of users who speak the language

toString

public String toString()

Convert the language to a unique string, its name

Returns:The name of the language

urlParam

public String urlParam()

Get a representation of the language suitable for passage in a URL for API calls

Returns:Name of the language encoded for inclusion in a URL