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

ContentDescriptionReader

public class ContentDescriptionReader extends Object implements ChunkReader
Reads and interprets the data of a ASF chunk containing title, author...
author
Christian Laireiter
see
org.jaudiotagger.audio.asf.data.ContentDescription

Fields Summary
private static final org.jaudiotagger.audio.asf.data.GUID[]
APPLYING
The GUID this reader {@linkplain #getApplyingIds() applies to}
Constructors Summary
protected ContentDescriptionReader()
Should not be used for now.


               
      
        // NOTHING toDo
    
Methods Summary
public booleancanFail()
{@inheritDoc}

        return false;
    
public org.jaudiotagger.audio.asf.data.GUID[]getApplyingIds()
{@inheritDoc}

        return APPLYING.clone();
    
private int[]getStringSizes(java.io.InputStream stream)
Returns the next 5 UINT16 values as an array.

param
stream stream to read from
return
5 int values read from stream.
throws
IOException on I/O Errors.

        final int[] result = new int[5];
        for (int i = 0; i < result.length; i++) {
            result[i] = Utils.readUINT16(stream);
        }
        return result;
    
public org.jaudiotagger.audio.asf.data.Chunkread(org.jaudiotagger.audio.asf.data.GUID guid, java.io.InputStream stream, long chunkStart)
{@inheritDoc}

        final BigInteger chunkSize = Utils.readBig64(stream);
        /*
         * Now comes 16-Bit values representing the length of the Strings which
         * follows.
         */
        final int[] stringSizes = getStringSizes(stream);

        /*
         * Now we know the String length of each occuring String.
         */
        final String[] strings = new String[stringSizes.length];
        for (int i = 0; i < strings.length; i++) {
            if (stringSizes[i] > 0) {
                strings[i] = Utils
                        .readFixedSizeUTF16Str(stream, stringSizes[i]);
            }
        }
        /*
         * Now create the result
         */
        final ContentDescription result = new ContentDescription(chunkStart,
                chunkSize);
        if (stringSizes[0] > 0) {
            result.setTitle(strings[0]);
        }
        if (stringSizes[1] > 0) {
            result.setAuthor(strings[1]);
        }
        if (stringSizes[2] > 0) {
            result.setCopyright(strings[2]);
        }
        if (stringSizes[3] > 0) {
            result.setComment(strings[3]);
        }
        if (stringSizes[4] > 0) {
            result.setRating(strings[4]);
        }
        return result;