public class StkCityDatabaseQuery extends Object
StkCityDatabase
.
The following example shows how to query the city database for cities matching certain criteria:
StkCityDatabase db = new StkCityDatabase(dbDirectory, "stkCityDb");
// Create a query object and then populate it with the properties to query on.
// Regular expressions are used to query on strings.
StkCityDatabaseQuery query = new StkCityDatabaseQuery();
query.setCityName(Pattern.compile("Philadelphia"));
// only look in PA, because there's also a New Philadelphia in Ohio
query.setProvinceName(Pattern.compile("Pennsylvania"));
// Get the database entries matching the query and print out the Longitude and Latitude of each.
for (StkCityDatabaseEntry entry : db.getEntries(query)) {
System.out.format("%s: Longitude %f, Latitude %f%n", entry.getCityName(), entry.getLongitude(), entry.getLatitude());
}
Constructor and Description |
---|
StkCityDatabaseQuery() |
Modifier and Type | Method and Description |
---|---|
Pattern |
getCentralBodyName()
|
Pattern |
getCityName()
|
Pattern |
getCountryName()
|
Double |
getMaximumLatitude()
|
Double |
getMaximumLongitude()
|
Double |
getMinimumLatitude()
|
Double |
getMinimumLongitude()
|
Pattern |
getProvinceName()
|
CityType |
getTypeOfCity()
|
boolean |
matches(StkCityDatabaseEntry entry)
Determines if an entry matches this query.
|
void |
setCentralBodyName(Pattern value)
|
void |
setCityName(Pattern value)
|
void |
setCountryName(Pattern value)
|
void |
setMaximumLatitude(Double value)
|
void |
setMaximumLongitude(Double value)
|
void |
setMinimumLatitude(Double value)
|
void |
setMinimumLongitude(Double value)
|
void |
setProvinceName(Pattern value)
|
void |
setTypeOfCity(CityType value)
|
public final Pattern getCityName()
public final void setCityName(Pattern value)
public final Pattern getProvinceName()
public final void setProvinceName(Pattern value)
public final Pattern getCountryName()
public final void setCountryName(Pattern value)
public final Pattern getCentralBodyName()
public final void setCentralBodyName(Pattern value)
public final boolean matches(@Nonnull StkCityDatabaseEntry entry)
entry
- The entry to check.true
if the entry matches this query; otherwise false
.ArgumentNullException
- Thrown when entry
is null
.