~ubuntu-branches/ubuntu/utopic/libjaudiotagger-java/utopic-proposed

« back to all changes in this revision

Viewing changes to org/jaudiotagger/tag/id3/framebody/FrameBodyPCNT.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath, Damien Raude-Morvan, Varun Hiremath
  • Date: 2009-04-01 19:17:56 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090401191756-bygniim270guy7o1
Tags: 1.0.9-1
[ Damien Raude-Morvan ]
* New upstream release
* debian/watch: Use java.net repository (which contains new releases!)
* debian/control:
  - Build-Depends on default-jdk-builddep
  - Bump Standards-Version to 3.8.1 (no changes needed)
  - Change section to "java"
* debian/rules: use default-java as JAVA_HOME
* debina/orig-tar.{sh|excludes}: strip audio and others binary files from ZIP
* debian/build.xml:
  - compile with "nowarn" to keep build log readable
  - exclude LogFormatter from build (use com.sun classes)
* debian/ant.properties: new source directory is "src" in orig.tar.gz
* Add myself as Uploaders

[ Varun Hiremath ]
* Accept changes made by Damien Raude-Morvan (Closes: #522130)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  MusicTag Copyright (C)2003,2004
3
 
 *
4
 
 *  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
5
 
 *  General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
6
 
 *  or (at your option) any later version.
7
 
 *
8
 
 *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9
 
 *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 
 *  See the GNU Lesser General Public License for more details.
11
 
 *
12
 
 *  You should have received a copy of the GNU Lesser General Public License along with this library; if not,
13
 
 *  you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
14
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
 
 */
16
 
package org.jaudiotagger.tag.id3.framebody;
17
 
 
18
 
import org.jaudiotagger.tag.InvalidTagException;
19
 
import org.jaudiotagger.tag.datatype.DataTypes;
20
 
import org.jaudiotagger.tag.datatype.NumberVariableLength;
21
 
import org.jaudiotagger.tag.id3.ID3v24Frames;
22
 
 
23
 
import java.nio.ByteBuffer;
24
 
 
25
 
/**
26
 
 * Play counter frame.
27
 
 * 
28
 
 * <p>
29
 
 * This is simply a counter of the number of times a file has been
30
 
 * played. The value is increased by one every time the file begins to
31
 
 * play. There may only be one "PCNT" frame in each tag. When the
32
 
 * counter reaches all one's, one byte is inserted in front of the
33
 
 * counter thus making the counter eight bits bigger. The counter must
34
 
 * be at least 32-bits long to begin with.
35
 
 * </p><p><table border=0 width="70%">
36
 
 * <tr><td colspan=2> &lt;Header for 'Play counter', ID: "PCNT"&gt;</td></tr>
37
 
 * <tr><td>Counter </td><td>$xx xx xx xx (xx ...)</td></tr>
38
 
 * </table></p>
39
 
 * 
40
 
 * <p>For more details, please refer to the ID3 specifications:
41
 
 * <ul>
42
 
 * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
43
 
 * </ul>
44
 
 * 
45
 
 * @author : Paul Taylor
46
 
 * @author : Eric Farng
47
 
 * @version $Id: FrameBodyPCNT.java,v 1.12 2007/08/06 16:04:34 paultaylor Exp $
48
 
 */
49
 
public class FrameBodyPCNT extends AbstractID3v2FrameBody implements ID3v24FrameBody,ID3v23FrameBody
50
 
{
51
 
     private static final int COUNTER_MINIMUM_FIELD_SIZE=4;
52
 
 
53
 
    /**
54
 
     * Creates a new FrameBodyPCNT datatype.
55
 
     */
56
 
    public FrameBodyPCNT()
57
 
    {
58
 
        this.setObjectValue(DataTypes.OBJ_NUMBER, 0L);
59
 
    }
60
 
 
61
 
    public FrameBodyPCNT(FrameBodyPCNT body)
62
 
    {
63
 
        super(body);
64
 
    }
65
 
 
66
 
    /**
67
 
     * Creates a new FrameBodyPCNT datatype.
68
 
     *
69
 
     * @param counter 
70
 
     */
71
 
    public FrameBodyPCNT(long counter)
72
 
    {
73
 
        this.setObjectValue(DataTypes.OBJ_NUMBER, counter);
74
 
    }
75
 
 
76
 
    /**
77
 
     * Creates a new FrameBodyPCNT datatype.
78
 
     *
79
 
     * @throws InvalidTagException if unable to create framebody from buffer
80
 
     */
81
 
    public FrameBodyPCNT(ByteBuffer byteBuffer, int frameSize)
82
 
        throws InvalidTagException
83
 
    {
84
 
        super(byteBuffer, frameSize);
85
 
    }
86
 
 
87
 
    /**
88
 
     *
89
 
     *
90
 
     * @return the play count of this file
91
 
     */
92
 
    public long getCounter()
93
 
    {
94
 
        return ((Number) getObjectValue(DataTypes.OBJ_NUMBER)).longValue();
95
 
    }
96
 
 
97
 
    /**
98
 
     * Set the play counter of this file
99
 
     *
100
 
     * @param counter
101
 
     */
102
 
    public void setCounter(long counter)
103
 
    {
104
 
        setObjectValue(DataTypes.OBJ_NUMBER, counter);
105
 
    }
106
 
    /**
107
 
      * The ID3v2 frame identifier
108
 
      *
109
 
      * @return the ID3v2 frame identifier  for this frame type
110
 
     */
111
 
    public String getIdentifier()
112
 
    {
113
 
        return ID3v24Frames.FRAME_ID_PLAY_COUNTER;
114
 
    }
115
 
 
116
 
    /**
117
 
     * 
118
 
     */
119
 
    protected void setupObjectList()
120
 
    {
121
 
        objectList.add(new NumberVariableLength(DataTypes.OBJ_NUMBER, this,COUNTER_MINIMUM_FIELD_SIZE));
122
 
    }
123
 
}