bcds.tools
Class FilenameSeq

java.lang.Object
  extended by bcds.tools.FilenameSeq

public class FilenameSeq
extends java.lang.Object

FileNameSeq creates file names based on a name pattern with an embedded sequence marker. The sequence mark is either {%d} or {%:d}, where the colon character : stands for a width/padding specifier as used in Java's String.format.

Thus: new FilenameSeq("some_file_{%d}.txt").expand(1) returns "some_file_1.txt", while new FilenameSeq("some_file_{%03d}.txt").expand(9) returns "some_file_009.txt".

If the file pattern does not contain a sequence marker, expand returns the same string.

Author:
Juan Segovia S.

Constructor Summary
FilenameSeq(java.lang.String fname_pattern)
          Creates a new instance which uses the given filename pattern.
 
Method Summary
 java.lang.String expand(int seq)
          Returns the filename in which the integer seq embedded, if hasSequenceMarker() is true, or simply the same filename passed to its constructor otherwise.
 boolean hasSequenceMarker()
          Returns true if the filename to which this instance is bound contains a sequence marker, and false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilenameSeq

public FilenameSeq(java.lang.String fname_pattern)
Creates a new instance which uses the given filename pattern.

Throws:
java.lang.IllegalArgumentException - if fname_pattern contains an invalid sequence marker.
Method Detail

hasSequenceMarker

public boolean hasSequenceMarker()
Returns true if the filename to which this instance is bound contains a sequence marker, and false otherwise.


expand

public java.lang.String expand(int seq)
Returns the filename in which the integer seq embedded, if hasSequenceMarker() is true, or simply the same filename passed to its constructor otherwise.