public class FileStorageModel
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected Datum |
implicitTimeDelta
limit on the length of files with startTimeOnly set.
|
protected boolean |
startTimeOnly
The filename time only contains the start time of the interval, the end of the interval
is only bounded by the next file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cacheCleanup()
remove files that have been identified as old versions.
|
boolean |
containsFile(java.io.File file)
return true if the file came (or could come) from this FileStorageModel.
|
static FileStorageModel |
create(FileSystem root,
java.lang.String template)
creates a FileStorageModel for the given template, which uses:
|
static FileStorageModel |
create(FileSystem root,
java.lang.String template,
java.lang.String fieldName,
TimeParser.FieldHandler fieldHandler)
creates a FileStorageModel for the given template, but with a custom FieldHandler and
field.
|
java.lang.String[] |
generateNamesFor(DatumRange range)
generate the names of the files that would cover this range.
|
java.io.File[] |
getBestFilesFor(DatumRange targetRange)
return the best files found for the range, without progress feedback.
|
java.io.File[] |
getBestFilesFor(DatumRange targetRange,
ProgressMonitor monitor)
Get the files for the range, using versioning info ($v,etc).
|
java.lang.String[] |
getBestNamesFor(DatumRange targetRange,
ProgressMonitor monitor)
return the names in the range, minding version numbers, or all available
names if the range is null.
|
static CacheTag |
getCacheTagFor(FileStorageModel fsm,
DatumRange range,
java.io.File[] files) |
static CacheTag |
getCacheTagFor(FileStorageModel fsm,
DatumRange range,
java.lang.String[] names) |
java.lang.String |
getField(java.lang.String field,
java.lang.String name)
return the field value for the given name.
|
java.io.File |
getFileFor(java.lang.String name)
download the file for the given name within the filesystem.
|
java.io.File |
getFileFor(java.lang.String name,
ProgressMonitor monitor)
download the file for the given name within the filesystem.
|
java.lang.String |
getFilenameFor(Datum start,
Datum end)
return a filename that would intersect the range.
|
java.io.File[] |
getFilesFor(DatumRange targetRange) |
java.io.File[] |
getFilesFor(DatumRange targetRange,
ProgressMonitor monitor)
Download the files within the range.
|
java.io.File[] |
getFilesFor(java.lang.String[] names,
ProgressMonitor monitor)
download the files for each of the given names within the filesystem.
|
FileSystem |
getFileSystem()
return the filesystem used to implement this.
|
java.lang.String |
getNameFor(java.io.File file)
Provides a way to recover the model name of a file.
|
java.lang.String[] |
getNamesFor(DatumRange targetRange)
return the names in the range, or all names if the range is null.
|
java.lang.String[] |
getNamesFor(DatumRange targetRange,
ProgressMonitor monitor)
return the names in the range, or all available names if the range is null.
|
FileStorageModel |
getParent()
returns the parent or null if none exists.
|
DatumRange |
getRangeFor(java.lang.String name)
return the time range represented by this name.
|
java.lang.String |
getRepresentativeFile(ProgressMonitor monitor)
return a random file from the FSM, which can be used to represent a typical file.
|
java.lang.String |
getRepresentativeFile(ProgressMonitor monitor,
java.lang.String childRegex)
return a random file from the FSM, which can be used to represent a typical file.
|
java.lang.String |
getRepresentativeFile(ProgressMonitor monitor,
java.lang.String childRegex,
DatumRange range)
Return a random file from the FSM, which can be used to represent a typical file.
|
protected static java.lang.String |
makeCanonical(java.lang.String template)
Autoplot introduced the dollar sign instead of the percent, because $ is
more URI-friendly.
|
DatumRange |
quantize(DatumRange timeRange)
return the timerange that contains the given timerange and
exactly contains a set of granules.
|
void |
setContext(DatumRange trdr)
set the datum range giving context to the files.
|
static int |
splitIndex(java.lang.String surl)
This returns the index splitting the static part of the filename from the templated part.
|
java.lang.String |
toString() |
protected boolean startTimeOnly
protected Datum implicitTimeDelta
public FileSystem getFileSystem()
public java.lang.String getRepresentativeFile(ProgressMonitor monitor) throws java.io.IOException
monitor - progress monitor in case a file must be downloaded.java.io.IOExceptionpublic java.lang.String getRepresentativeFile(ProgressMonitor monitor, java.lang.String childRegex) throws java.io.IOException
monitor - progress monitor in case a file must be downloaded.childRegex - the parent must contain a file/folder matching childRegexjava.io.IOExceptionpublic java.lang.String getRepresentativeFile(ProgressMonitor monitor, java.lang.String childRegex, DatumRange range) throws java.io.IOException
monitor - progress monitor in case a file must be downloaded.childRegex - the parent must contain a file/folder matching childRegexrange - hint at the range where we are looking.java.io.IOException - if the file cannot be downloaded.public void setContext(DatumRange trdr)
trdr - the contextpublic java.lang.String getFilenameFor(Datum start, Datum end)
start - end - public java.lang.String[] generateNamesFor(DatumRange range)
range - the time range to cover.public DatumRange quantize(DatumRange timeRange)
timeRange - arbitrary time rangepublic java.lang.String[] getNamesFor(DatumRange targetRange) throws java.io.IOException
targetRange - range limit, or null.java.io.IOExceptionpublic java.lang.String[] getNamesFor(DatumRange targetRange, ProgressMonitor monitor) throws java.io.IOException
targetRange - range limit, or null.monitor - java.io.IOExceptionpublic java.lang.String[] getBestNamesFor(DatumRange targetRange, ProgressMonitor monitor) throws java.io.IOException
targetRange - range limit, or null.monitor - java.io.IOExceptionpublic static CacheTag getCacheTagFor(FileStorageModel fsm, DatumRange range, java.lang.String[] names)
public static CacheTag getCacheTagFor(FileStorageModel fsm, DatumRange range, java.io.File[] files)
public java.io.File[] getFilesFor(DatumRange targetRange) throws java.io.IOException
java.io.IOExceptionpublic java.io.File[] getBestFilesFor(DatumRange targetRange) throws java.io.IOException
targetRange - java.io.IOExceptionpublic void cacheCleanup()
public DatumRange getRangeFor(java.lang.String name)
name - like 2013-10-31java.lang.IllegalArgumentException - if the name is not part of the FileStorageModel.public java.lang.String getField(java.lang.String field,
java.lang.String name)
field - field, for example "v"name - name, for example 2014/04/04/20140404_v2.3.datpublic boolean containsFile(java.io.File file)
file - the filepublic java.lang.String getNameFor(java.io.File file)
file - the filepublic java.io.File getFileFor(java.lang.String name)
throws java.io.IOException
name - the name within the filesystem.java.io.IOExceptionpublic java.io.File getFileFor(java.lang.String name,
ProgressMonitor monitor)
throws java.io.IOException
name - the name within the filesystem.monitor - monitor for the download.java.io.IOExceptionpublic java.io.File[] getFilesFor(java.lang.String[] names,
ProgressMonitor monitor)
throws java.io.IOException
names - array of names within the filesystemmonitor - monitor for the downloads.java.io.IOException - during the transferpublic java.io.File[] getFilesFor(DatumRange targetRange, ProgressMonitor monitor) throws java.io.IOException
targetRange - range limit, or null if no constraint used here.monitor - the monitorjava.io.IOExceptionpublic java.io.File[] getBestFilesFor(DatumRange targetRange, ProgressMonitor monitor) throws java.io.IOException
targetRange - range limit, or null if no constraint used here.monitor - the monitorjava.io.IOExceptionpublic FileStorageModel getParent()
protected static java.lang.String makeCanonical(java.lang.String template)
template, - e.g "/%Y/%m%d.dat"public static int splitIndex(java.lang.String surl)
http://autoplot.org/data/ C1_CP_EDI_EGD__$Y$m$d_V$v.cefand http://emfisis.physics.uiowa.edu/Flight/RBSP-A/Quick-Look/$Y/$m/$d/rbsp-a_magnetometer_4sec-gsm_emfisis-Quick-Look_$Y$m$d_v$(v,sep).cdf:
http://emfisis.physics.uiowa.edu/Flight/RBSP-A/Quick-Look/ $Y/$m/$d/rbsp-a_magnetometer_4sec-gsm_emfisis-Quick-Look_$Y$m$d_v$(v,sep).cdf
This new version uses regexs and is more complete than versions found in Autoplot, and they should eventually use this instead. Note the Autoplot one returns the index of the last /, whereas this returns that index plus one.
Taken from Autoplot's AggregatingDataSourceFactory, where Autoplot just has a URI and needs to get a file list. See also org/autoplot/pngwalk/WalkUtil.java splitIndex, which also allows wildcards like *.
surl - a string like http://autoplot.org/data/C1_CP_EDI_EGD__$Y$m$d_V$v.cefpublic static FileStorageModel create(FileSystem root, java.lang.String template)
%Y-%m-%dT%H:%M:%S.%{milli}Z";
%Y 4-digit year
%m 2-digit month
%d 2-digit day of month
%j 3-digit day of year
%H 2-digit Hour
%M 2-digit Minute
%S 2-digit second
%v best version by number Also %(v,sep) for 4.3.2 or %(v,alpha)
%{milli} 3-digit milliseconds
product_$(o,id=ftp://stevens.lanl.gov/pub/projects/rbsp/autoplot/orbits/rbspa_pp).pngroot - FileSystem source of the files.template - describes how filenames are constructed. This is converted to a regular expression and may contain regex elements without groups. The
string may contain $ instead of percents as long as there are no percents in the string.public static FileStorageModel create(FileSystem root, java.lang.String template, java.lang.String fieldName, TimeParser.FieldHandler fieldHandler)
root - FileSystem source of the files.template - describes how filenames are constructed. This is converted to a regular expression and may contain regex elements without groups. The
string may contain $ instead of percents as long as there are no percents in the string.fieldName - custom field namefieldHandler - TimeParser.FieldHandler to call with the field contents.public java.lang.String toString()
toString in class java.lang.Object