Package thredds.inventory
Class CollectionAbstract
- java.lang.Object
-
- thredds.inventory.CollectionAbstract
-
- All Implemented Interfaces:
Closeable,AutoCloseable,MCollection
- Direct Known Subclasses:
CollectionFiltered,CollectionGeneral,CollectionGlob,CollectionList,CollectionListRange,CollectionManagerAbstract,CollectionPathMatcher,DirectoryCollection,DirectoryPartition,PartitionManagerFromIndexDirectory,PartitionManagerFromIndexList
public abstract class CollectionAbstract extends Object implements MCollection
Abstract superclass for Collections of MFiles. Deal with the collection element of feature collections:
where:-
spec: is handled by CollectionSpecParser. it provides the root directory, Pattern filter, and optionally a
dateExtractor
-
name: getCollectionName()
-
olderThan: getOlderThanMsecs()
-
dateFormatMark: dateExtractor
-
timePartition: CollectionGeneral, DirectoryPartition, FilePartition, TimePartition
- Since:
- 11/20/13
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCollectionAbstract.DateSorterclassCollectionAbstract.MyStreamFilter
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>auxInfostatic StringCATALOGprotected StringcollectionNameprotected DateExtractordateExtractorstatic StringDIRstatic StringFILEstatic StringGLOBprotected longlastModifiedstatic StringLISTprotected org.slf4j.Loggerloggerprotected FeatureCollectionConfig.ProtoChoiceprotoChoiceprotected Stringrootprotected DirectoryStream.Filter<Path>sfilterprotected CalendarDatestartCollection
-
Constructor Summary
Constructors Modifier Constructor Description protectedCollectionAbstract(String collectionName, org.slf4j.Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcleanName(String name)CalendarDateextractDate(MFile mfile)Use the date extractor to extract the date from the filename.ObjectgetAuxInfo(String key)StringgetCollectionName()The name of the collectionList<String>getFilenames()Get list of sorted filenames that are in this collection.StringgetIndexFilename(String suffix)longgetLastModified()last time this collection was modifiedMFilegetLatestFile()The latest file in the collection.CalendarDategetPartitionDate()The date to partition on, usually the starting date of the collection.intgetProtoIndex(int n)Choose Proto dataset as index from [0..n-1], based on configuration.StringgetRoot()Get common root directory of all MFiles in the collection - may be nullbooleanhasDateExtractor()Does this CollectionManager have the ability to extract a date from the MFile ?protected List<MFile>makeFileListSorted()static MCollectionopen(String collectionName, String collectionSpec, String olderThan, Formatter errlog)protected longparseOlderThanString(String olderThan)parse the "olderThan" TimeDuration, meaning files must not have been modified since this amount of timevoidputAuxInfo(String key, Object value)voidsetDateExtractor(DateExtractor dateExtractor)protected voidsetRoot(String root)voidsetStreamFilter(DirectoryStream.Filter<Path> filter)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface thredds.inventory.MCollection
close, getFileIterator, getFilesSorted
-
-
-
-
Field Detail
-
CATALOG
public static final String CATALOG
- See Also:
- Constant Field Values
-
DIR
public static final String DIR
- See Also:
- Constant Field Values
-
FILE
public static final String FILE
- See Also:
- Constant Field Values
-
LIST
public static final String LIST
- See Also:
- Constant Field Values
-
GLOB
public static final String GLOB
- See Also:
- Constant Field Values
-
collectionName
protected String collectionName
-
root
protected String root
-
logger
protected final org.slf4j.Logger logger
-
protoChoice
protected FeatureCollectionConfig.ProtoChoice protoChoice
-
dateExtractor
protected DateExtractor dateExtractor
-
startCollection
protected CalendarDate startCollection
-
lastModified
protected long lastModified
-
sfilter
protected DirectoryStream.Filter<Path> sfilter
-
-
Constructor Detail
-
CollectionAbstract
protected CollectionAbstract(String collectionName, org.slf4j.Logger logger)
-
-
Method Detail
-
open
public static MCollection open(String collectionName, String collectionSpec, String olderThan, Formatter errlog) throws IOException
- Throws:
IOException
-
getCollectionName
public String getCollectionName()
Description copied from interface:MCollectionThe name of the collection- Specified by:
getCollectionNamein interfaceMCollection- Returns:
- name of the collection
-
getIndexFilename
public String getIndexFilename(String suffix)
- Specified by:
getIndexFilenamein interfaceMCollection
-
setStreamFilter
public void setStreamFilter(DirectoryStream.Filter<Path> filter)
-
getRoot
public String getRoot()
Description copied from interface:MCollectionGet common root directory of all MFiles in the collection - may be null- Specified by:
getRootin interfaceMCollection- Returns:
- root directory name, or null.
-
setRoot
protected void setRoot(String root)
-
getLastModified
public long getLastModified()
Description copied from interface:MCollectionlast time this collection was modified- Specified by:
getLastModifiedin interfaceMCollection- Returns:
- msess since epoch
-
getLatestFile
public MFile getLatestFile() throws IOException
Description copied from interface:MCollectionThe latest file in the collection. Only call if hasDateExtractor() == true.- Specified by:
getLatestFilein interfaceMCollection- Returns:
- latest file in the collection
- Throws:
IOException
-
getFilenames
public List<String> getFilenames() throws IOException
Description copied from interface:MCollectionGet list of sorted filenames that are in this collection.- Specified by:
getFilenamesin interfaceMCollection- Throws:
IOException
-
extractDate
public CalendarDate extractDate(MFile mfile)
Description copied from interface:MCollectionUse the date extractor to extract the date from the filename. Only call if hasDateExtractor() == true.- Specified by:
extractDatein interfaceMCollection- Parameters:
mfile- extract from here- Returns:
- Date, or null if none
-
hasDateExtractor
public boolean hasDateExtractor()
Description copied from interface:MCollectionDoes this CollectionManager have the ability to extract a date from the MFile ?- Specified by:
hasDateExtractorin interfaceMCollection- Returns:
- true if CollectionManager has a DateExtractor
-
setDateExtractor
public void setDateExtractor(DateExtractor dateExtractor)
-
getPartitionDate
public CalendarDate getPartitionDate()
Description copied from interface:MCollectionThe date to partition on, usually the starting date of the collection.- Specified by:
getPartitionDatein interfaceMCollection- Returns:
- partition date of the collection, or null if unknown
-
getAuxInfo
public Object getAuxInfo(String key)
- Specified by:
getAuxInfoin interfaceMCollection
-
putAuxInfo
public void putAuxInfo(String key, Object value)
- Specified by:
putAuxInfoin interfaceMCollection
-
getProtoIndex
public int getProtoIndex(int n)
Description copied from interface:MCollectionChoose Proto dataset as index from [0..n-1], based on configuration.- Specified by:
getProtoIndexin interfaceMCollection- Parameters:
n- size to choose from- Returns:
- index within range [0..n-1]
-
makeFileListSorted
protected List<MFile> makeFileListSorted() throws IOException
- Throws:
IOException
-
parseOlderThanString
protected long parseOlderThanString(String olderThan)
parse the "olderThan" TimeDuration, meaning files must not have been modified since this amount of time- Parameters:
olderThan- TimeDuration string- Returns:
- TimeDuration in millisecs
-
-