summaryrefslogtreecommitdiff
path: root/songdbj/de/jarnbjo/vorbis/CommentHeader.java
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
committerBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
commit7039a05147b8bbfc829babea1c65bd436450b505 (patch)
tree4ba555eb84ed97b72b0575034d5b0530a393713e /songdbj/de/jarnbjo/vorbis/CommentHeader.java
parent6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff)
downloadrockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.gz
rockbox-7039a05147b8bbfc829babea1c65bd436450b505.zip
Splitting out songdbj
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11953 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'songdbj/de/jarnbjo/vorbis/CommentHeader.java')
-rw-r--r--songdbj/de/jarnbjo/vorbis/CommentHeader.java244
1 files changed, 0 insertions, 244 deletions
diff --git a/songdbj/de/jarnbjo/vorbis/CommentHeader.java b/songdbj/de/jarnbjo/vorbis/CommentHeader.java
deleted file mode 100644
index dd00ebca38..0000000000
--- a/songdbj/de/jarnbjo/vorbis/CommentHeader.java
+++ /dev/null
@@ -1,244 +0,0 @@
1/*
2 * $ProjectName$
3 * $ProjectRevision$
4 * -----------------------------------------------------------
5 * $Id$
6 * -----------------------------------------------------------
7 *
8 * $Author$
9 *
10 * Description:
11 *
12 * Copyright 2002-2003 Tor-Einar Jarnbjo
13 * -----------------------------------------------------------
14 *
15 * Change History
16 * -----------------------------------------------------------
17 * $Log$
18 * Revision 1.1 2005/07/11 15:42:36 hcl
19 * Songdb java version, source. only 1.5 compatible
20 *
21 * Revision 1.1.1.1 2004/04/04 22:09:12 shred
22 * First Import
23 *
24 * Revision 1.2 2003/03/16 01:11:12 jarnbjo
25 * no message
26 *
27 *
28 */
29
30package de.jarnbjo.vorbis;
31
32import java.io.*;
33
34import java.util.*;
35
36import de.jarnbjo.util.io.BitInputStream;
37
38/**
39 */
40
41public class CommentHeader {
42
43 public static final String TITLE = "TITLE";
44 public static final String ARTIST = "ARTIST";
45 public static final String ALBUM = "ALBUM";
46 public static final String TRACKNUMBER = "TRACKNUMBER";
47 public static final String VERSION = "VERSION";
48 public static final String PERFORMER = "PERFORMER";
49 public static final String COPYRIGHT = "COPYRIGHT";
50 public static final String LICENSE = "LICENSE";
51 public static final String ORGANIZATION = "ORGANIZATION";
52 public static final String DESCRIPTION = "DESCRIPTION";
53 public static final String GENRE = "GENRE";
54 public static final String DATE = "DATE";
55 public static final String LOCATION = "LOCATION";
56 public static final String CONTACT = "CONTACT";
57 public static final String ISRC = "ISRC";
58
59 private String vendor;
60 private HashMap comments=new HashMap();
61 private boolean framingBit;
62
63 private static final long HEADER = 0x736962726f76L; // 'vorbis'
64
65 public CommentHeader(BitInputStream source) throws VorbisFormatException, IOException {
66 if(source.getLong(48)!=HEADER) {
67 throw new VorbisFormatException("The identification header has an illegal leading.");
68 }
69
70 vendor=getString(source);
71
72 int ucLength=source.getInt(32);
73
74 for(int i=0; i<ucLength; i++) {
75 String comment=getString(source);
76 int ix=comment.indexOf('=');
77 String key=comment.substring(0, ix);
78 String value=comment.substring(ix+1);
79 //comments.put(key, value);
80 addComment(key, value);
81 }
82
83 framingBit=source.getInt(8)!=0;
84 }
85
86 private void addComment(String key, String value) {
87 key = key.toUpperCase(); // Comment keys are case insensitive
88 ArrayList al=(ArrayList)comments.get(key);
89 if(al==null) {
90 al=new ArrayList();
91 comments.put(key, al);
92 }
93 al.add(value);
94 }
95
96 public String getVendor() {
97 return vendor;
98 }
99
100 public String getComment(String key) {
101 ArrayList al=(ArrayList)comments.get(key);
102 return al==null?(String)null:(String)al.get(0);
103 }
104
105 public String[] getComments(String key) {
106 ArrayList al=(ArrayList)comments.get(key);
107 return al==null?new String[0]:(String[])al.toArray(new String[al.size()]);
108 }
109
110 public String getTitle() {
111 return getComment(TITLE);
112 }
113
114 public String[] getTitles() {
115 return getComments(TITLE);
116 }
117
118 public String getVersion() {
119 return getComment(VERSION);
120 }
121
122 public String[] getVersions() {
123 return getComments(VERSION);
124 }
125
126 public String getAlbum() {
127 return getComment(ALBUM);
128 }
129
130 public String[] getAlbums() {
131 return getComments(ALBUM);
132 }
133
134 public String getTrackNumber() {
135 return getComment(TRACKNUMBER);
136 }
137
138 public String[] getTrackNumbers() {
139 return getComments(TRACKNUMBER);
140 }
141
142 public String getArtist() {
143 return getComment(ARTIST);
144 }
145
146 public String[] getArtists() {
147 return getComments(ARTIST);
148 }
149
150 public String getPerformer() {
151 return getComment(PERFORMER);
152 }
153
154 public String[] getPerformers() {
155 return getComments(PERFORMER);
156 }
157
158 public String getCopyright() {
159 return getComment(COPYRIGHT);
160 }
161
162 public String[] getCopyrights() {
163 return getComments(COPYRIGHT);
164 }
165
166 public String getLicense() {
167 return getComment(LICENSE);
168 }
169
170 public String[] getLicenses() {
171 return getComments(LICENSE);
172 }
173
174 public String getOrganization() {
175 return getComment(ORGANIZATION);
176 }
177
178 public String[] getOrganizations() {
179 return getComments(ORGANIZATION);
180 }
181
182 public String getDescription() {
183 return getComment(DESCRIPTION);
184 }
185
186 public String[] getDescriptions() {
187 return getComments(DESCRIPTION);
188 }
189
190 public String getGenre() {
191 return getComment(GENRE);
192 }
193
194 public String[] getGenres() {
195 return getComments(GENRE);
196 }
197
198 public String getDate() {
199 return getComment(DATE);
200 }
201
202 public String[] getDates() {
203 return getComments(DATE);
204 }
205
206 public String getLocation() {
207 return getComment(LOCATION);
208 }
209
210 public String[] getLocations() {
211 return getComments(LOCATION);
212 }
213
214 public String getContact() {
215 return getComment(CONTACT);
216 }
217
218 public String[] getContacts() {
219 return getComments(CONTACT);
220 }
221
222 public String getIsrc() {
223 return getComment(ISRC);
224 }
225
226 public String[] getIsrcs() {
227 return getComments(ISRC);
228 }
229
230
231 private String getString(BitInputStream source) throws IOException, VorbisFormatException {
232
233 int length=source.getInt(32);
234
235 byte[] strArray=new byte[length];
236
237 for(int i=0; i<length; i++) {
238 strArray[i]=(byte)source.getInt(8);
239 }
240
241 return new String(strArray, "UTF-8");
242 }
243
244} \ No newline at end of file