harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r440297 - in /incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java: javax/sound/midi/ org/apache/harmony/sound/internal/nls/
Date Tue, 05 Sep 2006 08:48:42 GMT
Author: mloenko
Date: Tue Sep  5 01:48:41 2006
New Revision: 440297

URL: http://svn.apache.org/viewvc?view=rev&rev=440297
Log:
applied patch for HARMONY-1334
[classlib][internationalization]Internationalization of the sound module
with minor fixes

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MetaMessage.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiMessage.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequence.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequencer.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/ShortMessage.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/SysexMessage.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Track.java
    incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MetaMessage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MetaMessage.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MetaMessage.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MetaMessage.java
Tue Sep  5 01:48:41 2006
@@ -16,6 +16,8 @@
 
 package javax.sound.midi;
 
+import org.apache.harmony.sound.internal.nls.Messages;
+
 public class MetaMessage extends MidiMessage {
     public static final int META = 255;
     
@@ -58,7 +60,7 @@
 
     public int getType() {
         if ((super.data != null) && (super.length >= 2)) {
-            return (int) (super.data[1] & 0xFF);
+            return super.data[1] & 0xFF;
         } else {
             return 0;
         }
@@ -66,10 +68,12 @@
 
     public void setMessage(int type, byte[] data, int length) throws InvalidMidiDataException
{
         if (type < 0 || type >= 128) {
-            throw new InvalidMidiDataException("Invalid meta event with type " + type);
+            // sound.0A=Invalid meta event with type {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.0A", type)); //$NON-NLS-1$
         }
         if (length < 0 || (data != null && length > data.length)) {
-            throw new InvalidMidiDataException("length out of bounds: " + length);
+            // sound.03=length out of bounds: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.03", length)); //$NON-NLS-1$
         }
         try {
             if (data == null) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiMessage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiMessage.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiMessage.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/MidiMessage.java
Tue Sep  5 01:48:41 2006
@@ -16,6 +16,8 @@
 
 package javax.sound.midi;
 
+import org.apache.harmony.sound.internal.nls.Messages;
+
 public abstract class MidiMessage implements Cloneable {
 
     protected byte[] data;
@@ -48,13 +50,14 @@
         if ((data == null) || (length == 0)) {
             return 0;
         } else {
-            return (int) (data[0] & 0xFF);
+            return data[0] & 0xFF;
         }
     }
 
     protected void setMessage(byte[] data, int length) throws InvalidMidiDataException {
         if ((length < 0) || (length > data.length)) {
-            throw new IndexOutOfBoundsException("length out of bounds: " + length);
+            // sound.03=length out of bounds: {0}
+            throw new IndexOutOfBoundsException(Messages.getString("sound.03", length));
//$NON-NLS-1$
         }
 
         this.data = new byte[length];

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequence.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequence.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequence.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequence.java
Tue Sep  5 01:48:41 2006
@@ -18,6 +18,8 @@
 
 import java.util.Vector;
 
+import org.apache.harmony.sound.internal.nls.Messages;
+
 public class Sequence {
     public static final float PPQ = 0.0f;
 
@@ -43,7 +45,8 @@
                 divisionType != Sequence.SMPTE_25 &&
                 divisionType != Sequence.SMPTE_30 &&
                 divisionType != Sequence.SMPTE_30DROP ) {
-            throw new InvalidMidiDataException("Unsupported division type: " + divisionType);
     
+            // sound.0B=Unsupported division type: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.0B", divisionType));
      //$NON-NLS-1$
         }
         this.divisionType = divisionType;
         this.resolution = resolution;
@@ -59,7 +62,8 @@
                 divisionType != Sequence.SMPTE_25 &&
                 divisionType != Sequence.SMPTE_30 &&
                 divisionType != Sequence.SMPTE_30DROP ) {
-            throw new InvalidMidiDataException("Unsupported division type: " + divisionType);
     
+            // sound.0B=Unsupported division type: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.0B", divisionType));
      //$NON-NLS-1$
         }
         this.divisionType = divisionType;
         this.resolution = resolution;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequencer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequencer.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequencer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Sequencer.java
Tue Sep  5 01:48:41 2006
@@ -23,13 +23,13 @@
     int LOOP_CONTINUOUSLY = -1;
 
     class SyncMode {
-        public static final SyncMode INTERNAL_CLOCK = new SyncMode("INTERNAL_CLOCK");
+        public static final SyncMode INTERNAL_CLOCK = new SyncMode("INTERNAL_CLOCK"); //$NON-NLS-1$
 
-        public static final SyncMode MIDI_SYNC = new SyncMode("MIDI_SYNC");
+        public static final SyncMode MIDI_SYNC = new SyncMode("MIDI_SYNC"); //$NON-NLS-1$
 
-        public static final SyncMode MIDI_TIME_CODE = new SyncMode("MIDI_TIME_CODE");
+        public static final SyncMode MIDI_TIME_CODE = new SyncMode("MIDI_TIME_CODE"); //$NON-NLS-1$
 
-        public static final SyncMode NO_SYNC = new SyncMode("NO_SYNC");
+        public static final SyncMode NO_SYNC = new SyncMode("NO_SYNC"); //$NON-NLS-1$
 
         private String name;
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/ShortMessage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/ShortMessage.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/ShortMessage.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/ShortMessage.java
Tue Sep  5 01:48:41 2006
@@ -16,6 +16,8 @@
 
 package javax.sound.midi;
 
+import org.apache.harmony.sound.internal.nls.Messages;
+
 public class ShortMessage extends MidiMessage {
 
     public static final int ACTIVE_SENSING = 254;
@@ -73,7 +75,7 @@
         if ((data == null) || (data.length == 0)) {
             return 0;
         } else {
-            return ((int) (data[0] & 0xFF)) % 16;
+            return data[0] & 0x0F;
         }
     }
 
@@ -84,7 +86,7 @@
         if ((data == null) || (data.length == 0)) {
             return 0;
         } else {
-            return ((int) (data[0] & 0xFF)) - getChannel();
+            return (data[0] & 0xFF) - getChannel();
         }
     }
 
@@ -94,7 +96,7 @@
         } else if (data.length < 2) {
             return 0;
         } else {
-            return (int) (data[1] & 0xFF);
+            return data[1] & 0xFF;
         }
     }
 
@@ -104,7 +106,7 @@
         } else if (data.length < 3) {
             return 0;
         } else {
-            return (int) (data[2] & 0xFF);
+            return data[2] & 0xFF;
         }
     }
 
