FileDocCategorySizeDatePackage
ChunkRemover.javaAPI DocJaudiotagger 2.0.41988Wed Mar 30 16:11:50 BST 2011org.jaudiotagger.audio.asf.io

ChunkRemover

public class ChunkRemover extends Object implements ChunkModifier
This {@link ChunkModifier} implementation is meant to remove selected chunks.
author
Christian Laireiter

Fields Summary
private final Set
toRemove
Stores the GUIDs, which are about to be removed by this modifier.
Constructors Summary
public ChunkRemover(org.jaudiotagger.audio.asf.data.GUID guids)
Creates an instance, for removing selected chunks.

param
guids the GUIDs which are about to be removed by this modifier.

        this.toRemove = new HashSet<GUID>();
        for (final GUID current : guids) {
            this.toRemove.add(current);
        }
    
Methods Summary
public booleanisApplicable(org.jaudiotagger.audio.asf.data.GUID guid)
{@inheritDoc}

        return this.toRemove.contains(guid);
    
public ModificationResultmodify(org.jaudiotagger.audio.asf.data.GUID guid, java.io.InputStream source, java.io.OutputStream destination)
{@inheritDoc}

        ModificationResult result;
        if (guid == null) {
            // Now a chunk should be added, however, this implementation is for
            // removal.
            result = new ModificationResult(0, 0);
        } else {
            assert isApplicable(guid);
            // skip the chunk length minus 24 bytes for the already read length
            // and the guid.
            final long chunkLen = Utils.readUINT64(source);
            source.skip(chunkLen - 24);
            result = new ModificationResult(-1, -1 * chunkLen, guid);
        }
        return result;