toxi.util
Class FileSequenceDescriptor

java.lang.Object
  extended by toxi.util.FileSequenceDescriptor
All Implemented Interfaces:
java.lang.Iterable<java.lang.String>

public class FileSequenceDescriptor
extends java.lang.Object
implements java.lang.Iterable<java.lang.String>

A descriptor and iterator for handling file sequences.


Field Summary
 int end
           
 java.lang.String extension
           
 java.lang.String filePattern
           
 int numDigits
           
 int start
           
 
Constructor Summary
FileSequenceDescriptor(java.lang.String filePattern, java.lang.String extension, int numDigits, int start)
          Creates a new descriptor from the given sequence details.
 
Method Summary
 java.lang.String getBasePath()
          Returns the base path of the sequence, i.e.
 int getDuration()
          Calculates sequence duration
 int getFinalIndex()
          Identifies the index of the last file of the sequence.
 java.lang.String getPathForIndex(int i)
          Constructs the file path for the given absolute index
 int getStartIndex()
          Returns the index of the first file of the sequence.
 java.util.Iterator<java.lang.String> iterator()
          Creates an iterator providing paths for each file in the sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filePattern

public java.lang.String filePattern

extension

public java.lang.String extension

numDigits

public int numDigits

start

public int start

end

public int end
Constructor Detail

FileSequenceDescriptor

public FileSequenceDescriptor(java.lang.String filePattern,
                              java.lang.String extension,
                              int numDigits,
                              int start)
Creates a new descriptor from the given sequence details.

Parameters:
filePattern - file pattern in the format: e.g. "path/basename%d04.ext"
extension - file extension (e.g. ".tga")
numDigits - number of digits used for the index
start - start index
Method Detail

getBasePath

public java.lang.String getBasePath()
Returns the base path of the sequence, i.e. the substring of the sequence's file pattern from the beginning until the first occurence of the % sign indicating the frame numbers.

Returns:
path string

getDuration

public int getDuration()
Calculates sequence duration

Returns:
number of files in sequence

getFinalIndex

public int getFinalIndex()
Identifies the index of the last file of the sequence.

Returns:
final index

getPathForIndex

public java.lang.String getPathForIndex(int i)
Constructs the file path for the given absolute index

Parameters:
i - index
Returns:
path

getStartIndex

public int getStartIndex()
Returns the index of the first file of the sequence.

Returns:
start index

iterator

public java.util.Iterator<java.lang.String> iterator()
Creates an iterator providing paths for each file in the sequence. The iterator does not support the remove() method and attempts to use it results in an UnsupportedOperationException being thrown.

Specified by:
iterator in interface java.lang.Iterable<java.lang.String>