Region

public class Region extends Place

A Region is a specific kind of Place that stores the ID and name of a region. It can also store the name and ID of the region’s country, but this is not mandatory. If any geographical descriptor (e.g. city, region, or country) is not specified, its name will be stored as Place.NOWHERE, but this constant should not be used by clients. Note that the region descriptor is mandatory.

Fields

countryName

public String countryName

Name of the country (may store Place.NOWHERE

regionName

public String regionName

Name of the region (should always be specified and not as Place.NOWHERE

Constructors

Region

public Region(long regionId, long countryId, String regionName, String countryName, Point latLng, long population, String featureCode)

Initialize instance fields and those of superclass with provided parameters No parameters should be set to Place.NOWHERE or Location.NOWHERE For regions with explicitly specified countries

Parameters:
  • regionId – ID of region
  • countryId – ID of country
  • regionName – Name of region
  • countryName – Name of country
  • latLng – Latitude and longitude coordinates of the region
  • population – Population of the region
  • featureCode – Region’s feature code

Region

public Region(long regionId, String regionName, Point latLng, long population, String featureCode)

Initialize instance fields and those of superclass with provided parameters No parameters should be set to Place.NOWHERE or Location.NOWHERE For regions that have no specified country

Parameters:
  • regionId – ID of region
  • regionName – Name of region
  • latLng – Latitude and longitude coordinates of the region
  • population – Population of the region
  • featureCode – Region’s feature code

Region

public Region(JSONObject json)

Initialize instance fields and those of superclass based on provided JSON This class extracts the following fields, if they are present: country_name. It requires that the key name exist, as its value will be used as the region’s name

Parameters:
  • json – JSON object describing the region to create
Throws:
  • JSONException – May be thrown in response to an invalidly formatted JSON object

Region

public Region()

Empty constructor for database use only. This should never be called by our code.

Methods

getFullName

public String getFullName()

Get a name for the region that lists all available geographic descriptor names. For example, Washington, D.C. would be expressed as Washington, D.C., United States, while San Francisco would be expressed as San Francisco, California, United States.

Returns:Name of city that includes all available geographic descriptors

getName

public String getName()

Get the name of the region

Returns:Name of region

getShortName

public String getShortName()

Now display just region name.

toString

public String toString()

Represent the object as a string suitable for debugging, but not for display to user.

Returns:String representation of the form Class[var=value, var=value, var=value, ...]