@@ -130,18 +132,22 @@
          * - from 246 up to 255 -- return 0;
          */
         if (status < 0) {
-            throw new InvalidMidiDataException("Invalid status byte: " + status);
+            // sound.04=Invalid status byte: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.04", status)); //$NON-NLS-1$
         }
         if (((status % 256) >= 0) && ((status % 256) <= 127)) {
-            throw new InvalidMidiDataException("Invalid status byte: " + status);
+            // sound.04=Invalid status byte: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.04", status)); //$NON-NLS-1$
         }
         if (((status / 256) == 0)
                 && ((status == 240) || (status == 244) || (status == 245))) {
-            throw new InvalidMidiDataException("Invalid status byte: " + status);
+            // sound.04=Invalid status byte: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.04", status)); //$NON-NLS-1$
         }
         if (((status / 256) != 0) && ((status % 256) >= 244)
                 && ((status % 256) <= 255)) {
-            throw new InvalidMidiDataException("Invalid status byte: " + status);
+            // sound.04=Invalid status byte: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.04", status)); //$NON-NLS-1$
         }
 
         if ((status / 256) == 0) {
@@ -167,7 +173,8 @@
          * value of variable status is more or equals 246 and less or equals 255
          */
         if ((status < 246) || (status > 255)) {
-            throw new InvalidMidiDataException("Invalid status byte: " + status);
+            // sound.04=Invalid status byte: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.04", status)); //$NON-NLS-1$
         }
         super.setMessage(new byte[] {(byte) status}, 1);
     }
@@ -183,7 +190,8 @@
          * it's true.
          */
         if ((status < 246) || (status > 255)) {
-            throw new InvalidMidiDataException("Invalid status byte: " + status);
+            // sound.04=Invalid status byte: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.04", status)); //$NON-NLS-1$
         }
         super.setMessage(new byte[] {(byte) status}, 1);
     }
@@ -200,13 +208,15 @@
              * when this exception throw out, the value of variable command
              * should be the hexadecimal number
              */
-            throw new InvalidMidiDataException("command out of range: " + command);
+            // sound.05=command out of range: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.05", command));
//$NON-NLS-1$
         }
         /*
          * value of variable channel is more or equals 0 and less or equals 15
          */
         if ((channel < 0) || (channel > 15)) {
-            throw new InvalidMidiDataException("channel out of range: " + channel);
+            // sound.06=channel out of range: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.06", channel));
//$NON-NLS-1$
         }
         /*
          * value of data1 and data2 is more or equals 0 and less or equals 127,
@@ -215,10 +225,12 @@
          * case, and in other cases it return 2
          */
         if ((getDataLength(command) >= 1) && ((data1 < 0) || (data1 > 127)))
{
-            throw new InvalidMidiDataException("data1 out of range: " + data1);
+            // sound.07=data1 out of range: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.07", data1)); //$NON-NLS-1$
         }
         if ((getDataLength(command) == 2) && ((data2 < 0) || (data2 > 127)))
{
-            throw new InvalidMidiDataException("data2 out of range: " + data2);
+            // sound.08=data2 out of range: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.08", data2)); //$NON-NLS-1$
         }
 
         int tcom = command - (command % 16);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/SysexMessage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/SysexMessage.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/SysexMessage.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/SysexMessage.java
