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 forDatasetobjects. 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 FileworkingDir
-
Constructor Summary
Constructors Constructor Description DatasetFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DatasetcreateDataset(String id, String location)Returns a Dataset object representing the data at the given location.abstract DatasetcreateDataset(String id, String location, boolean forceRefresh)Returns a Dataset object representing the data at the given location.static DatasetFactoryforName(String clazz)Gets aDatasetFactoryfrom the class namestatic voidsetDefaultDatasetFactoryClass(Class<?> clazz)static voidsetWorkingDirectory(File workingDir)
-
-
-
Field Detail
-
workingDir
protected static File workingDir
-
-
Method Detail
-
setDefaultDatasetFactoryClass
public static void setDefaultDatasetFactoryClass(Class<?> clazz)
- Parameters:
clazz- The defaultDatasetFactoryclass for reading data
-
setWorkingDirectory
public static void setWorkingDirectory(File workingDir)
- Parameters:
workingDir- A default working directory whichDatasetFactorysubclasses 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 aDatasetFactoryfrom the class name- Parameters:
clazz- The qualified name of theDatasetFactoryclass- Returns:
- Either an instance of the requested class, or of the default dataset
factory class if
nullor 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 setSecurityExceptionNoSuchMethodExceptionInvocationTargetExceptionIllegalArgumentException
-
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 totrueto ensure that any cached information is not used- Throws:
EdalException- If there is a problem creating the datasetIOException
-
-