public class Loaded_Database
extends java.lang.Object
This class will attempt to make certain that there is consistency between the specified fields and the data entries. It attempts to make certain that there all entries have the same size as the number of fields. It also tries to make sure that the fields match with what should be there as specified by the Unique Key and the Required Fields. Other than that it is lenient in what can be put into it.
As a note, while attempting to keep consistency between the fields and the entries this class only makes sure that the entry size is only at least the size of the list of fields. If there are more fields filled in an entry than there are fields in the database the data will be kept intact. As a rule the fields of this class should be filled out before anything else, but it is possible to fill the data in first. However, take caution when removing fields as the corresponding column will be removed from the data entries.
This class also includes the ability to define a null value for each field. Then, when inserting entries each value in each entry will be checked against the null value for the field that it represents. If the values match then the value in the entry will be set to null. This comparison is case sensitive.
All field comparisons in this class are case sensitive.
The Unique Key field should be specified after the fields have been filled. This is because the key will only be set if it exists in the list of fields.
Required fields are loaded into this class any time a change occurs with the
configuration. Required fields are optional in the configuration file and
should be specified in the required fields group
in the configuration group
for this class. Below is an
example Configuration file.
Group = Loaded_Database
Group = Required_Fields
Product_ID
Center
Footprint
End_Group
End_Group
PIRL.Configuration
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector<java.lang.String> |
Altered_Fields_From
The list of altered field names in the external database
|
protected java.lang.String |
Altered_Fields_Group
The group for finding Altered Fields
|
protected java.util.Vector<java.lang.String> |
Altered_Fields_To
The list of altered field names in the local database
|
protected int |
Base
The base for configuration fields
|
protected java.lang.String |
Column_Number_Pathname
The column number pathname
|
protected PIRL.Configuration.Configuration |
Config
The Configuration file for this class.
|
protected java.lang.String |
Config_Group
The group to gather configuration information from for this class.
|
protected java.util.Vector<java.util.Vector<java.lang.String>> |
Data
The data from the database.
|
static java.lang.String |
DEFAULT_ALTERED_FIELDS_GROUP
The default group for finding Altered Fields
|
static int |
DEFAULT_BASE
The default base for configuration fields
|
static java.lang.String |
DEFAULT_COLUMN_NUMBER_PATHNAME
The default column number pathname
|
static java.lang.String |
DEFAULT_CONFIG_FILENAME
The default name for the configuration file.
|
static java.lang.String |
DEFAULT_CONFIG_GROUP
The default group to gather configuration information from for this class
if no other group is specified.
|
static java.lang.String |
DEFAULT_EXCLUDED_FIELDS_GROUP
The default group for finding Excluded Fields
|
static java.lang.String |
DEFAULT_FIELD_NAME_PATHNAME
The default field name pathname.
|
static java.lang.String |
DEFAULT_FIELD_PATHNAME
The default field pathname.
|
static java.lang.String |
DEFAULT_NULL_VALUE_PATHNAME
The default null values pathname
|
static java.lang.String |
DEFAULT_REQUIRED_FIELDS_GROUP
The default group for finding required fields if no other group is specified.
|
static java.lang.String |
DEFAULT_UNIQUE_KEY_PATHNAME
The default Unique key pathname
|
protected java.util.Vector<java.lang.Integer> |
Excluded_Field_Numbers
The field numbers for excluded fields
|
protected java.util.Vector<java.lang.String> |
Excluded_Fields
The list of excluded fields
|
protected java.lang.String |
Excluded_Fields_Group
The group for finding Excluded Fields
|
protected java.lang.String |
Field_Name_Pathname
The field name pathname
|
protected java.lang.String |
Field_Pathname
The configuration pathname for fields
|
protected java.util.Vector<java.lang.String> |
Fields
The field names from the database.
|
static java.lang.String |
ID
The Class identification with revision number.
|
protected java.lang.String |
Null_Value_Pathname
The null values pathname
|
protected java.util.Vector<java.lang.String> |
Null_Values
A list of null values for the fields
|
protected java.util.Vector<java.lang.String> |
Required_Fields
A list of field names that are required by the program using this database.
|
protected java.lang.String |
Required_Fields_Group
The group to gather required fields from within the
main group . |
protected java.lang.String |
Unique_Key
The name of the unique key field for this database.
|
protected java.lang.String |
Unique_Key_Pathname
The Unique key pathname
|
Constructor and Description |
---|
Loaded_Database()
This creates a Loaded_Database with all default values.
|
Loaded_Database(PIRL.Configuration.Configuration config)
This creates a Loaded_Database with a configuration object and a default config group
|
Loaded_Database(PIRL.Configuration.Configuration config,
java.lang.String config_group)
This creates a Loaded_Database with a configuration from an object and a non-default config_group
|
Loaded_Database(java.lang.String config_filename)
This creates a Loaded_Database with a configuration from a file name and a default config group
|
Loaded_Database(java.lang.String config_filename,
java.lang.String config_group)
This creates a Loaded_Database with a configuration from a file and a non-default config_group
|
Modifier and Type | Method and Description |
---|---|
void |
Add_Entry(java.util.Vector<java.lang.String> entry)
This method adds an entry to the data of the Loaded_Database
|
boolean |
Add_Field(int index,
java.lang.String field,
java.lang.String null_value)
This adds a field to the list of fields and a null value
at a specified index.
|
boolean |
Add_Field(java.lang.String field)
This adds a field to the list of fields and sets the null value
for that field to null.
|
boolean |
Add_Field(java.lang.String field,
boolean force)
This allows a field to be forcefully added
|
boolean |
Add_Field(java.lang.String field,
java.lang.String null_value)
This adds a field to the list of fields and a null value
|
void |
Add_Fields(java.util.Vector<java.lang.String> fields)
This adds a bunch of fields to the list of fields and sets the null value
for each field to null.
|
void |
Add_Fields(java.util.Vector<java.lang.String> fields,
java.util.Vector<java.lang.String> null_values)
This adds a bunch of fields to the list of fields and a their cooresponding
null values.
|
void |
Clear_Data()
This clears the data from the data set.
|
void |
Clear_Fields()
This clears out both the fields and the data
|
static java.lang.String |
Create_180180_WKT_Centroid_Point(java.lang.String x,
java.lang.String y)
This returns a WKT center point based on Strings and converts them to
the 180,-180 longitude domain.
|
static java.lang.String |
Create_180180_WKT_ROI_Polygon_From_Strings(java.util.Vector<java.util.Vector<java.lang.String>> points)
This returns a WKT polygon based on a Vector of Vectors of Strings that is in the
180,-180 longitude format.
|
static java.lang.String |
Create_WKT_Centroid_Point(double x,
double y)
This returns a WKT center point based on doubles
|
static java.lang.String |
Create_WKT_Centroid_Point(java.lang.String x,
java.lang.String y)
This returns a WKT center point based on Strings
|
static java.lang.String |
Create_WKT_ROI_Polygon_From_Doubles(java.util.Vector<java.util.Vector<java.lang.Double>> points)
This returns a WKT polygon based on a Vector of Vectors of doubles
|
static java.lang.String |
Create_WKT_ROI_Polygon_From_Strings(java.util.Vector<java.util.Vector<java.lang.String>> points)
This returns a WKT polygon based on a Vector of Vectors of Strings
|
void |
Fill_Fields(PIRL.PVL.Parameter config)
This uses a Parameter to fill out the fields
|
void |
Fill_Fields(java.lang.String url)
This uses a PVL parameter file stored at a URL to fill out the fields
|
java.lang.String |
Get_Altered_Fields_Group()
This returns the Vector of Strings of altered fields
|
int |
Get_Base()
This gets the base for the field numbers
|
java.lang.String |
Get_Column_Number_Pathname()
This gets the column number pathname
|
java.lang.String |
Get_Configuration_Group()
This gets the configuration group for this class
|
PIRL.Configuration.Configuration |
Get_Configuration()
This gets the configuration for this class
|
java.util.Vector<java.util.Vector<java.lang.String>> |
Get_Data()
This returns a copy of the data in the Loaded_Database
|
java.util.Vector<java.lang.Integer> |
Get_Excluded_Field_Numbers()
This gets the field numbers for excluded fields
|
java.lang.String |
Get_Excluded_Fields_Group()
This returns the Vector of Strings of excluded fields
|
java.lang.String |
Get_Field_Name_Pathname()
This gets the field name pathname
|
java.lang.String |
Get_Field_Pathname()
This gets the field pathname
|
java.util.Vector<java.lang.String> |
Get_Fields()
This returns a list of the fields
|
java.lang.String |
Get_Key() |
java.lang.String |
Get_Null_Value_Pathname()
This gets the null values pathname
|
java.lang.String |
Get_Required_Fields_Group()
This returns the Vector of Strings of required fields
|
java.lang.String |
Get_Unique_Key_Pathname()
This gets the Unique key pathname
|
int |
Number_Of_Fields()
This returns the number of fields
|
java.util.Vector<java.util.Vector<java.lang.String>> |
Remove_Data()
This removes and returns the data from the data set.
|
void |
Remove_Entry(int entry)
This method removes an entry from a specified location
|
void |
Remove_Entry(java.lang.String key)
This method removes an entry based on its unique key
|
void |
Remove_Field(java.lang.String field)
This removes a field from the list if it is there.
|
void |
Remove_Fields(java.util.Vector<java.lang.String> fields)
This removes a bunch of fields from the list of fields if they are there
|
void |
Set_Altered_Fields_Group(java.lang.String altered_fields_group)
This sets the group that the altered fields should be taken from.
|
void |
Set_Base(int base)
This sets the base for the field numbers
|
void |
Set_Column_Number_Pathname(java.lang.String path)
This sets the column number pathname
|
void |
Set_Configuration_Group(java.lang.String config_group)
This sets the configuration group for this class
|
void |
Set_Configuration(PIRL.Configuration.Configuration config)
This sets the configuration based on a configuration object
|
void |
Set_Configuration(java.lang.String config_filename)
This sets the classes configuration based on a filename
|
void |
Set_Excluded_Fields_Group(java.lang.String excluded_fields_group)
This sets the group that the excluded fields should be taken from.
|
void |
Set_Field_Name_Pathname(java.lang.String path)
This sets the field name pathname
|
void |
Set_Field_Pathname(java.lang.String path)
This sets the field pathname
|
void |
Set_Key(java.lang.String key)
This method sets the unique key string
|
void |
Set_Null_Value_Pathname(java.lang.String path)
This sets the null values pathname
|
void |
Set_Required_Fields_Group(java.lang.String required_fields_group)
This sets the group that the required fields should be taken from.
|
void |
Set_Unique_Key_Pathname(java.lang.String path)
This sets the Unique key pathname
|
int |
Size()
This returns the size of the data set
|
boolean |
Validate()
This method validates the loaded database.
|
public static final java.lang.String ID
protected PIRL.Configuration.Configuration Config
public static final java.lang.String DEFAULT_CONFIG_FILENAME
protected java.lang.String Config_Group
public static final java.lang.String DEFAULT_CONFIG_GROUP
protected java.lang.String Required_Fields_Group
main group
.public static final java.lang.String DEFAULT_REQUIRED_FIELDS_GROUP
protected java.util.Vector<java.util.Vector<java.lang.String>> Data
protected java.util.Vector<java.lang.String> Fields
protected java.lang.String Unique_Key
protected java.util.Vector<java.lang.String> Required_Fields
protected java.util.Vector<java.lang.String> Null_Values
protected java.lang.String Null_Value_Pathname
protected java.util.Vector<java.lang.String> Excluded_Fields
protected java.lang.String Excluded_Fields_Group
protected java.util.Vector<java.lang.Integer> Excluded_Field_Numbers
public static final java.lang.String DEFAULT_EXCLUDED_FIELDS_GROUP
protected java.util.Vector<java.lang.String> Altered_Fields_From
protected java.util.Vector<java.lang.String> Altered_Fields_To
protected java.lang.String Altered_Fields_Group
public static final java.lang.String DEFAULT_ALTERED_FIELDS_GROUP
public static final java.lang.String DEFAULT_NULL_VALUE_PATHNAME
protected java.lang.String Field_Pathname
public static final java.lang.String DEFAULT_FIELD_PATHNAME
protected java.lang.String Field_Name_Pathname
public static final java.lang.String DEFAULT_FIELD_NAME_PATHNAME
protected java.lang.String Column_Number_Pathname
public static final java.lang.String DEFAULT_COLUMN_NUMBER_PATHNAME
protected java.lang.String Unique_Key_Pathname
public static final java.lang.String DEFAULT_UNIQUE_KEY_PATHNAME
protected int Base
public static final int DEFAULT_BASE
public Loaded_Database() throws PIRL.Configuration.Configuration_Exception
PIRL.Configuration.Configuration_Exception
- Thrown when the creation of the configuration fails.public Loaded_Database(PIRL.Configuration.Configuration config)
config
- The configuration object.public Loaded_Database(java.lang.String config_filename) throws PIRL.Configuration.Configuration_Exception
config_filename
- The name of the configuration file.PIRL.Configuration.Configuration_Exception
- Thrown when the creation of the configuration fails.public Loaded_Database(PIRL.Configuration.Configuration config, java.lang.String config_group)
config
- The configuration objectconfig_group
- The name of the config grouppublic Loaded_Database(java.lang.String config_filename, java.lang.String config_group) throws PIRL.Configuration.Configuration_Exception
config_filename
- the name of the configuration file.config_group
- the name of the config group.PIRL.Configuration.Configuration_Exception
public void Set_Configuration(PIRL.Configuration.Configuration config)
This also re-obtains the required fields with the new information.
config
- The new configuration object.public void Set_Configuration(java.lang.String config_filename) throws PIRL.Configuration.Configuration_Exception
This also re-obtains the required fields with the new information.
config_filename
- The name of the new configuration filePIRL.Configuration.Configuration_Exception
public PIRL.Configuration.Configuration Get_Configuration()
public void Set_Configuration_Group(java.lang.String config_group)
This also re-obtains the required fields with the new information.
config_group
- The configuration group name.public java.lang.String Get_Configuration_Group()
public void Set_Required_Fields_Group(java.lang.String required_fields_group)
The group is the group within the configuration file that the required fields are listed in. This also re-obtains those fields with the new information.
required_fields_group
- The name of the group.public java.lang.String Get_Required_Fields_Group()
public void Set_Excluded_Fields_Group(java.lang.String excluded_fields_group)
The group is the group within the configuration file that the excluded fields are listed in. This also re-obtains those fields with the new information.
excluded_fields_group
- The name of the group.public java.lang.String Get_Excluded_Fields_Group()
public void Set_Altered_Fields_Group(java.lang.String altered_fields_group)
The group is the group within the configuration file that the altered fields are listed in. This also re-obtains those fields with the new information.
altered_fields_group
- The name of the group.public java.lang.String Get_Altered_Fields_Group()
public boolean Validate()
All rules must be met for data to be valid.
First rule: a Unique Key must be set and in the Field Vector.
Second rule: all Strings in the Required_Fields Vector must
be in the Field Vector.
All field comparisons are case sensitive.
public void Set_Key(java.lang.String key)
The key must be in the list of fields, and the comparison is case sensitive.
key
- the name of the new unique key.public java.lang.String Get_Key()
public void Add_Entry(java.util.Vector<java.lang.String> entry)
The entry is checked against the list of Null Values and if a value is found to contain the value defined as null for that field then it will be set to null.
entry
- the entry to add.public void Remove_Entry(int entry)
entry
- the index of the entry to removepublic void Remove_Entry(java.lang.String key)
If there is no key this has no effect. If the key is not actually unique then this removes the first instance of it. The comparison to the key is case sensitive.
key
- The key to remove.public java.util.Vector<java.util.Vector<java.lang.String>> Get_Data()
public int Size()
public int Number_Of_Fields()
public void Clear_Data()
public java.util.Vector<java.util.Vector<java.lang.String>> Remove_Data()
public boolean Add_Field(java.lang.String field)
field
- The field to addpublic boolean Add_Field(java.lang.String field, boolean force)
field
- The field to addforce
- true will force the add, false will notpublic boolean Add_Field(java.lang.String field, java.lang.String null_value)
field
- The field to addnull_value
- The null value for that fieldpublic boolean Add_Field(int index, java.lang.String field, java.lang.String null_value)
If the Vectors are not large enough then they are expanded. If the index is below 0 then the values are placed at the end of the Vectors.
index
- The index to add these things atfield
- The field to addnull_value
- The null value for that fieldpublic void Add_Fields(java.util.Vector<java.lang.String> fields)
fields
- A Vector of Strings of field namespublic void Add_Fields(java.util.Vector<java.lang.String> fields, java.util.Vector<java.lang.String> null_values)
If the size of the two Vectors is not the same this has no effect.
fields
- A Vector of Strings of field namesnull_values
- A Vector of Strings of null valuespublic void Remove_Field(java.lang.String field)
The corresponding column in the data set is also removed. The comparison is case sensitive.
field
- The field to removepublic void Remove_Fields(java.util.Vector<java.lang.String> fields)
fields
- The list of fieldspublic void Clear_Fields()
public java.util.Vector<java.lang.String> Get_Fields()
public void Set_Null_Value_Pathname(java.lang.String path)
path
- The String representation of the pathnamepublic java.lang.String Get_Null_Value_Pathname()
public void Set_Field_Pathname(java.lang.String path)
path
- The String representation of the pathnamepublic java.lang.String Get_Field_Pathname()
public void Set_Field_Name_Pathname(java.lang.String path)
path
- The String representation of the pathnamepublic java.lang.String Get_Field_Name_Pathname()
public void Set_Column_Number_Pathname(java.lang.String path)
path
- The String representation of the pathnamepublic java.lang.String Get_Column_Number_Pathname()
public void Set_Unique_Key_Pathname(java.lang.String path)
path
- The String representation of the pathnamepublic java.lang.String Get_Unique_Key_Pathname()
public void Set_Base(int base)
This base is used when filling fields from a configuration. If the columns in the configuration are 0 indexed the base should be 0. If the columns in the configuration are 1 indexed the base should be 1.
base
- The number at which field numbers will start.public int Get_Base()
public java.util.Vector<java.lang.Integer> Get_Excluded_Field_Numbers()
public void Fill_Fields(java.lang.String url) throws java.net.MalformedURLException, PIRL.PVL.PVL_Exception, java.io.IOException
This makes the URL object then creates a Parameter and passes
it to Fill_Fields(PIRL.PVL.Parameter)
.
url
- The String representation of the URLjava.net.MalformedURLException
PIRL.PVL.PVL_Exception
java.io.IOException
public void Fill_Fields(PIRL.PVL.Parameter config)
This will hunt for fields in the parameter where fields are aggregates will information in them. It then tries to find the name, column number, and a null value for the field. The name is all that is necessary, but if a column number is provided then it will place the field at that index in the list of fields. If a null value is provided then it will insert that into the list of null values at the proper index, otherwise it inserts a null object into that index.
Lastly, this will try to find a Unique key in the parameter. If the unique key is defined as an array in the parameter it will be ignored.
When this method encounters a problem (such as the specified pathname for a field aggregate not containing a name for the field) it skips silently. Use this method cautiously and check its work.
config
- The Parameter objectpublic static java.lang.String Create_WKT_Centroid_Point(double x, double y)
x
- The x coordinate for the centery
- The y coordinate for the centerpublic static java.lang.String Create_WKT_Centroid_Point(java.lang.String x, java.lang.String y) throws java.lang.NumberFormatException
The strings are converted to doubles to ensure data validity
x
- The x coordinate for the centery
- The y coordinate for the centerjava.lang.NumberFormatException
- thrown if the given Strings
aren't standard floating point numberspublic static java.lang.String Create_180180_WKT_Centroid_Point(java.lang.String x, java.lang.String y) throws java.lang.NumberFormatException
The strings are converted to doubles to ensure data validity. This will subtract 360 from the longitude if it is above 180 and below or equal to 360.
x
- The x coordinate for the centery
- The y coordinate for the centerjava.lang.NumberFormatException
- thrown if the given Strings
aren't standard floating point numberspublic static java.lang.String Create_WKT_ROI_Polygon_From_Doubles(java.util.Vector<java.util.Vector<java.lang.Double>> points)
This method will make sure that the WKT polygon is wrapped around. Meaning that it puts the first point as both the first point and the last
points
- The list of points that make the polygonpublic static java.lang.String Create_WKT_ROI_Polygon_From_Strings(java.util.Vector<java.util.Vector<java.lang.String>> points) throws java.lang.NumberFormatException
This method will make sure that the WKT polygon is wrapped around. Meaning that it puts the first point as both the first point and the last. This method also ensures data validity by converting the strings to doubles.
points
- The list of points that make the polygonjava.lang.NumberFormatException
- thrown if the given Strings aren't standard
floating point numberspublic static java.lang.String Create_180180_WKT_ROI_Polygon_From_Strings(java.util.Vector<java.util.Vector<java.lang.String>> points) throws java.lang.NumberFormatException
This method will make sure that the WKT polygon is wrapped around. Meaning that it puts the first point as both the first point and the last. This method also ensures data validity by converting the strings to doubles. This will subtract 360 from the longitude points if they are above 180 and below or equal to 360.
points
- The list of points that make the polygonjava.lang.NumberFormatException
- thrown if the given Strings aren't standard
floating point numbersCopyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona