TEMERITY

us.temerity.pipeline
Class FileSeq

java.lang.Object
  extended by us.temerity.pipeline.FileSeq
All Implemented Interfaces:
Serializable, Cloneable, Comparable<FileSeq>, Glueable

public class FileSeq
extends Object
implements Comparable<FileSeq>, Cloneable, Glueable, Serializable

A sequence of one or more files associated with a Pipeline node.

The file sequence is composed of FilePattern and FrameRange components which together define a unique set of files.

See Also:
FilePattern, FrameRange, Serialized Form

Constructor Summary
FileSeq()
          This constructor is required by the GlueDecoder to instantiate the class when encountered during the reading of GLUE format files and should not be called from user code.
FileSeq(FilePattern pattern, FrameRange range)
          Construct a general FileSeq from FilePattern and FrameRange components.
FileSeq(FileSeq fseq)
          Copy constructor.
FileSeq(FileSeq fseq, int idx)
          Construct a FileSeq which contains only a single file extracted from the given file sequence.
FileSeq(FileSeq fseq, int startIdx, int endIdx)
          Construct a FileSeq which contains a subset of the frames from the given file sequence.
FileSeq(String path, FileSeq fseq)
          Construct a FileSeq by prepend a path to an existing file sequence.
FileSeq(String prefix, String suffix)
          Construct a FileSeq which contains a single frame without a frame number.
 
Method Summary
 Object clone()
          Return a deep copy of this object.
static TreeSet<FileSeq> collate(Set<File> files, boolean ignoreInvalid)
          Constructs the minimum set of file sequences which include all of the given files.
static TreeSet<FileSeq> collateSeqs(Set<FileSeq> fseqs)
          Constructs the minimum set of file sequences which include all of the files associated with the given set of file sequences.
 int compareTo(FileSeq fseq)
          Compares this FileSeq with the given FileSeq for order.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 void fromGlue(GlueDecoder decoder)
          Restores the non-transient fields of the class from Glue.
static FileSeq fromString(String stringRep)
          Construct a FileSeq from the string representation of a file sequence.
 File getFile(int idx)
          Generated a literal filename for the given frame number.
 FilePattern getFilePattern()
          Get the filename pattern.
 ArrayList<File> getFiles()
          Generate a list of all of the files in the file sequence.
 FrameRange getFrameRange()
          Get the file sequence frame range.
 Path getPath(int idx)
          Generated an abstract pathname for the given frame number.
 ArrayList<Path> getPaths()
          Generate a list of abstract pathnames of all of the files in the file sequence.
 boolean hasFrameNumbers()
          Does this FileSeq have a frame number component?
 int hashCode()
          Returns a hash code value for the object.
 boolean isSingle()
          Is this a single frame sequence?
 int numFrames()
          The total number of frames in the file sequence.
 boolean similarTo(FileSeq fseq)
          Whether the given file sequence have an identical prefix and suffix as this file sequence.
 void toGlue(GlueEncoder encoder)
          Saves the non-transient fields of this object as Glue.
 String toString()
          Return a string representation of the object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileSeq

public FileSeq()
This constructor is required by the GlueDecoder to instantiate the class when encountered during the reading of GLUE format files and should not be called from user code.


FileSeq

public FileSeq(String prefix,
               String suffix)
Construct a FileSeq which contains a single frame without a frame number.

Parameters:
prefix - The required filename prefix component. This argument cannot be null.
suffix - The filename extension (or suffix) component. If null is passed for this argument, then the filename will have no suffix component.

FileSeq

public FileSeq(FilePattern pattern,
               FrameRange range)
Construct a general FileSeq from FilePattern and FrameRange components.

Parameters:
pattern - The filename pattern. This argument cannot be null.
range - The frame range of the file sequence. If this is a single frame file sequence without frame numbers, null should be passed for this argument.
Throws:
IllegalArgumentException - If the pattern has a frame number component and the range is null. If the pattern has NO frame number component and the range is NOT null.

FileSeq

public FileSeq(FileSeq fseq,
               int idx)
Construct a FileSeq which contains only a single file extracted from the given file sequence.

Parameters:
fseq - The file sequence which contains the file to be extracted.
idx - The frame index of the file to be extracted.

FileSeq

public FileSeq(FileSeq fseq,
               int startIdx,
               int endIdx)
Construct a FileSeq which contains a subset of the frames from the given file sequence.

Parameters:
fseq - The original file sequence.
startIdx - The frame index of the first file.
endIdx - The frame index of the last file.

