org.opensha.commons.data.siteData
Class OrderedSiteDataProviderList

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

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


Field Summary
static java.lang.String XML_METADATA_NAME
           
 
Constructor Summary
OrderedSiteDataProviderList(java.util.ArrayList<SiteData<?>> providers)
           
 
Method Summary
 void add(int index, SiteData<?> data)
           
 void add(SiteData<?> data)
           
 void addChangeListener(javax.swing.event.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)
           
 java.util.ArrayList<SiteDataValueList<?>> getAllAvailableData(java.util.List<Site> sites)
           
 java.util.ArrayList<SiteDataValue<?>> getAllAvailableData(Location loc)
          This method returns a list of the data from every enabled provider
 java.util.ArrayList<SiteDataValueList<?>> getAllAvailableData(LocationList locs)
           
 java.util.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.
 java.util.ArrayList<SiteData<?>> getEnabledProviders()
           
 int getIndexOf(SiteData<?> data)
           
 java.util.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)
           
 java.util.Iterator<SiteData<?>> iterator()
           
static void main(java.lang.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)
           
 java.lang.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 java.lang.String XML_METADATA_NAME
See Also:
Constant Field Values
Constructor Detail

OrderedSiteDataProviderList

public OrderedSiteDataProviderList(java.util.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 java.io.IOException
Returns the best data value for the given location, with metadata

Parameters:
loc -
Returns:
Throws:
java.io.IOException

getAllAvailableData

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

getEnabledProviders

public java.util.ArrayList<SiteData<?>> getEnabledProviders()

getAllAvailableData

public java.util.ArrayList<SiteDataValueList<?>> getAllAvailableData(LocationList locs)
                                                              throws java.io.IOException
Throws:
java.io.IOException

getAllAvailableData

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

Parameters:
loc -
Returns:

getBestAvailableData

public java.util.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 java.util.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 java.util.Iterator<SiteData<?>> iterator()
Specified by:
iterator in interface java.lang.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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)

clone

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

Overrides:
clone in class java.lang.Object

toXMLMetadata

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

fromXMLMetadata

public static OrderedSiteDataProviderList fromXMLMetadata(Element orderedListEl)
                                                   throws java.io.IOException
Throws:
java.io.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(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException