public class FilePattern
extends java.lang.Object
 A file pattern can be constructed from a pattern string, where
 variable parts are represented by blocks delimited by angle
 brackets. For instance, the pattern
 img_<R,G,B>.ext expands to
 img_R.ext, img_G.ext and
 img_B.ext.
 
 In addition to comma-separated series as the one shown above,
 pattern blocks can contain a sequence expression in the
 START-STOP:STEP format. For instance, the pattern
 <0-36:3>m.tiff expands to 0m.tiff,
 3m.tiff, 6m.tiff ... 36m.tiff. If the step increment is one,
 it can be omitted: TAABA<1-3>.PIC expands to
 TAABA1.PIC, TAABA2.PIC, TAABA3.PIC. The start number
 can have leading zeroes to denote zero-padded numbers:
 img_<08-10>.ext expands to img_08.ext,
 img_09.ext, img_10.ext. Sequence expressions also support
 alphabetic ranges: img_<C-E>.ext expands to
 img_C.ext, img_D.ext, img_E.ext.
 
 A multi-block pattern is expanded by substituting the blocks with
 the tuples from the cartesian product of all block expansions. For
 instance, z<1-2><R,G,B>.tiff expands to
 z1R.tiff, z1G.tiff, z1B.tiff, z2R.tiff, z2G.tiff,
 z2B.tiff.
 
 If a pattern has zero blocks, it will be treated as a regular
 expression to be matched against the names of existing files. If
 there are no matches, the pattern expands to itself. For instance,
 /tmp/z.*.tif expands to /tmp/z1.tif if
 that file exists (and it's the only matching file), otherwise it
 expands to itself.  If the pattern contains no special regex
 syntax, it also expands to itself (a single file is a special case
 of file pattern).
 
 A FilePattern can also be created from a Location or from a basename and directory. In these cases, the
 pattern string is inferred from the names of other files in the
 same directory.
 
| Modifier and Type | Field and Description | 
|---|---|
| private FilePatternBlock[] | blocksList of pattern blocks for this file pattern. | 
| private int[] | endIndexIndices into the pattern indicating the end of a numerical block. | 
| private java.lang.String[] | filesFile listing for this file pattern. | 
| private boolean | isRegexWhether or not this FilePattern represents a regular expression. | 
| private java.lang.String | msgError message generated during file pattern construction. | 
| private java.lang.String | patternThe file pattern string. | 
| private int[] | startIndexIndices into the pattern indicating the start of a numerical block. | 
| private boolean | validThe validity of the file pattern. | 
| Constructor and Description | 
|---|
| FilePattern(loci.common.Location file)Creates a pattern object using the given file as a template. | 
| FilePattern(java.lang.String pattern)Creates a pattern object for files with the given pattern string. | 
| FilePattern(java.lang.String name,
           java.lang.String dir)Creates a pattern object using the given
 filename and directory path as a template. | 
| Modifier and Type | Method and Description | 
|---|---|
| private void | buildFiles(java.lang.String prefix,
          int ndx,
          java.util.List<java.lang.String> fileList) | 
| static java.lang.String | findPattern(java.io.File file)Identifies the group pattern from a given file within that group. | 
| static java.lang.String | findPattern(loci.common.Location file)Identifies the group pattern from a given file within that group. | 
| static java.lang.String | findPattern(java.lang.String path)Identifies the group pattern from a given file within that group. | 
| static java.lang.String | findPattern(java.lang.String[] names)Generate a pattern from a list of file names. | 
| static java.lang.String | findPattern(java.lang.String name,
           java.lang.String dir)Identifies the group pattern from a given filename and directory. | 
| private static java.lang.String | findPattern(java.lang.String name,
           java.lang.String[] nameList,
           int ndx,
           int end,
           java.lang.String p) | 
| static java.lang.String | findPattern(java.lang.String name,
           java.lang.String dir,
           java.lang.String[] nameList)Identifies the group pattern from a given filename, directory and
 list of candidate filenames. | 
| static java.lang.String | findPattern(java.lang.String name,
           java.lang.String dir,
           java.lang.String[] nameList,
           int[] excludeAxes)Identifies the group pattern from a given filename, directory and
 list of candidate filenames. | 
| static java.lang.String[] | findSeriesPatterns(java.lang.String base)Works like  findSeriesPatterns(String, String, String[]),
 but dir and nameList are inferred from the given file's absolute
 path. | 
| static java.lang.String[] | findSeriesPatterns(java.lang.String base,
                  java.lang.String dir,
                  java.lang.String[] nameList)Similar to  findPattern(String, String, String[]), but
 this does not merge series indices into a pattern block. | 
| private java.lang.String[] | getAllFiles(java.lang.String dir) | 
| java.lang.String | getBlock(int i)Gets the specified file pattern block (e.g., <0-9>). | 
| java.lang.String[] | getBlocks()Gets all file pattern blocks. | 
| private static java.lang.String | getBounds(java.math.BigInteger[] numbers,
         boolean fixed)Gets a string containing start, end and step values
 for a sorted list of numbers. | 
| int[] | getCount()Gets the number of elements for each pattern block. | 
| java.lang.String[][] | getElements()Gets individual elements for each pattern block. | 
| java.lang.String | getErrorMessage()Gets the file pattern error message, if any. | 
| java.lang.String[] | getFiles()Gets a listing of all files matching this file pattern. | 
| java.math.BigInteger[] | getFirst()Gets the START element for all blocks. | 
| java.math.BigInteger[] | getLast()Gets the STOP element for all blocks. | 
| java.lang.String | getPattern()Gets the file pattern string. | 
| java.lang.String | getPrefix()Gets the pattern's substring that comes before any block sections. | 
| java.lang.String | getPrefix(int i)Gets the pattern's substring between block i-1 (or the beginning
 of the pattern, if i is 0) and block i. | 
