harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r436746 - in /incubator/harmony/enhanced/classlib/trunk/modules/sound: META-INF/ make/ src/main/java/javax/sound/midi/ src/main/java/javax/sound/midi/spi/ src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/
Date Fri, 25 Aug 2006 10:15:02 GMT
Author: mloenko
Date: Fri Aug 25 03:14:59 2006
New Revision: 436746

URL: http://svn.apache.org/viewvc?rev=436746&view=rev
Log:
some new simple classes in sound module

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiDeviceProvider.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileReader.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileWriter.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/SoundbankReader.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiDeviceProviderTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiFileWriterTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/sound/META-INF/MANIFEST.MF
    incubator/harmony/enhanced/classlib/trunk/modules/sound/make/patternset.txt
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiDevice.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/META-INF/MANIFEST.MF?rev=436746&r1=436745&r2=436746&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/META-INF/MANIFEST.MF (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/META-INF/MANIFEST.MF Fri Aug 25
03:14:59 2006
@@ -9,4 +9,5 @@
  java.util,
  java.io,
  java.net
-Export-Package: javax.sound.midi
+Export-Package: javax.sound.midi,
+ javax.sound.midi.spi

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/make/patternset.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/make/patternset.txt?rev=436746&r1=436745&r2=436746&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/make/patternset.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/make/patternset.txt Fri Aug 25
03:14:59 2006
@@ -12,4 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
  
-javax/sound/midi/*
+javax/sound/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiDevice.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiDevice.java?rev=436746&r1=436745&r2=436746&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiDevice.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiDevice.java
Fri Aug 25 03:14:59 2006
@@ -35,35 +35,13 @@
             this.version = version;
         }
 
+        /*
+         * returns true when objects are the same
+         * 
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
         public final boolean equals(Object obj) {
-            if (this == obj)
-                return true;
-            if (!super.equals(obj))
-                return false;
-            if (getClass() != obj.getClass())
-                return false;
-            final Info other = (Info) obj;
-            if (description == null) {
-                if (other.description != null)
-                    return false;
-            } else if (!description.equals(other.description))
-                return false;
-            if (name == null) {
-                if (other.name != null)
-                    return false;
-            } else if (!name.equals(other.name))
-                return false;
-            if (vendor == null) {
-                if (other.vendor != null)
-                    return false;
-            } else if (!vendor.equals(other.vendor))
-                return false;
-            if (version == null) {
-                if (other.version != null)
-                    return false;
-            } else if (!version.equals(other.version))
-                return false;
-            return true;
+            return this == obj;
         }
 
         public final String getDescription() {

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiDeviceProvider.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiDeviceProvider.java?rev=436746&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiDeviceProvider.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiDeviceProvider.java
Fri Aug 25 03:14:59 2006
@@ -0,0 +1,36 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.sound.midi.spi;
+
+import javax.sound.midi.MidiDevice;
+
+public abstract class MidiDeviceProvider {
+
+    public abstract MidiDevice getDevice(MidiDevice.Info info);
+
+    public abstract MidiDevice.Info[] getDeviceInfo();
+
+    public boolean isDeviceSupported(MidiDevice.Info info) {
+        MidiDevice.Info[] devices = getDeviceInfo();
+        for (int i = 0; i < devices.length; i++) {
+            if (info.equals(devices[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileReader.java?rev=436746&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileReader.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileReader.java
Fri Aug 25 03:14:59 2006
@@ -0,0 +1,39 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.Sequence;
+
+public abstract class MidiFileReader {
+
+    public abstract MidiFileFormat getMidiFileFormat(File file);
+
+    public abstract MidiFileFormat getMidiFileFormat(InputStream stream);
+
+    public abstract MidiFileFormat getMidiFileFormat(URL url);
+
+    public abstract Sequence getSequence(File file);
+
+    public abstract Sequence getSequence(InputStream stream);
+
+    public abstract Sequence getSequence(URL url);
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileWriter.java?rev=436746&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileWriter.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/MidiFileWriter.java
Fri Aug 25 03:14:59 2006
@@ -0,0 +1,53 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.OutputStream;
+
+import javax.sound.midi.Sequence;
+
+public abstract class MidiFileWriter {
+
+    public abstract int[] getMidiFileTypes();
+
+    public abstract int[] getMidiFileTypes(Sequence sequence);
+
+    public boolean isFileTypeSupported(int fileType) {
+        int[] supported = getMidiFileTypes();
+        for (int i = 0; i < supported.length; i++) {
+            if (fileType == supported[i]) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean isFileTypeSupported(int fileType, Sequence sequence) {
+        int[] supported = getMidiFileTypes(sequence);
+        for (int i = 0; i < supported.length; i++) {
+            if (fileType == supported[i]) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public abstract int write(Sequence in, int fileType, File out);
+
+    public abstract int write(Sequence in, int fileType, OutputStream out);
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/SoundbankReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/SoundbankReader.java?rev=436746&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/SoundbankReader.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/spi/SoundbankReader.java
Fri Aug 25 03:14:59 2006
@@ -0,0 +1,32 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.Soundbank;
+
+public abstract class SoundbankReader {
+
+    public abstract Soundbank getSoundbank(File file);
+
+    public abstract Soundbank getSoundbank(InputStream stream);
+
+    public abstract Soundbank getSoundbank(URL url);
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiDeviceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiDeviceProviderTest.java?rev=436746&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiDeviceProviderTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiDeviceProviderTest.java
Fri Aug 25 03:14:59 2006
@@ -0,0 +1,62 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi.spi;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+import junit.framework.TestCase;
+
+public class MidiDeviceProviderTest extends TestCase {
+
+    static MidiDevice.Info[] recorded;
+
+    /**
+     * @tests javax.sound.midi.spi.MidiDeviceProvider#isDeviceSupported(MidiDevice.Info)
+     */
+    public void testIsDeviceSupported() {
+        MidiDeviceProvider myProvider = new MidiDeviceProvider() {
+
+            public MidiDevice getDevice(MidiDevice.Info info) {
+                fail("what are doing here?");
+                return null;
+            }
+
+            public MidiDevice.Info[] getDeviceInfo() {
+                return recorded;
+            }
+        };
+
+        recorded = new MidiDevice.Info[1];
+        recorded[0] = new MidiDevice.Info("1", "2", "3", "4") {};
+        assertTrue(myProvider.isDeviceSupported(recorded[0]));
+
+        MidiDevice.Info similar = new MidiDevice.Info("1", "2", "3", "4") {};
+        assertFalse(myProvider.isDeviceSupported(similar));
+
+        try {
+            myProvider.isDeviceSupported(null);
+            fail("NPE expected");
+        } catch (NullPointerException e) {}
+
+        recorded = null;
+        try {
+            myProvider.isDeviceSupported(similar);
+            fail("NPE expected");
+        } catch (NullPointerException e) {}
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiFileWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiFileWriterTest.java?rev=436746&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiFileWriterTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/spi/MidiFileWriterTest.java
Fri Aug 25 03:14:59 2006
@@ -0,0 +1,108 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.OutputStream;
+
+import javax.sound.midi.Sequence;
+import javax.sound.midi.spi.MidiFileWriter;
+
+import junit.framework.TestCase;
+
+public class MidiFileWriterTest extends TestCase {
+
+    static int[] recorded;
+
+    /**
+     * @tests javax.sound.midi.spi.MidiFileWriter#isFileTypeSupported(int)
+     */
+    public void testIsFileTypeSupported1() {
+        MidiFileWriter writer = new MidiFileWriter() {
+
+            public int[] getMidiFileTypes() {
+                return recorded;
+            }
+
+            public int[] getMidiFileTypes(Sequence sequence) {
+                fail("what are doing here?");
+                return null;
+            }
+
+            public int write(Sequence in, int fileType, File out) {
+                fail("what are doing here?");
+                return 0;
+            }
+
+            public int write(Sequence in, int fileType, OutputStream out) {
+                fail("what are doing here?");
+                return 0;
+            }
+        };
+
+        recorded = new int[1];
+        recorded[0] = 3;
+
+        assertTrue(writer.isFileTypeSupported(3));
+        assertFalse(writer.isFileTypeSupported(5));
+
+        recorded = null;
+        try {
+            writer.isFileTypeSupported(10);
+            fail("NPE expected");
+        } catch (NullPointerException e) {}
+    }
+
+    /**
+     * @tests javax.sound.midi.spi.MidiFileWriter#isFileTypeSupported(int,Sequence)
+     */
+    public void testIsFileTypeSupported2() {
+        MidiFileWriter writer = new MidiFileWriter() {
+
+            public int[] getMidiFileTypes() {
+                fail("what are doing here?");
+                return null;
+            }
+
+            public int[] getMidiFileTypes(Sequence sequence) {
+                return recorded;
+            }
+
+            public int write(Sequence in, int fileType, File out) {
+                fail("what are doing here?");
+                return 0;
+            }
+
+            public int write(Sequence in, int fileType, OutputStream out) {
+                fail("what are doing here?");
+                return 0;
+            }
+        };
+
+        recorded = new int[1];
+        recorded[0] = 3;
+
+        assertTrue(writer.isFileTypeSupported(3, null));
+        assertFalse(writer.isFileTypeSupported(5, null));
+
+        recorded = null;
+        try {
+            writer.isFileTypeSupported(10, null);
+            fail("NPE expected");
+        } catch (NullPointerException e) {}
+    }
+}



Mime
View raw message