marytts.tools.voiceimport
Class BasenameList

java.lang.Object
  extended by marytts.tools.voiceimport.BasenameList

public class BasenameList
extends java.lang.Object

The BasenameList class produces and stores an alphabetically-sorted array of basenames issued from the .wav files present in a given directory.

Author:
sacha

Constructor Summary
BasenameList()
          Default constructor for an empty list.
BasenameList(java.lang.String fileName)
          This constructor loads the basename list from a random access file.
BasenameList(java.lang.String[] str)
          Constructor from an array of strings.
BasenameList(java.lang.String dirName, java.lang.String extension)
          This constructor lists the . files from directory dir, and initializes an an array with their list of alphabetically sorted basenames.
BasenameList(java.lang.String setFromDir, java.lang.String setFromExt, java.util.Vector setVec)
          Default constructor from an existing vector and fields.
 
Method Summary
 void add(java.lang.String str)
          Adds a basename to the list.
 void add(java.lang.String[] str)
          Adds an array of basenames to the list.
 void clear()
          Clear the list.
 boolean contains(BasenameList bnl)
          Check if the list contains another given one.
 boolean contains(java.lang.String str)
          Check if the given basename is part of the list.
 BasenameList duplicate()
          Duplicates the list (i.e., emits an autonomous copy of it).
 boolean equals(BasenameList bnl)
          Check if two lists are equal.
 java.lang.String getDir()
          An accessor for the original directory.
 java.lang.String getExt()
          An accessor for the original extension.
 int getLength()
          An accessor for the list's length
 java.lang.String[] getListAsArray()
          An accessor for the list of basenames, returned as an array of strings
 java.util.Vector getListAsVector()
          Another accessor for the list of basenames, returned as a vector of strings
 java.lang.String getName(int i)
          Return a copy of the basename at index i.
 boolean hasChanged()
           
 void load(java.lang.String fileName)
          Read the basenameList from a file
 boolean remove(BasenameList bnl)
          Removes a list from another list.
 boolean remove(java.lang.String str)
          Removes a basename from the list, if it was present.
 void sort()
          Ensure that the list is alphabetically sorted.
 BasenameList subList(int fromIndex, int toIndex)
          Returns an autonomous sublist between fromIndex, inclusive, and toIndex, exclusive.
 void write(java.io.File file)
          Write the basenameList to a File.
 void write(java.lang.String fileName)
          Write the basenameList to a file, identified by its name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasenameList

public BasenameList()
Default constructor for an empty list.


BasenameList

public BasenameList(java.lang.String setFromDir,
                    java.lang.String setFromExt,
                    java.util.Vector setVec)
Default constructor from an existing vector and fields.


BasenameList

public BasenameList(java.lang.String[] str)
Constructor from an array of strings.


BasenameList

public BasenameList(java.lang.String dirName,
                    java.lang.String extension)
This constructor lists the . files from directory dir, and initializes an an array with their list of alphabetically sorted basenames.

Parameters:
dir - The name of the directory to list the files from.
extension - The extension of the files to list.

BasenameList

public BasenameList(java.lang.String fileName)
             throws java.io.IOException
This constructor loads the basename list from a random access file.

Parameters:
fileName - The file to read from.
Throws:
java.io.IOException
Method Detail

write

public void write(java.lang.String fileName)
           throws java.io.IOException
Write the basenameList to a file, identified by its name.

Throws:
java.io.IOException

write

public void write(java.io.File file)
           throws java.io.IOException
Write the basenameList to a File.

Throws:
java.io.IOException

load

public void load(java.lang.String fileName)
          throws java.io.IOException
Read the basenameList from a file

Throws:
java.io.IOException

add

public void add(java.lang.String str)
Adds a basename to the list.


add

public void add(java.lang.String[] str)
Adds an array of basenames to the list.


remove

public boolean remove(java.lang.String str)
Removes a basename from the list, if it was present.

Parameters:
str - The basename to remove.
Returns:
true if the list was containing the basename.

remove

public boolean remove(BasenameList bnl)
Removes a list from another list.

Parameters:
bnl - The basename list to remove.
Returns:
true if the list was containing any element of the list to remove.

duplicate

public BasenameList duplicate()
Duplicates the list (i.e., emits an autonomous copy of it).


subList

public BasenameList subList(int fromIndex,
                            int toIndex)
Returns an autonomous sublist between fromIndex, inclusive, and toIndex, exclusive.


getListAsArray

public java.lang.String[] getListAsArray()
An accessor for the list of basenames, returned as an array of strings


getListAsVector

public java.util.Vector getListAsVector()
Another accessor for the list of basenames, returned as a vector of strings


getLength

public int getLength()
An accessor for the list's length


getDir

public java.lang.String getDir()
An accessor for the original directory. Returns null if the original directory is undefined.


getExt

public java.lang.String getExt()
An accessor for the original extension. Returns null if the original extension is undefined.


getName

public java.lang.String getName(int i)
Return a copy of the basename at index i.

Parameters:
i - The index of the basename to consider.
Returns:
The corresponding basename.

contains

public boolean contains(java.lang.String str)
Check if the given basename is part of the list.

Parameters:
str - The basename to check for.
Returns:
true if yes, false if no.

contains

public boolean contains(BasenameList bnl)
Check if the list contains another given one.

Parameters:
bnl - The list of basenames to check for.
Returns:
true if yes, false if no.

equals

public boolean equals(BasenameList bnl)
Check if two lists are equal.

Parameters:
bnl - The list of basenames to check for.
Returns:
true if yes, false if no.

sort

public void sort()
Ensure that the list is alphabetically sorted.


clear

public void clear()
Clear the list.


hasChanged

public boolean hasChanged()