org.opensha.commons.eq.cat
Interface Catalog

All Known Implementing Classes:
DefaultCatalog, MutableCatalog

public interface Catalog

Catalog interface providing reference fields for primary catalog data types.

Version:
$Id: Catalog.java 7478 2011-02-15 04:56:25Z pmpowers $
Author:
Peter Powers

Field Summary
static int MAX_SIZE
          Maximum size of a catalog; currently set to 800,000 events.
 
Method Summary
 void addData(DataType type, Object data)
          Adds an array of data of the specified type to this catalog.
 boolean contains(DataType type)
          Returns whether this catalog contains a particular DataType.
 Object getData(DataType type)
          Returns a copy of the requested data type or null if the DataType is not present in this catalog.
 Date getDate(int index)
          Returns the Date of the event at index.
 int getEventID(int index)
          Returns the eventID of the event at index.
 String getEventString(int index)
          Returns a string representation of the event at a given index.
 String getEventStringWithID(int index)
          Returns a string representation of the event at a given index.
 long getTime(int index)
          Returns the time of the event at index (in milliseconds).
 double getValue(DataType type, int index)
          Returns the value of a the requested DataType for the event at the specified index.
 Date maxDate()
          Returns end date of this catalog or null if it is not set.
 double maxForType(DataType type)
          Returns the maximum value of the requested DataType.
 Date minDate()
          Returns start date of this catalog or null if it is not set.
 double minForType(DataType type)
          Returns the minimum value of the requested DataType.
 boolean readable()
          Returns whether copies of or references to internal data are provided by getData().
 int size()
          Returns the number of events in this catalog or -1 if the catalog is empty.
 

Field Detail

MAX_SIZE

static final int MAX_SIZE
Maximum size of a catalog; currently set to 800,000 events.

See Also:
Constant Field Values
Method Detail

addData

void addData(DataType type,
             Object data)
Adds an array of data of the specified type to this catalog. The first call to this method sets the catalog size based on the supplied array. Method sets the size of the catalog if it has not yet been set. When event times are added to the catalog, they must be sorted ascending.

Parameters:
type - of data to be added
data - array to be added
Throws:
NullPointerException - if type or data are null
IllegalArgumentException - if (1) type already exists in catalog, (2) data is not an array, (3) data is not of the class specified by DataType.clazz(), (4) data is longer than MAX_SIZE, (5) data is not the first array being added and data.length != size(), or (6) type is DataType.TIME and data is not sorted ascending
IllegalArgumentException - if type is one of [LONGITUDE, LATITUDE, DEPTH, MAGNITUDE] and data contains values that are out of range for the type

getData

Object getData(DataType type)
Returns a copy of the requested data type or null if the DataType is not present in this catalog. Implementations may return a reference or a deep copy of the requested data array.

Parameters:
type - requested
Returns:
the data array

size

int size()
Returns the number of events in this catalog or -1 if the catalog is empty.

Returns:
the catalog size

contains

boolean contains(DataType type)
Returns whether this catalog contains a particular DataType.

Parameters:
type - to look for
Returns:
whether data of the specified type exists in this catalog

readable

boolean readable()
Returns whether copies of or references to internal data are provided by getData().

Returns:
read access status

getEventString

String getEventString(int index)
Returns a string representation of the event at a given index. Method will throw an exception if index is out of range or catalog does not contain time and magnitude data.

Parameters:
index - of event
Returns:
a string describing an earthquake event
Throws:
IndexOutOfBoundsException - if requested index is out of range
IllegalStateException - if catalog does not include magnitude or date values

getEventStringWithID

String getEventStringWithID(int index)
Returns a string representation of the event at a given index.

Parameters:
index - of event
Returns:
a string describing an earthquake event
Throws:
IndexOutOfBoundsException - if requested index is out of range
IllegalStateException - if catalog does not include event ID, magnitude or date values

getEventID

int getEventID(int index)
Returns the eventID of the event at index.

Parameters:
index - of event
Returns:
the eventID value
Throws:
IndexOutOfBoundsException - if requested index is out of range
IllegalStateException - if catalog does not include event ID values

getTime

long getTime(int index)
Returns the time of the event at index (in milliseconds).

Parameters:
index - of event
Returns:
the time of the event
Throws:
IndexOutOfBoundsException - if requested index is out of range
IllegalStateException - if catalog does not include event time values

getDate

Date getDate(int index)
Returns the Date of the event at index.

Parameters:
index - of event
Returns:
the Date of the event
Throws:
IndexOutOfBoundsException - if requested index is out of range
IllegalStateException - if catalog does not include event time values

minDate

Date minDate()
Returns start date of this catalog or null if it is not set.

Returns:
the catalog start Date

maxDate

Date maxDate()
Returns end date of this catalog or null if it is not set.

Returns:
the catalog end Date

getValue

double getValue(DataType type,
                int index)
Returns the value of a the requested DataType for the event at the specified index. Method is only valid for the following double-valued DataTypes: [LONGITUDE, LATITUDE, DEPTH, MAGNITUDE]

Parameters:
type - requested
index - of event
Returns:
the type value at event index
Throws:
NullPointerException - if type is null
IllegalArgumentException - if requested type is not valid
IndexOutOfBoundsException - if requested index is out of range
IllegalStateException - if catalog does not include values for the requested type

minForType

double minForType(DataType type)
Returns the minimum value of the requested DataType. Method is only valid for the following double-valued DataTypes: [LONGITUDE, LATITUDE, DEPTH, MAGNITUDE]

Parameters:
type - requested
Returns:
the minimum value for the DatType
Throws:
NullPointerException - if type is null
IllegalArgumentException - if requested type is not valid
IllegalStateException - if requested type is valid but was never added to catalog

maxForType

double maxForType(DataType type)
Returns the maximum value of the requested DataType. Method is only valid for the following double-valued DataTypes: [LONGITUDE, LATITUDE, DEPTH, MAGNITUDE]

Parameters:
type - requested
Returns:
the maximum value for the DatType
Throws:
NullPointerException - if type is null
IllegalArgumentException - if requested type is not valid
IllegalStateException - if requested type is valid but was never added to catalog