thredds.cataloggen.config
Class DatasetSource

java.lang.Object
  extended by thredds.cataloggen.config.DatasetSource
Direct Known Subclasses:
DodsDirDatasetSource, DodsFileServerDatasetSource, GrADSDataServerDatasetSource, LocalDatasetSource

public abstract class DatasetSource
extends Object

Represents a source from which a collection of datasets can be found and expanded into an InvCatalog. Besides expanding the DatasetSource, the datasets in the resulting catalog can be named, sorted, and have metadata added to them.

Currently an abstract class, three abstract methods must be implemented to make a concrete subclass. These methods are getTopLevelDataset():InvDataset, isCollection():boolean, and expandThisLevel(InvDataset):List. (In previous versions, expandThisType():void was the only abstract method.)

Version:
$Id: DatasetSource.java 63 2006-07-12 21:50:51Z edavis $
Author:
Ethan Davis

Field Summary
protected  InvDataset accessPointDataset
          Top-level dataset of the catalog generated by this DatasetSource.
protected  boolean addDatasetSize
           
protected  List catalogRefInfoList
          Information on the catalogRefs in the resulting catalog.
protected  boolean createCatalogRefs
           
protected  List datasetEnhancerList
           
protected  List datasetFilterList
           
protected  List datasetNamerList
           
protected  DatasetSorter datasetSorter
           
protected  boolean isValid
           
protected  StringBuffer msgLog
           
protected  InvCatalog resultingCatalog
          The catalog that results from expanding this DatasetSource.
protected  DatasetSourceType type
           
 
Constructor Summary
protected DatasetSource()
          Default Constructor
 
Method Summary
 void addDatasetEnhancer(DatasetEnhancer1 dsEnhancer)
           
 void addDatasetFilter(DatasetFilter datasetFilter)
           
 void addDatasetNamer(DatasetNamer datasetNamer)
           
protected abstract  InvDataset createDataset(String datasetLocation, String prefixUrlPath)
          Creates an InvDataset to represent the dataset at the given location on this DatasetSource.
protected abstract  InvCatalog createSkeletonCatalog(String prefixUrlPath)
          Return a skeleton InvCatalog for this DatasetSource.
 boolean equals(Object o)
           
 InvDataset expand()
          Crawl this DatasetSource and generate a new InvCatalog, return the top-level InvDataset.
 InvDataset expand(List accessPoints)
           
protected abstract  List expandThisLevel(InvDataset collectionDataset, String prefixUrlPath)
          Return a list of the InvDatasets contained in the given collection dataset on this DatasetSource.
 InvCatalog fullExpand()
          Crawl this DatasetSource and generate a new InvCatalog with all datasets named, sorted, and organized as defined by this DatasetSource, return the newly generated InvCatalog.
 String getAccessPoint()
           
 List getCatalogRefInfoList()
           
 List getDatasetEnhancerList()
           
 List getDatasetFilterList()
           
 List getDatasetNamerList()
           
 DatasetSorter getDatasetSorter()
           
 String getName()
           
 String getPrefixUrlPath()
           
 InvCatalog getResultingCatalog()
           
 ResultService getResultService()
           
 DatasetSourceStructure getStructure()
           
 DatasetSourceType getType()
           
 int hashCode()
           
 boolean isAddDatasetSize()
           
protected abstract  boolean isCollection(InvDataset dataset)
          Return true if the given dataset is a collection dataset, false otherwise.
 boolean isCreateCatalogRefs()
           
 boolean isFlatten()
           