Tue Sep  5 01:48:41 2006
@@ -16,6 +16,8 @@
 
 package javax.sound.midi;
 
+import org.apache.harmony.sound.internal.nls.Messages;
+
 public class SysexMessage extends MidiMessage {
     public static final int SPECIAL_SYSTEM_EXCLUSIVE = 247;
 
@@ -47,10 +49,11 @@
          * if this exception throw out, the value of wrong status byte
          * should be the hexadecimal value
          */
-        if((((int) (data[0] & 0xFF)) != SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE) &&
-                (((int) (data[0] & 0xFF)) != SysexMessage.SYSTEM_EXCLUSIVE)) {
-            throw new InvalidMidiDataException("Invalid status byte for sysex message: "
+ 
-                    (int) (data[0] & 0xFF));
+        if(((data[0] & 0xFF) != SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE) &&
+                ((data[0] & 0xFF) != SysexMessage.SYSTEM_EXCLUSIVE)) {
+            // sound.09=Invalid status byte for sysex message: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.09",  //$NON-NLS-1$
+                    data[0] & 0xFF));
         }
         super.setMessage(data, length);
     }
@@ -63,11 +66,13 @@
          */
         if((status != SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE) &&
                 (status != SysexMessage.SYSTEM_EXCLUSIVE)) {
-            throw new InvalidMidiDataException("Invalid status byte for sysex message: "
+ 
-                    status);
+            // sound.09=Invalid status byte for sysex message: {0}
+            throw new InvalidMidiDataException(Messages.getString("sound.09",  //$NON-NLS-1$
+                    status));
         }
         if((length < 0) || (length > data.length)) {
-            throw new IndexOutOfBoundsException("length out of bounds: " + length);
+            // sound.03=length out of bounds: {0}
+            throw new IndexOutOfBoundsException(Messages.getString("sound.03", length));
//$NON-NLS-1$
         }
         byte[] bt = new byte[length + 1];
         bt[0] = (byte) status;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Track.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Track.java?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Track.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/javax/sound/midi/Track.java
Tue Sep  5 01:48:41 2006
@@ -18,6 +18,8 @@
 
 import java.util.ArrayList;
 
+import org.apache.harmony.sound.internal.nls.Messages;
+
 public class Track {
     private ArrayList<MidiEvent> events; //vector of events contain in the Track
     
@@ -88,7 +90,8 @@
         if (events.size() == 0) {
             events.add(new MidiEvent(new MetaMessage(new byte[] {-1, 47, 0}), 0));
             badEvent = event;
-            throw new ArrayIndexOutOfBoundsException("-1");
+            // sounds.01=-1
+            throw new ArrayIndexOutOfBoundsException(Messages.getString("sound.01")); //$NON-NLS-1$
         } else {
             byte[] bt = events.get(events.size() - 1).getMessage().getMessage();
             if ((bt[0] != -1) && (bt[1] != 47) && (bt[2] != 0)) {
@@ -126,8 +129,8 @@
 
     public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException {
         if (index < 0 || index >= events.size()) {
-            throw new ArrayIndexOutOfBoundsException("Index: " + index + ", Size: " + 
-                    events.size());
+            // sound.02=Index: {0}, Size: {1}
+            throw new ArrayIndexOutOfBoundsException(Messages.getString("sound.02", index,
events.size()));  //$NON-NLS-1$
         }
         return events.get(index);
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties?view=diff&rev=440297&r1=440296&r2=440297
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties
Tue Sep  5 01:48:41 2006
@@ -14,3 +14,14 @@
 # 
 
 # messages for EN locale
+sound.01=-1
+sound.02=Index: {0}, Size: {1}
+sound.03=length out of bounds: {0}
+sound.04=Invalid status byte: {0}
+sound.05=command out of range: {0}
+sound.06=channel out of range: {0}
+sound.07=data1 out of range: {0}
+sound.08=data2 out of range: {0}
+sound.09=Invalid status byte for sysex message: {0}
+sound.0A=Invalid meta event with type {0}
+sound.0B=Unsupported division type: {0}



Mime
View raw message