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

« back to all changes in this revision

Viewing changes to org/jaudiotagger/tag/id3/framebody/FrameBodyGEOB.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.*;
20
 
import org.jaudiotagger.tag.id3.ID3v24Frames;
21
 
import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
22
 
 
23
 
import java.io.ByteArrayOutputStream;
24
 
import java.io.IOException;
25
 
import java.nio.ByteBuffer;
26
 
 
27
 
/**
28
 
 * General encapsulated object frame.
29
 
 * 
30
 
 * <p>
31
 
 * In this frame any type of file can be encapsulated. After the header,
32
 
 * 'Frame size' and 'Encoding' follows 'MIME type' represented as
33
 
 * as a terminated string encoded with ISO-8859-1. The
34
 
 * filename is case sensitive and is encoded as 'Encoding'. Then follows
35
 
 * a content description as terminated string, encoded as 'Encoding'.
36
 
 * The last thing in the frame is the actual object. The first two
37
 
 * strings may be omitted, leaving only their terminations. There may be more than one "GEOB"
38
 
 * frame in each tag, but only one with the same content descriptor.
39
 
 * </p><p><table border=0 width="70%">
40
 
 * <tr><td colspan=2> &lt;Header for 'General encapsulated object', ID: "GEOB"&gt;</td></tr>
41
 
 * <tr><td>Text encoding       </td><td>$xx                     </td></tr>
42
 
 * <tr><td>MIME type           </td><td>&lt;text string&gt; $00 </td></tr>
43
 
 * <tr><td>Filename            </td><td>&lt;text string according to encoding&gt; $00 (00)</td></tr>
44
 
 * <tr><td>Content description </td><td><text string according to enc�ding> $00 (00)</td></tr>
45
 
 * <tr><td>Encapsulated object </td><td>&lt;binary data&gt;     </td></tr>
46
 
 * </table></p>
47
 
 * 
48
 
 * <p>For more details, please refer to the ID3 specifications:
49
 
 * <ul>
50
 
 * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
51
 
 * </ul>
52
 
 * 
53
 
 * @author : Paul Taylor
54
 
 * @author : Eric Farng
55
 
 * @version $Id: FrameBodyGEOB.java,v 1.13 2007/11/13 14:24:34 paultaylor Exp $
56
 
 */
57
 
public class FrameBodyGEOB extends AbstractID3v2FrameBody implements ID3v24FrameBody,ID3v23FrameBody
58
 
{
59
 
 
60
 
    /**
61
 
     * Creates a new FrameBodyGEOB datatype.
62
 
     */
63
 
    public FrameBodyGEOB()
64
 
    {
65
 
        this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
66
 
        this.setObjectValue(DataTypes.OBJ_MIME_TYPE, "");
67
 
        this.setObjectValue(DataTypes.OBJ_FILENAME, "");
68
 
        this.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
69
 
        this.setObjectValue(DataTypes.OBJ_DATA, new byte[0]);
70
 
    }
71
 
 
72
 
    public FrameBodyGEOB(FrameBodyGEOB body)
73
 
    {
74
 
        super(body);
75
 
    }
76
 
 
77
 
    /**
78
 
     * Creates a new FrameBodyGEOB datatype.
79
 
     *
80
 
     * @param textEncoding 
81
 
     * @param mimeType     
82
 
     * @param filename     
83
 
     * @param description  
84
 
     * @param object       
85
 
     */
86
 
    public FrameBodyGEOB(byte textEncoding, String mimeType, String filename, String description, byte[] object)
87
 
    {
88
 
        this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
89
 
        this.setObjectValue(DataTypes.OBJ_MIME_TYPE, mimeType);
90
 
        this.setObjectValue(DataTypes.OBJ_FILENAME, filename);
91
 
        this.setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
92
 
        this.setObjectValue(DataTypes.OBJ_DATA, object);
93
 
    }
94
 
 
95
 
    /**
96
 
     * Creates a new FrameBodyGEOB datatype.
97
 
     *
98
 
     * @throws InvalidTagException if unable to create framebody from buffer
99
 
     */
100
 
    public FrameBodyGEOB(ByteBuffer byteBuffer, int frameSize)
101
 
        throws InvalidTagException
102
 
    {
103
 
        super(byteBuffer, frameSize);
104
 
    }
105
 
 
106
 
    /**
107
 
     * 
108
 
     *
109
 
     * @param description 
110
 
     */
111
 
    public void setDescription(String description)
112
 
    {
113
 
        setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
114
 
    }
115
 
 
116
 
    /**
117
 
     * 
118
 
     *
119
 
     * @return  the description field
120
 
     */
121
 
    public String getDescription()
122
 
    {
123
 
        return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
124
 
    }
125
 
 
126
 
    /**
127
 
     * 
128
 
     *
129
 
     * @return 
130
 
     */
131
 
    public String getIdentifier()
132
 
    {
133
 
        return ID3v24Frames.FRAME_ID_GENERAL_ENCAPS_OBJECT ;
134
 
    }
135
 
 
136
 
 
137
 
    /** If the filename or description cannot be encoded using current encoder, change the encoder */
138
 
    public void write(ByteArrayOutputStream tagBuffer)       
139
 
    {
140
 
        if (((AbstractString) getObject(DataTypes.OBJ_FILENAME)).canBeEncoded() == false)
141
 
        {
142
 
            this.setTextEncoding(TextEncoding.UTF_16);
143
 
        }
144
 
        if (((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded() == false)
145
 
        {
146
 
            this.setTextEncoding(TextEncoding.UTF_16);
147
 
        }
148
 
        super.write(tagBuffer);
149
 
    }
150
 
 
151
 
    /**
152
 
     * 
153
 
     */
154
 
    protected void setupObjectList()
155
 
    {
156
 
        objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
157
 
        objectList.add(new StringNullTerminated(DataTypes.OBJ_MIME_TYPE, this));
158
 
        objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_FILENAME, this));
159
 
        objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_DESCRIPTION, this));
160
 
        objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_DATA, this));
161
 
    }
162
 
}