org.opensha.commons.data.siteData
Class OrderedSiteDataProviderList

java.lang.Object
  extended by org.opensha.commons.data.siteData.OrderedSiteDataProviderList
All Implemented Interfaces:
Cloneable, Iterable<SiteData<?>>, XMLSaveable

public class OrderedSiteDataProviderList
extends Object
implements Iterable<SiteData<?>>, XMLSaveable, Cloneable


Field Summary
static String XML_METADATA_NAME
           
 
Constructor Summary
OrderedSiteDataProviderList(ArrayList<SiteData<?>> providers)
           
 
Method Summary
 void add(int index, SiteData<?> data)
           
 void add(SiteData<?> data)
           
 void addChangeListener(ChangeListener listener)
           
 OrderedSiteDataProviderList clone()
          Makes a shallow copy of this OrderedSiteDataProviderList
static OrderedSiteDataProviderList createCachedSiteDataProviderDefaults()
          Same as createSiteDataProviderDefaults, but returns a cached version of each one
static OrderedSiteDataProviderList createCompatibilityProviders(boolean useOldData)
          Creates a list with just Vs30 from Wills and Depth to 2.5 for compatibility with the old pieces of code which were hardcoded to only use those 2.
static OrderedSiteDataProviderList createDebugSiteDataProviders()
          Creates the debugging list of site data providers:
static OrderedSiteDataProviderList createSiteDataMapProviders()
          Creates the default list of site data providers, but with wills classes translated to doubles so that they can be mapped.
static OrderedSiteDataProviderList createSiteDataProviderDefaults()
          Creates the default list of site data providers: 1.
 void demote(int index)
           
 void enableOnlyFirstForEachType()
           
static OrderedSiteDataProviderList fromXMLMetadata(Element orderedListEl)
           
 ArrayList<SiteDataValueList<?>> getAllAvailableData(List<Site> sites)
           
 ArrayList<SiteDataValue<?>> getAllAvailableData(Location loc)
          This method returns a list of the data from every enabled provider
 ArrayList<SiteDataValueList<?>> getAllAvailableData(LocationList locs)
           
 ArrayList<SiteDataValue<?>> getBestAvailableData(Location loc)
          This method returns a list of the best available data for this location, where "best" is defined by the order of this provider list.
 ArrayList<SiteData<?>> getEnabledProviders()
           
 int getIndexOf(SiteData<?> data)
           
 ArrayList<SiteData<?>> getList()
           
 SiteDataValue<?> getPreferredValue(Location loc)
          Returns the best data value for the given location, with metadata
 SiteData<?> getProvider(int index)
           
 SiteData<?> getProviderForLocation(Location loc)
          Returns the best provider with data for the given location, or null if no provider is suitable for the given location.
 boolean isAtLeastOneEnabled()
           
 boolean isEnabled(int index)
           
 Iterator<SiteData<?>> iterator()
           
static void main(String[] args)
           
 void mergeWith(OrderedSiteDataProviderList newList)
          This will merge a new list with the current list.
 void printList()
           
 void promote(int index)
           
 SiteData<?> remove(int index)
           
 void removeDisabledProviders()
          Removes all providers that are currently disabled
 void set(int index, SiteData<?> data)
           
 void setEnabled(int index, boolean enabled)
           
 int size()
           
 void swap(int index1, int index2)
           
 String toString()
           
 Element toXMLMetadata(Element root)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_METADATA_NAME

public static final String XML_METADATA_NAME
See Also:
Constant Field Values
Constructor Detail

OrderedSiteDataProviderList

public OrderedSiteDataProviderList(ArrayList<SiteData<?>> providers)
Method Detail

getProviderForLocation

public SiteData<?> getProviderForLocation(Location loc)
Returns the best provider with data for the given location, or null if no provider is suitable for the given location.

Returns:

getPreferredValue

public SiteDataValue<?> getPreferredValue(Location loc)
                                   throws IOException
Returns the best data value for the given location, with metadata

Parameters:
loc -
Returns:
Throws:
IOException

getAllAvailableData

public ArrayList<SiteDataValueList<?>> getAllAvailableData(List<Site> sites)
                                                    throws IOException
Throws:
IOException

getEnabledProviders

public ArrayList<SiteData<?>> getEnabledProviders()

getAllAvailableData

public ArrayList<SiteDataValueList<?>> getAllAvailableData(LocationList locs)
                                                    throws IOException
Throws:
IOException

getAllAvailableData

public ArrayList<SiteDataValue<?>> getAllAvailableData(Location loc)
This method returns a list of the data from every enabled provider

Parameters:
loc -
Returns:

getBestAvailableData

public ArrayList<SiteDataValue<?>> getBestAvailableData(Location loc)
This method returns a list of the best available data for this location, where "best" is defined by the order of this provider list. The result will have, at most, one of each site data type (so, for example, if there are multiple Vs30 sources, only the "best" one will be used).

Parameters:
loc -
Returns:

enableOnlyFirstForEachType

public void enableOnlyFirstForEachType()

size

public int size()

getList

public ArrayList<SiteData<?>> getList()

getIndexOf

public int getIndexOf(SiteData<?> data)

remove

public SiteData<?> remove(int index)

add

public void add(SiteData<?> data)

add

public void add(int index,
                SiteData<?> data)

set

public void set(int index,
                SiteData<?> data)

promote

public void promote(int index)

demote

public void demote(int index)

swap

public void swap(int index1,
                 int index2)

getProvider

public SiteData<?> getProvider(int index)

isEnabled

public boolean isEnabled(int index)

setEnabled

public void setEnabled(int index,
                       boolean enabled)

isAtLeastOneEnabled

public boolean isAtLeastOneEnabled()

iterator

public Iterator<SiteData<?>> iterator()
Specified by:
iterator in interface Iterable<SiteData<?>>

createSiteDataProviderDefaults

public static OrderedSiteDataProviderList createSiteDataProviderDefaults()
Creates the default list of site data providers:

Returns:

createSiteDataMapProviders

public static OrderedSiteDataProviderList createSiteDataMapProviders()
Creates the default list of site data providers, but with wills classes translated to doubles so that they can be mapped.

Returns:

createCachedSiteDataProviderDefaults

public static OrderedSiteDataProviderList createCachedSiteDataProviderDefaults()
Same as createSiteDataProviderDefaults, but returns a cached version of each one

Returns:

createCompatibilityProviders

public static OrderedSiteDataProviderList createCompatibilityProviders(boolean useOldData)
Creates a list with just Vs30 from Wills and Depth to 2.5 for compatibility with the old pieces of code which were hardcoded to only use those 2.

Returns:

createDebugSiteDataProviders

public static OrderedSiteDataProviderList createDebugSiteDataProviders()
Creates the debugging list of site data providers:

Returns:

printList

public void printList()

removeDisabledProviders

public void removeDisabledProviders()
Removes all providers that are currently disabled


toString

public String toString()
Overrides:
toString in class Object

addChangeListener

public void addChangeListener(ChangeListener listener)

clone

public OrderedSiteDataProviderList clone()
Makes a shallow copy of this OrderedSiteDataProviderList

Overrides:
clone in class Object

toXMLMetadata

public Element toXMLMetadata(Element root)
Specified by:
toXMLMetadata in interface XMLSaveable

fromXMLMetadata

public static OrderedSiteDataProviderList fromXMLMetadata(Element orderedListEl)
                                                   throws IOException
Throws:
IOException

mergeWith

public void mergeWith(OrderedSiteDataProviderList newList)
This will merge a new list with the current list. If duplicates are found, the settings from the new list will be used (parameters, as well as enabled state).

Parameters:
newList -

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException