public class StkFacilityDatabase extends Object
The following example shows how to query the facility database for facilities matching certain criteria:
StkFacilityDatabase db = new StkFacilityDatabase(dbDirectory, "stkFacility");
// Create a query object and then populate it with the properties to query on.
// Regular expressions are used to query on strings.
StkFacilityDatabaseQuery query = new StkFacilityDatabaseQuery();
query.setFacilityName(Pattern.compile("^Diyarbak"));
// Get the database entries matching the query and print out the Longitude and Latitude of each.
for (StkFacilityDatabaseEntry entry : db.getEntries(query)) {
System.out.format("%s: Longitude %f, Latitude %f%n", entry.getFacilityName(), entry.getLongitude(), entry.getLatitude());
}
Constructor and Description |
---|
StkFacilityDatabase(String directory,
String baseFileName)
Initializes a new instance.
|
Modifier and Type | Method and Description |
---|---|
ArrayList<String> |
getCentralBodies()
Gets the central bodies of the facilities in the database.
|
ArrayList<StkFacilityDatabaseEntry> |
getEntries()
Gets all of the entries in the database.
|
ArrayList<StkFacilityDatabaseEntry> |
getEntries(StkFacilityDatabaseQuery query)
Gets all of the entries in the database matching a specified query.
|
GregorianDate |
getLastUpdateDate()
Gets the last update date reported in the Generic Database (.gd) file, or
GregorianDate.MinValue
if the file does not exist or does not contain a LastUpdate field. |
ArrayList<String> |
getNetworks()
Gets the networks of the facilities in the database.
|
String |
getVersion()
Gets the version number reported in the Generic Database (.gd) file, or "Unknown" if
the file does not exist or does not contain a Version field.
|
public StkFacilityDatabase(@Nonnull String directory, @Nonnull String baseFileName)
directory
- The directory in which the facility database is located.baseFileName
- The base filename (without extension) of the database within the directory.ArgumentNullException
- Thrown when directory
or baseFileName
is null
.public final String getVersion()
@Nonnull public final GregorianDate getLastUpdateDate()
GregorianDate.MinValue
if the file does not exist or does not contain a LastUpdate field.@Nonnull public final ArrayList<String> getNetworks()
@Nonnull public final ArrayList<String> getCentralBodies()
@Nonnull public final ArrayList<StkFacilityDatabaseEntry> getEntries()
@Nonnull public final ArrayList<StkFacilityDatabaseEntry> getEntries(@Nullable StkFacilityDatabaseQuery query)
query
- The query that returned entries must match,
or null
to return all entries.InvalidDataException
- Thrown when a required data file was not found.