org.jaudiotagger.audio.generic
Class ModificationHandler

java.lang.Object
  extended by org.jaudiotagger.audio.generic.ModificationHandler
All Implemented Interfaces:
AudioFileModificationListener

public class ModificationHandler
extends java.lang.Object
implements AudioFileModificationListener

This class multicasts the events to multiple listener instances.
Additionally the Vetos are handled. (other listeners are notified).

Author:
Christian Laireiter

Field Summary
private  java.util.Vector<AudioFileModificationListener> listeners
          The listeners to wich events are broadcasted are stored here.
 
Constructor Summary
ModificationHandler()
           
 
Method Summary
 void addAudioFileModificationListener(AudioFileModificationListener l)
          This method adds an AudioFileModificationListener
 void fileModified(AudioFile original, java.io.File temporary)
          (overridden)
 void fileOperationFinished(java.io.File result)
          (overridden)
 void fileWillBeModified(AudioFile file, boolean delete)
          (overridden)
 void removeAudioFileModificationListener(AudioFileModificationListener l)
          This method removes an AudioFileModificationListener
 void vetoThrown(AudioFileModificationListener cause, AudioFile original, ModifyVetoException veto)
          (overridden)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

private java.util.Vector<AudioFileModificationListener> listeners
The listeners to wich events are broadcasted are stored here.

Constructor Detail

ModificationHandler

public ModificationHandler()
Method Detail

addAudioFileModificationListener

public void addAudioFileModificationListener(AudioFileModificationListener l)
This method adds an AudioFileModificationListener

Parameters:
l - Listener to add.

fileModified

public void fileModified(AudioFile original,
                         java.io.File temporary)
                  throws ModifyVetoException
(overridden)

Specified by:
fileModified in interface AudioFileModificationListener
Parameters:
original - The original file on which the operation was started.
temporary - The modified copy. (It may be of zero size if the original was modified)
Throws:
ModifyVetoException - If the Results doesn't fit the expectations of the listener, it can prevent the replacement of the original by temporary.
If the original is already modified, this exception results in nothing.
See Also:
AudioFileModificationListener.fileModified(org.jaudiotagger.audio.AudioFile, File)

fileOperationFinished

public void fileOperationFinished(java.io.File result)
(overridden)

Specified by:
fileOperationFinished in interface AudioFileModificationListener
Parameters:
result - The remaining file. It's not of AudioFile since it may be possible that a new file was created. In that case the audiolibs would need to parse the file again, which leads to long and unnecessary operation time, if the tag data is not needed any more.
See Also:
AudioFileModificationListener.fileOperationFinished(File)

fileWillBeModified

public void fileWillBeModified(AudioFile file,
                               boolean delete)
                        throws ModifyVetoException
(overridden)

Specified by:
fileWillBeModified in interface AudioFileModificationListener
Parameters:
file - The file that will be modified.
delete - true if the deletion of tag data will be performed.
Throws:
ModifyVetoException - Thrown if the listener wants to prevent the process.
See Also:
AudioFileModificationListener.fileWillBeModified(org.jaudiotagger.audio.AudioFile, boolean)

removeAudioFileModificationListener

public void removeAudioFileModificationListener(AudioFileModificationListener l)
This method removes an AudioFileModificationListener

Parameters:
l - Listener to remove.

vetoThrown

public void vetoThrown(AudioFileModificationListener cause,
                       AudioFile original,
                       ModifyVetoException veto)
(overridden)

Specified by:
vetoThrown in interface AudioFileModificationListener
Parameters:
cause - The instance which caused the veto.
original - The original file, that was about to be modified.
veto - The thrown exception.
See Also:
AudioFileModificationListener.vetoThrown(org.jaudiotagger.audio.generic.AudioFileModificationListener, org.jaudiotagger.audio.AudioFile, org.jaudiotagger.audio.exceptions.ModifyVetoException)