org.jaudiotagger.audio.flac.metadatablock
Class MetadataBlockDataPicture

java.lang.Object
  extended by org.jaudiotagger.audio.flac.metadatablock.MetadataBlockDataPicture
All Implemented Interfaces:
MetadataBlockData, TagField

public class MetadataBlockDataPicture
extends java.lang.Object
implements MetadataBlockData, TagField

Picture Block

This block is for storing pictures associated with the file, most commonly cover art from CDs. There may be more than one PICTURE block in a file. The picture format is similar to the APIC frame in ID3v2. The PICTURE block has a type, MIME type, and UTF-8 description like ID3v2, and supports external linking via URL (though this is discouraged). The differences are that there is no uniqueness constraint on the description field, and the MIME type is mandatory. The FLAC PICTURE block also includes the resolution, color depth, and palette size so that the client can search for a suitable picture without having to scan them all

Format: Info <32> The picture type according to the ID3v2 APIC frame: (There may only be one each of picture type 1 and 2 in a file) <32> The length of the MIME type string in bytes. The MIME type string, in printable ASCII characters 0x20-0x7e. The MIME type may also be --> to signify that the data part is a URL of the picture instead of the picture data itself. <32> The length of the description string in bytes. The description of the picture, in UTF-8. <32> The width of the picture in pixels. <32> The height of the picture in pixels. <32> The color depth of the picture in bits-per-pixel. <32> For indexed-color pictures (e.g. GIF), the number of colors used, or 0 for non-indexed pictures. <32> The length of the picture data in bytes. The binary picture data.


Field Summary
private  int colourDepth
           
private  java.lang.String description
           
private  int height
           
static java.lang.String IMAGE_IS_URL
           
private  byte[] imageData
           
private  int indexedColouredCount
           
static java.util.logging.Logger logger
           
private  java.lang.String mimeType
           
private  int pictureType
           
private  int width
           
 
Constructor Summary
MetadataBlockDataPicture(byte[] imageData, int pictureType, java.lang.String mimeType, java.lang.String description, int width, int height, int colourDepth, int indexedColouredCount)
          Construct new MetadataPicture block
MetadataBlockDataPicture(MetadataBlockHeader header, java.io.RandomAccessFile raf)
          Construct picture block by reading from file
 
Method Summary
 void copyContent(TagField field)
          This method copies the data of the given field to the current data.
 byte[] getBytes()
           
 int getColourDepth()
           
 java.lang.String getDescription()
           
 int getHeight()
           
 java.lang.String getId()
          Returns the Id of the represented tag field.
This value should uniquely identify a kind of tag data, like title.
 byte[] getImageData()
           
 java.lang.String getImageUrl()
           
 int getIndexedColourCount()
           
 int getLength()
           
 java.lang.String getMimeType()
           
 int getPictureType()
           
 byte[] getRawContent()
          This method delivers the binary representation of the fields data in order to be directly written to the file.
private  java.lang.String getString(java.nio.ByteBuffer rawdata, int length, java.lang.String charset)
           
 int getWidth()
           
 boolean isBinary()
          Determines whether the represented field contains (is made up of) binary data, instead of text data.
Software can identify fields to be displayed because they are human readable if this method returns false.
 void isBinary(boolean b)
          Deprecated. As for now is of no use. Implementations should use another way of setting this property.
 boolean isCommon()
          Identifies a field to be of common use.

Some software may differ between common and not common fields.

 boolean isEmpty()
          Determines whether the content of the field is empty.
 boolean isImageUrl()
           
 java.lang.String toString()
          This method returns a human readable description of the fields contents.
For text fields it should be the text itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IMAGE_IS_URL

public static final java.lang.String IMAGE_IS_URL
See Also:
Constant Field Values

pictureType

private int pictureType

mimeType

private java.lang.String mimeType

description

private java.lang.String description

width

private int width

height

private int height

colourDepth

private int colourDepth

indexedColouredCount

private int indexedColouredCount

imageData

private byte[] imageData

logger

public static java.util.logging.Logger logger
Constructor Detail

MetadataBlockDataPicture

