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

« back to all changes in this revision

Viewing changes to src/org/jaudiotagger/tag/asf/AsfTagField.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-04-28 23:52:43 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110428235243-pzalvw6lncis3ukf
Tags: 2.0.3-1
* d/control: Drop Depends on default-jre per Debian Java Policy as its
  a library package.
* d/watch: Fix to directly monitor SVN tags.
* Switch to 3.0 (quilt) format.
* Bump Standards-Version to 3.9.2 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Entagged Audio Tag library
 
3
 * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
 
4
 * 
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *  
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 * 
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
package org.jaudiotagger.tag.asf;
 
20
 
 
21
import org.jaudiotagger.audio.asf.data.MetadataDescriptor;
 
22
import org.jaudiotagger.tag.TagField;
 
23
import org.jaudiotagger.tag.asf.AsfFieldKey;
 
24
import org.jaudiotagger.tag.asf.AsfTag;
 
25
 
 
26
/**
 
27
 * This class encapsulates a
 
28
 * {@link org.jaudiotagger.audio.asf.data.MetadataDescriptor}and provides access
 
29
 * to it. <br>
 
30
 * The metadata descriptor used for construction is copied.
 
31
 * 
 
32
 * @author Christian Laireiter (liree)
 
33
 */
 
34
public class AsfTagField implements TagField, Cloneable {
 
35
 
 
36
    /**
 
37
     * This descriptor is wrapped.
 
38
     */
 
39
    protected MetadataDescriptor toWrap;
 
40
 
 
41
    /**
 
42
     * Creates a tag field.
 
43
     * 
 
44
     * @param field
 
45
     *            the ASF field that should be represented.
 
46
     */
 
47
    public AsfTagField(final AsfFieldKey field) {
 
48
        assert field != null;
 
49
        this.toWrap = new MetadataDescriptor(field.getHighestContainer(), field
 
50
                .getFieldName(), MetadataDescriptor.TYPE_STRING);
 
51
    }
 
52
 
 
53
    /**
 
54
     * Creates an instance.
 
55
     * 
 
56
     * @param source
 
57
     *            The descriptor which should be represented as a
 
58
     *            {@link TagField}.
 
59
     */
 
60
    public AsfTagField(final MetadataDescriptor source) {
 
61
        assert source != null;
 
62
        // XXX Copy ? maybe not really.
 
63
        this.toWrap = source.createCopy();
 
64
    }
 
65
 
 
66
    /**
 
67
     * Creates a tag field.
 
68
     * 
 
69
     * @param fieldKey
 
70
     *            The field identifier to use.
 
71
     */
 
72
    public AsfTagField(final String fieldKey) {
 
73
        assert fieldKey != null;
 
74
        this.toWrap = new MetadataDescriptor(AsfFieldKey.getAsfFieldKey(
 
75
                fieldKey).getHighestContainer(), fieldKey,
 
76
                MetadataDescriptor.TYPE_STRING);
 
77
    }
 
78
 
 
79
    /**
 
80
     * {@inheritDoc}
 
81
     */
 
82
    @Override
 
83
    public Object clone() throws CloneNotSupportedException {
 
84
        return super.clone();
 
85
    }
 
86
 
 
87
    /**
 
88
     * {@inheritDoc}
 
89
     */
 
90
    public void copyContent(final TagField field) {
 
91
        throw new UnsupportedOperationException("Not implemented yet.");
 
92
    }
 
93
 
 
94
    /**
 
95
     * Returns the wrapped metadata descriptor (which actually stores the
 
96
     * values).
 
97
     * 
 
98
     * @return the wrapped metadata descriptor
 
99
     */
 
100
    public MetadataDescriptor getDescriptor() {
 
101
        return this.toWrap;
 
102
    }
 
103
 
 
104
    /**
 
105
     * {@inheritDoc}
 
106
     */
 
107
    public String getId() {
 
108
        return this.toWrap.getName();
 
109
    }
 
110
 
 
111
    /**
 
112
     * {@inheritDoc}
 
113
     */
 
114
    public byte[] getRawContent() {
 
115
        return this.toWrap.getRawData();
 
116
    }
 
117
 
 
118
    /**
 
119
     * {@inheritDoc}
 
120
     */
 
121
    public boolean isBinary() {
 
122
        return this.toWrap.getType() == MetadataDescriptor.TYPE_BINARY;
 
123
    }
 
124
 
 
125
    /**
 
126
     * {@inheritDoc}
 
127
     */
 
128
    public void isBinary(final boolean value) {
 
129
        if (!value && isBinary()) {
 
130
            throw new UnsupportedOperationException("No conversion supported.");
 
131
        }
 
132
        this.toWrap.setBinaryValue(this.toWrap.getRawData());
 
133
    }
 
134
 
 
135
    /**
 
136
     * {@inheritDoc}
 
137
     */
 
138
    public boolean isCommon() {
 
139
        // HashSet is safe against null comparison
 
140
        return AsfTag.COMMON_FIELDS.contains(AsfFieldKey
 
141
                .getAsfFieldKey(getId()));
 
142
    }
 
143
 
 
144
    /**
 
145
     * {@inheritDoc}
 
146
     */
 
147
    public boolean isEmpty() {
 
148
        return this.toWrap.isEmpty();
 
149
    }
 
150
 
 
151
    /**
 
152
     * {@inheritDoc}
 
153
     */
 
154
    @Override
 
155
    public String toString() {
 
156
        return this.toWrap.getString();
 
157
    }
 
158
 
 
159
}
 
 
b'\\ No newline at end of file'