FileDocCategorySizeDatePackage
ContentDescription.javaAPI DocJaudiotagger 2.0.48364Wed Mar 30 16:11:50 BST 2011org.jaudiotagger.audio.asf.data

ContentDescription

public final class ContentDescription extends MetadataContainer
This class represents the data of a chunk which contains title, author, copyright, description and the rating of the file.
It is optional within ASF files. But if, exists only once.
author
Christian Laireiter

Fields Summary
public static final Set
ALLOWED
Stores the only allowed keys of this metadata container.
public static final String
KEY_AUTHOR
Field key for author.
public static final String
KEY_COPYRIGHT
Field key for copyright.
public static final String
KEY_DESCRIPTION
Field key for description.
public static final String
KEY_RATING
Field key for rating.
public static final String
KEY_TITLE
Field key for title.
Constructors Summary
public ContentDescription()
Creates an instance.


     
        ALLOWED = new HashSet<String>(Arrays.asList(KEY_AUTHOR,
                KEY_COPYRIGHT, KEY_DESCRIPTION, KEY_RATING, KEY_TITLE));
    
        this(0, BigInteger.ZERO);
    
public ContentDescription(long pos, BigInteger chunkLen)
Creates an instance.

param
pos Position of content description within file or stream
param
chunkLen Length of content description.

        super(ContainerType.CONTENT_DESCRIPTION, pos, chunkLen);
    
Methods Summary
public java.lang.StringgetAuthor()

return
Returns the author.

        return getValueFor(KEY_AUTHOR);
    
public java.lang.StringgetComment()

return
Returns the comment.

        return getValueFor(KEY_DESCRIPTION);
    
public java.lang.StringgetCopyRight()

return
Returns the copyRight.

        return getValueFor(KEY_COPYRIGHT);
    
public longgetCurrentAsfChunkSize()
{@inheritDoc}

        long result = 44; // GUID + UINT64 for size + 5 times string length
        // (each
        // 2 bytes) + 5 times zero term char (2 bytes each).
        result += getAuthor().length() * 2; // UTF-16LE
        result += getComment().length() * 2;
        result += getRating().length() * 2;
        result += getTitle().length() * 2;
        result += getCopyRight().length() * 2;
        return result;
    
public java.lang.StringgetRating()

return
returns the rating.

        return getValueFor(KEY_RATING);
    
public java.lang.StringgetTitle()

return
Returns the title.

        return getValueFor(KEY_TITLE);
    
public booleanisAddSupported(MetadataDescriptor descriptor)
{@inheritDoc}

        return ALLOWED.contains(descriptor.getName())
                && super.isAddSupported(descriptor);
    
public java.lang.StringprettyPrint(java.lang.String prefix)
{@inheritDoc}

        final StringBuilder result = new StringBuilder(super.prettyPrint(prefix));
        result.append(prefix).append("  |->Title      : ").append(getTitle())
                .append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |->Author     : ").append(getAuthor())
                .append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |->Copyright  : ").append(
                getCopyRight()).append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |->Description: ").append(getComment())
                .append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |->Rating     :").append(getRating())
                .append(Utils.LINE_SEPARATOR);
        return result.toString();
    
public voidsetAuthor(java.lang.String fileAuthor)

param
fileAuthor The author to set.
throws
IllegalArgumentException If "UTF-16LE"-byte-representation would take more than 65535 bytes.

        setStringValue(KEY_AUTHOR, fileAuthor);
    
public voidsetComment(java.lang.String tagComment)

param
tagComment The comment to set.
throws
IllegalArgumentException If "UTF-16LE"-byte-representation would take more than 65535 bytes.

        setStringValue(KEY_DESCRIPTION, tagComment);
    
public voidsetCopyright(java.lang.String cpright)

param
cpright The copyRight to set.
throws
IllegalArgumentException If "UTF-16LE"-byte-representation would take more than 65535 bytes.

        setStringValue(KEY_COPYRIGHT, cpright);
    
public voidsetRating(java.lang.String ratingText)

param
ratingText The rating to be set.
throws
IllegalArgumentException If "UTF-16LE"-byte-representation would take more than 65535 bytes.

        setStringValue(KEY_RATING, ratingText);
    
public voidsetTitle(java.lang.String songTitle)

param
songTitle The title to set.
throws
IllegalArgumentException If "UTF-16LE"-byte-representation would take more than 65535 bytes.

        setStringValue(KEY_TITLE, songTitle);
    
public longwriteInto(java.io.OutputStream out)
{@inheritDoc}

        final long chunkSize = getCurrentAsfChunkSize();

        out.write(this.getGuid().getBytes());
        Utils.writeUINT64(getCurrentAsfChunkSize(), out);
        // write the sizes of the string representations plus 2 bytes zero term
        // character
        Utils.writeUINT16(getTitle().length() * 2 + 2, out);
        Utils.writeUINT16(getAuthor().length() * 2 + 2, out);
        Utils.writeUINT16(getCopyRight().length() * 2 + 2, out);
        Utils.writeUINT16(getComment().length() * 2 + 2, out);
        Utils.writeUINT16(getRating().length() * 2 + 2, out);
        // write the Strings
        out.write(Utils.getBytes(getTitle(), AsfHeader.ASF_CHARSET));
        out.write(AsfHeader.ZERO_TERM);
        out.write(Utils.getBytes(getAuthor(), AsfHeader.ASF_CHARSET));
        out.write(AsfHeader.ZERO_TERM);
        out.write(Utils.getBytes(getCopyRight(), AsfHeader.ASF_CHARSET));
        out.write(AsfHeader.ZERO_TERM);
        out.write(Utils.getBytes(getComment(), AsfHeader.ASF_CHARSET));
        out.write(AsfHeader.ZERO_TERM);
        out.write(Utils.getBytes(getRating(), AsfHeader.ASF_CHARSET));
        out.write(AsfHeader.ZERO_TERM);
        return chunkSize;