public MetadataBlockDataPicture(MetadataBlockHeader header,
                                java.io.RandomAccessFile raf)
                         throws java.io.IOException,
                                InvalidFrameException
Construct picture block by reading from file

Parameters:
header -
raf -
Throws:
java.io.IOException
InvalidFrameException

MetadataBlockDataPicture

public MetadataBlockDataPicture(byte[] imageData,
                                int pictureType,
                                java.lang.String mimeType,
                                java.lang.String description,
                                int width,
                                int height,
                                int colourDepth,
                                int indexedColouredCount)
Construct new MetadataPicture block

Parameters:
imageData -
pictureType -
mimeType -
description -
width -
height -
colourDepth -
indexedColouredCount -
Method Detail

getString

private java.lang.String getString(java.nio.ByteBuffer rawdata,
                                   int length,
                                   java.lang.String charset)
                            throws java.io.IOException
Throws:
java.io.IOException

getBytes

public byte[] getBytes()
Specified by:
getBytes in interface MetadataBlockData
Returns:
the rawdata as it will be written to file

getLength

public int getLength()
Specified by:
getLength in interface MetadataBlockData
Returns:
the length in bytes that the data uses when written to file

getPictureType

public int getPictureType()

getMimeType

public java.lang.String getMimeType()

getDescription

public java.lang.String getDescription()

getWidth

public int getWidth()

getHeight

public int getHeight()

getColourDepth

public int getColourDepth()

getIndexedColourCount

public int getIndexedColourCount()

getImageData

public byte[] getImageData()

isImageUrl

public boolean isImageUrl()
Returns:
true if imagedata is held as a url rather than actually being imagedata

getImageUrl

public java.lang.String getImageUrl()
Returns:
the image url if there is otherwise return an empty String

toString

public java.lang.String toString()
Description copied from interface: TagField
This method returns a human readable description of the fields contents.
For text fields it should be the text itself. Other fields containing images may return a formatted string with image properties like width, height and so on.

Specified by:
toString in interface TagField
Overrides:
toString in class java.lang.Object
Returns:
Description of the fields content.

copyContent

public void copyContent(TagField field)
This method copies the data of the given field to the current data.

Specified by:
copyContent in interface TagField
Parameters:
field - The field containing the data to be taken.

getId

public java.lang.String getId()
Returns the Id of the represented tag field.
This value should uniquely identify a kind of tag data, like title. AbstractTag will use the "id" to summarize multiple fields.

Specified by:
getId in interface TagField
Returns:
Unique identifier for the fields type. (title, artist...)

getRawContent

public byte[] getRawContent()
                     throws java.io.UnsupportedEncodingException
This method delivers the binary representation of the fields data in order to be directly written to the file.

Specified by:
getRawContent in interface TagField
Returns:
Binary data representing the current tag field.
Throws:
java.io.UnsupportedEncodingException - Most tag data represents text. In some cases the underlying implementation will need to convert the text data in java to a specific charset encoding. In these cases an UnsupportedEncodingException may occur.

isBinary

public boolean isBinary()
Determines whether the represented field contains (is made up of) binary data, instead of text data.
Software can identify fields to be displayed because they are human readable if this method returns false.

Specified by:
isBinary in interface TagField
Returns:
true if field represents binary data (not human readable).

isBinary

public void isBinary(boolean b)
Deprecated. As for now is of no use. Implementations should use another way of setting this property.

This method will set the field to represent binary data.

Some implementations may support conversions.
As of now (Octobre 2005) there is no implementation really using this method to perform useful operations.

Specified by:
isBinary in interface TagField
Parameters:
b - true, if the field contains binary data.

isCommon

public boolean isCommon()
Identifies a field to be of common use.

Some software may differ between common and not common fields. A common one is for sure the title field. A web link may not be of common use for tagging. However some file formats, or future development of users expectations will make more fields common than now can be known.

Specified by:
isCommon in interface TagField
Returns:
true if the field is of common use.

isEmpty

public boolean isEmpty()
Determines whether the content of the field is empty.

Specified by:
isEmpty in interface TagField
Returns:
true if no data is stored (or empty String).