static DatasetSource newDatasetSource(String name, DatasetSourceType type, DatasetSourceStructure structure, String accessPoint, ResultService resultService)
          Factory method for this abstract class.
 void setAccessPoint(String accessPoint)
           
 void setAddDatasetSize(boolean addDatasetSize)
           
 void setCreateCatalogRefs(boolean createCatalogRefs)
           
 void setDatasetSorter(DatasetSorter datasetSorter)
           
 void setName(String name)
           
 void setPrefixUrlPath(String prefixUrlPath)
           
 void setResultService(ResultService resultService)
           
 void setStructure(DatasetSourceStructure structure)
           
 String toString()
          string representation
 boolean validate(StringBuilder out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

resultingCatalog

protected InvCatalog resultingCatalog
The catalog that results from expanding this DatasetSource.


accessPointDataset

protected InvDataset accessPointDataset
Top-level dataset of the catalog generated by this DatasetSource.


catalogRefInfoList

protected List catalogRefInfoList
Information on the catalogRefs in the resulting catalog.


type

protected DatasetSourceType type

createCatalogRefs

protected boolean createCatalogRefs

datasetNamerList

protected List datasetNamerList

datasetFilterList

protected List datasetFilterList

datasetSorter

protected DatasetSorter datasetSorter

datasetEnhancerList

protected List datasetEnhancerList

addDatasetSize

protected boolean addDatasetSize

isValid

protected boolean isValid

msgLog

protected StringBuffer msgLog
Constructor Detail

DatasetSource

protected DatasetSource()
Default Constructor

Method Detail

newDatasetSource

public static final DatasetSource newDatasetSource(String name,
                                                   DatasetSourceType type,
                                                   DatasetSourceStructure structure,
                                                   String accessPoint,
                                                   ResultService resultService)
Factory method for this abstract class.

Parameters:
name -
type -
structure -
accessPoint -
Throws:
IllegalArgumentException - if DatasetSource type is null or unsupported.

getResultingCatalog

public InvCatalog getResultingCatalog()

getCatalogRefInfoList

public List getCatalogRefInfoList()

getName

public String getName()

setName

public void setName(String name)

getType

public DatasetSourceType getType()

getStructure

public DatasetSourceStructure getStructure()

setStructure

public void setStructure(DatasetSourceStructure structure)

isFlatten

public boolean isFlatten()

getAccessPoint

public String getAccessPoint()

setAccessPoint

public void setAccessPoint(String accessPoint)

getPrefixUrlPath

public String getPrefixUrlPath()

setPrefixUrlPath

public void setPrefixUrlPath(String prefixUrlPath)

getResultService

public ResultService getResultService()

setResultService

public void setResultService(ResultService resultService)

isCreateCatalogRefs

public boolean isCreateCatalogRefs()

setCreateCatalogRefs

public void setCreateCatalogRefs(boolean createCatalogRefs)

getDatasetNamerList

public List getDatasetNamerList()

addDatasetNamer

public void addDatasetNamer(DatasetNamer datasetNamer)

getDatasetFilterList

public List getDatasetFilterList()

addDatasetFilter

public void addDatasetFilter(DatasetFilter datasetFilter)

getDatasetSorter

public DatasetSorter getDatasetSorter()

setDatasetSorter

public void setDatasetSorter(DatasetSorter datasetSorter)

getDatasetEnhancerList

public List getDatasetEnhancerList()

addDatasetEnhancer

public void addDatasetEnhancer(DatasetEnhancer1 dsEnhancer)

isAddDatasetSize

public boolean isAddDatasetSize()

setAddDatasetSize

public void setAddDatasetSize(boolean addDatasetSize)

validate

public boolean validate(StringBuilder out)

toString

public String toString()
string representation

Overrides:
toString in class Object

expand

public InvDataset expand()
                  throws IOException
Crawl this DatasetSource and generate a new InvCatalog, return the top-level InvDataset. Each object found on the DatasetSource becomes an InvDataset if it is accepted by at least one DatasetFilter. The catalog reflects the heirarchical structure of the DatasetSource. All datasets are named with the location of the object they represent on the dataset source.

Returns:
the top-level InvDataset in the generated InvCatalog.
Throws:
IOException - if the accessPoint for this DatasetSource is not a container dataset.

expand

public InvDataset expand(List accessPoints)
                  throws IOException
Parameters:
accessPoints -
Returns:
the top-level dataset
Throws:
IOException - if the main access point for this DatasetSource is not a container dataset or any of the given access points do not exist or are not under the main access point.

fullExpand

public InvCatalog fullExpand()
                      throws IOException
Crawl this DatasetSource and generate a new InvCatalog with all datasets named, sorted, and organized as defined by this DatasetSource, return the newly generated InvCatalog.

Returns:
the generated InvCatalog.
Throws:
IOException - if DatasetSource does not reference a container dataset.

createDataset

protected abstract InvDataset createDataset(String datasetLocation,
                                            String prefixUrlPath)
                                     throws IOException
Creates an InvDataset to represent the dataset at the given location on this DatasetSource.

Parameters:
datasetLocation - a String indicating the location of a dataset.
prefixUrlPath - a path name to be prefixed on the urlPath
Returns:
an InvDataset for the given dataset location.
Throws:
IOException - if the dataset location does not correspond to an actual dataset or is not below the accessPointHeader directory.
NullPointerException - if the given dataset location is null.

isCollection

protected abstract boolean isCollection(InvDataset dataset)
Return true if the given dataset is a collection dataset, false otherwise.

Parameters:
dataset - - the InvDataset to test for being a collection dataset.
Returns:
true if the given dataset is a collection dataset, false otherwise.
Throws:
NullPointerException - if the given InvDataset is null.
ClassCastException - if the given InvDataset is not a LocalInvDataset.

createSkeletonCatalog

protected abstract InvCatalog createSkeletonCatalog(String prefixUrlPath)
                                             throws IOException
Return a skeleton InvCatalog for this DatasetSource. The skeleton catalog is unnamed with a single top-level dataset representing the DatasetSource accessPoint and a service built from the DatasetSource ResultService.

Parameters:
prefixUrlPath -
Returns:
a skeleton InvCatalog for this DatasetSource.
Throws:
IOException - if top-level dataset does not exist or is not a collection dataset.

expandThisLevel

protected abstract List expandThisLevel(InvDataset collectionDataset,
                                        String prefixUrlPath)
Return a list of the InvDatasets contained in the given collection dataset on this DatasetSource.

Parameters:
collectionDataset - - the collection dataset to be expanded.
prefixUrlPath -
Returns:
A list of the InvDatasets contained in the given collection dataset.
Throws:
IllegalArgumentException - when given dataset is not a collection dataset.
NullPointerException - if given dataset is null.
ClassCastException - if the given InvDataset is not a LocalInvDataset.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.