[pkg-java] r6141 - in trunk: . entagged entagged/debian entagged/debian/patches entagged/entagged entagged/entagged/audioformats

twerner at alioth.debian.org twerner at alioth.debian.org
Fri Apr 11 21:56:13 UTC 2008


Author: twerner
Date: 2008-04-11 21:56:13 +0000 (Fri, 11 Apr 2008)
New Revision: 6141

Added:
   trunk/entagged/
   trunk/entagged/debian/
   trunk/entagged/debian/changelog
   trunk/entagged/debian/compat
   trunk/entagged/debian/control
   trunk/entagged/debian/copyright
   trunk/entagged/debian/docs
   trunk/entagged/debian/entagged.1
   trunk/entagged/debian/entagged.desktop
   trunk/entagged/debian/entagged.sh
   trunk/entagged/debian/manpages
   trunk/entagged/debian/orig-tar.sh
   trunk/entagged/debian/patches/
   trunk/entagged/debian/patches/build.diff
   trunk/entagged/debian/patches/series
   trunk/entagged/debian/rules
   trunk/entagged/debian/watch
   trunk/entagged/entagged/
   trunk/entagged/entagged/audioformats/
   trunk/entagged/entagged/audioformats/AudioFileIO.java
Log:
import package entagged


Added: trunk/entagged/debian/changelog
===================================================================
--- trunk/entagged/debian/changelog	                        (rev 0)
+++ trunk/entagged/debian/changelog	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,48 @@
+entagged (0.31.ds2-1) unstable; urgency=low
+  
+  * Repackage the source - some problems with the previous tarball.     
+  * Remove debian/build.xml and debian/ant.properties and switch back to
+    upstream build.xml.
+  * Include docs also in the package.
+
+ -- Varun Hiremath <varunhiremath at gmail.com>  Mon, 05 Nov 2007 22:40:38 +0530
+
+entagged (0.31.ds1-1) unstable; urgency=low
+
+  * Use 0.31.ds1 version to move the orig.tar.gz to main (Closes: #447455)
+  * Disable broken miage support in audiformats. Couldn't add a patch
+    because of some text encoding problem.
+  * debian/control:
+    + Seperate out Build-Depends and Build-Depends-Indep
+    + Add Homepage, Vcs-{Svn, Browser} Headers.
+    + Remove java-virtual-machine from Depends
+  * Add custom build.xml, ant.properties to debian dir.
+  * Add a new fixed version of entagged.desktop to debian dir.
+  * debian/rules:
+    + Clean up everything
+    + Move the orig.tar.gz creation steps to debian/orig-tar.sh
+    + Add squareness and junit to DEB_JARS
+  * Remove debian/install and install jars from debian/rules
+  * Update debian/watch to call debian/orig-tar.sh
+  
+ -- Varun Hiremath <varunhiremath at gmail.com>  Wed, 24 Oct 2007 15:07:43 +0530
+
+entagged (0.31-3) unstable; urgency=low
+
+  * Change Architecture: all.
+
+ -- Torsten Werner <twerner at debian.org>  Sat, 06 Oct 2007 00:17:30 +0200
+
+entagged (0.31-2) unstable; urgency=low
+
+  * Add myself to Uploaders.
+  * Switch to java-gcj-compat-dev from sun-java5-jdk.
+  * Move package to main.
+
+ -- Torsten Werner <twerner at debian.org>  Sat, 06 Oct 2007 00:09:44 +0200
+
+entagged (0.31-1) unstable; urgency=low
+
+  * Initial release (Closes: #415687)
+
+ -- Varun Hiremath <varunhiremath at gmail.com>  Mon, 29 Jan 2007 02:38:47 +0530

Added: trunk/entagged/debian/compat
===================================================================
--- trunk/entagged/debian/compat	                        (rev 0)
+++ trunk/entagged/debian/compat	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1 @@
+5

Added: trunk/entagged/debian/control
===================================================================
--- trunk/entagged/debian/control	                        (rev 0)
+++ trunk/entagged/debian/control	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,21 @@
+Source: entagged
+Section: editors
+Priority: optional
+Maintainer: Varun Hiremath <varunhiremath at gmail.com>
+Uploaders: Torsten Werner <twerner at debian.org>
+Build-Depends: cdbs, debhelper (>= 5), quilt
+Build-Depends-Indep: ant, junit, libhsqldb-java, java-gcj-compat-dev
+Standards-Version: 3.7.2
+Homepage: http://sourceforge.net/projects/entagged
+Vcs-Svn: https://bollin.googlecode.com/svn/entagged/
+Vcs-Browser: http://bollin.googlecode.com/svn/entagged/
+
+Package: entagged
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, java-gcj-compat |
+ java1-runtime | java2-runtime, libhsqldb-java, squareness
+Description: Java Audio File Tagger
+ Entagged is a audiofile tagger, using the freedb online database for
+ the retrieval of the tags. It supports custom file renaming from tags
+ (with any directory stucture) and vice versa. Supports: mp3, ogg,
+ flac, mpc, ape, wma.

Added: trunk/entagged/debian/copyright
===================================================================
--- trunk/entagged/debian/copyright	                        (rev 0)
+++ trunk/entagged/debian/copyright	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,48 @@
+This package was debianized by Varun Hiremath <varunhiremath at gmail.com> on
+Mon, 29 Jan 2007 02:38:47 +0530.
+
+It was downloaded from http://sourceforge.net/projects/entagged
+
+Upstream Author: 
+Raphal Slinckx <raphael at slinckx.net>
+Christian Laireiter <liree at web.de>
+
+Copyright: 
+(c) 2003-2005 Raphal Slinckx <raphael at slinckx.net>
+(c) 2004-2005 Christian Laireiter <liree at web.de>
+
+License:
+
+   This package is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This package is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+
+-----
+
+Files in the audioformat directory are licensed under GNU Lesser
+General Public License:
+
+    This package is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This package is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+On Debian systems, the complete text of the GNU Lesser General
+Public License can be found in `/usr/share/common-licenses/LGPL'.
+
+The Debian packaging is (C) 2007, Varun Hiremath <varunhiremath at gmail.com> and
+is licensed under the GPL, see above.

Added: trunk/entagged/debian/docs
===================================================================
--- trunk/entagged/debian/docs	                        (rev 0)
+++ trunk/entagged/debian/docs	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,2 @@
+build/entagged/docs/readme.html
+build/entagged/docs/images

Added: trunk/entagged/debian/entagged.1
===================================================================
--- trunk/entagged/debian/entagged.1	                        (rev 0)
+++ trunk/entagged/debian/entagged.1	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,66 @@
+.TH ENTAGGED 1 "October 20, 2006"
+.SH NAME
+entagged - Java Audio File Tagger
+.SH DESCRIPTION
+.PP
+Entagged provides a convenient way of changing the value of tag
+fields, either manually, or automatically via the freedb
+database. 
+
+Entagged can also do a lot of organization work. You can rename your
+files from their tag in any way you like, including complex directory
+structures. You can also tag the files from their filename, this
+avoid copying all the information by hand.
+
+Best of all, Entagged hides all the different format complexity, with
+one unique interface, you can work with mixed file formats eg. you
+can use freedb with a mixed album of WMA, MP3 and OGG files without
+worrying!
+.PP
+.SH Features
+.PP
+.PP
+* Support for OGG Vorbis files - MP3 (id3v1 and id3v2 tags) files - FLAC
+Files - MPC(MP+) Musepack Files - APE Monkey Audio Files - WAV files
+.PP
+* Handles all files independently of their type (allows to batch files
+even from mixed types)
+.PP
+* Edit essential tag information
+(Artist-Album-Title-TrackNb-Comment-Genre-Year) easily
+.PP
+* Rename files from their tag using any of the above infos with any
+pattern
+.PP
+* Tag files (again using the above fields) from their filename with any
+pattern
+.PP
+* Pattern can use filename but also directory name, easy to create a
+well structured audio files repository
+.PP
+* freedb search using automatically computed cddb id's (the way it is
+meant to be used). Simply select some files that represent an album,
+then query and tag.
+.PP
+* freedb search using manually searched cddb id. When entagged can't
+find any match, you can search freedb for a given artist/album and
+find the correct match yourself, then ask entagged to tag the files.
+.PP
+* Supports Multi langage (currently only english,french and spanish)
+(contributors appreciated)
+.PP
+* Recursive processing of all the above operations, easily !
+.PP
+* Text transformation: capitalize, uppercase roman numerals, lowercase,
+and more that can be used either while tagging or renaming.
+.PP
+* Separate freedb and audioformats libraries that can be used
+independently by anyone who want to read and/or write meta data to
+audio files
+.SH DOCUMENTAION
+Please see /usr/share/doc/entagged/readme.html
+.SH HOMEPAGE
+http://entagged.sourceforge.net/
+.SH AUTHOR
+This manual page was written by Varun Hiremath <varunhiremath at gmail.com>,
+for the Debian project (but may be used by others).

Added: trunk/entagged/debian/entagged.desktop
===================================================================
--- trunk/entagged/debian/entagged.desktop	                        (rev 0)
+++ trunk/entagged/debian/entagged.desktop	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=Entagged
+Comment=Tag Editor
+Comment[fr]=Editeur de Tags
+Exec=entagged
+Icon=entagged.png
+TryExec=entagged
+Terminal=0
+Type=Application
+Categories=AudioVideo;

Added: trunk/entagged/debian/entagged.sh
===================================================================
--- trunk/entagged/debian/entagged.sh	                        (rev 0)
+++ trunk/entagged/debian/entagged.sh	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+exec java -classpath "/usr/share/java/hsqldb.jar:/usr/share/java/entagged-tageditor.jar:/usr/share/java/squareness.jar" entagged.tageditor.TagEditorFrameSplash
+


Property changes on: trunk/entagged/debian/entagged.sh
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/entagged/debian/manpages
===================================================================
--- trunk/entagged/debian/manpages	                        (rev 0)
+++ trunk/entagged/debian/manpages	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1 @@
+debian/entagged.1

Added: trunk/entagged/debian/orig-tar.sh
===================================================================
--- trunk/entagged/debian/orig-tar.sh	                        (rev 0)
+++ trunk/entagged/debian/orig-tar.sh	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,20 @@
+#!/bin/sh -e
+
+# called by uscan with '--upstream-version' <version> <file>
+DIR=entagged-$2.orig
+
+# clean up the upstream tarball
+mkdir temp
+tar -x -z -f $3 -C temp
+mv temp/entagged $DIR
+GZIP=--best tar -c -z -f $3 --exclude '*.jar' --exclude '*CVS*' $DIR
+rm -rf $DIR temp
+
+# move to directory 'tarballs'
+if [ -r .svn/deb-layout ]; then
+  . .svn/deb-layout
+  mv $3 $origDir
+  echo "moved $3 to $origDir"
+fi
+
+exit 0


Property changes on: trunk/entagged/debian/orig-tar.sh
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/entagged/debian/patches/build.diff
===================================================================
--- trunk/entagged/debian/patches/build.diff	                        (rev 0)
+++ trunk/entagged/debian/patches/build.diff	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,68 @@
+Index: entagged-0.31/build.xml
+===================================================================
+--- entagged-0.31.orig/build.xml	2007-03-23 15:25:25.000000000 +0100
++++ entagged-0.31/build.xml	2007-04-08 11:53:57.000000000 +0200
+@@ -28,9 +28,9 @@
+ 	
+ 	<!-- set global properties -->
+ 	<property name="entagged_dir" location="."/>
+-	<property name="entagged_base_dir" location=".."/>
++	<property name="entagged_base_dir" location="."/>
+ 	<property name="tageditor_dir" location="tageditor"/>
+-	<property name="tageditor_version" value="0.21"/>
++	<property name="tageditor_version" value="0.31"/>
+ 	<property name="tageditor_jar" value="entagged-tageditor-${tageditor_version}.jar"/>
+ 	<property name="tageditor_zip" value="entagged-tageditor-${tageditor_version}.zip"/>
+ 	<property name="tageditor_tar" value="entagged-tageditor-${tageditor_version}.tar"/>
+@@ -52,7 +52,7 @@
+ 	
+ 	<!-- Compile the sources -->
+     <target name="compile" depends="clean">
+-		<javac srcdir="${entagged_dir}" classpath="${entagged_base_dir}" excludes="entagged/junit/*" source="1.4"/>
++		<javac srcdir="${entagged_dir}" classpath="${entagged_base_dir}:/usr/share/ant/lib/junit.jar" excludes="entagged/junit/*" source="1.5"/>
+ <echo>
+ Entagged Tag editor is now fully compiled.
+ You can use either:
+@@ -71,7 +71,7 @@
+ 	<!-- Prepares the classes to be packaged -->
+ 	<target name="build" depends="compile">
+ 		<!-- Jar the classes files  -->
+-		<jar destfile="${tageditor_jar}" basedir="${entagged_base_dir}" includes="entagged/**/*.class entagged/**/*.xsl entagged/**/*.dtd entagged/**/*.properties entagged/**/*.html entagged/tageditor/resources/**/*" excludes="**/*.java" >
++		<jar destfile="${tageditor_jar}" basedir="${entagged_base_dir}" includes="entagged/**/*.class entagged/**/*.xsl entagged/**/*.dtd entagged/**/*.properties entagged/**/*.html entagged/tageditor/resources/**/* miage/**/*.class" excludes="**/*.java" >
+ 			<manifest>
+ 				<attribute name="Class-Path" value="${tageditor_jar_classpath}"/>
+ 				<attribute name="Main-Class" value="${tageditor_jar_mainclass}"/>
+@@ -82,16 +82,29 @@
+ 	<target name="build-dir" depends="build">
+ 		<mkdir dir="${build_dir}" />
+ 		<copy todir="${build_dir}/docs">
+-			<fileset dir="entagged-doc" includes="**/*.html **/*.png **/*.txt **/*.jpg" />
+-			<fileset dir="lib" includes="*.txt" />
++			<fileset dir="entagged/entagged-doc" includes="**/*.html **/*.png **/*.txt **/*.jpg" />
+ 		</copy>
+-		
+-		<copy todir="${build_dir}" file="lib/squareness.jar" />
++	
+ 		<move todir="${build_dir}" file="${tageditor_jar}" />
+ 		<exec executable="jar" dir="${build_dir}" >
+ 		 	<arg line="-i ${tageditor_jar}"/>
+ 		</exec>
+ 	</target>
++
++	<!-- Install -->
++	<target name="install">
++		<mkdir dir="${destdir}/usr/share/java/"/>
++		<mkdir dir="${destdir}/usr/share/doc/entagged/"/>
++		<copy todir="${destdir}/usr/share/java/">
++		      <fileset file="${build_dir}/${tageditor_jar}" />
++		</copy>
++		<copy todir="${destdir}/usr/share/doc/entagged/">
++		      <fileset file="${build_dir}/docs/readme.html" />
++		</copy>
++		<copy todir="${destdir}/usr/share/doc/entagged/images/">
++		      <fileset	dir="${build_dir}/docs/images/" />
++		</copy>
++	</target>
+ 	
+ 	<!-- Package the jar files for distribution in a source tarball and an easy to deploy zip file -->
+ 	<target name="package" depends="build-dir">

Added: trunk/entagged/debian/patches/series
===================================================================
--- trunk/entagged/debian/patches/series	                        (rev 0)
+++ trunk/entagged/debian/patches/series	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1 @@
+build.diff

Added: trunk/entagged/debian/rules
===================================================================
--- trunk/entagged/debian/rules	                        (rev 0)
+++ trunk/entagged/debian/rules	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,27 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/class/ant.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/rules/patchsys-quilt.mk
+
+JAVA_HOME		:= /usr/lib/jvm/java-gcj
+DEB_ANT_BUILD_TARGET 	:= build-dir
+DEB_JARS  		:= hsqldb
+
+IMAGE_SRCDIR  := entagged/entagged-build-resources/image
+IMAGE_DESTDIR := $(DEB_DESTDIR)/usr/share/icons/hicolor
+
+install/entagged::
+	install -m 644 -D build/entagged/entagged-tageditor*.jar \
+	  $(DEB_DESTDIR)/usr/share/java/entagged-tageditor-$(DEB_UPSTREAM_VERSION).jar
+	dh_link /usr/share/java/entagged-tageditor-$(DEB_UPSTREAM_VERSION).jar \
+	  /usr/share/java/entagged-tageditor.jar
+	dh_install debian/entagged.desktop /usr/share/applications
+	install -m 755 -D debian/entagged.sh $(DEB_DESTDIR)/usr/bin/entagged
+	install -m 644 -D $(IMAGE_SRCDIR)/entagged-32x32.png \
+	  $(IMAGE_DESTDIR)/32x32/apps/entagged.png
+	install -m 644 -D $(IMAGE_SRCDIR)/entagged-128x128.png \
+	  $(IMAGE_DESTDIR)/128x128/apps/entagged.png
+
+get-orig-source:
+	-uscan --upstream-version 0 --rename


Property changes on: trunk/entagged/debian/rules
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/entagged/debian/watch
===================================================================
--- trunk/entagged/debian/watch	                        (rev 0)
+++ trunk/entagged/debian/watch	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,2 @@
+version=3
+http://sf.net/entagged/ entagged-tageditor-(\d.*)\.tar\.gz debian debian/orig-tar.sh

Added: trunk/entagged/entagged/audioformats/AudioFileIO.java
===================================================================
--- trunk/entagged/entagged/audioformats/AudioFileIO.java	                        (rev 0)
+++ trunk/entagged/entagged/audioformats/AudioFileIO.java	2008-04-11 21:56:13 UTC (rev 6141)
@@ -0,0 +1,297 @@
+/*
+ * Entagged Audio Tag library
+ * Copyright (c) 2003-2005 Raphaël Slinckx <raphael at slinckx.net>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *  
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+package entagged.audioformats;
+
+import java.io.File;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import entagged.audioformats.ape.MonkeyFileReader;
+import entagged.audioformats.ape.MonkeyFileWriter;
+import entagged.audioformats.asf.AsfFileReader;
+import entagged.audioformats.asf.AsfFileWriter;
+import entagged.audioformats.exceptions.CannotReadException;
+import entagged.audioformats.exceptions.CannotWriteException;
+import entagged.audioformats.flac.FlacFileReader;
+import entagged.audioformats.flac.FlacFileWriter;
+import entagged.audioformats.generic.AudioFileModificationListener;
+import entagged.audioformats.generic.AudioFileReader;
+import entagged.audioformats.generic.AudioFileWriter;
+import entagged.audioformats.generic.ModificationHandler;
+import entagged.audioformats.generic.Utils;
+import entagged.audioformats.mp3.Mp3FileReader;
+import entagged.audioformats.mp3.Mp3FileWriter;
+import entagged.audioformats.mpc.MpcFileReader;
+import entagged.audioformats.mpc.MpcFileWriter;
+import entagged.audioformats.ogg.OggFileReader;
+import entagged.audioformats.ogg.OggFileWriter;
+import entagged.audioformats.wav.WavFileReader;
+import entagged.audioformats.wav.WavFileWriter;
+
+/**
+ * <p>
+ * The main entry point for the Tag Reading/Writing operations, this class will
+ * select the appropriate reader/writer for the given file.
+ * </p>
+ * <p>
+ * It selects the appropriate reader/writer based on the file extension (case
+ * ignored).
+ * </p>
+ * <p>
+ * Here is an simple example of use:
+ * </p>
+ * <p>
+ * <code>
+ *		AudioFile audioFile = AudioFileIO.read(new File("audiofile.mp3")); //Reads the given file.<br/>
+ *		int bitrate = audioFile.getBitrate(); //Retreives the bitrate of the file.<br/>
+ *		String artist = audioFile.getTag().getArtist(); //Retreive the artist name.<br/>
+ *		audioFile.getTag().setGenre("Progressive Rock"); //Sets the genre to Prog. Rock, note the file on disk is still unmodified.<br/>
+ *		AudioFileIO.write(audioFile); //Write the modifications in the file on disk.
+ *	</code>
+ * </p>
+ * <p>
+ * You can also use the <code>commit()</code> method defined for
+ * <code>AudioFile</code>s to achieve the same goal as
+ * <code>AudioFileIO.write(File)</code>, like this:
+ * </p>
+ * <p>
+ * <code>
+ *		AudioFile audioFile = AudioFileIO.read(new File("audiofile.mp3"));<br/>
+ *		audioFile.getTag().setGenre("Progressive Rock");<br/>
+ *		audioFile.commit(); //Write the modifications in the file on disk.<br/>
+ *	</code>
+ * </p>
+ * 
+ * @author Raphael Slinckx ; Nicolas Velin
+ * @version $Id: AudioFileIO.java,v 1.1 2007/03/23 14:16:55 nicov1 Exp $
+ * @since v0.01
+ * @see AudioFile
+ * @see Tag
+ */
+public class AudioFileIO {
+	// !! Do not forget to also add new supported extensions to AudioFileFilter
+	// !!
+
+	/**
+	 * This field contains the default instance for static use.
+	 */
+	private static AudioFileIO defaultInstance;
+
+	/**
+	 * <p>
+	 * Delete the tag, if any, contained in the given file.
+	 * </p>
+	 * 
+	 * @param f
+	 *            The file where the tag will be deleted
+	 * @exception CannotWriteException
+	 *                If the file could not be written/accessed, the extension
+	 *                wasn't recognized, or other IO error occured.
+	 */
+	public static void delete(AudioFile f) throws CannotWriteException {
+		getDefaultAudioFileIO().deleteTag(f);
+	}
+
+	/**
+	 * This method returns the default isntance for static use.<br>
+	 * 
+	 * @return The default instance.
+	 */
+	public static AudioFileIO getDefaultAudioFileIO() {
+		if (defaultInstance == null) {
+			defaultInstance = new AudioFileIO();
+		}
+		return defaultInstance;
+	}
+
+	/**
+	 * <p>
+	 * Read the tag contained in the given file.
+	 * </p>
+	 * 
+	 * @param f
+	 *            The file to read.
+	 * @return The AudioFile with the file tag and the file encoding infos.
+	 * @exception CannotReadException
+	 *                If the file could not be read, the extension wasn't
+	 *                recognized, or an IO error occured during the read.
+	 */
+	public static AudioFile read(File f) throws CannotReadException {
+		return getDefaultAudioFileIO().readFile(f);
+	}
+
+	/**
+	 * <p>
+	 * Write the tag contained in the audiofile in the actual file on the disk.
+	 * </p>
+	 * 
+	 * @param f
+	 *            The AudioFile to be written
+	 * @exception CannotWriteException
+	 *                If the file could not be written/accessed, the extension
+	 *                wasn't recognized, or other IO error occured.
+	 */
+	public static void write(AudioFile f) throws CannotWriteException {
+	        //f.setID(miage.sgbd.DataProvider.getFichierID(f));
+		getDefaultAudioFileIO().writeFile(f);
+		//miage.sgbd.DataProvider.modifierFichier(f);
+	}
+
+	/**
+	 * This member is used to broadcast modification events to registered
+	 * {@link entagged.audioformats.generic.AudioFileModificationListener}
+	 */
+	private final ModificationHandler modificationHandler;
+
+	// These tables contains all the readers/writers associated with extension
+	// as a key
+	private Hashtable readers = new Hashtable();
+
+	private Hashtable writers = new Hashtable();
+
+	/**
+	 * Creates an instance.
+	 * 
+	 */
+	public AudioFileIO() {
+		this.modificationHandler = new ModificationHandler();
+		prepareReadersAndWriters();
+	}
+
+	/**
+	 * Adds an listener for all file formats.
+	 * 
+	 * @param listener
+	 *            listener
+	 */
+	public void addAudioFileModificationListener(
+			AudioFileModificationListener listener) {
+		this.modificationHandler.addAudioFileModificationListener(listener);
+	}
+
+	/**
+	 * <p>
+	 * Delete the tag, if any, contained in the given file.
+	 * </p>
+	 * 
+	 * @param f
+	 *            The file where the tag will be deleted
+	 * @exception CannotWriteException
+	 *                If the file could not be written/accessed, the extension
+	 *                wasn't recognized, or other IO error occured.
+	 */
+	public void deleteTag(AudioFile f) throws CannotWriteException {
+		String ext = Utils.getExtension(f);
+
+		Object afw = writers.get(ext);
+		if (afw == null)
+			throw new CannotWriteException(
+					"No Deleter associated to this extension: " + ext);
+
+		((AudioFileWriter) afw).delete(f);
+	}
+
+	/**
+	 * Creates the readers and writers.
+	 */
+	private void prepareReadersAndWriters() {
+		// Tag Readers
+		readers.put("mp3", new Mp3FileReader());
+		readers.put("ogg", new OggFileReader());
+		readers.put("flac", new FlacFileReader());
+		readers.put("wav", new WavFileReader());
+		readers.put("mpc", new MpcFileReader());
+		readers.put("mp+", readers.get("mpc"));
+		readers.put("ape", new MonkeyFileReader());
+		readers.put("wma", new AsfFileReader());
+
+		// Tag Writers
+		writers.put("mp3", new Mp3FileWriter());
+		writers.put("ogg", new OggFileWriter());
+		writers.put("flac", new FlacFileWriter());
+		writers.put("wav", new WavFileWriter());
+		writers.put("mpc", new MpcFileWriter());
+		writers.put("mp+", writers.get("mpc"));
+		writers.put("ape", new MonkeyFileWriter());
+		writers.put("wma", new AsfFileWriter());
+
+		// Register modificationHandler
+		Iterator it = writers.values().iterator();
+		while (it.hasNext()) {
+			AudioFileWriter curr = (AudioFileWriter) it.next();
+			curr.setAudioFileModificationListener(this.modificationHandler);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Read the tag contained in the given file.
+	 * </p>
+	 * 
+	 * @param f
+	 *            The file to read.
+	 * @return The AudioFile with the file tag and the file encoding infos.
+	 * @exception CannotReadException
+	 *                If the file could not be read, the extension wasn't
+	 *                recognized, or an IO error occured during the read.
+	 */
+	public AudioFile readFile(File f) throws CannotReadException {
+		String ext = Utils.getExtension(f);
+
+		Object afr = readers.get(ext);
+		if (afr == null)
+			throw new CannotReadException(
+					"No Reader associated to this extension: " + ext);
+
+		return ((AudioFileReader) afr).read(f);
+	}
+
+	/**
+	 * Removes an listener for all file formats.
+	 * 
+	 * @param listener
+	 *            listener
+	 */
+	public void removeAudioFileModificationListener(
+			AudioFileModificationListener listener) {
+		this.modificationHandler.removeAudioFileModificationListener(listener);
+	}
+
+	/**
+	 * <p>
+	 * Write the tag contained in the audiofile in the actual file on the disk.
+	 * </p>
+	 * 
+	 * @param f
+	 *            The AudioFile to be written
+	 * @exception CannotWriteException
+	 *                If the file could not be written/accessed, the extension
+	 *                wasn't recognized, or other IO error occured.
+	 */
+	public void writeFile(AudioFile f) throws CannotWriteException {
+		String ext = Utils.getExtension(f);
+
+		Object afw = writers.get(ext);
+		if (afw == null)
+			throw new CannotWriteException(
+					"No Writer associated to this extension: " + ext);
+
+		((AudioFileWriter) afw).write(f);
+	}
+}


Property changes on: trunk/entagged/entagged/audioformats/AudioFileIO.java
___________________________________________________________________
Name: svn:executable
   + 




More information about the pkg-java-commits mailing list