net.sf.jmp3renamer
Class DataManager

java.lang.Object
  extended by java.util.Observable
      extended by net.sf.jmp3renamer.DataManager

public class DataManager
extends Observable

This class holds the data used for renaming and tagging. The data is stored in DataSet objects which are stored in a vector. If you want to change the data, you have to do it via the DataManager. After changing any of the DataSets you have to notify all "interested" components by calling the method notifyObservers() (Observer/Observable pattern).


Nested Class Summary
private  class DataManager.Container
           
 
Field Summary
static int CAPITALIZED
           
private  Vector datasets
           
private static int id
           
private static DataManager instance
           
private  Logger logger
           
static int LOWERCASE
           
static int UPPERCASE
           
 
Constructor Summary
private DataManager()
           
 
Method Summary
private  String addLeadingZeros(String track, int count)
           
 void addObserver(Observer o)
          If you have a component which should be notified about changes, you have to add your component via this method.
 void addRow(DataSet row)
           
private  String capitalize(String string)
           
 Vector getDatasets()
          Returns the current DataSets.
static DataManager getInstance()
           
static int getNextID()
           
 void moveRow(int row, int to)
          This method moves a dataset to another row in the table.
 void notifyObservers()
          If you have changed any of the DataSets, you have to notify all observers, so that they can show/work with the new data.
 void removeRow(int row)
           
 void replaceBy(String r, String b)
          Replaces all substrings, which equal r, with b in all tag fields
 void setDatasets(Vector datasets)
          Replaces the current datasets, with the new ones in the given vector.
 void setLeadingZeros(int count)
           
 void setWordCase(int wordCase)
          Changes the case of all words in the tag fields to UPPERCASE, lowercase or Capitalized
 void trySort()
          This method tries to assign datasets to files, so that the user does not have to use the "up"- and "down"-buttons.
 
Methods inherited from class java.util.Observable
clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

private static int id

logger

private Logger logger

datasets

private Vector datasets

instance

private static DataManager instance

CAPITALIZED

public static final int CAPITALIZED
See Also:
Constant Field Values

UPPERCASE

public static final int UPPERCASE
See Also:
Constant Field Values

LOWERCASE

public static final int LOWERCASE
See Also:
Constant Field Values
Constructor Detail

DataManager

private DataManager()
Method Detail

getInstance

public static DataManager getInstance()

addObserver

public void addObserver(Observer o)
If you have a component which should be notified about changes, you have to add your component via this method. Maybe you have made a plugin, which has to know the up to date data.

Overrides:
addObserver in class Observable

notifyObservers

public void notifyObservers()
If you have changed any of the DataSets, you have to notify all observers, so that they can show/work with the new data.

Overrides:
notifyObservers in class Observable

getDatasets

public Vector getDatasets()
Returns the current DataSets. This method will return a vector containing DataSet objects. The order of the elements is the same as in the JTable.

Returns:
the current datasets.

setDatasets

public void setDatasets(Vector datasets)
Replaces the current datasets, with the new ones in the given vector. If you want to replace all datasets instead of changing only some of them, you may use this method.

Parameters:
datasets - the new datasets in a vector

trySort

public void trySort()
This method tries to assign datasets to files, so that the user does not have to use the "up"- and "down"-buttons. Basis for comparison is the song title.


moveRow

public void moveRow(int row,
                    int to)
This method moves a dataset to another row in the table.

Parameters:
row - The row which should be moved
to - The row to which "row" should be moved

getNextID

public static int getNextID()

removeRow

public void removeRow(int row)

addRow

public void addRow(DataSet row)

setLeadingZeros

public void setLeadingZeros(int count)

addLeadingZeros

private String addLeadingZeros(String track,
                               int count)

replaceBy

public void replaceBy(String r,
                      String b)
Replaces all substrings, which equal r, with b in all tag fields

Parameters:
r -
b -

setWordCase

public void setWordCase(int wordCase)
Changes the case of all words in the tag fields to UPPERCASE, lowercase or Capitalized

Parameters:
wordCase -

capitalize

private String capitalize(String string)