View Javadoc

1   /*
2    * Entagged Audio Tag library
3    * Copyright (c) 2003-2005 Raphaël Slinckx <raphael@slinckx.net>
4    * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
5    * 
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or (at your option) any later version.
10   *  
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19   */
20  package entagged.audioformats.ogg.util;
21  
22  import entagged.audioformats.ogg.*;
23  import entagged.audioformats.generic.Utils;
24  
25  import java.io.*;
26  
27  public class OggTagReader {
28  
29  	public OggTag read( RandomAccessFile raf ) throws IOException {
30  		OggTag tag = new OggTag();
31  		
32  		byte[] b = new byte[4];
33  		raf.read( b );
34  		int vendorStringLength = Utils.getNumber( b, 0, 3);
35  		b = new byte[vendorStringLength];
36  		raf.read( b );
37  
38  		tag.setVendor( new String( b, "UTF-8" ) );
39  		
40  		b = new byte[4];
41  		raf.read( b );
42  		int userComments = Utils.getNumber( b, 0, 3);
43  
44  		for ( int i = 0; i < userComments; i++ ) {
45  			b = new byte[4];
46  			raf.read( b );
47  			int commentLength = Utils.getNumber( b, 0, 3);
48  			b = new byte[commentLength];
49  			raf.read( b );
50  			
51  			OggTagField field = new OggTagField(b);
52  			tag.add(field);
53  		}
54  		
55  		return tag;
56  	}
57  }
58