| java.lang.String[] | getPrefixes()Gets all block prefixes. | 
| java.math.BigInteger[] | getStep()Gets the STEP element for all blocks. | 
| java.lang.String | getSuffix()Gets the pattern's substring that comes after all block sections. | 
| boolean | isRegex()Returns whether or not this pattern is a regular expression. | 
| boolean | isValid()Returns whether or not the file pattern is valid. | 
| private static java.lang.String[] | matchFiles(java.lang.String[] inFiles,
          NumberFilter filter) | 
private java.lang.String pattern
private boolean valid
private java.lang.String msg
private int[] startIndex
private int[] endIndex
private FilePatternBlock[] blocks
private java.lang.String[] files
private boolean isRegex
public FilePattern(loci.common.Location file)
file - the file as a Location instance.public FilePattern(java.lang.String name,
                   java.lang.String dir)
name - file basename.dir - directory path.public FilePattern(java.lang.String pattern)
pattern - the pattern string.public boolean isRegex()
public java.lang.String getPattern()
public boolean isValid()
public java.lang.String getErrorMessage()
public java.lang.String[] getFiles()
public java.lang.String[][] getElements()
public int[] getCount()
public java.lang.String getBlock(int i)
i - block indexpublic java.lang.String[] getBlocks()
public java.lang.String getPrefix()
public java.lang.String getSuffix()
public java.lang.String getPrefix(int i)
i - block index.public java.lang.String[] getPrefixes()
public static java.lang.String findPattern(java.lang.String path)
path - The file path to use as a template for the match.public static java.lang.String findPattern(loci.common.Location file)
file - The Location to use as a template for the match.public static java.lang.String findPattern(java.io.File file)
file - The file to use as a template for the match.public static java.lang.String findPattern(java.lang.String name,
                                           java.lang.String dir)
name - The file basename to use as a template for the match.dir - The directory in which to search for matching files.public static java.lang.String findPattern(java.lang.String name,
                                           java.lang.String dir,
                                           java.lang.String[] nameList)
name - The file basename to use as a template for the match.dir - The directory prefix to use for matching files.nameList - The names through which to search for matching files.public static java.lang.String findPattern(java.lang.String name,
                                           java.lang.String dir,
                                           java.lang.String[] nameList,
                                           int[] excludeAxes)
name - The file basename to use as a template for the match.dir - The directory prefix to use for matching files.nameList - The names through which to search for matching files.excludeAxes - The list of axis types which should be
 excluded from the pattern (see AxisGuesser).public static java.lang.String findPattern(java.lang.String[] names)
names - the list of filenames.public static java.lang.String[] findSeriesPatterns(java.lang.String base)
findSeriesPatterns(String, String, String[]),
 but dir and nameList are inferred from the given file's absolute
 path.base - The file basename to use as a template for the match.public static java.lang.String[] findSeriesPatterns(java.lang.String base,
                                                    java.lang.String dir,
                                                    java.lang.String[] nameList)
findPattern(String, String, String[]), but
 this does not merge series indices into a pattern block. Instead,
 it returns a separate pattern for each series index. For
 instance, if the file names are:
   "foo_s1_z1.ext", "foo_s1_z2.ext", "foo_s2_z1.ext", "foo_s2_z2.ext"
 Then findPattern
 will find a single "foo_s<1-2>_z<1-2>.ext" pattern, whereas this
 method will find "foo_s1_z<1-2>.ext" and "foo_s2_z<1-2>.ext".base - The file basename to use as a template for the match.dir - The directory prefix to use for matching files.nameList - The names through which to search for matching files.private static java.lang.String findPattern(java.lang.String name,
                                            java.lang.String[] nameList,
                                            int ndx,
                                            int end,
                                            java.lang.String p)
private static java.lang.String getBounds(java.math.BigInteger[] numbers,
                                          boolean fixed)
numbers - a sorted list of numbersfixed - whether the numbers to a fixed width blockprivate static java.lang.String[] matchFiles(java.lang.String[] inFiles,
                                             NumberFilter filter)
private void buildFiles(java.lang.String prefix,
                        int ndx,
                        java.util.List<java.lang.String> fileList)
private java.lang.String[] getAllFiles(java.lang.String dir)
public java.math.BigInteger[] getFirst()
public java.math.BigInteger[] getLast()
public java.math.BigInteger[] getStep()
Copyright © 2023 Open Microscopy Environment