--- /dev/null
+/* ByteArrayInputStream.java -- Read an array as a stream
+ Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+//package java.io;
+
+/**
+ * This class permits an array of bytes to be read as an input stream.
+ *
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class ByteArrayInputStream extends InputStream
+{
+ /**
+ * The array that contains the data supplied during read operations
+ */
+ protected byte[] buf;
+
+ /**
+ * The array index of the next byte to be read from the buffer
+ * <code>buf</code>
+ */
+ protected int pos;
+
+ /**
+ * The currently marked position in the stream. This defaults to 0, so a
+ * reset operation on the stream resets it to read from array index 0 in
+ * the buffer - even if the stream was initially created with an offset
+ * greater than 0
+ */
+ protected int mark;
+
+ /**
+ * This indicates the maximum number of bytes that can be read from this
+ * stream. It is the array index of the position after the last valid
+ * byte in the buffer <code>buf</code>
+ */
+ protected int count;
+
+ /**
+ * Create a new ByteArrayInputStream that will read bytes from the passed
+ * in byte array. This stream will read from the beginning to the end
+ * of the array. It is identical to calling an overloaded constructor
+ * as <code>ByteArrayInputStream(buf, 0, buf.length)</code>.
+ * <p>
+ * Note that this array is not copied. If its contents are changed
+ * while this stream is being read, those changes will be reflected in the
+ * bytes supplied to the reader. Please use caution in changing the
+ * contents of the buffer while this stream is open.
+ *
+ * @param buffer The byte array buffer this stream will read from.
+ */
+ public ByteArrayInputStream(byte[] buffer)
+ {
+ this(buffer, 0, buffer.length);
+ }
+
+ /**
+ * Create a new ByteArrayInputStream that will read bytes from the
+ * passed in byte array. This stream will read from position
+ * <code>offset</code> in the array for a length of
+ * <code>length</code> bytes past <code>offset</code>. If the
+ * stream is reset to a position before <code>offset</code> then
+ * more than <code>length</code> bytes can be read from the stream.
+ * The <code>length</code> value should be viewed as the array index
+ * one greater than the last position in the buffer to read.
+ * <p>
+ * Note that this array is not copied. If its contents are changed
+ * while this stream is being read, those changes will be reflected in the
+ * bytes supplied to the reader. Please use caution in changing the
+ * contents of the buffer while this stream is open.
+ *
+ * @param buffer The byte array buffer this stream will read from.
+ * @param offset The index into the buffer to start reading bytes from
+ * @param length The number of bytes to read from the buffer
+ */
+ public ByteArrayInputStream(byte[] buffer, int offset, int length)
+ {
+ if (offset < 0 || length < 0 || offset > buffer.length)
+ throw new IllegalArgumentException();
+
+ buf = buffer;
+
+ count = offset + length;
+ if (count > buf.length)
+ count = buf.length;
+
+ pos = offset;
+ mark = pos;
+ }
+
+ /**
+ * This method returns the number of bytes available to be read from this
+ * stream. The value returned will be equal to <code>count - pos</code>.
+ *
+ * @return The number of bytes that can be read from this stream
+ * before blocking, which is all of them
+ */
+ public synchronized int available()
+ {
+ return count - pos;
+ }
+
+ /**
+ * This method sets the mark position in this stream to the current
+ * position. Note that the <code>readlimit</code> parameter in this
+ * method does nothing as this stream is always capable of
+ * remembering all the bytes int it.
+ * <p>
+ * Note that in this class the mark position is set by default to
+ * position 0 in the stream. This is in constrast to some other
+ * stream types where there is no default mark position.
+ *
+ * @param readLimit The number of bytes this stream must remember.
+ * This parameter is ignored.
+ */
+ public synchronized void mark(int readLimit)
+ {
+ // readLimit is ignored per Java Class Lib. book, p.220.
+ mark = pos;
+ }
+
+ /**
+ * This method overrides the <code>markSupported</code> method in
+ * <code>InputStream</code> in order to return <code>true</code> -
+ * indicating that this stream class supports mark/reset
+ * functionality.
+ *
+ * @return <code>true</code> to indicate that this class supports
+ * mark/reset.
+ */
+ public boolean markSupported()
+ {
+ return true;
+ }
+
+ /**
+ * This method reads one byte from the stream. The <code>pos</code>
+ * counter is advanced to the next byte to be read. The byte read is
+ * returned as an int in the range of 0-255. If the stream position
+ * is already at the end of the buffer, no byte is read and a -1 is
+ * returned in order to indicate the end of the stream.
+ *
+ * @return The byte read, or -1 if end of stream
+ */
+ public synchronized int read()
+ {
+ if (pos < count)
+ return ((int) buf[pos++]) & 0xFF;
+ return -1;
+ }
+
+ /**
+ * This method reads bytes from the stream and stores them into a
+ * caller supplied buffer. It starts storing the data at index
+ * <code>offset</code> into the buffer and attempts to read
+ * <code>len</code> bytes. This method can return before reading
+ * the number of bytes requested if the end of the stream is
+ * encountered first. The actual number of bytes read is returned.
+ * If no bytes can be read because the stream is already at the end
+ * of stream position, a -1 is returned.
+ * <p>
+ * This method does not block.
+ *
+ * @param buffer The array into which the bytes read should be stored.
+ * @param offset The offset into the array to start storing bytes
+ * @param length The requested number of bytes to read
+ *
+ * @return The actual number of bytes read, or -1 if end of stream.
+ */
+ public synchronized int read(byte[] buffer, int offset, int length)
+ {
+ if (pos >= count)
+ return -1;
+
+ int numBytes = Math.min(count - pos, length);
+ System.arraycopy(buf, pos, buffer, offset, numBytes);
+ pos += numBytes;
+ return numBytes;
+ }
+
+ /**
+ * This method sets the read position in the stream to the mark
+ * point by setting the <code>pos</code> variable equal to the
+ * <code>mark</code> variable. Since a mark can be set anywhere in
+ * the array, the mark/reset methods int this class can be used to
+ * provide random search capabilities for this type of stream.
+ */
+ public synchronized void reset()
+ {
+ pos = mark;
+ }
+
+ /**
+ * This method attempts to skip the requested number of bytes in the
+ * input stream. It does this by advancing the <code>pos</code>
+ * value by the specified number of bytes. It this would exceed the
+ * length of the buffer, then only enough bytes are skipped to
+ * position the stream at the end of the buffer. The actual number
+ * of bytes skipped is returned.
+ *
+ * @param num The requested number of bytes to skip
+ *
+ * @return The actual number of bytes skipped.
+ */
+ public synchronized long skip(long num)
+ {
+ // Even though the var numBytes is a long, in reality it can never
+ // be larger than an int since the result of subtracting 2 positive
+ // ints will always fit in an int. Since we have to return a long
+ // anyway, numBytes might as well just be a long.
+ long numBytes = Math.min((long) (count - pos), num < 0 ? 0L : num);
+ pos += numBytes;
+ return numBytes;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* Cloneable.java -- Interface for marking objects cloneable by Object.clone()
+ Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+//package java.lang;
+
+/**
+ * This interface should be implemented by classes wishing to
+ * support of override <code>Object.clone()</code>. The default
+ * behaviour of <code>clone()</code> performs a shallow copy, but
+ * subclasses often change this to perform a deep copy. Therefore,
+ * it is a good idea to document how deep your clone will go.
+ * If <code>clone()</code> is called on an object which does not
+ * implement this interface, a <code>CloneNotSupportedException</code>
+ * will be thrown.
+ *
+ * <p>This interface is simply a tagging interface; it carries no
+ * requirements on methods to implement. However, it is typical for
+ * a Cloneable class to implement at least <code>equals</code>,
+ * <code>hashCode</code>, and <code>clone</code>, sometimes
+ * increasing the accessibility of clone to be public. The typical
+ * implementation of <code>clone</code> invokes <code>super.clone()</code>
+ * rather than a constructor, but this is not a requirement.
+ *
+ * <p>If an object that implement Cloneable should not be cloned,
+ * simply override the <code>clone</code> method to throw a
+ * <code>CloneNotSupportedException</code>.
+ *
+ * <p>All array types implement Cloneable, and have a public
+ * <code>clone</code> method that will never fail with a
+ * <code>CloneNotSupportedException</code>.
+ *
+ * @author Paul Fisher
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @see Object#clone()
+ * @see CloneNotSupportedException
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface Cloneable
+{
+ // Tagging interface only.
+}
--- /dev/null
+/* FileDescriptor.java -- Opaque file handle class
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+//package java.io;
+
+/*import gnu.java.nio.FileChannelImpl;
+
+ import java.nio.channels.ByteChannel;
+ import java.nio.channels.FileChannel;
+ */
+/**
+ * This class represents an opaque file handle as a Java class. It should
+ * be used only to pass to other methods that expect an object of this
+ * type. No system specific information can be obtained from this object.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ * @date September 24, 1998
+ */
+public final class FileDescriptor
+{
+ /**
+ * A <code>FileDescriptor</code> representing the system standard input
+ * stream. This will usually be accessed through the
+ * <code>System.in</code>variable.
+ */
+ public static final FileDescriptor in
+ = new FileDescriptor ("System.in" /*FileChannelImpl.in*/);
+
+ /**
+ * A <code>FileDescriptor</code> representing the system standard output
+ * stream. This will usually be accessed through the
+ * <code>System.out</code>variable.
+ */
+ public static final FileDescriptor out
+ = new FileDescriptor ("System.out" /*FileChannelImpl.out*/);
+
+ /**
+ * A <code>FileDescriptor</code> representing the system standard error
+ * stream. This will usually be accessed through the
+ * <code>System.err</code>variable.
+ */
+ public static final FileDescriptor err
+ = new FileDescriptor ("System.err" /*FileChannelImpl.err*/);
+
+ //final ByteChannel channel;
+ final String channel;
+
+ /**
+ * This method is used to initialize an invalid FileDescriptor object.
+ */
+ public FileDescriptor() {
+ channel = null;
+ }
+
+ /**
+ * This method is used to initialize a FileDescriptor object.
+ */
+ /*FileDescriptor(ByteChannel channel)
+ {
+ this.channel = channel;
+ }*/
+
+ FileDescriptor(String channel) {
+ this.channel = channel;
+ }
+
+
+ /**
+ * This method forces all data that has not yet been physically written to
+ * the underlying storage medium associated with this
+ * <code>FileDescriptor</code>
+ * to be written out. This method will not return until all data has
+ * been fully written to the underlying device. If the device does not
+ * support this functionality or if an error occurs, then an exception
+ * will be thrown.
+ */
+ /*public void sync () throws SyncFailedException
+ {
+ if (channel instanceof FileChannel)
+ {
+ try
+ {
+ ((FileChannel) channel).force(true);
+ }
+ catch (IOException ex)
+ {
+ if (ex instanceof SyncFailedException)
+ throw (SyncFailedException) ex;
+ else
+ throw new SyncFailedException(ex.toString());
+ }
+ }
+ }*/
+
+ /**
+ * This methods tests whether or not this object represents a valid open
+ * native file handle.
+ *
+ * @return <code>true</code> if this object represents a valid
+ * native file handle, <code>false</code> otherwise
+ */
+ /*public boolean valid ()
+ {
+ ByteChannel c = channel;
+ return (c != null) && (c.isOpen());
+ }*/
+}
--- /dev/null
+//import java.io.FileDescriptor;
+
+public class FileOutputStream extends OutputStream {
+ private int fd;
+
+ public FileOutputStream(String pathname) {
+ fd=nativeOpen(pathname.getBytes());
+ }
+
+ public FileOutputStream(String pathname, boolean append) {
+ if(append)
+ fd=nativeAppend(pathname.getBytes());
+ else
+ fd=nativeOpen(pathname.getBytes());
+ }
+
+ public FileOutputStream(String pathname, int mode) {
+ if(mode==0)
+ fd=nativeAppend(pathname.getBytes());
+ if(mode==1)
+ fd=nativeOpen(pathname.getBytes());
+ }
+
+ public FileOutputStream(File path) {
+ fd=nativeOpen(path.getPath().getBytes());
+ }
+
+ public FileOutputStreamOpen(String pathname) {
+ fd = nativeOpen(pathname.getBytes());
+ }
+
+ public FileOutputStream(FileDescriptor fdObj) {
+ fd = nativeOpen(fdObj.channel.getBytes());
+ }
+
+ private static native int nativeOpen(byte[] filename);
+ private static native int nativeAppend(byte[] filename);
+ private static native void nativeWrite(int fd, byte[] array, int off, int len);
+ private static native void nativeClose(int fd);
+ private static native void nativeFlush(int fd);
+
+ public void write(int ch) {
+ byte b[]=new byte[1];
+ b[0]=(byte)ch;
+ write(b);
+ }
+
+ public void write(byte[] b) {
+ nativeWrite(fd, b, 0, b.length);
+ }
+
+ public void write(byte[] b, int index, int len) {
+ nativeWrite(fd, b, index, len);
+ }
+
+ public void flush() {
+ nativeFlush(fd);
+ }
+
+ public void close() {
+ nativeClose(fd);
+ }
+}
--- /dev/null
+/* Float.java -- object wrapper for float
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+/**
+ * Instances of class <code>Float</code> represent primitive
+ * <code>float</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to floats.
+ *
+ * @author Paul Fisher
+ * @author Andrew Haley (aph@cygnus.com)
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.0
+ * @status partly updated to 1.5
+ */
+public final class Float
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -2671257302660747028L;
+
+ /**
+ * The maximum positive value a <code>double</code> may represent
+ * is 3.4028235e+38f.
+ */
+ public static final float MAX_VALUE = 3.4028235e+38f;
+
+ /**
+ * The minimum positive value a <code>float</code> may represent
+ * is 1.4e-45.
+ */
+ public static final float MIN_VALUE = 1.4e-45f;
+
+ /**
+ * The value of a float representation -1.0/0.0, negative infinity.
+ */
+ public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
+
+ /**
+ * The value of a float representation 1.0/0.0, positive infinity.
+ */
+ public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
+
+ /**
+ * All IEEE 754 values of NaN have the same value in Java.
+ */
+ public static final float NaN = 0.0f / 0.0f;
+
+ /**
+ * The primitive type <code>float</code> is represented by this
+ * <code>Class</code> object.
+ * @since 1.1
+ */
+ //public static final Class<Float> TYPE = (Class<Float>) VMClassLoader.getPrimitiveClass('F');
+
+ /**
+ * The number of bits needed to represent a <code>float</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 32;
+
+ /**
+ * Cache representation of 0
+ */
+ private static final Float ZERO = new Float(0.0f);
+
+ /**
+ * Cache representation of 1
+ */
+ private static final Float ONE = new Float(1.0f);
+
+ /**
+ * The immutable value of this Float.
+ *
+ * @serial the wrapped float
+ */
+ private final float value;
+
+ /**
+ * Create a <code>Float</code> from the primitive <code>float</code>
+ * specified.
+ *
+ * @param value the <code>float</code> argument
+ */
+ public Float(float value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * Create a <code>Float</code> from the primitive <code>double</code>
+ * specified.
+ *
+ * @param value the <code>double</code> argument
+ */
+ public Float(double value)
+ {
+ this.value = (float) value;
+ }
+
+ /**
+ * Create a <code>Float</code> from the specified <code>String</code>.
+ * This method calls <code>Float.parseFloat()</code>.
+ *
+ * @param s the <code>String</code> to convert
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>float</code>
+ * @throws NullPointerException if <code>s</code> is null
+ * @see #parseFloat(String)
+ */
+ public Float(String s)
+ {
+ value = parseFloat(s);
+ }
+
+ /**
+ * Convert the <code>float</code> to a <code>String</code>.
+ * Floating-point string representation is fairly complex: here is a
+ * rundown of the possible values. "<code>[-]</code>" indicates that a
+ * negative sign will be printed if the value (or exponent) is negative.
+ * "<code><number></code>" means a string of digits ('0' to '9').
+ * "<code><digit></code>" means a single digit ('0' to '9').<br>
+ *
+ * <table border=1>
+ * <tr><th>Value of Float</th><th>String Representation</th></tr>
+ * <tr><td>[+-] 0</td> <td><code>[-]0.0</code></td></tr>
+ * <tr><td>Between [+-] 10<sup>-3</sup> and 10<sup>7</sup>, exclusive</td>
+ * <td><code>[-]number.number</code></td></tr>
+ * <tr><td>Other numeric value</td>
+ * <td><code>[-]<digit>.<number>
+ * E[-]<number></code></td></tr>
+ * <tr><td>[+-] infinity</td> <td><code>[-]Infinity</code></td></tr>
+ * <tr><td>NaN</td> <td><code>NaN</code></td></tr>
+ * </table>
+ *
+ * Yes, negative zero <em>is</em> a possible value. Note that there is
+ * <em>always</em> a <code>.</code> and at least one digit printed after
+ * it: even if the number is 3, it will be printed as <code>3.0</code>.
+ * After the ".", all digits will be printed except trailing zeros. The
+ * result is rounded to the shortest decimal number which will parse back
+ * to the same float.
+ *
+ * <p>To create other output formats, use {@link java.text.NumberFormat}.
+ *
+ * @XXX specify where we are not in accord with the spec.
+ *
+ * @param f the <code>float</code> to convert
+ * @return the <code>String</code> representing the <code>float</code>
+ */
+ /*public static String toString(float f)
+ {
+ return VMFloat.toString(f);
+ }*/
+
+ /**
+ * Convert a float value to a hexadecimal string. This converts as
+ * follows:
+ * <ul>
+ * <li> A NaN value is converted to the string "NaN".
+ * <li> Positive infinity is converted to the string "Infinity".
+ * <li> Negative infinity is converted to the string "-Infinity".
+ * <li> For all other values, the first character of the result is '-'
+ * if the value is negative. This is followed by '0x1.' if the
+ * value is normal, and '0x0.' if the value is denormal. This is
+ * then followed by a (lower-case) hexadecimal representation of the
+ * mantissa, with leading zeros as required for denormal values.
+ * The next character is a 'p', and this is followed by a decimal
+ * representation of the unbiased exponent.
+ * </ul>
+ * @param f the float value
+ * @return the hexadecimal string representation
+ * @since 1.5
+ */
+ /*public static String toHexString(float f)
+ {
+ if (isNaN(f))
+ return "NaN";
+ if (isInfinite(f))
+ return f < 0 ? "-Infinity" : "Infinity";
+
+ int bits = floatToIntBits(f);
+ CPStringBuilder result = new CPStringBuilder();
+
+ if (bits < 0)
+ result.append('-');
+ result.append("0x");
+
+ final int mantissaBits = 23;
+ final int exponentBits = 8;
+ int mantMask = (1 << mantissaBits) - 1;
+ int mantissa = bits & mantMask;
+ int expMask = (1 << exponentBits) - 1;
+ int exponent = (bits >>> mantissaBits) & expMask;
+
+ result.append(exponent == 0 ? '0' : '1');
+ result.append('.');
+ // For Float only, we have to adjust the mantissa.
+ mantissa <<= 1;
+ result.append(Integer.toHexString(mantissa));
+ if (exponent == 0 && mantissa != 0)
+ {
+ // Treat denormal specially by inserting '0's to make
+ // the length come out right. The constants here are
+ // to account for things like the '0x'.
+ int offset = 4 + ((bits < 0) ? 1 : 0);
+ // The silly +3 is here to keep the code the same between
+ // the Float and Double cases. In Float the value is
+ // not a multiple of 4.
+ int desiredLength = offset + (mantissaBits + 3) / 4;
+ while (result.length() < desiredLength)
+ result.insert(offset, '0');
+ }
+ result.append('p');
+ if (exponent == 0 && mantissa == 0)
+ {
+ // Zero, so do nothing special.
+ }
+ else
+ {
+ // Apply bias.
+ boolean denormal = exponent == 0;
+ exponent -= (1 << (exponentBits - 1)) - 1;
+ // Handle denormal.
+ if (denormal)
+ ++exponent;
+ }
+
+ result.append(Integer.toString(exponent));
+ return result.toString();
+ }*/
+
+ /**
+ * Creates a new <code>Float</code> object using the <code>String</code>.
+ *
+ * @param s the <code>String</code> to convert
+ * @return the new <code>Float</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>float</code>
+ * @throws NullPointerException if <code>s</code> is null
+ * @see #parseFloat(String)
+ */
+ public static Float valueOf(String s)
+ {
+ return valueOf(parseFloat(s));
+ }
+
+ /**
+ * Returns a <code>Float</code> object wrapping the value.
+ * In contrast to the <code>Float</code> constructor, this method
+ * may cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Float</code>
+ * @since 1.5
+ */
+ public static Float valueOf(float val)
+ {
+ if ((val == 0.0)/* && (floatToRawIntBits(val) == 0)*/)
+ return ZERO;
+ else if (val == 1.0)
+ return ONE;
+ else
+ return new Float(val);
+ }
+
+ /**
+ * Parse the specified <code>String</code> as a <code>float</code>. The
+ * extended BNF grammar is as follows:<br>
+ * <pre>
+ * <em>DecodableString</em>:
+ * ( [ <code>-</code> | <code>+</code> ] <code>NaN</code> )
+ * | ( [ <code>-</code> | <code>+</code> ] <code>Infinity</code> )
+ * | ( [ <code>-</code> | <code>+</code> ] <em>FloatingPoint</em>
+ * [ <code>f</code> | <code>F</code> | <code>d</code>
+ * | <code>D</code>] )
+ * <em>FloatingPoint</em>:
+ * ( { <em>Digit</em> }+ [ <code>.</code> { <em>Digit</em> } ]
+ * [ <em>Exponent</em> ] )
+ * | ( <code>.</code> { <em>Digit</em> }+ [ <em>Exponent</em> ] )
+ * <em>Exponent</em>:
+ * ( ( <code>e</code> | <code>E</code> )
+ * [ <code>-</code> | <code>+</code> ] { <em>Digit</em> }+ )
+ * <em>Digit</em>: <em><code>'0'</code> through <code>'9'</code></em>
+ * </pre>
+ *
+ * <p>NaN and infinity are special cases, to allow parsing of the output
+ * of toString. Otherwise, the result is determined by calculating
+ * <em>n * 10<sup>exponent</sup></em> to infinite precision, then rounding
+ * to the nearest float. Remember that many numbers cannot be precisely
+ * represented in floating point. In case of overflow, infinity is used,
+ * and in case of underflow, signed zero is used. Unlike Integer.parseInt,
+ * this does not accept Unicode digits outside the ASCII range.
+ *
+ * <p>If an unexpected character is found in the <code>String</code>, a
+ * <code>NumberFormatException</code> will be thrown. Leading and trailing
+ * 'whitespace' is ignored via <code>String.trim()</code>, but spaces
+ * internal to the actual number are not allowed.
+ *
+ * <p>To parse numbers according to another format, consider using
+ * {@link java.text.NumberFormat}.
+ *
+ * @XXX specify where/how we are not in accord with the spec.
+ *
+ * @param str the <code>String</code> to convert
+ * @return the <code>float</code> value of <code>s</code>
+ * @throws NumberFormatException if <code>str</code> cannot be parsed as a
+ * <code>float</code>
+ * @throws NullPointerException if <code>str</code> is null
+ * @see #MIN_VALUE
+ * @see #MAX_VALUE
+ * @see #POSITIVE_INFINITY
+ * @see #NEGATIVE_INFINITY
+ * @since 1.2
+ */
+ public static float parseFloat(String str)
+ {
+ //return VMFloat.parseFloat(str);
+ return (float)(Long.parseLong(str));
+ }
+
+ /**
+ * Return <code>true</code> if the <code>float</code> has the same
+ * value as <code>NaN</code>, otherwise return <code>false</code>.
+ *
+ * @param v the <code>float</code> to compare
+ * @return whether the argument is <code>NaN</code>
+ */
+ public static boolean isNaN(float v)
+ {
+ // This works since NaN != NaN is the only reflexive inequality
+ // comparison which returns true.
+ return v != v;
+ }
+
+ /**
+ * Return <code>true</code> if the <code>float</code> has a value
+ * equal to either <code>NEGATIVE_INFINITY</code> or
+ * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+ *
+ * @param v the <code>float</code> to compare
+ * @return whether the argument is (-/+) infinity
+ */
+ public static boolean isInfinite(float v)
+ {
+ return v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY;
+ }
+
+ /**
+ * Return <code>true</code> if the value of this <code>Float</code>
+ * is the same as <code>NaN</code>, otherwise return <code>false</code>.
+ *
+ * @return whether this <code>Float</code> is <code>NaN</code>
+ */
+ public boolean isNaN()
+ {
+ return isNaN(value);
+ }
+
+ /**
+ * Return <code>true</code> if the value of this <code>Float</code>
+ * is the same as <code>NEGATIVE_INFINITY</code> or
+ * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+ *
+ * @return whether this <code>Float</code> is (-/+) infinity
+ */
+ public boolean isInfinite()
+ {
+ return isInfinite(value);
+ }
+
+ /**
+ * Convert the <code>float</code> value of this <code>Float</code>
+ * to a <code>String</code>. This method calls
+ * <code>Float.toString(float)</code> to do its dirty work.
+ *
+ * @return the <code>String</code> representation
+ * @see #toString(float)
+ */
+ /*public String toString()
+ {
+ return toString(value);
+ }*/
+
+ /**
+ * Return the value of this <code>Float</code> as a <code>byte</code>.
+ *
+ * @return the byte value
+ * @since 1.1
+ */
+ public byte byteValue()
+ {
+ return (byte) value;
+ }
+
+ /**
+ * Return the value of this <code>Float</code> as a <code>short</code>.
+ *
+ * @return the short value
+ * @since 1.1
+ */
+ public short shortValue()
+ {
+ return (short) value;
+ }
+
+ /**
+ * Return the value of this <code>Integer</code> as an <code>int</code>.
+ *
+ * @return the int value
+ */
+ public int intValue()
+ {
+ return (int) value;
+ }
+
+ /**
+ * Return the value of this <code>Integer</code> as a <code>long</code>.
+ *
+ * @return the long value
+ */
+ public long longValue()
+ {
+ return (long) value;
+ }
+
+ /**
+ * Return the value of this <code>Float</code>.
+ *
+ * @return the float value
+ */
+ public float floatValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Float</code> as a <code>double</code>
+ *
+ * @return the double value
+ */
+ public double doubleValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return a hashcode representing this Object. <code>Float</code>'s hash
+ * code is calculated by calling <code>floatToIntBits(floatValue())</code>.
+ *
+ * @return this Object's hash code
+ * @see #floatToIntBits(float)
+ */
+ /*public int hashCode()
+ {
+ return floatToIntBits(value);
+ }*/
+
+ /**
+ * Returns <code>true</code> if <code>obj</code> is an instance of
+ * <code>Float</code> and represents the same float value. Unlike comparing
+ * two floats with <code>==</code>, this treats two instances of
+ * <code>Float.NaN</code> as equal, but treats <code>0.0</code> and
+ * <code>-0.0</code> as unequal.
+ *
+ * <p>Note that <code>f1.equals(f2)</code> is identical to
+ * <code>floatToIntBits(f1.floatValue()) ==
+ * floatToIntBits(f2.floatValue())</code>.
+ *
+ * @param obj the object to compare
+ * @return whether the objects are semantically equal
+ */
+ /*public boolean equals(Object obj)
+ {
+ if (obj instanceof Float)
+ {
+ float f = ((Float) obj).value;
+ return (floatToRawIntBits(value) == floatToRawIntBits(f)) ||
+ (isNaN(value) && isNaN(f));
+ }
+ return false;
+ }*/
+
+ /**
+ * Convert the float to the IEEE 754 floating-point "single format" bit
+ * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+ * (masked by 0x7f800000) represent the exponent, and bits 22-0
+ * (masked by 0x007fffff) are the mantissa. This function collapses all
+ * versions of NaN to 0x7fc00000. The result of this function can be used
+ * as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the
+ * original <code>float</code> value.
+ *
+ * @param value the <code>float</code> to convert
+ * @return the bits of the <code>float</code>
+ * @see #intBitsToFloat(int)
+ */
+ /*public static int floatToIntBits(float value)
+ {
+ if (isNaN(value))
+ return 0x7fc00000;
+ else
+ return VMFloat.floatToRawIntBits(value);
+ }*/
+
+ /**
+ * Convert the float to the IEEE 754 floating-point "single format" bit
+ * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+ * (masked by 0x7f800000) represent the exponent, and bits 22-0
+ * (masked by 0x007fffff) are the mantissa. This function leaves NaN alone,
+ * rather than collapsing to a canonical value. The result of this function
+ * can be used as the argument to <code>Float.intBitsToFloat(int)</code> to
+ * obtain the original <code>float</code> value.
+ *
+ * @param value the <code>float</code> to convert
+ * @return the bits of the <code>float</code>
+ * @see #intBitsToFloat(int)
+ */
+ /*public static int floatToRawIntBits(float value)
+ {
+ return VMFloat.floatToRawIntBits(value);
+ }*/
+
+ /**
+ * Convert the argument in IEEE 754 floating-point "single format" bit
+ * layout to the corresponding float. Bit 31 (the most significant) is the
+ * sign bit, bits 30-23 (masked by 0x7f800000) represent the exponent, and
+ * bits 22-0 (masked by 0x007fffff) are the mantissa. This function leaves
+ * NaN alone, so that you can recover the bit pattern with
+ * <code>Float.floatToRawIntBits(float)</code>.
+ *
+ * @param bits the bits to convert
+ * @return the <code>float</code> represented by the bits
+ * @see #floatToIntBits(float)
+ * @see #floatToRawIntBits(float)
+ */
+ /*public static float intBitsToFloat(int bits)
+ {
+ return VMFloat.intBitsToFloat(bits);
+ }*/
+
+ /**
+ * Compare two Floats numerically by comparing their <code>float</code>
+ * values. The result is positive if the first is greater, negative if the
+ * second is greater, and 0 if the two are equal. However, this special
+ * cases NaN and signed zero as follows: NaN is considered greater than
+ * all other floats, including <code>POSITIVE_INFINITY</code>, and positive
+ * zero is considered greater than negative zero.
+ *
+ * @param f the Float to compare
+ * @return the comparison
+ * @since 1.2
+ */
+ /*public int compareTo(Float f)
+ {
+ return compare(value, f.value);
+ }*/
+
+ /**
+ * Behaves like <code>new Float(x).compareTo(new Float(y))</code>; in
+ * other words this compares two floats, special casing NaN and zero,
+ * without the overhead of objects.
+ *
+ * @param x the first float to compare
+ * @param y the second float to compare
+ * @return the comparison
+ * @since 1.4
+ */
+ /*public static int compare(float x, float y)
+ {
+ // handle the easy cases:
+ if (x < y)
+ return -1;
+ if (x > y)
+ return 1;
+
+ // handle equality respecting that 0.0 != -0.0 (hence not using x == y):
+ int ix = floatToRawIntBits(x);
+ int iy = floatToRawIntBits(y);
+ if (ix == iy)
+ return 0;
+
+ // handle NaNs:
+ if (x != x)
+ return (y != y) ? 0 : 1;
+ else if (y != y)
+ return -1;
+
+ // handle +/- 0.0
+ return (ix < iy) ? -1 : 1;
+ }*/
+}
public class Integer {
@LOC("V") private int value;
+
+ /**
+ * The maximum value an <code>int</code> can represent is 2147483647 (or
+ * 2<sup>31</sup> - 1).
+ */
+ public static final int MAX_VALUE = 0x7fffffff;
public Integer(int value) {
this.value = value;
--- /dev/null
+/* Long.java -- object wrapper for long
+ Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+/**
+ * Instances of class <code>Long</code> represent primitive
+ * <code>long</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to longs.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Warren Levy
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @author Ian Rogers
+ * @since 1.0
+ * @status updated to 1.5
+ */
+public final class Long //extends Number implements Comparable<Long>
+{
+ /**
+ * Compatible with JDK 1.0.2+.
+ */
+ private static final long serialVersionUID = 4290774380558885855L;
+
+ /**
+ * The minimum value a <code>long</code> can represent is
+ * -9223372036854775808L (or -2<sup>63</sup>).
+ */
+ public static final long MIN_VALUE = 0x8000000000000000L;
+
+ /**
+ * The maximum value a <code>long</code> can represent is
+ * 9223372036854775807 (or 2<sup>63</sup> - 1).
+ */
+ public static final long MAX_VALUE = 0x7fffffffffffffffL;
+
+ /**
+ * The primitive type <code>long</code> is represented by this
+ * <code>Class</code> object.
+ * @since 1.1
+ */
+ //public static final Class<Long> TYPE = (Class<Long>) VMClassLoader.getPrimitiveClass ('J');
+
+ /**
+ * The number of bits needed to represent a <code>long</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 64;
+
+ // This caches some Long values, and is used by boxing
+ // conversions via valueOf(). We cache at least -128..127;
+ // these constants control how much we actually cache.
+ private static final int MIN_CACHE = -128;
+ private static final int MAX_CACHE = 127;
+ private static final Long[] longCache = new Long[MAX_CACHE - MIN_CACHE + 1];
+ static
+ {
+ for (int i=MIN_CACHE; i <= MAX_CACHE; i++)
+ longCache[i - MIN_CACHE] = new Long(i);
+ }
+
+ /**
+ * The immutable value of this Long.
+ *
+ * @serial the wrapped long
+ */
+ private final long value;
+
+ /**
+ * Create a <code>Long</code> object representing the value of the
+ * <code>long</code> argument.
+ *
+ * @param value the value to use
+ */
+ public Long(long value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * Create a <code>Long</code> object representing the value of the
+ * argument after conversion to a <code>long</code>.
+ *
+ * @param s the string to convert
+ * @throws NumberFormatException if the String does not contain a long
+ * @see #valueOf(String)
+ */
+ public Long(String s)
+ {
+ value = parseLong(s, 10, false);
+ }
+
+ /**
+ * Return the size of a string large enough to hold the given number
+ *
+ * @param num the number we want the string length for (must be positive)
+ * @param radix the radix (base) that will be used for the string
+ * @return a size sufficient for a string of num
+ */
+ private static int stringSize(long num, int radix) {
+ int exp;
+ if (radix < 4)
+ {
+ exp = 1;
+ }
+ else if (radix < 8)
+ {
+ exp = 2;
+ }
+ else if (radix < 16)
+ {
+ exp = 3;
+ }
+ else if (radix < 32)
+ {
+ exp = 4;
+ }
+ else
+ {
+ exp = 5;
+ }
+ int size=0;
+ do
+ {
+ num >>>= exp;
+ size++;
+ }
+ while(num != 0);
+ return size;
+ }
+
+ /**
+ * Converts the <code>long</code> to a <code>String</code> using
+ * the specified radix (base). If the radix exceeds
+ * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10
+ * is used instead. If the result is negative, the leading character is
+ * '-' ('\\u002D'). The remaining characters come from
+ * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z').
+ *
+ * @param num the <code>long</code> to convert to <code>String</code>
+ * @param radix the radix (base) to use in the conversion
+ * @return the <code>String</code> representation of the argument
+ */
+ /*public static String toString(long num, int radix)
+ {
+ if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
+ radix = 10;
+
+ // Is the value negative?
+ boolean isNeg = num < 0;
+
+ // Is the string a single character?
+ if (!isNeg && num < radix)
+ return new String(digits, (int)num, 1, true);
+
+ // Compute string size and allocate buffer
+ // account for a leading '-' if the value is negative
+ int size;
+ int i;
+ char[] buffer;
+ if (isNeg)
+ {
+ num = -num;
+
+ // When the value is MIN_VALUE, it overflows when made positive
+ if (num < 0)
+ {
+ i = size = stringSize(MAX_VALUE, radix) + 2;
+ buffer = new char[size];
+ buffer[--i] = digits[(int) (-(num + radix) % radix)];
+ num = -(num / radix);
+ }
+ else
+ {
+ i = size = stringSize(num, radix) + 1;
+ buffer = new char[size];
+ }
+ }
+ else
+ {
+ i = size = stringSize(num, radix);
+ buffer = new char[size];
+ }
+
+ do
+ {
+ buffer[--i] = digits[(int) (num % radix)];
+ num /= radix;
+ }
+ while (num > 0);
+
+ if (isNeg)
+ buffer[--i] = '-';
+
+ // Package constructor avoids an array copy.
+ return new String(buffer, i, size - i, true);
+ }*/
+
+ /**
+ * Converts the <code>long</code> to a <code>String</code> assuming it is
+ * unsigned in base 16.
+ *
+ * @param l the <code>long</code> to convert to <code>String</code>
+ * @return the <code>String</code> representation of the argument
+ */
+ /*public static String toHexString(long l)
+ {
+ return toUnsignedString(l, 4);
+ }*/
+
+ /**
+ * Converts the <code>long</code> to a <code>String</code> assuming it is
+ * unsigned in base 8.
+ *
+ * @param l the <code>long</code> to convert to <code>String</code>
+ * @return the <code>String</code> representation of the argument
+ */
+ /*public static String toOctalString(long l)
+ {
+ return toUnsignedString(l, 3);
+ }*/
+
+ /**
+ * Converts the <code>long</code> to a <code>String</code> assuming it is
+ * unsigned in base 2.
+ *
+ * @param l the <code>long</code> to convert to <code>String</code>
+ * @return the <code>String</code> representation of the argument
+ */
+ /*public static String toBinaryString(long l)
+ {
+ return toUnsignedString(l, 1);
+ }*/
+
+ /**
+ * Converts the <code>long</code> to a <code>String</code> and assumes
+ * a radix of 10.
+ *
+ * @param num the <code>long</code> to convert to <code>String</code>
+ * @return the <code>String</code> representation of the argument
+ * @see #toString(long, int)
+ */
+ public static String toString(long num)
+ {
+ //return toString(num, 10);
+ return String.valueOf(num);
+ }
+
+ /**
+ * Converts the specified <code>String</code> into an <code>int</code>
+ * using the specified radix (base). The string must not be <code>null</code>
+ * or empty. It may begin with an optional '-', which will negate the answer,
+ * provided that there are also valid digits. Each digit is parsed as if by
+ * <code>Character.digit(d, radix)</code>, and must be in the range
+ * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
+ * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
+ * Unlike Double.parseDouble, you may not have a leading '+'; and 'l' or
+ * 'L' as the last character is only valid in radices 22 or greater, where
+ * it is a digit and not a type indicator.
+ *
+ * @param str the <code>String</code> to convert
+ * @param radix the radix (base) to use in the conversion
+ * @return the <code>String</code> argument converted to <code>long</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>long</code>
+ */
+ public static long parseLong(String str, int radix)
+ {
+ return parseLong(str, radix, false);
+ }
+
+ /**
+ * Converts the specified <code>String</code> into a <code>long</code>.
+ * This function assumes a radix of 10.
+ *
+ * @param s the <code>String</code> to convert
+ * @return the <code>int</code> value of <code>s</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>long</code>
+ * @see #parseLong(String, int)
+ */
+ public static long parseLong(String s)
+ {
+ return parseLong(s, 10, false);
+ }
+
+ /**
+ * Creates a new <code>Long</code> object using the <code>String</code>
+ * and specified radix (base).
+ *
+ * @param s the <code>String</code> to convert
+ * @param radix the radix (base) to convert with
+ * @return the new <code>Long</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>long</code>
+ * @see #parseLong(String, int)
+ */
+ public static Long valueOf(String s, int radix)
+ {
+ return valueOf(parseLong(s, radix, false));
+ }
+
+ /**
+ * Creates a new <code>Long</code> object using the <code>String</code>,
+ * assuming a radix of 10.
+ *
+ * @param s the <code>String</code> to convert
+ * @return the new <code>Long</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>long</code>
+ * @see #Long(String)
+ * @see #parseLong(String)
+ */
+ public static Long valueOf(String s)
+ {
+ return valueOf(parseLong(s, 10, false));
+ }
+
+ /**
+ * Returns a <code>Long</code> object wrapping the value.
+ *
+ * @param val the value to wrap
+ * @return the <code>Long</code>
+ * @since 1.5
+ */
+ public static Long valueOf(long val)
+ {
+ if (val < MIN_CACHE || val > MAX_CACHE)
+ return new Long(val);
+ else
+ return longCache[((int)val) - MIN_CACHE];
+ }
+
+ /**
+ * Convert the specified <code>String</code> into a <code>Long</code>.
+ * The <code>String</code> may represent decimal, hexadecimal, or
+ * octal numbers.
+ *
+ * <p>The extended BNF grammar is as follows:<br>
+ * <pre>
+ * <em>DecodableString</em>:
+ * ( [ <code>-</code> ] <em>DecimalNumber</em> )
+ * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
+ * | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } )
+ * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
+ * <em>DecimalNumber</em>:
+ * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
+ * <em>DecimalDigit</em>:
+ * <em>Character.digit(d, 10) has value 0 to 9</em>
+ * <em>OctalDigit</em>:
+ * <em>Character.digit(d, 8) has value 0 to 7</em>
+ * <em>DecimalDigit</em>:
+ * <em>Character.digit(d, 16) has value 0 to 15</em>
+ * </pre>
+ * Finally, the value must be in the range <code>MIN_VALUE</code> to
+ * <code>MAX_VALUE</code>, or an exception is thrown. Note that you cannot
+ * use a trailing 'l' or 'L', unlike in Java source code.
+ *
+ * @param str the <code>String</code> to interpret
+ * @return the value of the String as a <code>Long</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>long</code>
+ * @throws NullPointerException if <code>s</code> is null
+ * @since 1.2
+ */
+ public static Long decode(String str)
+ {
+ return valueOf(parseLong(str, 10, true));
+ }
+
+ /**
+ * Return the value of this <code>Long</code> as a <code>byte</code>.
+ *
+ * @return the byte value
+ */
+ public byte byteValue()
+ {
+ return (byte) value;
+ }
+
+ /**
+ * Return the value of this <code>Long</code> as a <code>short</code>.
+ *
+ * @return the short value
+ */
+ public short shortValue()
+ {
+ return (short) value;
+ }
+
+ /**
+ * Return the value of this <code>Long</code> as an <code>int</code>.
+ *
+ * @return the int value
+ */
+ public int intValue()
+ {
+ return (int) value;
+ }
+
+ /**
+ * Return the value of this <code>Long</code>.
+ *
+ * @return the long value
+ */
+ public long longValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Long</code> as a <code>float</code>.
+ *
+ * @return the float value
+ */
+ public float floatValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Long</code> as a <code>double</code>.
+ *
+ * @return the double value
+ */
+ public double doubleValue()
+ {
+ return value;
+ }
+
+ /**
+ * Converts the <code>Long</code> value to a <code>String</code> and
+ * assumes a radix of 10.
+ *
+ * @return the <code>String</code> representation
+ */
+ public String toString()
+ {
+ //return toString(value, 10);
+ return String.valueOf(value);
+ }
+
+ /**
+ * Return a hashcode representing this Object. <code>Long</code>'s hash
+ * code is calculated by <code>(int) (value ^ (value >> 32))</code>.
+ *
+ * @return this Object's hash code
+ */
+ public int hashCode()
+ {
+ return (int) (value ^ (value >>> 32));
+ }
+
+ /**
+ * Returns <code>true</code> if <code>obj</code> is an instance of
+ * <code>Long</code> and represents the same long value.
+ *
+ * @param obj the object to compare
+ * @return whether these Objects are semantically equal
+ */
+ public boolean equals(Object obj)
+ {
+ return obj instanceof Long && value == ((Long) obj).value;
+ }
+
+ /**
+ * Get the specified system property as a <code>Long</code>. The
+ * <code>decode()</code> method will be used to interpret the value of
+ * the property.
+ *
+ * @param nm the name of the system property
+ * @return the system property as a <code>Long</code>, or null if the
+ * property is not found or cannot be decoded
+ * @throws SecurityException if accessing the system property is forbidden
+ * @see System#getProperty(String)
+ * @see #decode(String)
+ */
+ public static Long getLong(String nm)
+ {
+ return getLong(nm, null);
+ }
+
+ /**
+ * Get the specified system property as a <code>Long</code>, or use a
+ * default <code>long</code> value if the property is not found or is not
+ * decodable. The <code>decode()</code> method will be used to interpret
+ * the value of the property.
+ *
+ * @param nm the name of the system property
+ * @param val the default value
+ * @return the value of the system property, or the default
+ * @throws SecurityException if accessing the system property is forbidden
+ * @see System#getProperty(String)
+ * @see #decode(String)
+ */
+ public static Long getLong(String nm, long val)
+ {
+ Long result = getLong(nm, null);
+ return result == null ? valueOf(val) : result;
+ }
+
+ /**
+ * Get the specified system property as a <code>Long</code>, or use a
+ * default <code>Long</code> value if the property is not found or is
+ * not decodable. The <code>decode()</code> method will be used to
+ * interpret the value of the property.
+ *
+ * @param nm the name of the system property
+ * @param def the default value
+ * @return the value of the system property, or the default
+ * @throws SecurityException if accessing the system property is forbidden
+ * @see System#getProperty(String)
+ * @see #decode(String)
+ */
+ public static Long getLong(String nm, Long def)
+ {
+ if (nm == null || "".equals(nm))
+ return def;
+ nm = null;//System.getProperty(nm);
+ if (nm == null)
+ return def;
+ /*try
+ {
+ return decode(nm);
+ }
+ catch (NumberFormatException e)
+ {
+ return def;
+ }*/
+ }
+
+ /**
+ * Compare two Longs numerically by comparing their <code>long</code>
+ * values. The result is positive if the first is greater, negative if the
+ * second is greater, and 0 if the two are equal.
+ *
+ * @param l the Long to compare
+ * @return the comparison
+ * @since 1.2
+ */
+ public int compareTo(Long l)
+ {
+ if (value == l.value)
+ return 0;
+ // Returns just -1 or 1 on inequality; doing math might overflow the long.
+ return value > l.value ? 1 : -1;
+ }
+
+ /**
+ * Return the number of bits set in x.
+ * @param x value to examine
+ * @since 1.5
+ */
+ public static int bitCount(long x)
+ {
+ // Successively collapse alternating bit groups into a sum.
+ x = ((x >> 1) & 0x5555555555555555L) + (x & 0x5555555555555555L);
+ x = ((x >> 2) & 0x3333333333333333L) + (x & 0x3333333333333333L);
+ int v = (int) ((x >>> 32) + x);
+ v = ((v >> 4) & 0x0f0f0f0f) + (v & 0x0f0f0f0f);
+ v = ((v >> 8) & 0x00ff00ff) + (v & 0x00ff00ff);
+ return ((v >> 16) & 0x0000ffff) + (v & 0x0000ffff);
+ }
+
+ /**
+ * Rotate x to the left by distance bits.
+ * @param x the value to rotate
+ * @param distance the number of bits by which to rotate
+ * @since 1.5
+ */
+ public static long rotateLeft(long x, int distance)
+ {
+ // This trick works because the shift operators implicitly mask
+ // the shift count.
+ return (x << distance) | (x >>> - distance);
+ }
+
+ /**
+ * Rotate x to the right by distance bits.
+ * @param x the value to rotate
+ * @param distance the number of bits by which to rotate
+ * @since 1.5
+ */
+ public static long rotateRight(long x, int distance)
+ {
+ // This trick works because the shift operators implicitly mask
+ // the shift count.
+ return (x << - distance) | (x >>> distance);
+ }
+
+ /**
+ * Find the highest set bit in value, and return a new value
+ * with only that bit set.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static long highestOneBit(long value)
+ {
+ value |= value >>> 1;
+ value |= value >>> 2;
+ value |= value >>> 4;
+ value |= value >>> 8;
+ value |= value >>> 16;
+ value |= value >>> 32;
+ return value ^ (value >>> 1);
+ }
+
+ /**
+ * Return the number of leading zeros in value.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static int numberOfLeadingZeros(long value)
+ {
+ value |= value >>> 1;
+ value |= value >>> 2;
+ value |= value >>> 4;
+ value |= value >>> 8;
+ value |= value >>> 16;
+ value |= value >>> 32;
+ return bitCount(~value);
+ }
+
+ /**
+ * Find the lowest set bit in value, and return a new value
+ * with only that bit set.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static long lowestOneBit(long value)
+ {
+ // Classic assembly trick.
+ return value & - value;
+ }
+
+ /**
+ * Find the number of trailing zeros in value.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static int numberOfTrailingZeros(long value)
+ {
+ return bitCount((value & -value) - 1);
+ }
+
+ /**
+ * Return 1 if x is positive, -1 if it is negative, and 0 if it is
+ * zero.
+ * @param x the value to examine
+ * @since 1.5
+ */
+ public static int signum(long x)
+ {
+ return (int) ((x >> 63) | (-x >>> 63));
+
+ // The LHS propagates the sign bit through every bit in the word;
+ // if X < 0, every bit is set to 1, else 0. if X > 0, the RHS
+ // negates x and shifts the resulting 1 in the sign bit to the
+ // LSB, leaving every other bit 0.
+
+ // Hacker's Delight, Section 2-7
+ }
+
+ /**
+ * Reverse the bytes in val.
+ * @since 1.5
+ */
+ /*public static long reverseBytes(long val)
+ {
+ int hi = Integer.reverseBytes((int) val);
+ int lo = Integer.reverseBytes((int) (val >>> 32));
+ return (((long) hi) << 32) | lo;
+ }*/
+
+ /**
+ * Reverse the bits in val.
+ * @since 1.5
+ */
+ /*public static long reverse(long val)
+ {
+ long hi = Integer.reverse((int) val) & 0xffffffffL;
+ long lo = Integer.reverse((int) (val >>> 32)) & 0xffffffffL;
+ return (hi << 32) | lo;
+ }*/
+
+ /**
+ * Helper for converting unsigned numbers to String.
+ *
+ * @param num the number
+ * @param exp log2(digit) (ie. 1, 3, or 4 for binary, oct, hex)
+ */
+ /*private static String toUnsignedString(long num, int exp)
+ {
+ // Compute string length
+ int size = 1;
+ long copy = num >>> exp;
+ while (copy != 0)
+ {
+ size++;
+ copy >>>= exp;
+ }
+ // Quick path for single character strings
+ if (size == 1)
+ return new String(digits, (int)num, 1, true);
+
+ // Encode into buffer
+ int mask = (1 << exp) - 1;
+ char[] buffer = new char[size];
+ int i = size;
+ do
+ {
+ buffer[--i] = digits[(int) num & mask];
+ num >>>= exp;
+ }
+ while (num != 0);
+
+ // Package constructor avoids an array copy.
+ return new String(buffer, i, size - i, true);
+ }*/
+
+ /**
+ * Helper for parsing longs.
+ *
+ * @param str the string to parse
+ * @param radix the radix to use, must be 10 if decode is true
+ * @param decode if called from decode
+ * @return the parsed long value
+ * @throws NumberFormatException if there is an error
+ * @throws NullPointerException if decode is true and str is null
+ * @see #parseLong(String, int)
+ * @see #decode(String)
+ */
+ private static long parseLong(String str, int radix, boolean decode)
+ {
+ if (! decode && str == null)
+ throw new /*NumberFormat*/Exception("NumberFormatException");
+ int index = 0;
+ int len = str.length();
+ boolean isNeg = false;
+ if (len == 0)
+ throw new /*NumberFormat*/Exception("NumberFormatException");
+ int ch = str.charAt(index);
+ if (ch == '-')
+ {
+ if (len == 1)
+ throw new /*NumberFormat*/Exception("NumberFormatException");
+ isNeg = true;
+ ch = str.charAt(++index);
+ }
+ if (decode)
+ {
+ if (ch == '0')
+ {
+ if (++index == len)
+ return 0;
+ if ((str.charAt(index) & ~('x' ^ 'X')) == 'X')
+ {
+ radix = 16;
+ index++;
+ }
+ else
+ radix = 8;
+ }
+ else if (ch == '#')
+ {
+ radix = 16;
+ index++;
+ }
+ }
+ if (index == len)
+ throw new /*NumberFormat*/Exception("NumberFormatException");
+
+ long max = MAX_VALUE / radix;
+ // We can't directly write `max = (MAX_VALUE + 1) / radix'.
+ // So instead we fake it.
+ if (isNeg && MAX_VALUE % radix == radix - 1)
+ ++max;
+
+ long val = 0;
+ while (index < len)
+ {
+ if (val < 0 || val > max)
+ throw new /*NumberFormat*/Exception("NumberFormatException");
+
+ ch = Character.digit(str.charAt(index++), radix);
+ val = val * radix + ch;
+ if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
+ throw new /*NumberFormat*/Exception("NumberFormatException");
+ }
+ return isNeg ? -val : val;
+ }
+}
private String() {
}
+ public String(byte str[]) {
+ char charstr[]=new char[str.length];
+ for(int i=0; i<str.length; i++)
+ charstr[i]=(char)str[i];
+ this.value=charstr;
+ this.count=str.length;
+ this.offset=0;
+ }
+
+
+ public String(byte str[], String encoding) {
+ int length = this.count;
+ if (length>(str.length))
+ length=str.length;
+ char charstr[]=new char[length];
+ for(int i=0; i<length; i++)
+ charstr[i]=(char)str[i];
+ this.value=charstr;
+ this.count=length;
+ this.offset=0;
+ }
+
public String(@LOC("IN") String str) {
this.value=str.value;
this.count=str.count;
return o.toString();
}
+ public static String valueOf(boolean b) {
+ if (b)
+ return new String("true");
+ else
+ return new String("false");
+ }
+
+ public static String valueOf(char c) {
+ char ar[]=new char[1];
+ ar[0]=c;
+ return new String(ar);
+ }
+
+ public static String valueOf(int x) {
+ int length=0;
+ int tmp;
+ if (x<0)
+ tmp=-x;
+ else
+ tmp=x;
+ do {
+ tmp=tmp/10;
+ length=length+1;
+ } while(tmp!=0);
+
+ char chararray[];
+ if (x<0)
+ chararray=new char[length+1];
+ else
+ chararray=new char[length];
+ int voffset;
+ if (x<0) {
+ chararray[0]='-';
+ voffset=1;
+ x=-x;
+ } else
+ voffset=0;
+
+ do {
+ chararray[--length+voffset]=(char)(x%10+'0');
+ x=x/10;
+ } while (length!=0);
+ return new String(chararray);
+ }
+
+ public static String valueOf(double val) {
+ char[] chararray=new char[20];
+ String s=new String();
+ s.offset=0;
+ s.count=convertdoubletochar(val, chararray);
+ s.value=chararray;
+ return s;
+ }
+
+ public static String valueOf(long x) {
+ int length=0;
+ long tmp;
+ if (x<0)
+ tmp=-x;
+ else
+ tmp=x;
+ do {
+ tmp=tmp/10;
+ length=length+1;
+ } while(tmp!=0);
+
+ char chararray[];
+ if (x<0)
+ chararray=new char[length+1];
+ else
+ chararray=new char[length];
+ int voffset;
+ if (x<0) {
+ chararray[0]='-';
+ voffset=1;
+ x=-x;
+ } else
+ voffset=0;
+
+ do {
+ chararray[--length+voffset]=(char)(x%10+'0');
+ x=x/10;
+ } while (length!=0);
+ return new String(chararray);
+ }
+
@LATTICE("O<V,V<C,C<IN,THISLOC=IN,C*")
@RETURNLOC("O")
public byte[] getBytes() {
return str;
}
+
+
@RETURNLOC("IN")
public int length() {
return count;
--- /dev/null
+public class StringBuffer {
+ char value[];
+ int count;
+ // private static final int DEFAULTSIZE=16;
+
+ public StringBuffer(String str) {
+ value=new char[str.count+16]; //16 is DEFAULTSIZE
+ count=str.count;
+ for(int i=0; i<count; i++)
+ value[i]=str.value[i+str.offset];
+ }
+
+ public StringBuffer() {
+ value=new char[16]; //16 is DEFAULTSIZE
+ count=0;
+ }
+
+ public StringBuffer(int i) {
+ value=new char[i];
+ count=0;
+ }
+
+ public int length() {
+ return count;
+ }
+
+ public int capacity() {
+ return value.length;
+ }
+
+ public char charAt(int x) {
+ return value[x];
+ }
+
+ public StringBuffer append(char c) {
+ return append(String.valueOf(c));
+ }
+
+ public StringBuffer append(String s) {
+ if ((s.count+count)>value.length) {
+ // Need to allocate
+ char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
+ for(int i=0; i<count; i++)
+ newvalue[i]=value[i];
+ for(int i=0; i<s.count; i++)
+ newvalue[i+count]=s.value[i+s.offset];
+ value=newvalue;
+ count+=s.count;
+ } else {
+ for(int i=0; i<s.count; i++) {
+ value[i+count]=s.value[i+s.offset];
+ }
+ count+=s.count;
+ }
+ return this;
+ }
+
+ public void ensureCapacity(int i) {
+ int size=2*count;
+ if (i>size)
+ size=i;
+ if (i>value.length) {
+ char newvalue[]=new char[i];
+ for(int ii=0; ii<count; ii++)
+ newvalue[ii]=value[ii];
+ value=newvalue;
+ }
+ }
+
+ public StringBuffer append(StringBuffer s) {
+ if ((s.count+count)>value.length) {
+ // Need to allocate
+ char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
+ for(int i=0; i<count; i++)
+ newvalue[i]=value[i];
+ for(int i=0; i<s.count; i++)
+ newvalue[i+count]=s.value[i];
+ value=newvalue;
+ count+=s.count;
+ } else {
+ for(int i=0; i<s.count; i++) {
+ value[i+count]=s.value[i];
+ }
+ count+=s.count;
+ }
+ return this;
+ }
+
+ public int indexOf(String str) {
+ return indexOf(str, 0);
+ }
+
+ public synchronized int indexOf(String str, int fromIndex) {
+ String vstr = new String(value, 0, count);
+ return vstr.indexOf(str, fromIndex);
+ }
+
+ public String toString() {
+ return new String(this);
+ }
+
+ public synchronized StringBuffer replace(int start, int end, String str) {
+ if (start < 0) {
+ // FIXME
+ System.printString("StringIndexOutOfBoundsException: "+start+"\n");
+ }
+ if (start > count) {
+ // FIXME
+ System.printString("StringIndexOutOfBoundsException: start > length()\n");
+ }
+ if (start > end) {
+ // FIXME
+ System.printString("StringIndexOutOfBoundsException: start > end\n");
+ }
+ if (end > count)
+ end = count;
+
+ if (end > count)
+ end = count;
+ int len = str.length();
+ int newCount = count + len - (end - start);
+ if (newCount > value.length)
+ expandCapacity(newCount);
+
+ System.arraycopy(value, end, value, start + len, count - end);
+ str.getChars(value, start);
+ count = newCount;
+ return this;
+ }
+
+ void expandCapacity(int minimumCapacity) {
+ int newCapacity = (value.length + 1) * 2;
+ if (newCapacity < 0) {
+ newCapacity = 0x7fffffff /*Integer.MAX_VALUE*/;
+ } else if (minimumCapacity > newCapacity) {
+ newCapacity = minimumCapacity;
+ }
+ char newValue[] = new char[newCapacity];
+ System.arraycopy(value, 0, newValue, 0, count);
+ value = newValue;
+ }
+}
*----------------------------------------------------------------------\r
*/\r
\r
-import java.io.BufferedInputStream;\r
-import java.io.ByteArrayInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.PushbackInputStream;\r
-\r
\r
/**\r
* The <code>Bistream</code> class is responsible for parsing\r
// REVIEW: use resource bundle to map error codes\r
// to locale-sensitive strings.\r
\r
- return "Bitstream errorcode "+Integer.toHexString(errorcode);\r
+// return "Bitstream errorcode "+Integer.toHexString(errorcode);\r
+ return "Bitstream errorcode "+errorcode;\r
}\r
\r
\r
\r
public Object clone()\r
{\r
- try\r
- {\r
- return super.clone();\r
- }\r
- catch (CloneNotSupportedException ex)\r
- { \r
- throw new InternalError(this+": "+ex);\r
- }\r
+ //TODO: need to have better clone method\r
+ Params clone=new Params();\r
+ clone.outputChannels=outputChannels;\r
+ clone.equalizer=equalizer;\r
+ return clone;\r
+// try\r
+// {\r
+// return super.clone();\r
+// }\r
+// catch (CloneNotSupportedException ex)\r
+// { \r
+// throw new InternalError(this+": "+ex);\r
+// }\r
}\r
\r
public void setOutputChannels(OutputChannels out)\r
// REVIEW: use resource file to map error codes\r
// to locale-sensitive strings. \r
\r
- return "Decoder errorcode "+Integer.toHexString(errorcode);\r
+// return "Decoder errorcode "+Integer.toHexString(errorcode);\r
+ return "Decoder errorcode "+errorcode;\r
}\r
\r
\r
@LOC("HNS") private int h_number_of_subbands;\r
@LOC("HI") private int h_intensity_stereo_bound;\r
@LOC("H") private boolean h_copyright;\r
- @LOC("H") private int h_original;\r
+ @LOC("H") private boolean h_original;\r
// VBR support added by E.B\r
- @LOC("T") private double[] h_vbr_time_per_frame = {-1, 384, 1152, 1152};\r
+ @LOC("T") private double[] h_vbr_time_per_frame = {-1.0, 384.0, 1152.0, 1152.0};\r
@LOC("T") private boolean h_vbr;\r
@LOC("T") private int h_vbr_frames;\r
@LOC("T") private int h_vbr_scale;\r
-/*\r
- * 11/19/04 1.0 moved to LGPL.\r
- * 12/12/99 Initial version. mdm@techie.com\r
- *-----------------------------------------------------------------------\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU Library General Public License as published\r
- * by the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU Library General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Library General Public\r
- * License along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- *----------------------------------------------------------------------\r
- */\r
-\r
-\r
-import java.io.PrintStream;\r
-\r
-\r
-/**\r
- * The JavaLayerException is the base class for all API-level\r
- * exceptions thrown by JavaLayer. To facilitate conversion and \r
- * common handling of exceptions from other domains, the class \r
- * can delegate some functionality to a contained Throwable instance. \r
- * <p> \r
- * \r
- * @author MDM\r
- */\r
-public class JavaLayerException extends Exception\r
-{\r
- \r
- private Throwable exception;\r
- \r
- \r
- public JavaLayerException()\r
- {\r
- }\r
- \r
- public JavaLayerException(String msg)\r
- {\r
- super(msg);\r
- }\r
- \r
- public JavaLayerException(String msg, Throwable t)\r
- {\r
- super(msg);\r
- exception = t;\r
- }\r
- \r
- public Throwable getException()\r
- {\r
- return exception; \r
- }\r
- \r
- \r
- public void printStackTrace()\r
- {\r
- printStackTrace(System.err); \r
- }\r
- \r
- public void printStackTrace(PrintStream ps)\r
- {\r
- if (this.exception==null)\r
- {\r
- super.printStackTrace(ps); \r
- }\r
- else\r
- {\r
- exception.printStackTrace();\r
- }\r
- }\r
- \r
- \r
-}\r
+/*
+ * 11/19/04 1.0 moved to LGPL.
+ * 12/12/99 Initial version. mdm@techie.com
+ *-----------------------------------------------------------------------
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *----------------------------------------------------------------------
+ */
+
+
+//import java.io.PrintStream;
+
+
+/**
+ * The JavaLayerException is the base class for all API-level
+ * exceptions thrown by JavaLayer. To facilitate conversion and
+ * common handling of exceptions from other domains, the class
+ * can delegate some functionality to a contained Throwable instance.
+ * <p>
+ *
+ * @author MDM
+ */
+public class JavaLayerException extends Exception
+{
+
+ private Throwable exception;
+
+
+ public JavaLayerException()
+ {
+ }
+
+ public JavaLayerException(String msg)
+ {
+ super(msg);
+ }
+
+ public JavaLayerException(String msg, Throwable t)
+ {
+ super(msg);
+ exception = t;
+ }
+
+ public Throwable getException()
+ {
+ return exception;
+ }
+
+
+ public void printStackTrace()
+ {
+// printStackTrace(System.err);
+ }
+
+ public void printStackTrace(PrintStream ps)
+ {
+// if (this.exception==null)
+// {
+// super.printStackTrace(ps);
+// }
+// else
+// {
+// exception.printStackTrace();
+// }
+ }
+
+
+}
*/
@LATTICE("L<SH,SH<H,SH*")
@METHODDEFAULT("OUT<V,V<SH,SH<IN,SH*,THISLOC=V,GLOBALLOC=IN")
- class LayerIDecoder //implements FrameDecoder //compiler cannot do interfaces
+ class LayerIDecoder implements FrameDecoder
{
@LOC("H") protected Bitstream stream;
@LOC("H") protected Header header;
}
- /**
- * Abstract base class for subband classes of layer I and II
- */
- @LATTICE("L<H")
- static abstract class Subband
- {
- /*
- * Changes from version 1.1 to 1.2:
- * - array size increased by one, although a scalefactor with index 63
- * is illegal (to prevent segmentation faults)
- */
- // Scalefactors for layer I and II, Annex 3-B.1 in ISO/IEC DIS 11172:
- @LOC("H") public static final float scalefactors[] =
- {
- 2.00000000000000f, 1.58740105196820f, 1.25992104989487f, 1.00000000000000f,
- 0.79370052598410f, 0.62996052494744f, 0.50000000000000f, 0.39685026299205f,
- 0.31498026247372f, 0.25000000000000f, 0.19842513149602f, 0.15749013123686f,
- 0.12500000000000f, 0.09921256574801f, 0.07874506561843f, 0.06250000000000f,
- 0.04960628287401f, 0.03937253280921f, 0.03125000000000f, 0.02480314143700f,
- 0.01968626640461f, 0.01562500000000f, 0.01240157071850f, 0.00984313320230f,
- 0.00781250000000f, 0.00620078535925f, 0.00492156660115f, 0.00390625000000f,
- 0.00310039267963f, 0.00246078330058f, 0.00195312500000f, 0.00155019633981f,
- 0.00123039165029f, 0.00097656250000f, 0.00077509816991f, 0.00061519582514f,
- 0.00048828125000f, 0.00038754908495f, 0.00030759791257f, 0.00024414062500f,
- 0.00019377454248f, 0.00015379895629f, 0.00012207031250f, 0.00009688727124f,
- 0.00007689947814f, 0.00006103515625f, 0.00004844363562f, 0.00003844973907f,
- 0.00003051757813f, 0.00002422181781f, 0.00001922486954f, 0.00001525878906f,
- 0.00001211090890f, 0.00000961243477f, 0.00000762939453f, 0.00000605545445f,
- 0.00000480621738f, 0.00000381469727f, 0.00000302772723f, 0.00000240310869f,
- 0.00000190734863f, 0.00000151386361f, 0.00000120155435f, 0.00000000000000f /* illegal scalefactor */
- };
-
- public abstract void read_allocation (Bitstream stream, Header header, Crc16 crc) throws DecoderException;
- public abstract void read_scalefactor (Bitstream stream, Header header);
- public abstract boolean read_sampledata (Bitstream stream);
- public abstract boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2);
- };
+// /**
+// * Abstract base class for subband classes of layer I and II
+// */
+// @LATTICE("L<H")
+// static abstract class Subband
+// {
+// /*
+// * Changes from version 1.1 to 1.2:
+// * - array size increased by one, although a scalefactor with index 63
+// * is illegal (to prevent segmentation faults)
+// */
+// // Scalefactors for layer I and II, Annex 3-B.1 in ISO/IEC DIS 11172:
+// @LOC("H") public static final float scalefactors[] =
+// {
+// 2.00000000000000f, 1.58740105196820f, 1.25992104989487f, 1.00000000000000f,
+// 0.79370052598410f, 0.62996052494744f, 0.50000000000000f, 0.39685026299205f,
+// 0.31498026247372f, 0.25000000000000f, 0.19842513149602f, 0.15749013123686f,
+// 0.12500000000000f, 0.09921256574801f, 0.07874506561843f, 0.06250000000000f,
+// 0.04960628287401f, 0.03937253280921f, 0.03125000000000f, 0.02480314143700f,
+// 0.01968626640461f, 0.01562500000000f, 0.01240157071850f, 0.00984313320230f,
+// 0.00781250000000f, 0.00620078535925f, 0.00492156660115f, 0.00390625000000f,
+// 0.00310039267963f, 0.00246078330058f, 0.00195312500000f, 0.00155019633981f,
+// 0.00123039165029f, 0.00097656250000f, 0.00077509816991f, 0.00061519582514f,
+// 0.00048828125000f, 0.00038754908495f, 0.00030759791257f, 0.00024414062500f,
+// 0.00019377454248f, 0.00015379895629f, 0.00012207031250f, 0.00009688727124f,
+// 0.00007689947814f, 0.00006103515625f, 0.00004844363562f, 0.00003844973907f,
+// 0.00003051757813f, 0.00002422181781f, 0.00001922486954f, 0.00001525878906f,
+// 0.00001211090890f, 0.00000961243477f, 0.00000762939453f, 0.00000605545445f,
+// 0.00000480621738f, 0.00000381469727f, 0.00000302772723f, 0.00000240310869f,
+// 0.00000190734863f, 0.00000151386361f, 0.00000120155435f, 0.00000000000000f /* illegal scalefactor */
+// };
+//
+// public abstract void read_allocation (Bitstream stream, Header header, Crc16 crc) throws DecoderException;
+// public abstract void read_scalefactor (Bitstream stream, Header header);
+// public abstract boolean read_sampledata (Bitstream stream);
+// public abstract boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2);
+// };
/**
* Class for layer I subbands in single channel mode.
*/
@LATTICE("L<SH,SH<H,SH*")
@METHODDEFAULT("OUT<V,V<SH,SH<IN,SH*,THISLOC=V,GLOBALLOC=IN")
-class LayerIIDecoder extends LayerIDecoder //implements FrameDecoder //compiler cannot do interfaces
+class LayerIIDecoder extends LayerIDecoder implements FrameDecoder
{
public LayerIIDecoder()
@LOC("GN") protected int groupnumber;
@LOC("SN") protected int samplenumber;
@LOC("L") protected float[] samples = new float[3];
- @LOC("ARR") protected float[] c = {0};
- @LOC("ARR") protected float[] d = {0};
+ @LOC("ARR") protected float[] c = {0.0f};
+ @LOC("ARR") protected float[] d = {0.0f};
/**
* Constructor
*/
//protected boolean channel2_grouping; ???? Never used!
@LOC("ARR") protected int[] channel2_codelength = {0};
//protected float[][] channel2_groupingtable = {{0},{0}};
- @LOC("ARR") protected float[] channel2_factor = {0};
+ @LOC("ARR") protected float[] channel2_factor = {0.0f};
@LOC("L") protected float[] channel2_samples;
- @LOC("ARR") protected float[] channel2_c = {0};
- @LOC("ARR") protected float[] channel2_d = {0};
+ @LOC("ARR") protected float[] channel2_c = {0.0f};
+ @LOC("ARR") protected float[] channel2_d = {0.0f};
/**
* Constructor
* \r
* @since 0.0\r
*/\r
-@LATTICE("FS<BR,BR<SF,LR<IR,IR<IP,IP<SF,LR<K,K<F,LR<VAR,LR<RO,RO<F,VAR<F,VAR<RAW,CSH<F,SAM<O,O<F,\r
-SF<SI,SI<CH,SFREQ<H,MAX<H,H<CH,FLCH<CH,FLCH<WCH,SF<SFT,SFT<NS,NS<C,TS<RAW,O<TS,LY<F,\r
-C*,FS*,SI*,IP*,IR*,LR*,K*,O*,TS*,\r
-TS<BT,BT<GR,GR<SI,\r
-LR<S,S<ME,ME<CH,K<SH,K<LSF,LSF<H,LSF<CH,IP<SH,SH<J,J<S,S<ME,SH<SFREQ,SH<RO,IP<TMP2,LSF<H,TMP2<F,J*,SH*,\r
-O<RO2,RO2<RO3,RO3<RO4,RO4<RO5,O<RO1,RO1<RO5,RO5<RO6,RO6<RO7,RO7<RO8,RO8<RO9,RO9<SFREQ,RO9<F,RO1*,RO4*,RO5*,RO6*,RO9*")\r
+@LATTICE("FS<BR,BR<SF,LR<IR,IR<IP,IP<SF,LR<K,K<F,LR<VAR,LR<RO,RO<F,VAR<F,VAR<RAW,CSH<F,SAM<O,O<F,SF<SI,SI<CH,SFREQ<H,MAX<H,H<CH,FLCH<CH,FLCH<WCH,SF<SFT,SFT<NS,NS<C,TS<RAW,O<TS,LY<F,C*,FS*,SI*,IP*,IR*,LR*,K*,O*,TS*,TS<BT,BT<GR,GR<SI,LR<S,S<ME,ME<CH,K<SH,K<LSF,LSF<H,LSF<CH,IP<SH,SH<J,J<S,S<ME,SH<SFREQ,SH<RO,IP<TMP2,LSF<H,TMP2<F,J*,SH*,O<RO2,RO2<RO3,RO3<RO4,RO4<RO5,O<RO1,RO1<RO5,RO5<RO6,RO6<RO7,RO7<RO8,RO8<RO9,RO9<SFREQ,RO9<F,RO1*,RO4*,RO5*,RO6*,RO9*")\r
//4th: added for hybrid.\r
//5th added for stereo\r
//6th added for reorder method\r
@LOC("THIS,LayerIIIDecoder.ME") int mode_ext = header.mode_extension();\r
@LOC("THIS,LayerIIIDecoder.SH") int sfb;\r
@LOC("THIS,LayerIIIDecoder.SH") int i;\r
- @LOC("THIS,LayerIIIDecoder.SH") int line;\r
+ @LOC("THIS,LayerIIIDecoder.SH") int lines;\r
@LOC("THIS,LayerIIIDecoder.SH") int temp;\r
@LOC("THIS,LayerIIIDecoder.TMP2") int temp2;\r
\r
@RETURNLOC("IN")
private final short clip(@LOC("IN") float sample)
{
- return ((sample > 32767.0f) ? 32767 :
- ((sample < -32768.0f) ? -32768 :
+ return ((sample > 32767.0f) ? (short) 32767 :
+ ((sample < -32768.0f) ? (short) -32768 :
(short) sample));
}
*/\r
\r
\r
-import java.io.InputStream;\r
+//import java.io.InputStream;\r
\r
\r
/**\r
--- /dev/null
+//package ssJava.mp3decoder;
+
+/**
+ * Abstract base class for subband classes of layer I and II
+ */
+ @LATTICE("L<H")
+static abstract class Subband
+{
+ /*
+ * Changes from version 1.1 to 1.2:
+ * - array size increased by one, although a scalefactor with index 63
+ * is illegal (to prevent segmentation faults)
+ */
+ // Scalefactors for layer I and II, Annex 3-B.1 in ISO/IEC DIS 11172:
+ @LOC("H") public static final float scalefactors[] =
+ {
+ 2.00000000000000f, 1.58740105196820f, 1.25992104989487f, 1.00000000000000f,
+ 0.79370052598410f, 0.62996052494744f, 0.50000000000000f, 0.39685026299205f,
+ 0.31498026247372f, 0.25000000000000f, 0.19842513149602f, 0.15749013123686f,
+ 0.12500000000000f, 0.09921256574801f, 0.07874506561843f, 0.06250000000000f,
+ 0.04960628287401f, 0.03937253280921f, 0.03125000000000f, 0.02480314143700f,
+ 0.01968626640461f, 0.01562500000000f, 0.01240157071850f, 0.00984313320230f,
+ 0.00781250000000f, 0.00620078535925f, 0.00492156660115f, 0.00390625000000f,
+ 0.00310039267963f, 0.00246078330058f, 0.00195312500000f, 0.00155019633981f,
+ 0.00123039165029f, 0.00097656250000f, 0.00077509816991f, 0.00061519582514f,
+ 0.00048828125000f, 0.00038754908495f, 0.00030759791257f, 0.00024414062500f,
+ 0.00019377454248f, 0.00015379895629f, 0.00012207031250f, 0.00009688727124f,
+ 0.00007689947814f, 0.00006103515625f, 0.00004844363562f, 0.00003844973907f,
+ 0.00003051757813f, 0.00002422181781f, 0.00001922486954f, 0.00001525878906f,
+ 0.00001211090890f, 0.00000961243477f, 0.00000762939453f, 0.00000605545445f,
+ 0.00000480621738f, 0.00000381469727f, 0.00000302772723f, 0.00000240310869f,
+ 0.00000190734863f, 0.00000151386361f, 0.00000120155435f, 0.00000000000000f /* illegal scalefactor */
+ };
+
+ public abstract void read_allocation (Bitstream stream, Header header, Crc16 crc) throws DecoderException;
+ public abstract void read_scalefactor (Bitstream stream, Header header);
+ public abstract boolean read_sampledata (Bitstream stream);
+ public abstract boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2);
+};
) * scalefactor);\r
\r
_tmpOut[i] = pcm_sample;\r
- actual_v\r
+// actual_v\r
dvp += 16;\r
} // for\r
}\r
//final float[] dp = d16[i];\r
@LOC("THIS,SynthesisFilter.PCM") float pcm_sample;\r
\r
- pcm_sample = (float)(((actual_v[3 + dvp] * d16[0]) +\r
+ pcm_sample = (float) ( ( (actual_v[3 + dvp] * d16[0]) +\r
(actual_v[2 + dvp] * d16[1]) +\r
(actual_v[1 + dvp] * d16[2]) +\r
(actual_v[0 + dvp] * d16[3]) +\r
(actual_v[13 + dvp] * d16[7]) +\r
(actual_v[12 + dvp] * d16[8]) +\r
(actual_v[11 + dvp] * d16[9]) +\r
- (actual_v[10 + dvp] * d16[10]) +@LOC("I")\r
+ (actual_v[10 + dvp] * d16[10]) +\r
(actual_v[9 + dvp] * d16[11]) +\r
(actual_v[8 + dvp] * d16[12]) +\r
(actual_v[7 + dvp] * d16[13]) +\r