Package uk.ac.rdg.resc.edal.dataset
Class DatasetFactory
- java.lang.Object
-
- uk.ac.rdg.resc.edal.dataset.DatasetFactory
-
- Direct Known Subclasses:
ArgoDatasetFactory
,CdmDatasetFactory
,FakeTrajectoryDatasetFactory
,HydromodelVtkDatasetFactory
,ModisLcDatasetFactory
,WaterMLDatasetFactory
public abstract class DatasetFactory extends Object
A factory forDataset
objects. The intention is that one factory object will be created for each type of data source (e.g. one factory object per file format). These objects can be stateless (hence thread-safe) singletons and shared between datasets.- Author:
- Guy Griffiths, Jon
-
-
Field Summary
Fields Modifier and Type Field Description protected static File
workingDir
-
Constructor Summary
Constructors Constructor Description DatasetFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Dataset
createDataset(String id, String location)
Returns a Dataset object representing the data at the given location.abstract Dataset
createDataset(String id, String location, boolean forceRefresh)
Returns a Dataset object representing the data at the given location.static DatasetFactory
forName(String clazz)
Gets aDatasetFactory
from the class namestatic void
setDefaultDatasetFactoryClass(Class<?> clazz)
static void
setWorkingDirectory(File workingDir)
-
-
-
Field Detail
-
workingDir
protected static File workingDir
-
-
Method Detail
-
setDefaultDatasetFactoryClass
public static void setDefaultDatasetFactoryClass(Class<?> clazz)
- Parameters:
clazz
- The defaultDatasetFactory
class for reading data
-
setWorkingDirectory
public static void setWorkingDirectory(File workingDir)
- Parameters:
workingDir
- A default working directory whichDatasetFactory
subclasses can use to store data (e.g. to write spatial indices to disk)
-
forName
public static DatasetFactory forName(String clazz) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
Gets aDatasetFactory
from the class name- Parameters:
clazz
- The qualified name of theDatasetFactory
class- Returns:
- Either an instance of the requested class, or of the default dataset
factory class if
null
or an empty string is supplied - Throws:
InstantiationException
- If there is a problem instantiating the class (e.g it is an abstract class or an interface)IllegalAccessException
- If the requested class has no public no-argument constructorClassNotFoundException
- If the class is not found on the classpath, or if the default has been requested but no default class has been setSecurityException
NoSuchMethodException
InvocationTargetException
IllegalArgumentException
-
createDataset
public Dataset createDataset(String id, String location) throws IOException, EdalException
Returns a Dataset object representing the data at the given location.- Parameters:
id
- The ID to assign to this datasetlocation
- The location of the source data: this may be a file, database connection string or a remote server address.- Throws:
EdalException
- If there is a problem creating the datasetIOException
-
createDataset
public abstract Dataset createDataset(String id, String location, boolean forceRefresh) throws IOException, EdalException
Returns a Dataset object representing the data at the given location.- Parameters:
id
- The ID to assign to this datasetlocation
- The location of the source data: this may be a file, database connection string or a remote server address.forceRefresh
- Set totrue
to ensure that any cached information is not used- Throws:
EdalException
- If there is a problem creating the datasetIOException
-
-