FileSeq

public FileSeq(String path,
               FileSeq fseq)
Construct a FileSeq by prepend a path to an existing file sequence.

Parameters:
path - The path to prepend.
fseq - The file sequence to prepend.

FileSeq

public FileSeq(FileSeq fseq)
Copy constructor.

Method Detail

hasFrameNumbers

public boolean hasFrameNumbers()
Does this FileSeq have a frame number component?


isSingle

public boolean isSingle()
Is this a single frame sequence?


getFilePattern

public FilePattern getFilePattern()
Get the filename pattern.


getFrameRange

public FrameRange getFrameRange()
Get the file sequence frame range.


numFrames

public int numFrames()
The total number of frames in the file sequence.


getFile

public File getFile(int idx)
Generated a literal filename for the given frame number.

Parameters:
idx - The frame index of the file. Valid frame indices are in the range: [0,numFrames()).

getFiles

public ArrayList<File> getFiles()
Generate a list of all of the files in the file sequence.


getPath

public Path getPath(int idx)
Generated an abstract pathname for the given frame number.

Parameters:
idx - The frame index of the file. Valid frame indices are in the range: [0,numFrames()).

getPaths

public ArrayList<Path> getPaths()
Generate a list of abstract pathnames of all of the files in the file sequence.


equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
obj - The reference object with which to compare.

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object

toString

public String toString()
Return a string representation of the object.

Overrides:
toString in class Object

compareTo

public int compareTo(FileSeq fseq)
Compares this FileSeq with the given FileSeq for order.

Specified by:
compareTo in interface Comparable<FileSeq>
Parameters:
fseq - The FileSeq to be compared.

similarTo

public boolean similarTo(FileSeq fseq)
Whether the given file sequence have an identical prefix and suffix as this file sequence.

The similarity of file sequences is independent of whether they have any frame numbers in common. In other words, there is no requirement that they share any literal files.


clone

public Object clone()
Return a deep copy of this object.

Overrides:
clone in class Object

toGlue

public void toGlue(GlueEncoder encoder)
            throws GlueException
Description copied from interface: Glueable
Saves the non-transient fields of this object as Glue. Typically, the implementation will call GlueEncoder.encode for each non-transient field of the parent object.

Specified by:
toGlue in interface Glueable
Parameters:
encoder - [modified] The object used to encode this object's fields into Glue format.
Throws:
GlueException

fromGlue

public void fromGlue(GlueDecoder decoder)
              throws GlueException
Description copied from interface: Glueable
Restores the non-transient fields of the class from Glue. Typically, the implementation will call GlueDecoder.decode for each non-transient field of the parent object.

Specified by:
fromGlue in interface Glueable
Parameters:
decoder - The object used to decode this object's fields from Glue format.
Throws:
GlueException

collateSeqs

public static TreeSet<FileSeq> collateSeqs(Set<FileSeq> fseqs)
Constructs the minimum set of file sequences which include all of the files associated with the given set of file sequences.

Parameters:
fseqs - The original file sequences.
Returns:
The collated file sequences.

collate

public static TreeSet<FileSeq> collate(Set<File> files,
                                       boolean ignoreInvalid)
                                throws PipelineException
Constructs the minimum set of file sequences which include all of the given files.

WARNING: The prefix of the returned file sequences will be seperated with an operating system dependent character.

Parameters:
files - The files which define the file sequences created.
ignoreInvalid - Whether to ignore files which do not conform to the file naming conventions.
Returns:
The generated file sequences.
Throws:
PipelineException - If invalid or conflicting files are given.

fromString

public static FileSeq fromString(String stringRep)
Construct a FileSeq from the string representation of a file sequence.

prefix[.#|@...][.suffix][,start[-end[xby]]]

Completely specifies a file sequence associated with the target node. The filename prefix (prefix) is required. The optional frame number pattern may either be a (#) character for 4-digit padded frame numbers or one or more (@) characters, each specifying one digit of padding. A single (@) character is the same as unpadded frame numbers. The last entry is an optional filename suffix (suffix). If a frame number pattern was specified, the start frame (start) must also be specified. If the file sequence contains only a single frame, the single frame number is specified by the start frame. Multiple frame sequences also specify an end frame (end) and optionally a frame step increment (by).

Parameters:
stringRep - The string representation of the FileSeq.
Returns:
The file sequence represented by the string.
Throws:
IllegalArgumentException - If the string passed in does not represent a valid FileSeq

TEMERITY