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:-
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 class
CollectionAbstract.DateSorter
class
CollectionAbstract.MyStreamFilter
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>
auxInfo
static String
CATALOG
protected String
collectionName
protected DateExtractor
dateExtractor
static String
DIR
static String
FILE
static String
GLOB
protected long
lastModified
static String
LIST
protected org.slf4j.Logger
logger
protected FeatureCollectionConfig.ProtoChoice
protoChoice
protected String
root
protected DirectoryStream.Filter<Path>
sfilter
protected CalendarDate
startCollection
-
Constructor Summary
Constructors Modifier Constructor Description protected
CollectionAbstract(String collectionName, org.slf4j.Logger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
cleanName(String name)
CalendarDate
extractDate(MFile mfile)
Use the date extractor to extract the date from the filename.Object
getAuxInfo(String key)
String
getCollectionName()
The name of the collectionList<String>
getFilenames()
Get list of sorted filenames that are in this collection.String
getIndexFilename(String suffix)
long
getLastModified()
last time this collection was modifiedMFile
getLatestFile()
The latest file in the collection.CalendarDate
getPartitionDate()
The date to partition on, usually the starting date of the collection.int
getProtoIndex(int n)
Choose Proto dataset as index from [0..n-1], based on configuration.String
getRoot()
Get common root directory of all MFiles in the collection - may be nullboolean
hasDateExtractor()
Does this CollectionManager have the ability to extract a date from the MFile ?protected List<MFile>
makeFileListSorted()
static MCollection
open(String collectionName, String collectionSpec, String olderThan, Formatter errlog)
protected long
parseOlderThanString(String olderThan)
parse the "olderThan" TimeDuration, meaning files must not have been modified since this amount of timevoid
putAuxInfo(String key, Object value)
void
setDateExtractor(DateExtractor dateExtractor)
protected void
setRoot(String root)
void
setStreamFilter(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:MCollection
The name of the collection- Specified by:
getCollectionName
in interfaceMCollection
- Returns:
- name of the collection
-
getIndexFilename
public String getIndexFilename(String suffix)
- Specified by:
getIndexFilename
in interfaceMCollection
-
setStreamFilter
public void setStreamFilter(DirectoryStream.Filter<Path> filter)
-
getRoot
public String getRoot()
Description copied from interface:MCollection
Get common root directory of all MFiles in the collection - may be null- Specified by:
getRoot
in interfaceMCollection
- Returns:
- root directory name, or null.
-
setRoot
protected void setRoot(String root)
-
getLastModified
public long getLastModified()
Description copied from interface:MCollection
last time this collection was modified- Specified by:
getLastModified
in interfaceMCollection
- Returns:
- msess since epoch
-
getLatestFile
public MFile getLatestFile() throws IOException
Description copied from interface:MCollection
The latest file in the collection. Only call if hasDateExtractor() == true.- Specified by:
getLatestFile
in interfaceMCollection
- Returns:
- latest file in the collection
- Throws:
IOException
-
getFilenames
public List<String> getFilenames() throws IOException
Description copied from interface:MCollection
Get list of sorted filenames that are in this collection.- Specified by:
getFilenames
in interfaceMCollection
- Throws:
IOException
-
extractDate
public CalendarDate extractDate(MFile mfile)
Description copied from interface:MCollection
Use the date extractor to extract the date from the filename. Only call if hasDateExtractor() == true.- Specified by:
extractDate
in interfaceMCollection
- Parameters:
mfile
- extract from here- Returns:
- Date, or null if none
-
hasDateExtractor
public boolean hasDateExtractor()
Description copied from interface:MCollection
Does this CollectionManager have the ability to extract a date from the MFile ?- Specified by:
hasDateExtractor
in interfaceMCollection
- Returns:
- true if CollectionManager has a DateExtractor
-
setDateExtractor
public void setDateExtractor(DateExtractor dateExtractor)
-
getPartitionDate
public CalendarDate getPartitionDate()
Description copied from interface:MCollection
The date to partition on, usually the starting date of the collection.- Specified by:
getPartitionDate
in interfaceMCollection
- Returns:
- partition date of the collection, or null if unknown
-
getAuxInfo
public Object getAuxInfo(String key)
- Specified by:
getAuxInfo
in interfaceMCollection
-
putAuxInfo
public void putAuxInfo(String key, Object value)
- Specified by:
putAuxInfo
in interfaceMCollection
-
getProtoIndex
public int getProtoIndex(int n)
Description copied from interface:MCollection
Choose Proto dataset as index from [0..n-1], based on configuration.- Specified by:
getProtoIndex
in 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
-
-