HiRISE

HiRISE.HiPlan.PTF
Class PTF_Record_List

java.lang.Object
  extended by HiRISE.HiPlan.PTF.PTF_Record_List

public class PTF_Record_List
extends Object

A list of HiRISE PTF records.

This class is not an implementation of the List interface.

Version:
1.18
Author:
Ben Pearson - UA/PIRL
See Also:
"Payload Target File and Integrated Payload Target File Software Interface Specification (JPL MRO SEQ032)"

Nested Class Summary
static class PTF_Record_List.Import_Exception
          An exception for reporting problems during PTF record imports.
 
Field Summary
static String ID
          Class identification name with source code version and date.
 
Constructor Summary
PTF_Record_List()
          Creates a new, empty record list.
PTF_Record_List(InputStream input_stream)
          Creates a new list and populates it with data from an input stream.
PTF_Record_List(String source)
          Creates a new list and populates it with data from a given PTF source.
 
Method Summary
 void add_record(PTF_Record record)
          Adds a PTF record to this list.
 void add_record(String record_text)
          Adds a PTF record to this list.
 HashMap<String,String> bad_observations()
          Gets the map of bad observations and the reasons they were marked as being bad.
 PTF_Comparison compare_with_hicat(Observation_Record_Broker broker)
          Compares each PTF record in this list with its counterpart in HiCat via the indicated record broker.
 PTF_Comparison compare_with_ptf_record_list(PTF_Record_List target)
          Compares each PTF record in this list with its counterpart in a target PTF.
 PTF_Record get_record(String observation_id)
          Gets the named record from this list.
 ArrayList observation_ids()
          Gets the list of observation IDs for the records in this list.
 void read_ptf(InputStream stream)
          Populates the record list with data from an input stream.
 void read_ptf(InputStream stream, String name)
          Populates the record list with data from an input stream.
 void read_ptf(String source)
          Populates the record list with data from a named file, which must be a PTF.
 int record_count()
          Gets the total number of records in this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values
Constructor Detail

PTF_Record_List

public PTF_Record_List()
Creates a new, empty record list.


PTF_Record_List

public PTF_Record_List(String source)
                throws Invalid_Argument_Exception,
                       IOException
Creates a new list and populates it with data from a given PTF source. The source may be a filename or a URL.

Parameters:
source - the PTF source.
Throws:
Invalid_Argument_Exception - if the PTF is invalid.
IOException - if the PTF cannot be read.

PTF_Record_List

public PTF_Record_List(InputStream input_stream)
                throws Invalid_Argument_Exception,
                       IOException
Creates a new list and populates it with data from an input stream.

Parameters:
input_stream - an input stream containing PTF data.
Throws:
Invalid_Argument_Exception - if the PTF is invalid.
IOException - if the PTF cannot be read.
Method Detail

read_ptf

public void read_ptf(InputStream stream,
                     String name)
              throws Invalid_Argument_Exception,
                     IOException
Populates the record list with data from an input stream. The stream must contain a PTF. Data read from the stream are added to to the list. The stream is identified by a name, which may be null. A user might identify the stream by the name of the file from which the stream is derived.

If stream is null, no action is taken.

If a record is invalid, unidentified, or a duplicate of another record as identified by the team database ID, it is added to a collection of bad_observations.

Parameters:
stream - the input stream, which must contain a PTF.
name - the name of the stream, which may be null.
Throws:
Invalid_Argument_Exception - if stream does not contain a PTF.
IOException - if there is a problem reading the stream.

read_ptf

public void read_ptf(InputStream stream)
              throws Invalid_Argument_Exception,
                     IOException
Populates the record list with data from an input stream. The stream must contain a PTF. Data read from the stream are added to to the list.

If stream is null, no action is taken.

If a record is invalid, unidentified, or a duplicate of another record as identified by the team database ID, it is added to a collection of bad_observations.

Parameters:
stream - the input stream, which must contain a PTF.
Throws:
Invalid_Argument_Exception - if stream does not contain a PTF.
IOException - if there is a problem reading the stream.

read_ptf

public void read_ptf(String source)
              throws Invalid_Argument_Exception,
                     IOException
Populates the record list with data from a named file, which must be a PTF. Data read from the PTF are added to the list.

The source may be a URL, a relative file pathname, or an absolute file pathname. If it is null, no action is taken.

If a record is invalid, unidentified, or a duplicate of another record as identified by the team database ID, it is added to a collection of bad_observations.

Parameters:
source - the source filename; the file must be a PTF.
Throws:
Invalid_Argument_Exception - if source is not a PTF.
IOException - if the source cannot be read.

compare_with_hicat

public PTF_Comparison compare_with_hicat(Observation_Record_Broker broker)
                                  throws Database_Exception
Compares each PTF record in this list with its counterpart in HiCat via the indicated record broker. If a record is missing in HiCat, it is added to a collection of bad_observations.

Parameters:
broker - the broker that conducts operations with HiCat.
Returns:
the results of the comparison.
Throws:
Database_Exception - if the database cannot be read or the user has insuffcient access.

compare_with_ptf_record_list

public PTF_Comparison compare_with_ptf_record_list(PTF_Record_List target)
Compares each PTF record in this list with its counterpart in a target PTF. If a record is missing in the target list, or if a record in the target list is missing from this list, it is added to the collection of bad_observations.

Parameters:
target - the target PTF list against which this list is compared.
Returns:
the results of the comparison.

get_record

public PTF_Record get_record(String observation_id)
Gets the named record from this list.

Parameters:
observation_id - the identifier for the record.
Returns:
the PTF record with the given observation ID or null if it is not in this list.

add_record

public void add_record(PTF_Record record)
                throws PTF_Record_List.Import_Exception
Adds a PTF record to this list. The observation is identified uniquely by its team database ID, which is a HiRISE observation ID.

If the observation already exists in this list, an PTF_Record_List.Import_Exception is thrown with DUPLICATE as the exception's import problem. If the record has a trivial team database ID (that is, it is null or an empty or whitespace string), an import exception is thrown with UNIDENTIFIED as the exception's import problem.

Parameters:
record - the PTF record to be added to the comparison list. If null, no action is taken.
Throws:
PTF_Record_List.Import_Exception - if there is a problem with the PTF record.

add_record

public void add_record(String record_text)
                throws PTF_Record_List.Import_Exception
Adds a PTF record to this list. If a PTF record cannot be formed from the input record text, an PTF_Record_List.Import_Exception is thrown with INVALID as the exception's import problem.

If the observation already exists in this list, an PTF_Record_List.Import_Exception is thrown with DUPLICATE as the exception's import problem. If the record has a trivial team database ID (that is, it is null or an empty or whitespace string), an import exception is thrown with UNIDENTIFIED as the exception's import problem.

Parameters:
record_text - the text representation of the PTF record to be added.
Throws:
PTF_Record_List.Import_Exception - if there is a problem with the PTF record.

observation_ids

public ArrayList observation_ids()
Gets the list of observation IDs for the records in this list.

Returns:
the observation IDs.

bad_observations

public HashMap<String,String> bad_observations()
Gets the map of bad observations and the reasons they were marked as being bad. The map key is the name of the source and the line number on which the bad observation was found. The value is the reason.

Returns:
the map.

record_count

public int record_count()
Gets the total number of records in this list.

Returns:
the number of records in this list.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona