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

ContentBranding

public final class ContentBranding extends MetadataContainer
This structure represents the value of the content branding object, which stores the banner image, the banner image URL and the copyright URL.
author
Christian Laireiter

Fields Summary
public static final Set
ALLOWED
Stores the allowed {@linkplain MetadataDescriptor#getName() descriptor keys}.
public static final String
KEY_BANNER_IMAGE
Descriptor key representing the banner image.
public static final String
KEY_BANNER_TYPE
Descriptor key representing the banner image type.

Known/valid values are:
  1. 0: there is no image present
  2. 1: there is a BMP image
  3. 2: there is a JPEG image
  4. 3: there is a GIF image
public static final String
KEY_BANNER_URL
Descriptor key representing the banner image URL.
public static final String
KEY_COPYRIGHT_URL
Descriptor key representing the copyright URL.
Constructors Summary
public ContentBranding()
Creates an instance.


     
        ALLOWED = new HashSet<String>();
        ALLOWED.add(KEY_BANNER_IMAGE);
        ALLOWED.add(KEY_BANNER_TYPE);
        ALLOWED.add(KEY_BANNER_URL);
        ALLOWED.add(KEY_COPYRIGHT_URL);
    
        this(0, BigInteger.ZERO);
    
public ContentBranding(long pos, BigInteger size)
Creates an instance.

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

        super(ContainerType.CONTENT_BRANDING, pos, size);
    
Methods Summary
public java.lang.StringgetBannerImageURL()
Returns the banner image URL.

return
the banner image URL.

        return getValueFor(KEY_BANNER_URL);
    
public java.lang.StringgetCopyRightURL()
Returns the copyright URL.

return
the banner image URL.

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

        // GUID, size, image type, image data size, image url data size,
        // copyright data size
        long result = 40;
        result += assertDescriptor(KEY_BANNER_IMAGE,
                MetadataDescriptor.TYPE_BINARY).getRawDataSize();
        result += getBannerImageURL().length();
        result += getCopyRightURL().length();
        return result;
    
public byte[]getImageData()
Returns the binary image data.

return
binary image data.

        return assertDescriptor(KEY_BANNER_IMAGE,
                MetadataDescriptor.TYPE_BINARY).getRawData();
    
public longgetImageType()
Returns the image type.

see
#KEY_BANNER_TYPE for known/valid values.
return
image type

        if (!hasDescriptor(KEY_BANNER_TYPE)) {
            final MetadataDescriptor descriptor = new MetadataDescriptor(
                    ContainerType.CONTENT_BRANDING, KEY_BANNER_TYPE,
                    MetadataDescriptor.TYPE_DWORD);
            descriptor.setDWordValue(0);
            addDescriptor(descriptor);
        }
        return assertDescriptor(KEY_BANNER_TYPE).getNumber();
    
public booleanisAddSupported(MetadataDescriptor descriptor)
{@inheritDoc}

        return ALLOWED.contains(descriptor.getName())
                && super.isAddSupported(descriptor);
    
public voidsetBannerImageURL(java.lang.String imageURL)
This method sets the banner image URL, if imageURL is not blank.

param
imageURL image URL to set.

        if (Utils.isBlank(imageURL)) {
            removeDescriptorsByName(KEY_BANNER_URL);
        } else {
            assertDescriptor(KEY_BANNER_URL).setStringValue(imageURL);
        }
    
public voidsetCopyRightURL(java.lang.String copyRight)
This method sets the copyright URL, if copyRight is not blank.

param
copyRight copyright URL to set.

        if (Utils.isBlank(copyRight)) {
            removeDescriptorsByName(KEY_COPYRIGHT_URL);
        } else {
            assertDescriptor(KEY_COPYRIGHT_URL).setStringValue(copyRight);
        }
    
public voidsetImage(long imageType, byte[] imageData)

param
imageType
param
imageData

        assert imageType >= 0 && imageType <= 3;
        assert imageType > 0 || imageData.length == 0;
        assertDescriptor(KEY_BANNER_TYPE, MetadataDescriptor.TYPE_DWORD)
                .setDWordValue(imageType);
        assertDescriptor(KEY_BANNER_IMAGE, MetadataDescriptor.TYPE_BINARY)
                .setBinaryValue(imageData);
    
public longwriteInto(java.io.OutputStream out)
{@inheritDoc}

        final long chunkSize = getCurrentAsfChunkSize();
        out.write(getGuid().getBytes());
        Utils.writeUINT64(chunkSize, out);
        Utils.writeUINT32(getImageType(), out);
        assert getImageType() >= 0 && getImageType() <= 3;
        final byte[] imageData = getImageData();
        assert getImageType() > 0 || imageData.length == 0;
        Utils.writeUINT32(imageData.length, out);
        out.write(imageData);
        Utils.writeUINT32(getBannerImageURL().length(), out);
        out.write(getBannerImageURL().getBytes("ASCII"));
        Utils.writeUINT32(getCopyRightURL().length(), out);
        out.write(getCopyRightURL().getBytes("ASCII"));
        return chunkSize;