DatabaseNetwork¶
-
public class
DatabaseNetwork
¶ This class is solely for storing the bare, ID-only form of a network in the database. After being retrieved from the database or received from a network request, it should immediately be used to create a
Network
object, with the additional information that comes with. Storing only IDs in the database makes theDatabaseNetwork.nearLocation
,DatabaseNetwork.fromLocation
andDatabaseNetwork.languageId
references pointers to database entries with more information. This reduces the risk of conflicting information and reduces the overhead of updating data in more than one spot in the database.
Fields¶
fromLocation¶
-
public FromLocation
fromLocation
¶ The location where the users of this network are from. It may be
null
to indicate that no location is specified only ifDatabaseNetwork.isLanguageBased
isfalse
isLanguageBased¶
-
public boolean
isLanguageBased
¶ Denotes whether this network’s from attribute is based on where an individual is from or on what language they speak.
true
: Based on what language they speakfalse
: Based on what location they are from
languageId¶
-
public long
languageId
¶ The ID of the language the users of this network speak. It may be set to
-1
to indicate no language being specified only ifDatabaseNetwork.isLanguageBased
isfalse
nearLocation¶
-
public NearLocation
nearLocation
¶ The location where the users of this network currently reside. It must not be null.
Constructors¶
DatabaseNetwork¶
-
public
DatabaseNetwork
()¶ Empty constructor for database use only. This should never be called by our code.
DatabaseNetwork¶
-
public
DatabaseNetwork
(NearLocation nearLocation, FromLocation fromLocation, long id)¶ Create a new
DatabaseNetwork
for a network of people who come from the same areaParameters: - nearLocation – Where the network’s members currently reside
- fromLocation – Where the network’s members are from
- id – ID for this network
DatabaseNetwork¶
-
public
DatabaseNetwork
(NearLocation nearLocation, long langId, long id)¶ Create a new
DatabaseNetwork
for a network of people who speak the same languageParameters: - nearLocation – Where the network’s members currently reside
- langId – ID for the language the network’s members speak
- id – ID for this network
DatabaseNetwork¶
-
public
DatabaseNetwork
(JSONObject json)¶ If the key location_cur is present (old JSON version): Initialize instance fields with the data in the provided JSON. The following keys are mandatory and used:
location_cur
, whose value is expected to be a JSON describing aNearLocation
object and can be passed toNearLocation.NearLocation(JSONObject)
, andnetwork_class
, whose value is expected to be either0
, indicating a location-based network, or1
, indicating a language-based network. If the network is language-based, they keylanguage_origin
must exist with a value of a JSON object containing a keyid
whose value is the ID of aLanguage
. If the network is location-based, the keylocation_origin
must exist and have a value of a JSON object representing aFromLocation
that can be passed toFromLocation.FromLocation(JSONObject)
. NOTE: This JSON format is deprecated and should not be used if possible. If the key location_cur is not present (new JSON version): Initialize instance fields with the data in the provided JSON. The following keys are mandatory and used: All keys required byNearLocation.NearLocation(JSONObject)
and the keynetwork_class
, whose value is expected to be either_l
, indicating a language-based network, or one ofcc
,rc
, andco
, indicating a location-based network. If the network is language-based, the keyid_language_origin
must exist with a value of the ID of aLanguage
. If the network is location-based, all keys required byFromLocation.FromLocation(JSONObject)
must be present.Parameters: - json – JSON object describing the network in terms of IDs
Throws: - JSONException – May be thrown in response to improperly formatted JSON
Methods¶
isLanguageBased¶
-
public boolean
isLanguageBased
()¶ Check whether this network is of people who speak the same language
Returns: true
if the network is defined in terms of language,false
otherwise