FileDocCategorySizeDatePackage
FrameBodyPOPM.javaAPI DocJaudiotagger 2.0.46630Wed Mar 30 16:12:02 BST 2011org.jaudiotagger.tag.id3.framebody

FrameBodyPOPM

public class FrameBodyPOPM extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
Popularimeter frame.

The purpose of this frame is to specify how good an audio file is. Many interesting applications could be found to this frame such as a playlist that features better audiofiles more often than others or it could be used to profile a person's taste and find other 'good' files by comparing people's profiles. The frame is very simple. It contains the email address to the user, one rating byte and a four byte play counter, intended to be increased with one for every time the file is played. The email is a terminated string. The rating is 1-255 where 1 is worst and 255 is best. 0 is unknown. If no personal counter is wanted it may be omitted. When the counter reaches all one's, one byte is inserted in front of the counter thus making the counter eight bits bigger in the same away as the play counter ("PCNT"). There may be more than one "POPM" frame in each tag, but only one with the same email address.

<Header for 'Popularimeter', ID: "POPM">
Email to user<text string> $00
Rating $xx
Counter $xx xx xx xx (xx ...)

For more details, please refer to the ID3 specifications:

author
: Paul Taylor
author
: Eric Farng
version
$Id: FrameBodyPOPM.java 938 2010-12-10 13:17:22Z paultaylor $
todo
: Counter should be optional, whereas we always expect it although allow a size of zero needs testing.

Fields Summary
private static final int
RATING_FIELD_SIZE
private static final int
COUNTER_MINIMUM_FIELD_SIZE
public static final String
MEDIA_MONKEY_NO_EMAIL
Constructors Summary
public FrameBodyPOPM()
Creates a new FrameBodyPOPM datatype.

              
     
    
        this.setObjectValue(DataTypes.OBJ_EMAIL, "");
        this.setObjectValue(DataTypes.OBJ_RATING, (long) 0);
        this.setObjectValue(DataTypes.OBJ_COUNTER, (long) 0);
    
public FrameBodyPOPM(FrameBodyPOPM body)

        super(body);
    
public FrameBodyPOPM(String emailToUser, long rating, long counter)
Creates a new FrameBodyPOPM datatype.

param
emailToUser
param
rating
param
counter

        this.setObjectValue(DataTypes.OBJ_EMAIL, emailToUser);
        this.setObjectValue(DataTypes.OBJ_RATING, rating);
        this.setObjectValue(DataTypes.OBJ_COUNTER, counter);
    
public FrameBodyPOPM(ByteBuffer byteBuffer, int frameSize)
Creates a new FrameBodyPOPM datatype.

param
byteBuffer
param
frameSize
throws
InvalidTagException if unable to create framebody from buffer

        super(byteBuffer, frameSize);
    
Methods Summary
public longgetCounter()

return
the play count of this file

        return ((Number) getObjectValue(DataTypes.OBJ_COUNTER)).longValue();
    
public java.lang.StringgetEmailToUser()

return
the memail of the user who rated this

        return (String) getObjectValue(DataTypes.OBJ_EMAIL);
    
public java.lang.StringgetIdentifier()
The ID3v2 frame identifier

return
the ID3v2 frame identifier for this frame type

        return ID3v24Frames.FRAME_ID_POPULARIMETER;
    
public longgetRating()

return
the rating given to this file

        return ((Number) getObjectValue(DataTypes.OBJ_RATING)).longValue();
    
public java.lang.StringgetUserFriendlyValue()

        return getEmailToUser()+":"+getRating()+":"+getCounter();
    
public voidparseString(java.lang.String data)

        try
        {
            int value = Integer.parseInt(data);
            setRating(value);
            setEmailToUser(MEDIA_MONKEY_NO_EMAIL);
        }
        catch(NumberFormatException nfe)
        {

        }
    
public voidsetCounter(long counter)
Set the play counter of this file

param
counter

        setObjectValue(DataTypes.OBJ_COUNTER, counter);
    
public voidsetEmailToUser(java.lang.String description)

param
description

        setObjectValue(DataTypes.OBJ_EMAIL, description);
    
public voidsetRating(long rating)
Set the rating given to this file

param
rating

        setObjectValue(DataTypes.OBJ_RATING, rating);
    
protected voidsetupObjectList()

        objectList.add(new StringNullTerminated(DataTypes.OBJ_EMAIL, this));
        objectList.add(new NumberFixedLength(DataTypes.OBJ_RATING, this, RATING_FIELD_SIZE));
        objectList.add(new NumberVariableLength(DataTypes.OBJ_COUNTER, this, COUNTER_MINIMUM_FIELD_SIZE));