org.das2.fsm
Class FileStorageModelNew

java.lang.Object
  extended by org.das2.fsm.FileStorageModelNew

public class FileStorageModelNew
extends java.lang.Object

Represents a method for storing data sets in a set of files by time. The client provides a regex for the files and how each group of the regex is interpreted as a time digit. The model can then be used to provide the set of files that cover a time range, etc. This new implementation uses a TimeParser object to more quickly process file names.


Method Summary
 boolean containsFile(java.io.File file)
           
static FileStorageModelNew create(FileSystem root, java.lang.String template)
          creates a FileStorageModel for the given template, which uses: %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 %{milli} 3-digit milliseconds
static FileStorageModelNew 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.
static CacheTag getCacheTagFor(FileStorageModelNew fsm, DatumRange range, java.io.File[] files)
           
static CacheTag getCacheTagFor(FileStorageModelNew fsm, DatumRange range, java.lang.String[] names)
           
 java.lang.String getFilenameFor(Datum start, Datum end)
           
 java.io.File[] getFilesFor(DatumRange targetRange)
           
 java.io.File[] getFilesFor(DatumRange targetRange, ProgressMonitor monitor)
           
 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)
           
 java.lang.String[] getNamesFor(DatumRange targetRange, ProgressMonitor monitor)
           
 DatumRange getRangeFor(java.lang.String name)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getFilenameFor

public java.lang.String getFilenameFor(Datum start,
                                       Datum end)

getNamesFor

public java.lang.String[] getNamesFor(DatumRange targetRange)
                               throws java.io.IOException
Throws:
java.io.IOException

getNamesFor

public java.lang.String[] getNamesFor(DatumRange targetRange,
                                      ProgressMonitor monitor)
                               throws java.io.IOException
Throws:
java.io.IOException

getCacheTagFor

public static CacheTag getCacheTagFor(FileStorageModelNew fsm,
                                      DatumRange range,
                                      java.lang.String[] names)

getCacheTagFor

public static CacheTag getCacheTagFor(FileStorageModelNew fsm,
                                      DatumRange range,
                                      java.io.File[] files)

getFilesFor

public java.io.File[] getFilesFor(DatumRange targetRange)
                           throws java.io.IOException
Throws:
java.io.IOException

getRangeFor

public DatumRange getRangeFor(java.lang.String name)

containsFile

public boolean containsFile(java.io.File file)
Returns:
true if the file came (or could come) from this FileStorageModel.

getNameFor

public java.lang.String getNameFor(java.io.File file)
Provides a way to recover the model name of a file. The returned File from getFilesFor can be anywhere, so it would be good to provide a way to get it back into a FSM name. For example, a filesystem might download the remote file to a cache directory, which is the File that is provided to the client, sometimes the client will need to recover the name of the corresponding FileObject, so this maps the File back to the name.

Returns:
the canonical name of the file.

getFilesFor

public java.io.File[] getFilesFor(DatumRange targetRange,
                                  ProgressMonitor monitor)
                           throws java.io.IOException
Returns:
a list of files that can be used
Throws:
java.io.IOException

create

public static FileStorageModelNew create(FileSystem root,
                                         java.lang.String template)
creates a FileStorageModel for the given template, which uses: %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 %{milli} 3-digit milliseconds

Parameters:
root - FileSystem source of the files.
template - describes how filenames are constructed.
Returns:
a newly-created FileStorageModelNew.

create

public static FileStorageModelNew 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.

Parameters:
root - FileSystem source of the files.
template - describes how filenames are constructed.
fieldName - custom field name
fieldHandler - TimeParser.FieldHandler to call with the field contents.
Returns:
a newly-created FileStorageModelNew.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object