[llvm-commits] [llvm-gcc-4.2] r43913 [45/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...

Bill Wendling isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007


Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Cipher.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Cipher.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Cipher.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Cipher.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1155 @@
+/* Cipher.java -- Interface to a cryptographic cipher.
+   Copyright (C) 2004, 2006  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 javax.crypto;
+
+import gnu.java.security.Engine;
+
+import java.nio.ByteBuffer;
+import java.nio.ReadOnlyBufferException;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.StringTokenizer;
+
+/**
+ * <p>This class implements a cryptographic cipher for transforming
+ * data.</p>
+ *
+ * <p>Ciphers cannot be instantiated directly; rather one of the
+ * <code>getInstance</code> must be used to instantiate a given
+ * <i>transformation</i>, optionally with a specific provider.</p>
+ *
+ * <p>A transformation is of the form:</p>
+ *
+ * <ul>
+ * <li><i>algorithm</i>/<i>mode</i>/<i>padding</i>, or</li>
+ * <li><i>algorithm</i>
+ * </ul>
+ *
+ * <p>where <i>algorithm</i> is the base name of a cryptographic cipher
+ * (such as "AES"), <i>mode</i> is the abbreviated name of a block
+ * cipher mode (such as "CBC" for cipher block chaining mode), and
+ * <i>padding</i> is the name of a padding scheme (such as
+ * "PKCS5Padding"). If only the algorithm name is supplied, then the
+ * provider-specific default mode and padding will be used.</p>
+ *
+ * <p>An example transformation is:</p>
+ *
+ * <blockquote><code>Cipher c =
+ * Cipher.getInstance("AES/CBC/PKCS5Padding");</code></blockquote>
+ *
+ * <p>Finally, when requesting a block cipher in stream cipher mode
+ * (such as <acronym title="Advanced Encryption Standard">AES</acronym>
+ * in OFB or CFB mode) the number of bits to be processed
+ * at a time may be specified by appending it to the name of the mode;
+ * e.g. <code>"AES/OFB8/NoPadding"</code>. If no such number is
+ * specified a provider-specific default value is used.</p>
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @see java.security.KeyGenerator
+ * @see javax.crypto.SecretKey
+ */
+public class Cipher
+{
+
+  // Constants and variables.
+  // ------------------------------------------------------------------------
+
+  private static final String SERVICE = "Cipher";
+
+  /**
+   * The decryption operation mode.
+   */
+  public static final int DECRYPT_MODE = 2;
+
+  /**
+   * The encryption operation mode.
+   */
+  public static final int ENCRYPT_MODE = 1;
+
+  /**
+   * Constant for when the key to be unwrapped is a private key.
+   */
+  public static final int PRIVATE_KEY = 2;
+
+  /**
+   * Constant for when the key to be unwrapped is a public key.
+   */
+  public static final int PUBLIC_KEY = 1;
+
+  /**
+   * Constant for when the key to be unwrapped is a secret key.
+   */
+  public static final int SECRET_KEY = 3;
+
+  /**
+   * The key unwrapping operation mode.
+   */
+  public static final int UNWRAP_MODE = 4;
+
+  /**
+   * The key wrapping operation mode.
+   */
+  public static final int WRAP_MODE = 3;
+
+  /**
+   * The uninitialized state. This state signals that any of the
+   * <code>init</code> methods have not been called, and therefore no
+   * transformations can be done.
+   */
+  private static final int INITIAL_STATE = 0;
+
+  /** The underlying cipher service provider interface. */
+  private CipherSpi cipherSpi;
+
+  /** The provider from which this instance came. */
+  private Provider provider;
+
+  /** The transformation requested. */
+  private String transformation;
+
+  /** Our current state (encrypting, wrapping, etc.) */
+  private int state;
+
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * <p>Creates a new cipher instance for the given transformation.</p>
+   *
+   * <p>The installed providers are tried in order for an
+   * implementation, and the first appropriate instance is returned. If
+   * no installed provider can provide the implementation, an
+   * appropriate exception is thrown.</p>
+   *
+   * @param transformation The transformation to create.
+   * @return An appropriate cipher for this transformation.
+   * @throws java.security.NoSuchAlgorithmException If no installed
+   *         provider can supply the appropriate cipher or mode.
+   * @throws javax.crypto.NoSuchPaddingException If no installed
+   *         provider can supply the appropriate padding.
+   */
+  public static final Cipher getInstance(String transformation)
+    throws NoSuchAlgorithmException, NoSuchPaddingException
+  {
+    Provider[] providers = Security.getProviders();
+    NoSuchPaddingException ex = null;
+    String msg = "";
+    for (int i = 0; i < providers.length; i++)
+      {
+        try
+          {
+            return getInstance(transformation, providers[i]);
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+            msg = nsae.getMessage();
+            ex = null;
+          }
+        catch (NoSuchPaddingException nspe)
+          {
+            ex = nspe;
+          }
+      }
+    if (ex != null)
+      {
+        throw ex;
+      }
+    throw new NoSuchAlgorithmException(msg);
+  }
+
+  /**
+   * <p>Creates a new cipher instance for the given transformation and
+   * the named provider.</p>
+   *
+   * @param transformation The transformation to create.
+   * @param provider       The name of the provider to use.
+   * @return An appropriate cipher for this transformation.
+   * @throws java.security.NoSuchAlgorithmException If the provider cannot
+   *         supply the appropriate cipher or mode.
+   * @throws java.security.NoSuchProviderException If the named provider
+   *         is not installed.
+   * @throws javax.crypto.NoSuchPaddingException If the provider cannot
+   *         supply the appropriate padding.
+   */
+  public static final Cipher getInstance(String transformation, String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException,
+           NoSuchPaddingException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(transformation, p);
+  }
+
+  /**
+   * Creates a new cipher instance for the given transform and the given
+   * provider.
+   *
+   * @param transformation The transformation to create.
+   * @param provider       The provider to use.
+   * @return An appropriate cipher for this transformation.
+   * @throws java.security.NoSuchAlgorithmException If the given
+   *         provider cannot supply the appropriate cipher or mode.
+   * @throws javax.crypto.NoSuchPaddingException If the given
+   *         provider cannot supply the appropriate padding scheme.
+   */
+  public static final Cipher getInstance(String transformation, Provider provider)
+    throws NoSuchAlgorithmException, NoSuchPaddingException
+  {
+    CipherSpi result = null;
+    String key = null;
+    String alg = null, mode = null, pad = null;
+    String msg = "";
+    if (transformation.indexOf('/') < 0)
+      {
+        try
+          {
+            result = (CipherSpi) Engine.getInstance(SERVICE, transformation,
+                                                    provider);
+            return new Cipher(result, provider, transformation);
+          }
+        catch (Exception e)
+          {
+            msg = e.getMessage();
+          }
+      }
+    else
+      {
+        StringTokenizer tok = new StringTokenizer(transformation, "/");
+        if (tok.countTokens() != 3)
+          {
+            throw new NoSuchAlgorithmException("badly formed transformation");
+          }
+        alg = tok.nextToken();
+        mode = tok.nextToken();
+        pad = tok.nextToken();
+        try
+          {
+            result = (CipherSpi) Engine.getInstance(SERVICE, transformation,
+                                                    provider);
+            return new Cipher(result, provider, transformation);
+          }
+        catch (Exception e)
+          {
+            msg = e.getMessage();
+          }
+        try
+          {
+            result = (CipherSpi) Engine.getInstance(SERVICE, alg + '/' + mode,
+                                                    provider);
+            result.engineSetPadding(pad);
+            return new Cipher(result, provider, transformation);
+          }
+        catch (Exception e)
+          {
+            if (e instanceof NoSuchPaddingException)
+              {
+                throw (NoSuchPaddingException) e;
+              }
+            msg = e.getMessage();
+          }
+        try
+          {
+            result = (CipherSpi) Engine.getInstance(SERVICE, alg + "//" + pad,
+                                                    provider);
+            result.engineSetMode(mode);
+            return new Cipher(result, provider, transformation);
+          }
+        catch (Exception e)
+          {
+            msg = e.getMessage();
+          }
+        try
+          {
+            result = (CipherSpi) Engine.getInstance(SERVICE, alg, provider);
+            result.engineSetMode(mode);
+            result.engineSetPadding(pad);
+            return new Cipher(result, provider, transformation);
+          }
+        catch (Exception e)
+          {
+            if (e instanceof NoSuchPaddingException)
+              {
+                throw (NoSuchPaddingException) e;
+              }
+            msg = e.getMessage();
+          }
+      }
+    throw new NoSuchAlgorithmException(transformation + ": " + msg);
+  }
+
+// Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a cipher.
+   *
+   * @param cipherSpi The underlying implementation of the cipher.
+   * @param provider  The provider of this cipher implementation.
+   * @param transformation The transformation this cipher performs.
+   */
+  protected
+  Cipher(CipherSpi cipherSpi, Provider provider, String transformation)
+  {
+    this.cipherSpi = cipherSpi;
+    this.provider = provider;
+    this.transformation = transformation;
+    state = INITIAL_STATE;
+  }
+
+// Public instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the name that this cipher instance was created with; this is
+   * equivalent to the "transformation" argument given to any of the
+   * {@link #getInstance()} methods.
+   *
+   * @return The cipher name.
+   */
+  public final String getAlgorithm()
+  {
+    return transformation;
+  }
+
+  /**
+   * Return the size of blocks, in bytes, that this cipher processes.
+   *
+   * @return The block size.
+   */
+  public final int getBlockSize()
+  {
+    if (cipherSpi != null)
+      {
+        return cipherSpi.engineGetBlockSize();
+      }
+    return 1;
+  }
+
+  /**
+   * Return the currently-operating {@link ExemptionMechanism}.
+   *
+   * @return null, currently.
+   */
+  public final ExemptionMechanism getExemptionMechanism()
+  {
+    return null;
+  }
+
+  /**
+   * Return the <i>initialization vector</i> that this instance was
+   * initialized with.
+   *
+   * @return The IV.
+   */
+  public final byte[] getIV()
+  {
+    if (cipherSpi != null)
+      {
+        return cipherSpi.engineGetIV();
+      }
+    return null;
+  }
+
+  /**
+   * Return the {@link java.security.AlgorithmParameters} that this
+   * instance was initialized with.
+   *
+   * @return The parameters.
+   */
+  public final AlgorithmParameters getParameters()
+  {
+    if (cipherSpi != null) {
+      return cipherSpi.engineGetParameters();
+    }
+    return null;
+  }
+
+  /**
+   * Return this cipher's provider.
+   *
+   * @return The provider.
+   */
+  public final Provider getProvider()
+  {
+    return provider;
+  }
+
+  /**
+   * Finishes a multi-part transformation, and returns the final
+   * transformed bytes.
+   *
+   * @return The final transformed bytes.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized, or if a <tt>doFinal</tt> call has already
+   *         been made.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input is not a multiple of this cipher's
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is
+   *         decrypting and the padding bytes do not match this
+   *         instance's padding scheme.
+   */
+  public final byte[] doFinal()
+    throws IllegalStateException, IllegalBlockSizeException, BadPaddingException
+  {
+    return doFinal(new byte[0], 0, 0);
+  }
+
+  /**
+   * Finishes a multi-part transformation or does an entire
+   * transformation on the input, and returns the transformed bytes.
+   *
+   * @param input The final input bytes.
+   * @return The final transformed bytes.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized, or if a <tt>doFinal</tt> call has already
+   *         been made.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input is not a multiple of this cipher's
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is
+   *         decrypting and the padding bytes do not match this
+   *         instance's padding scheme.
+   */
+  public final byte[] doFinal(byte[] input)
+    throws IllegalStateException, IllegalBlockSizeException, BadPaddingException
+  {
+    return doFinal(input, 0, input.length);
+  }
+
+  /**
+   * Finishes a multi-part transformation or does an entire
+   * transformation on the input, and returns the transformed bytes.
+   *
+   * @param input       The final input bytes.
+   * @param inputOffset The index in the input bytes to start.
+   * @param inputLength The number of bytes to read from the input.
+   * @return The final transformed bytes.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized, or if a <tt>doFinal</tt> call has already
+   *         been made.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input is not a multiple of this cipher's
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is
+   *         decrypting and the padding bytes do not match this
+   *         instance's padding scheme.
+   */
+  public final byte[] doFinal(byte[] input, int inputOffset, int inputLength)
+    throws IllegalStateException, IllegalBlockSizeException, BadPaddingException
+  {
+    if (cipherSpi == null)
+      {
+        byte[] b = new byte[inputLength];
+        System.arraycopy(input, inputOffset, b, 0, inputLength);
+        return b;
+      }
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      {
+        throw new IllegalStateException("neither encrypting nor decrypting");
+      }
+    return cipherSpi.engineDoFinal(input, inputOffset, inputLength);
+  }
+
+  /**
+   * Finishes a multi-part transformation and stores the transformed
+   * bytes into the given array.
+   *
+   * @param output       The destination for the transformed bytes.
+   * @param outputOffset The offset in <tt>output</tt> to start storing
+   *        bytes.
+   * @return The number of bytes placed into the output array.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized, or if a <tt>doFinal</tt> call has already
+   *         been made.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input is not a multiple of this cipher's
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is
+   *         decrypting and the padding bytes do not match this
+   *         instance's padding scheme.
+   * @throws javax.crypto.ShortBufferException If the output array is
+   *         not large enough to hold the transformed bytes.
+   */
+  public final int doFinal(byte[] output, int outputOffset)
+    throws IllegalStateException, IllegalBlockSizeException, BadPaddingException,
+           ShortBufferException
+  {
+    if (cipherSpi == null)
+      {
+        return 0;
+      }
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      {
+        throw new IllegalStateException("neither encrypting nor decrypting");
+      }
+    return cipherSpi.engineDoFinal(new byte[0], 0, 0, output, outputOffset);
+  }
+
+  /**
+   * Finishes a multi-part transformation or transforms a portion of a
+   * byte array, and stores the result in the given byte array.
+   *
+   * @param input        The input bytes.
+   * @param inputOffset  The index in <tt>input</tt> to start.
+   * @param inputLength  The number of bytes to transform.
+   * @param output       The output buffer.
+   * @param outputOffset The index in <tt>output</tt> to start.
+   * @return The number of bytes placed into the output array.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized, or if a <tt>doFinal</tt> call has already
+   *         been made.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input is not a multiple of this cipher's
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is
+   *         decrypting and the padding bytes do not match this
+   *         instance's padding scheme.
+   * @throws javax.crypto.ShortBufferException If the output array is
+   *         not large enough to hold the transformed bytes.
+   */
+  public final int doFinal(byte[] input, int inputOffset, int inputLength,
+                           byte[] output, int outputOffset)
+    throws IllegalStateException, IllegalBlockSizeException, BadPaddingException,
+           ShortBufferException
+  {
+    if (cipherSpi == null)
+      {
+        if (inputLength > output.length - outputOffset)
+          {
+            throw new ShortBufferException();
+          }
+        System.arraycopy(input, inputOffset, output, outputOffset, inputLength);
+        return inputLength;
+      }
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      {
+        throw new IllegalStateException("neither encrypting nor decrypting");
+      }
+    return cipherSpi.engineDoFinal(input, inputOffset, inputLength,
+                                   output, outputOffset);
+  }
+
+  public final int doFinal(byte[] input, int inputOffset, int inputLength,
+                           byte[] output)
+    throws IllegalStateException, IllegalBlockSizeException, BadPaddingException,
+           ShortBufferException
+  {
+    return doFinal(input, inputOffset, inputLength, output, 0);
+  }
+
+  /**
+   * Finishes a multi-part transformation with, or completely
+   * transforms, a byte buffer, and stores the result into the output
+   * buffer.
+   *
+   * @param input  The input buffer.
+   * @param output The output buffer.
+   * @return The number of bytes stored into the output buffer.
+   * @throws IllegalArgumentException If the input and output buffers
+   *  are the same object.
+   * @throws IllegalStateException If this cipher was not initialized
+   *  for encryption or decryption.
+   * @throws ReadOnlyBufferException If the output buffer is not
+   *  writable.
+   * @throws IllegalBlockSizeException If this cipher requires a total
+   *  input that is a multiple of its block size to complete this
+   *  transformation.
+   * @throws ShortBufferException If the output buffer is not large
+   *  enough to hold the transformed bytes.
+   * @throws BadPaddingException If the cipher is a block cipher with
+   *  a padding scheme, and the decrypted bytes do not end with a
+   *  valid padding.
+   * @since 1.5
+   */
+  public final int doFinal (ByteBuffer input, ByteBuffer output)
+    throws ReadOnlyBufferException, ShortBufferException,
+           BadPaddingException, IllegalBlockSizeException
+  {
+    if (input == output)
+      throw new IllegalArgumentException
+        ("input and output buffers cannot be the same");
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      throw new IllegalStateException
+        ("not initialized for encrypting or decrypting");
+    return cipherSpi.engineDoFinal (input, output);
+  }
+
+  /**
+   * Returns the size an output buffer needs to be if this cipher is
+   * updated with a number of bytes.
+   *
+   * @param inputLength The input length.
+   * @return The output length given this input length.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized, or if a <tt>doFinal</tt> call has already
+   *         been made.
+   */
+  public final int getOutputSize(int inputLength) throws IllegalStateException
+  {
+    if (cipherSpi == null)
+      return inputLength;
+    return cipherSpi.engineGetOutputSize(inputLength);
+  }
+
+  /**
+   * <p>Initialize this cipher with the public key from the given
+   * certificate.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>As per the Java 1.4 specification, if <code>cert</code> is an
+   * instance of an {@link java.security.cert.X509Certificate} and its
+   * <i>key usage</i> extension field is incompatible with
+   * <code>opmode</code> then an {@link
+   * java.security.InvalidKeyException} is thrown.</p>
+   *
+   * <p>If this cipher requires any random bytes (for example for an
+   * initilization vector) than the {@link java.security.SecureRandom}
+   * with the highest priority is used as the source of these bytes.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode      The operation mode to use.
+   * @param certificate The certificate.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the certificate's public key, or if the
+   *         public key cannot be used as described above.
+   */
+  public final void init(int opmode, Certificate certificate)
+    throws InvalidKeyException
+  {
+    init(opmode, certificate, new SecureRandom());
+  }
+
+  /**
+   * <p>Initialize this cipher with the supplied key.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>If this cipher requires any random bytes (for example for an
+   * initilization vector) than the {@link java.security.SecureRandom}
+   * with the highest priority is used as the source of these bytes.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode The operation mode to use.
+   * @param key    The key.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the given key.
+   */
+  public final void init(int opmode, Key key) throws InvalidKeyException
+  {
+    if (cipherSpi != null)
+      {
+        cipherSpi.engineInit(opmode, key, new SecureRandom());
+      }
+    state = opmode;
+  }
+
+  /**
+   * <p>Initialize this cipher with the public key from the given
+   * certificate and the specified source of randomness.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>As per the Java 1.4 specification, if <code>cert</code> is an
+   * instance of an {@link java.security.cert.X509Certificate} and its
+   * <i>key usage</i> extension field is incompatible with
+   * <code>opmode</code> then an {@link
+   * java.security.InvalidKeyException} is thrown.</p>
+   *
+   * <p>If this cipher requires any random bytes (for example for an
+   * initilization vector) than the {@link java.security.SecureRandom}
+   * with the highest priority is used as the source of these bytes.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode      The operation mode to use.
+   * @param certificate The certificate.
+   * @param random      The source of randomness.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the certificate's public key, or if the
+   *         public key cannot be used as described above.
+   */
+  public final void
+  init(int opmode, Certificate certificate, SecureRandom random)
+  throws InvalidKeyException
+  {
+    if (certificate instanceof X509Certificate)
+      {
+        boolean[] keyInfo = ((X509Certificate) certificate).getKeyUsage();
+        if (keyInfo != null)
+          {
+            switch (opmode)
+              {
+              case DECRYPT_MODE:
+                if (!keyInfo[3])
+                  {
+                    throw new InvalidKeyException(
+                      "the certificate's key cannot be used for transforming data");
+                  }
+                if (keyInfo[7])
+                  {
+                    throw new InvalidKeyException(
+                      "the certificate's key can only be used for encryption");
+                  }
+                break;
+
+              case ENCRYPT_MODE:
+                if (!keyInfo[3])
+                  {
+                    throw new InvalidKeyException(
+                      "the certificate's key cannot be used for transforming data");
+                  }
+                if (keyInfo[8])
+                  {
+                    throw new InvalidKeyException(
+                      "the certificate's key can only be used for decryption");
+                  }
+                break;
+
+              case UNWRAP_MODE:
+                if (!keyInfo[2] || keyInfo[7])
+                  {
+                    throw new InvalidKeyException(
+                      "the certificate's key cannot be used for key unwrapping");
+                  }
+                break;
+
+              case WRAP_MODE:
+                if (!keyInfo[2] || keyInfo[8])
+                  {
+                    throw new InvalidKeyException(
+                      "the certificate's key cannot be used for key wrapping");
+                  }
+                break;
+              }
+          }
+      }
+    init(opmode, certificate.getPublicKey(), random);
+  }
+
+  /**
+   * <p>Initialize this cipher with the supplied key and source of
+   * randomness.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode The operation mode to use.
+   * @param key    The key.
+   * @param random The source of randomness to use.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the given key.
+   */
+  public final void init(int opmode, Key key, SecureRandom random)
+    throws InvalidKeyException
+  {
+    if (cipherSpi != null)
+      {
+        cipherSpi.engineInit(opmode, key, random);
+      }
+    state = opmode;
+  }
+
+  /**
+   * <p>Initialize this cipher with the supplied key and parameters.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>If this cipher requires any random bytes (for example for an
+   * initilization vector) then the {@link java.security.SecureRandom}
+   * with the highest priority is used as the source of these bytes.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode The operation mode to use.
+   * @param key    The key.
+   * @param params The algorithm parameters to initialize this instance
+   *               with.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the given key.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inappropriate for this cipher.
+   */
+  public final void init(int opmode, Key key, AlgorithmParameters params)
+    throws InvalidKeyException, InvalidAlgorithmParameterException
+  {
+    init(opmode, key, params, new SecureRandom());
+  }
+
+  /**
+   * <p>Initialize this cipher with the supplied key and parameters.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>If this cipher requires any random bytes (for example for an
+   * initilization vector) then the {@link java.security.SecureRandom}
+   * with the highest priority is used as the source of these bytes.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode The operation mode to use.
+   * @param key    The key.
+   * @param params The algorithm parameters to initialize this instance
+   *               with.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the given key.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inappropriate for this cipher.
+   */
+  public final void init(int opmode, Key key, AlgorithmParameterSpec params)
+    throws InvalidKeyException, InvalidAlgorithmParameterException
+  {
+    init(opmode, key, params, new SecureRandom());
+  }
+
+  /**
+   * <p>Initialize this cipher with the supplied key, parameters, and
+   * source of randomness.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode The operation mode to use.
+   * @param key    The key.
+   * @param params The algorithm parameters to initialize this instance
+   *               with.
+   * @param random The source of randomness to use.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the given key.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inappropriate for this cipher.
+   */
+  public final void init(int opmode, Key key, AlgorithmParameters params,
+                         SecureRandom random)
+    throws InvalidKeyException, InvalidAlgorithmParameterException
+  {
+    if (cipherSpi != null)
+      {
+        cipherSpi.engineInit(opmode, key, params, random);
+      }
+    state = opmode;
+  }
+
+  /**
+   * <p>Initialize this cipher with the supplied key, parameters, and
+   * source of randomness.</p>
+   *
+   * <p>The cipher will be initialized for encryption, decryption, key
+   * wrapping, or key unwrapping, depending upon whether the
+   * <code>opmode</code> argument is {@link #ENCRYPT_MODE}, {@link
+   * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
+   * respectively.</p>
+   *
+   * <p>A call to any of the <code>init</code> methods overrides the
+   * state of the instance, and is equivalent to creating a new instance
+   * and calling its <code>init</code> method.</p>
+   *
+   * @param opmode The operation mode to use.
+   * @param key    The key.
+   * @param params The algorithm parameters to initialize this instance
+   *               with.
+   * @param random The source of randomness to use.
+   * @throws java.security.InvalidKeyException If the underlying cipher
+   *         instance rejects the given key.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inappropriate for this cipher.
+   */
+  public final void init(int opmode, Key key, AlgorithmParameterSpec params,
+                         SecureRandom random)
+    throws InvalidKeyException, InvalidAlgorithmParameterException
+  {
+    if (cipherSpi != null)
+      {
+        cipherSpi.engineInit(opmode, key, params, random);
+      }
+    state = opmode;
+  }
+
+  /**
+   * Unwrap a previously-wrapped key.
+   *
+   * @param wrappedKey          The wrapped key.
+   * @param wrappedKeyAlgorithm The algorithm with which the key was
+   *        wrapped.
+   * @param wrappedKeyType      The type of key (public, private, or
+   *        secret) that this wrapped key respresents.
+   * @return The unwrapped key.
+   * @throws java.lang.IllegalStateException If this instance has not be
+   *         initialized for unwrapping.
+   * @throws java.security.InvalidKeyException If <code>wrappedKey</code>
+   *         is not a wrapped key, if the algorithm cannot unwrap this
+   *         key, or if the unwrapped key's type differs from the
+   *         specified type.
+   * @throws java.security.NoSuchAlgorithmException If
+   *         <code>wrappedKeyAlgorithm</code> is not a valid algorithm
+   *         name.
+   */
+  public final Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
+                          int wrappedKeyType)
+    throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException
+  {
+    if (cipherSpi == null)
+      {
+        return null;
+      }
+    if (state != UNWRAP_MODE)
+      {
+        throw new IllegalStateException("instance is not for unwrapping");
+      }
+    return cipherSpi.engineUnwrap(wrappedKey, wrappedKeyAlgorithm,
+                                  wrappedKeyType);
+  }
+
+  /**
+   * Continue a multi-part transformation on an entire byte array,
+   * returning the transformed bytes.
+   *
+   * @param input The input bytes.
+   * @return The transformed bytes.
+   * @throws java.lang.IllegalStateException If this cipher was not
+   *         initialized for encryption or decryption.
+   */
+  public final byte[] update(byte[] input) throws IllegalStateException
+  {
+    return update(input, 0, input.length);
+  }
+
+  /**
+   * Continue a multi-part transformation on part of a byte array,
+   * returning the transformed bytes.
+   *
+   * @param input       The input bytes.
+   * @param inputOffset The index in the input to start.
+   * @param inputLength The number of bytes to transform.
+   * @return The transformed bytes.
+   * @throws java.lang.IllegalStateException If this cipher was not
+   *         initialized for encryption or decryption.
+   */
+  public final byte[] update(byte[] input, int inputOffset, int inputLength)
+    throws IllegalStateException
+  {
+    if (cipherSpi == null)
+      {
+        byte[] b = new byte[inputLength];
+        System.arraycopy(input, inputOffset, b, 0, inputLength);
+        return b;
+      }
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      {
+        throw new IllegalStateException(
+          "cipher is not for encrypting or decrypting");
+      }
+    return cipherSpi.engineUpdate(input, inputOffset, inputLength);
+  }
+
+  /**
+   * Continue a multi-part transformation on part of a byte array,
+   * placing the transformed bytes into the given array.
+   *
+   * @param input       The input bytes.
+   * @param inputOffset The index in the input to start.
+   * @param inputLength The number of bytes to transform.
+   * @param output      The output byte array.
+   * @return The number of transformed bytes.
+   * @throws java.lang.IllegalStateException If this cipher was not
+   *         initialized for encryption or decryption.
+   * @throws javax.security.ShortBufferException If there is not enough
+   *         room in the output array to hold the transformed bytes.
+   */
+  public final int update(byte[] input, int inputOffset, int inputLength,
+                          byte[] output)
+    throws IllegalStateException, ShortBufferException
+  {
+    return update(input, inputOffset, inputLength, output, 0);
+  }
+
+  /**
+   * Continue a multi-part transformation on part of a byte array,
+   * placing the transformed bytes into the given array.
+   *
+   * @param input        The input bytes.
+   * @param inputOffset  The index in the input to start.
+   * @param inputLength  The number of bytes to transform.
+   * @param output       The output byte array.
+   * @param outputOffset The index in the output array to start.
+   * @return The number of transformed bytes.
+   * @throws java.lang.IllegalStateException If this cipher was not
+   *         initialized for encryption or decryption.
+   * @throws javax.security.ShortBufferException If there is not enough
+   *         room in the output array to hold the transformed bytes.
+   */
+  public final int update(byte[] input, int inputOffset, int inputLength,
+                          byte[] output, int outputOffset)
+    throws IllegalStateException, ShortBufferException
+  {
+    if (cipherSpi == null)
+      {
+        if (inputLength > output.length - outputOffset)
+          {
+            throw new ShortBufferException();
+          }
+        System.arraycopy(input, inputOffset, output, outputOffset, inputLength);
+        return inputLength;
+      }
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      {
+        throw new IllegalStateException(
+          "cipher is not for encrypting or decrypting");
+      }
+    return cipherSpi.engineUpdate(input, inputOffset, inputLength,
+                                  output, outputOffset);
+  }
+
+  /**
+   * Continue a multi-part transformation on a byte buffer, storing
+   * the transformed bytes into another buffer.
+   *
+   * @param input  The input buffer.
+   * @param output The output buffer.
+   * @return The number of bytes stored in <i>output</i>.
+   * @throws IllegalArgumentException If the two buffers are the same
+   *  object.
+   * @throws IllegalStateException If this cipher was not initialized
+   *  for encrypting or decrypting.
+   * @throws ReadOnlyBufferException If the output buffer is not
+   *  writable.
+   * @throws ShortBufferException If the output buffer does not have
+   *  enough available space for the transformed bytes.
+   * @since 1.5
+   */
+  public final int update (ByteBuffer input, ByteBuffer output)
+    throws ReadOnlyBufferException, ShortBufferException
+  {
+    if (input == output)
+      throw new IllegalArgumentException
+        ("input and output buffers must be different");
+    if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
+      throw new IllegalStateException
+        ("not initialized for encryption or decryption");
+    return cipherSpi.engineUpdate (input, output);
+  }
+
+  /**
+   * Wrap a key.
+   *
+   * @param key The key to wrap.
+   * @return The wrapped key.
+   * @throws java.lang.IllegalStateException If this instance was not
+   *         initialized for key wrapping.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the key is not a multiple of the block size.
+   * @throws java.security.InvalidKeyException If this instance cannot
+   *         wrap this key.
+   */
+  public final byte[] wrap(Key key)
+    throws IllegalStateException, IllegalBlockSizeException, InvalidKeyException
+  {
+    if (cipherSpi == null)
+      {
+        return null;
+      }
+    if (state != WRAP_MODE)
+      {
+        throw new IllegalStateException("instance is not for key wrapping");
+      }
+    return cipherSpi.engineWrap(key);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,368 @@
+/* CipherInputStream.java -- Filters input through a cipher.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.logging.Logger;
+
+/**
+ * This is an {@link java.io.InputStream} that filters its data
+ * through a {@link Cipher} before returning it. The <code>Cipher</code>
+ * argument must have been initialized before it is passed to the
+ * constructor.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class CipherInputStream extends FilterInputStream
+{
+
+  // Constants and variables.
+  // ------------------------------------------------------------------------
+
+  private static final Logger logger = SystemLogger.SYSTEM;
+
+  /**
+   * The underlying {@link Cipher} instance.
+   */
+  private final Cipher cipher;
+
+  /**
+   * Data that has been transformed but not read.
+   */
+  private byte[] outBuffer;
+
+  /**
+   * The offset into {@link #outBuffer} where valid data starts.
+   */
+  private int outOffset;
+
+  /**
+   * We set this when the cipher block size is 1, meaning that we can
+   * transform any amount of data.
+   */
+  private final boolean isStream;
+
+  /**
+   * Whether or not we've reached the end of the stream.
+   */
+  private boolean eof;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Creates a new input stream with a source input stream and cipher.
+   *
+   * @param in     The underlying input stream.
+   * @param cipher The cipher to filter data through.
+   */
+  public CipherInputStream(InputStream in, Cipher cipher)
+  {
+    super (in);
+    this.cipher = cipher;
+    isStream = cipher.getBlockSize () == 1;
+    eof = false;
+    if (Configuration.DEBUG)
+      logger.log (Component.CRYPTO, "I am born; cipher: {0}, stream? {1}",
+                  new Object[] { cipher.getAlgorithm (),
+                                 Boolean.valueOf (isStream) });
+  }
+
+  /**
+   * Creates a new input stream without a cipher. This constructor is
+   * <code>protected</code> because this class does not work without an
+   * underlying cipher.
+   *
+   * @param in The underlying input stream.
+   */
+  protected CipherInputStream(InputStream in)
+  {
+    this (in, new NullCipher ());
+  }
+
+  // Instance methods overriding java.io.FilterInputStream.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Returns the number of bytes available without blocking. The value
+   * returned is the number of bytes that have been processed by the
+   * cipher, and which are currently buffered by this class.
+   *
+   * @return The number of bytes immediately available.
+   * @throws java.io.IOException If an I/O exception occurs.
+   */
+  public int available() throws IOException
+  {
+    if (isStream)
+      return super.available();
+    if (outBuffer == null || outOffset >= outBuffer.length)
+      nextBlock ();
+    return outBuffer.length - outOffset;
+  }
+
+  /**
+   * Close this input stream. This method merely calls the {@link
+   * java.io.InputStream#close()} method of the underlying input stream.
+   *
+   * @throws java.io.IOException If an I/O exception occurs.
+   */
+  public synchronized void close() throws IOException
+  {
+    super.close();
+  }
+
+  /**
+   * Read a single byte from this input stream; returns -1 on the
+   * end-of-file.
+   *
+   * @return The byte read, or -1 if there are no more bytes.
+   * @throws java.io.IOExcpetion If an I/O exception occurs.
+   */
+  public synchronized int read() throws IOException
+  {
+    if (isStream)
+      {
+        byte[] buf = new byte[1];
+        int in = super.read();
+        if (in == -1)
+          return -1;
+        buf[0] = (byte) in;
+        try
+          {
+            cipher.update(buf, 0, 1, buf, 0);
+          }
+        catch (ShortBufferException shouldNotHappen)
+          {
+            throw new IOException(shouldNotHappen.getMessage());
+          }
+        return buf[0] & 0xFF;
+      }
+
+    if (outBuffer == null || outOffset == outBuffer.length)
+      {
+        if (eof)
+          return -1;
+        nextBlock ();
+      }
+    return outBuffer [outOffset++] & 0xFF;
+  }
+
+  /**
+   * Read bytes into an array, returning the number of bytes read or -1
+   * on the end-of-file.
+   *
+   * @param buf The byte array to read into.
+   * @param off The offset in <code>buf</code> to start.
+   * @param len The maximum number of bytes to read.
+   * @return The number of bytes read, or -1 on the end-of-file.
+   * @throws java.io.IOException If an I/O exception occurs.
+   */
+  public synchronized int read(byte[] buf, int off, int len)
+    throws IOException
+  {
+    // CipherInputStream has this wierd implementation where if
+    // the buffer is null, this call is the same as `skip'.
+    if (buf == null)
+      return (int) skip (len);
+
+    if (isStream)
+      {
+        len = super.read(buf, off, len);
+        if (len > 0)
+          {
+            try
+              {
+                cipher.update(buf, off, len, buf, off);
+              }
+            catch (ShortBufferException shouldNotHappen)
+              {
+                IOException ioe = new IOException ("Short buffer for stream cipher -- this should not happen");
+                ioe.initCause (shouldNotHappen);
+                throw ioe;
+              }
+          }
+        return len;
+      }
+
+    int count = 0;
+    while (count < len)
+      {
+        if (outBuffer == null || outOffset >= outBuffer.length)
+          {
+            if (eof)
+              {
+                if (count == 0)
+                  count = -1;
+                break;
+              }
+            nextBlock();
+          }
+        int l = Math.min (outBuffer.length - outOffset, len - count);
+        System.arraycopy (outBuffer, outOffset, buf, count+off, l);
+        count += l;
+        outOffset += l;
+      }
+    return count;
+  }
+
+  /**
+   * Read bytes into an array, returning the number of bytes read or -1
+   * on the end-of-file.
+   *
+   * @param buf The byte arry to read into.
+   * @return The number of bytes read, or -1 on the end-of-file.
+   * @throws java.io.IOException If an I/O exception occurs.
+   */
+  public int read(byte[] buf) throws IOException
+  {
+    return read(buf, 0, buf.length);
+  }
+
+  /**
+   * Skip a number of bytes. This class only supports skipping as many
+   * bytes as are returned by {@link #available()}, which is the number
+   * of transformed bytes currently in this class's internal buffer.
+   *
+   * @param bytes The number of bytes to skip.
+   * @return The number of bytes skipped.
+   */
+  public long skip(long bytes) throws IOException
+  {
+    if (isStream)
+      {
+        return super.skip(bytes);
+      }
+    long ret = 0;
+    if (bytes > 0 && outBuffer != null && outOffset >= outBuffer.length)
+      {
+        ret = outBuffer.length - outOffset;
+        outOffset = outBuffer.length;
+      }
+    return ret;
+  }
+
+  /**
+   * Returns whether or not this input stream supports the {@link
+   * #mark(long)} and {@link #reset()} methods; this input stream does
+   * not, however, and invariably returns <code>false</code>.
+   *
+   * @return <code>false</code>
+   */
+  public boolean markSupported()
+  {
+    return false;
+  }
+
+  /**
+   * Set the mark. This method is unsupported and is empty.
+   *
+   * @param mark Is ignored.
+   */
+  public void mark(int mark)
+  {
+  }
+
+  /**
+   * Reset to the mark. This method is unsupported and is empty.
+   */
+  public void reset() throws IOException
+  {
+    throw new IOException("reset not supported");
+  }
+
+  // Own methods.
+  // -------------------------------------------------------------------------
+
+  // FIXME: I don't fully understand how this class is supposed to work.
+
+  private void nextBlock() throws IOException
+  {
+    byte[] buf = new byte[cipher.getBlockSize ()];
+    if (Configuration.DEBUG)
+      logger.log (Component.CRYPTO, "getting a new data block");
+
+    try
+      {
+        outBuffer = null;
+        outOffset = 0;
+        while (outBuffer == null)
+          {
+            int l = in.read (buf);
+            if (Configuration.DEBUG)
+              logger.log (Component.CRYPTO, "we read {0} bytes",
+                          Integer.valueOf (l));
+            if (l == -1)
+              {
+                outBuffer = cipher.doFinal ();
+                eof = true;
+                return;
+              }
+
+            outOffset = 0;
+            outBuffer = cipher.update (buf, 0, l);
+          }
+      }
+    catch (BadPaddingException bpe)
+      {
+        IOException ioe = new IOException ("bad padding");
+        ioe.initCause (bpe);
+        throw ioe;
+      }
+    catch (IllegalBlockSizeException ibse)
+      {
+        IOException ioe = new IOException ("illegal block size");
+        ioe.initCause (ibse);
+        throw ioe;
+      }
+    finally
+      {
+        if (Configuration.DEBUG)
+          logger.log (Component.CRYPTO,
+                      "decrypted {0} bytes for reading",
+                      Integer.valueOf (outBuffer.length));
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+/* CipherOutputStream.java -- Filters output through a cipher.
+   Copyright (C) 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 javax.crypto;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A filtered output stream that transforms data written to it with a
+ * {@link Cipher} before sending it to the underlying output stream.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class CipherOutputStream extends FilterOutputStream
+{
+  /** The underlying cipher. */
+  private Cipher cipher;
+
+  /**
+   * Create a new cipher output stream. The cipher argument must have already
+   * been initialized.
+   *
+   * @param out The sink for transformed data.
+   * @param cipher The cipher to transform data with.
+   */
+  public CipherOutputStream(OutputStream out, Cipher cipher)
+  {
+    super(out);
+    this.cipher = (cipher != null) ? cipher : new NullCipher();
+  }
+
+  /**
+   * Create a cipher output stream with no cipher.
+   *
+   * @param out The sink for transformed data.
+   */
+  protected CipherOutputStream(OutputStream out)
+  {
+    super(out);
+  }
+
+  /**
+   * Close this output stream, and the sink output stream.
+   * <p>
+   * This method will first invoke the {@link Cipher#doFinal()} method of the
+   * underlying {@link Cipher}, and writes the output of that method to the
+   * sink output stream.
+   *
+   * @throws IOException If an I/O error occurs, or if an error is caused by
+   *           finalizing the transformation.
+   */
+  public void close() throws IOException
+  {
+    try
+      {
+        out.write(cipher.doFinal());
+        out.flush();
+        out.close();
+      }
+    catch (Exception cause)
+      {
+        IOException ioex = new IOException(String.valueOf(cause));
+        ioex.initCause(cause);
+        throw ioex;
+      }
+  }
+
+  /**
+   * Flush any pending output.
+   *
+   * @throws IOException If an I/O error occurs.
+   */
+  public void flush() throws IOException
+  {
+    out.flush();
+  }
+
+  /**
+   * Write a single byte to the output stream.
+   *
+   * @param b The next byte.
+   * @throws IOException If an I/O error occurs, or if the underlying cipher is
+   *           not in the correct state to transform data.
+   */
+  public void write(int b) throws IOException
+  {
+    write(new byte[] { (byte) b }, 0, 1);
+  }
+
+  /**
+   * Write a byte array to the output stream.
+   *
+   * @param buf The next bytes.
+   * @throws IOException If an I/O error occurs, or if the underlying cipher is
+   *           not in the correct state to transform data.
+   */
+  public void write(byte[] buf) throws IOException
+  {
+    write(buf, 0, buf.length);
+  }
+
+  /**
+   * Write a portion of a byte array to the output stream.
+   *
+   * @param buf The next bytes.
+   * @param off The offset in the byte array to start.
+   * @param len The number of bytes to write.
+   * @throws IOException If an I/O error occurs, or if the underlying cipher is
+   *           not in the correct state to transform data.
+   */
+  public void write(byte[] buf, int off, int len) throws IOException
+  {
+    out.write(cipher.update(buf, off, len));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/CipherSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,445 @@
+/* CipherSpi.java -- The cipher service provider interface.
+   Copyright (C) 2004, 2006  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 javax.crypto;
+
+import java.nio.ByteBuffer;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * <p>This class represents the <i>Service Provider Interface</i>
+ * (<b>SPI</b>) for cryptographic ciphers.</p>
+ *
+ * <p>Providers of cryptographic ciphers must subclass this for every
+ * cipher they implement, implementing the abstract methods as
+ * appropriate, then provide an entry that points to the subclass in
+ * their implementation of {@link java.security.Provider}.</p>
+ *
+ * <p>CipherSpi objects are instantiated along with {@link Cipher}s when
+ * the {@link Cipher#getInstance(java.lang.String)} methods are invoked.
+ * Particular ciphers are referenced by a <i>transformation</i>, which
+ * is a String consisting of the cipher's name or the ciper's name
+ * followed by a mode and a padding. Transformations all follow the
+ * general form:</p>
+ *
+ * <ul>
+ * <li><i>algorithm</i>, or</li>
+ * <li><i>algorithm</i>/<i>mode</i>/<i>padding</i>
+ * </ul>
+ *
+ * <p>Cipher names in the master {@link java.security.Provider} class
+ * may be:</p>
+ *
+ * <ol>
+ * <li>The algorithm's name, which uses a pluggable mode and padding:
+ * <code>Cipher.<i>algorithm</i></code></li>
+ * <li>The algorithm's name and the mode, which uses pluggable padding:
+ * <code>Cipher.<i>algorithm</i>/<i>mode</i></code></li>
+ * <li>The algorithm's name and the padding, which uses a pluggable
+ * mode: <code>Cipher.<i>algorithm</i>//<i>padding</i></code></li>
+ * <li>The algorihtm's name, the mode, and the padding:
+ * <code>Cipher.<i>algorithm</i>/<i>mode</i>/<i>padding</i></code></li>
+ * </ol>
+ *
+ * <p>When any {@link Cipher#getInstance(java.lang.String)} method is
+ * invoked, the following happens if the transformation is simply
+ * <i>algorithm</i>:</p>
+ *
+ * <ol>
+ * <li>If the provider defines a <code>CipherSpi</code> implementation
+ * for "<i>algorithm</i>", return it. Otherwise throw a {@link
+ * java.security.NoSuchAlgorithmException}.</li>
+ * </ol>
+ *
+ * <p>If the transformation is of the form
+ * <i>algorithm</i>/<i>mode</i>/<i>padding</i>:</p>
+ *
+ * <ol>
+ * <li>If the provider defines a <code>CipherSpi</code> subclass for
+ * "<i>algorithm</i>/<i>mode</i>/<i>padding</i>", return it. Otherwise
+ * go to step 2.</li>
+ *
+ * <li>If the provider defines a <code>CipherSpi</code> subclass for
+ * "<i>algorithm</i>/<i>mode</i>", instatiate it, call {@link
+ * #engineSetPadding(java.lang.String)} for the padding name, and return
+ * it. Otherwise go to step 3.</li>
+ *
+ * <li>If the provider defines a <code>CipherSpi</code> subclass for
+ * "<i>algorithm</i>//<i>padding</i>", instatiate it, call {@link
+ * #engineSetMode(java.lang.String)} for the mode name, and return
+ * it. Otherwise go to step 4.</li>
+ *
+ * <li>If the provider defines a <code>CipherSpi</code> subclass for
+ * "<i>algorithm</i>", instatiate it, call {@link
+ * #engineSetMode(java.lang.String)} for the mode name, call {@link
+ * #engineSetPadding(java.lang.String)} for the padding name, and return
+ * it. Otherwise throw a {@link java.security.NoSuchAlgorithmException}.</li>
+ * </ol>
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public abstract class CipherSpi
+{
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new CipherSpi.
+   */
+  public CipherSpi()
+  {
+  }
+
+  // Abstract methods to be implemented by providers.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Finishes a multi-part transformation or transforms a portion of a
+   * byte array, and returns the transformed bytes.
+   *
+   * @param input       The input bytes.
+   * @param inputOffset The index in the input at which to start.
+   * @param inputLength The number of bytes to transform.
+   * @return The transformed bytes in a new array.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input size is not a multiple of the
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is being
+   *         used for decryption and the padding is not appropriate for
+   *         this instance's padding scheme.
+   */
+  protected abstract byte[]
+  engineDoFinal(byte[] input, int inputOffset, int inputLength)
+  throws IllegalBlockSizeException, BadPaddingException;
+
+  /**
+   * Finishes a multi-part transformation or transforms a portion of a
+   * byte array, and stores the transformed bytes in the supplied array.
+   *
+   * @param input        The input bytes.
+   * @param inputOffset  The index in the input at which to start.
+   * @param inputLength  The number of bytes to transform.
+   * @param output       The output byte array.
+   * @param outputOffset The index in the output array at which to start.
+   * @return The number of transformed bytes stored in the output array.
+   * @throws javax.crypto.IllegalBlockSizeException If this instance has
+   *         no padding and the input size is not a multiple of the
+   *         block size.
+   * @throws javax.crypto.BadPaddingException If this instance is being
+   *         used for decryption and the padding is not appropriate for
+   *         this instance's padding scheme.
+   * @throws javax.crypto.ShortBufferException If there is not enough
+   *         space in the output array for the transformed bytes.
+   */
+  protected abstract int
+  engineDoFinal(byte[] input, int inputOffset, int inputLength,
+                byte[] output, int outputOffset)
+  throws IllegalBlockSizeException, BadPaddingException, ShortBufferException;
+
+  /**
+   * @since 1.5
+   */
+  protected int engineDoFinal (ByteBuffer input, ByteBuffer output)
+    throws BadPaddingException, IllegalBlockSizeException,
+           ShortBufferException
+  {
+    int total = 0;
+    byte[] inbuf = new byte[256];
+    while (input.hasRemaining ())
+      {
+        int in = Math.min (inbuf.length, input.remaining ());
+        input.get (inbuf, 0, in);
+        byte[] outbuf = new byte[engineGetOutputSize (in)];
+        int out = 0;
+        if (input.hasRemaining ()) // i.e., we have more 'update' calls
+          out = engineUpdate (inbuf, 0, in, outbuf, 0);
+        else
+          out = engineDoFinal (inbuf, 0, in, outbuf, 0);
+        output.put (outbuf, 0, out);
+        total += out;
+      }
+    return total;
+  }
+
+  /**
+   * Returns the block size of the underlying cipher.
+   *
+   * @return The block size.
+   */
+  protected abstract int engineGetBlockSize();
+
+  /**
+   * Returns the initializaiton vector this cipher was initialized with,
+   * if any.
+   *
+   * @return The IV, or null if this cipher uses no IV or if this
+   *         instance has not been initialized yet.
+   */
+  protected abstract byte[] engineGetIV();
+
+  /**
+   * <p>Return the length of the given key in bits.</p>
+   *
+   * <p>For compatibility this method is not declared
+   * <code>abstract</code>, and the default implementation will throw an
+   * {@link java.lang.UnsupportedOperationException}. Concrete
+   * subclasses should override this method to return the correct
+   * value.</p>
+   *
+   * @param key The key to get the size for.
+   * @return The size of the key, in bits.
+   * @throws java.security.InvalidKeyException If the key's length
+   *         cannot be determined by this implementation.
+   */
+  protected int engineGetKeySize(Key key) throws InvalidKeyException
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * <p>Returns the size, in bytes, an output buffer must be for a call
+   * to {@link #engineUpdate(byte[],int,int,byte[],int)} or {@link
+   * #engineDoFinal(byte[],int,int,byte[],int)} to succeed.</p>
+   *
+   * <p>The actual output length may be smaller than the value returned
+   * by this method, as it considers the padding length as well. The
+   * length considered is the argument plus the length of any buffered,
+   * unprocessed bytes.</p>
+   *
+   * @param inputLength The input length, in bytes.
+   * @return The size an output buffer must be.
+   */
+  protected abstract int engineGetOutputSize(int inputLength);
+
+  /**
+   * Returns the parameters that this cipher is using. This may be the
+   * parameters used to initialize this cipher, or it may be parameters
+   * that have been initialized with random values.
+   *
+   * @return This cipher's parameters, or <code>null</code> if this
+   *         cipher does not use parameters.
+   */
+  protected abstract AlgorithmParameters engineGetParameters();
+
+  /**
+   * Initializes this cipher with an operation mode, key, and source of
+   * randomness. If this cipher requires any other initializing data,
+   * for example an initialization vector, then it should generate it
+   * from the provided source of randomness.
+   *
+   * @param opmode The operation mode, one of {@link
+   *        Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link
+   *        Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}.
+   * @param key    The key to initialize this cipher with.
+   * @param random The source of random bytes to use.
+   * @throws java.security.InvalidKeyException If the given key is not
+   *         acceptable for this implementation.
+   */
+  protected abstract void engineInit(int opmode, Key key, SecureRandom random)
+  throws InvalidKeyException;
+
+  /**
+   * Initializes this cipher with an operation mode, key, parameters,
+   * and source of randomness. If this cipher requires any other
+   * initializing data, for example an initialization vector, then it should
+   * generate it from the provided source of randomness.
+   *
+   * @param opmode The operation mode, one of {@link
+   *        Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link
+   *        Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}.
+   * @param key    The key to initialize this cipher with.
+   * @param params The algorithm parameters to initialize with.
+   * @param random The source of random bytes to use.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         given parameters are not appropriate for this
+   *         implementation.
+   * @throws java.security.InvalidKeyException If the given key is not
+   *         acceptable for this implementation.
+   */
+  protected abstract void
+  engineInit(int opmode, Key key, AlgorithmParameters params,
+             SecureRandom random)
+  throws InvalidAlgorithmParameterException, InvalidKeyException;
+
+  /**
+   * Initializes this cipher with an operation mode, key, parameters,
+   * and source of randomness. If this cipher requires any other
+   * initializing data, for example an initialization vector, then it should
+   * generate it from the provided source of randomness.
+   *
+   * @param opmode The operation mode, one of {@link
+   *        Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link
+   *        Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}.
+   * @param key    The key to initialize this cipher with.
+   * @param params The algorithm parameters to initialize with.
+   * @param random The source of random bytes to use.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         given parameters are not appropriate for this
+   *         implementation.
+   * @throws java.security.InvalidKeyException If the given key is not
+   *         acceptable for this implementation.
+   */
+  protected abstract void
+  engineInit(int opmode, Key key, AlgorithmParameterSpec params,
+             SecureRandom random)
+  throws InvalidAlgorithmParameterException, InvalidKeyException;
+
+  /**
+   * Set the mode in which this cipher is to run.
+   *
+   * @param mode The name of the mode to use.
+   * @throws java.security.NoSuchAlgorithmException If the mode is
+   *         not supported by this cipher's provider.
+   */
+  protected abstract void engineSetMode(String mode)
+  throws NoSuchAlgorithmException;
+
+  /**
+   * Set the method with which the input is to be padded.
+   *
+   * @param padding The name of the padding to use.
+   * @throws javax.crypto.NoSuchPaddingException If the padding is not
+   *         supported by this cipher's provider.
+   */
+  protected abstract void engineSetPadding(String padding)
+  throws NoSuchPaddingException;
+
+  /**
+   * <p>Unwraps a previously-wrapped key.</p>
+   *
+   * <p>For compatibility this method is not declared
+   * <code>abstract</code>, and the default implementation will throw an
+   * {@link java.lang.UnsupportedOperationException}.</p>
+   *
+   * @param wrappedKey          The wrapped key.
+   * @param wrappedKeyAlgorithm The name of the algorithm used to wrap
+   *                            this key.
+   * @param wrappedKeyType      The type of wrapped key; one of
+   *                            {@link Cipher#PRIVATE_KEY},
+   *                            {@link Cipher#PUBLIC_KEY}, or
+   *                            {@link Cipher#SECRET_KEY}.
+   * @return The unwrapped key.
+   * @throws java.security.InvalidKeyException If the key cannot be
+   *         unwrapped, or if <code>wrappedKeyType</code> is an
+   *         inappropriate type for the unwrapped key.
+   * @throws java.security.NoSuchAlgorithmException If the
+   *         <code>wrappedKeyAlgorithm</code> is unknown.
+   */
+  protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
+                             int wrappedKeyType)
+  throws InvalidKeyException, NoSuchAlgorithmException
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Continue with a multi-part transformation, returning a new array of
+   * the transformed bytes.
+   *
+   * @param input       The next input bytes.
+   * @param inputOffset The index in the input array from which to start.
+   * @param inputLength The number of bytes to input.
+   * @return The transformed bytes.
+   */
+  protected abstract byte[]
+  engineUpdate(byte[] input, int inputOffset, int inputLength);
+
+  /**
+   * Continue with a multi-part transformation, storing the transformed
+   * bytes into the specified array.
+   *
+   * @param input        The next input bytes.
+   * @param inputOffset  The index in the input from which to start.
+   * @param inputLength  The number of bytes to input.
+   * @param output       The output buffer.
+   * @param outputOffset The index in the output array from which to start.
+   * @return The transformed bytes.
+   * @throws javax.crypto.ShortBufferException If there is not enough
+   *         space in the output array to store the transformed bytes.
+   */
+  protected abstract int
+  engineUpdate(byte[] input, int inputOffset, int inputLength,
+               byte[] output, int outputOffset)
+  throws ShortBufferException;
+
+  /**
+   * @since 1.5
+   */
+  protected int engineUpdate (ByteBuffer input, ByteBuffer output)
+    throws ShortBufferException
+  {
+    int total = 0;
+    byte[] inbuf = new byte[256];
+    while (input.hasRemaining ())
+      {
+        int in = Math.min (inbuf.length, input.remaining ());
+        input.get (inbuf, 0, in);
+        byte[] outbuf = new byte[engineGetOutputSize (in)];
+        int out = engineUpdate (inbuf, 0, in, outbuf, 0);
+        output.put (outbuf, 0, out);
+        total += out;
+      }
+    return total;
+  }
+
+  /**
+   * <p>Wrap a key.</p>
+   *
+   * <p>For compatibility this method is not declared
+   * <code>abstract</code>, and the default implementation will throw an
+   * {@link java.lang.UnsupportedOperationException}.</p>
+   *
+   * @param key The key to wrap.
+   * @return The wrapped key.
+   * @throws java.security.InvalidKeyException If the key cannot be
+   *         wrapped.
+   */
+  protected byte[] engineWrap(Key key) throws InvalidKeyException, IllegalBlockSizeException
+  {
+    throw new UnsupportedOperationException();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,317 @@
+/* EncryptedPrivateKeyInfo.java -- As in PKCS #8.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.java.security.OID;
+import gnu.java.security.der.DER;
+import gnu.java.security.der.DERReader;
+import gnu.java.security.der.DERValue;
+
+import java.io.IOException;
+import java.security.AlgorithmParameters;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An implementation of the <code>EncryptedPrivateKeyInfo</code> ASN.1
+ * type as specified in <a
+ * href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-8/">PKCS #8 -
+ * Private-Key Information Syntax Standard</a>.
+ *
+ * <p>The ASN.1 type <code>EncryptedPrivateKeyInfo</code> is:
+ *
+ * <blockquote>
+ * <pre>EncryptedPrivateKeyInfo ::= SEQUENCE {
+ *   encryptionAlgorithm EncryptionAlgorithmIdentifier,
+ *   encryptedData EncryptedData }
+ *
+ * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * EncrytpedData ::= OCTET STRING
+ *
+ * AlgorithmIdentifier ::= SEQUENCE {
+ *   algorithm  OBJECT IDENTIFIER,
+ *   parameters ANY DEFINED BY algorithm OPTIONAL }</pre>
+ * </blockquote>
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see java.security.spec.PKCS8EncodedKeySpec
+ */
+public class EncryptedPrivateKeyInfo
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  /** The encrypted data. */
+  private byte[] encryptedData;
+
+  /** The encoded, encrypted key. */
+  private byte[] encoded;
+
+  /** The OID of the encryption algorithm. */
+  private OID algOid;
+
+  /** The encryption algorithm name. */
+  private String algName;
+
+  /** The encryption algorithm's parameters. */
+  private AlgorithmParameters params;
+
+  /** The encoded ASN.1 algorithm parameters. */
+  private byte[] encodedParams;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new <code>EncryptedPrivateKeyInfo</code> object from raw
+   * encrypted data and the parameters used for encryption.
+   *
+   * <p>The <code>encryptedData</code> array is cloned.
+   *
+   * @param params        The encryption algorithm parameters.
+   * @param encryptedData The encrypted key data.
+   * @throws java.lang.IllegalArgumentException If the
+   *         <code>encryptedData</code> array is empty (zero-length).
+   * @throws java.security.NoSuchAlgorithmException If the algorithm
+   *         specified in the parameters is not supported.
+   * @throws java.lang.NullPointerException If <code>encryptedData</code>
+   *         is null.
+   */
+  public EncryptedPrivateKeyInfo(AlgorithmParameters params,
+                                 byte[] encryptedData)
+    throws IllegalArgumentException, NoSuchAlgorithmException
+  {
+    if (encryptedData.length == 0)
+      {
+        throw new IllegalArgumentException("0-length encryptedData");
+      }
+    this.params = params;
+    algName = params.getAlgorithm ();
+    algOid = getOid (algName);
+    this.encryptedData = (byte[]) encryptedData.clone();
+  }
+
+  /**
+   * Create a new <code>EncryptedPrivateKeyInfo</code> from an encoded
+   * representation, parsing the ASN.1 sequence.
+   *
+   * @param encoded The encoded info.
+   * @throws java.io.IOException If parsing the encoded data fails.
+   * @throws java.lang.NullPointerException If <code>encoded</code> is
+   *         null.
+   */
+  public EncryptedPrivateKeyInfo(byte[] encoded)
+    throws IOException
+  {
+    this.encoded = (byte[]) encoded.clone();
+    decode();
+  }
+
+  /**
+   * Create a new <code>EncryptedPrivateKeyInfo</code> from the cipher
+   * name and the encrytpedData.
+   *
+   * <p>The <code>encryptedData</code> array is cloned.
+   *
+   * @param algName       The name of the algorithm (as an object identifier).
+   * @param encryptedData The encrypted key data.
+   * @throws java.lang.IllegalArgumentException If the
+   *         <code>encryptedData</code> array is empty (zero-length).
+   * @throws java.security.NoSuchAlgorithmException If algName is not
+   *         the name of a supported algorithm.
+   * @throws java.lang.NullPointerException If <code>encryptedData</code>
+   *         is null.
+   */
+  public EncryptedPrivateKeyInfo(String algName, byte[] encryptedData)
+    throws IllegalArgumentException, NoSuchAlgorithmException,
+           NullPointerException
+  {
+    if (encryptedData.length == 0)
+      {
+        throw new IllegalArgumentException("0-length encryptedData");
+      }
+    this.algName = algName.toString (); // do NP check
+    this.algOid = getOid (algName);
+    this.encryptedData = (byte[]) encryptedData.clone();
+  }
+
+  /**
+   * Return the OID for the given cipher name.
+   *
+   * @param str The string.
+   * @throws NoSuchAlgorithmException If the OID is not known.
+   */
+  private static OID getOid (final String str)
+    throws NoSuchAlgorithmException
+  {
+    if (str.equalsIgnoreCase ("DSA"))
+      {
+        return new OID ("1.2.840.10040.4.3");
+      }
+    // FIXME add more
+
+    try
+      {
+        return new OID (str);
+      }
+    catch (Throwable t)
+      {
+      }
+    throw new NoSuchAlgorithmException ("cannot determine OID for '" + str + "'");
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Return the name of the cipher used to encrypt this key.
+   *
+   * @return The algorithm name.
+   */
+  public String getAlgName()
+  {
+    return algOid.toString();
+  }
+
+  public AlgorithmParameters getAlgParameters()
+  {
+    if (params == null && encodedParams != null)
+      {
+        try
+          {
+            params = AlgorithmParameters.getInstance(getAlgName());
+            params.init(encodedParams);
+          }
+        catch (NoSuchAlgorithmException ignore)
+          {
+            // FIXME throw exception?
+          }
+        catch (IOException ignore)
+          {
+          }
+      }
+    return params;
+  }
+
+  public synchronized byte[] getEncoded() throws IOException
+  {
+    if (encoded == null) encode();
+    return (byte[]) encoded.clone();
+  }
+
+  public byte[] getEncryptedData()
+  {
+    return encryptedData;
+  }
+
+  public PKCS8EncodedKeySpec getKeySpec(Cipher cipher)
+    throws InvalidKeySpecException
+  {
+    try
+      {
+        return new PKCS8EncodedKeySpec(cipher.doFinal(encryptedData));
+      }
+    catch (Exception x)
+      {
+        throw new InvalidKeySpecException(x.toString());
+      }
+  }
+
+  // Own methods.
+  // -------------------------------------------------------------------------
+
+  private void decode() throws IOException
+  {
+    DERReader der = new DERReader(encoded);
+    DERValue val = der.read();
+    if (val.getTag() != DER.SEQUENCE)
+      throw new IOException("malformed EncryptedPrivateKeyInfo");
+    val = der.read();
+    if (val.getTag() != DER.SEQUENCE)
+      throw new IOException("malformed AlgorithmIdentifier");
+    int algpLen = val.getLength();
+    DERValue oid = der.read();
+    if (oid.getTag() != DER.OBJECT_IDENTIFIER)
+      throw new IOException("malformed AlgorithmIdentifier");
+    algOid = (OID) oid.getValue();
+    if (algpLen == 0)
+      {
+        val = der.read();
+        if (val.getTag() != 0)
+          {
+            encodedParams = val.getEncoded();
+            der.read();
+          }
+      }
+    else if (oid.getEncodedLength() < val.getLength())
+      {
+        val = der.read();
+        encodedParams = val.getEncoded();
+      }
+    val = der.read();
+    if (val.getTag() != DER.OCTET_STRING)
+      throw new IOException("malformed AlgorithmIdentifier");
+    encryptedData = (byte[]) val.getValue();
+  }
+
+  private void encode() throws IOException
+  {
+    List algId = new ArrayList(2);
+    algId.add(new DERValue(DER.OBJECT_IDENTIFIER, algOid));
+    getAlgParameters();
+    if (params != null)
+      {
+        algId.add (DERReader.read (params.getEncoded()));
+      }
+    else
+      {
+        algId.add (new DERValue (DER.NULL, null));
+      }
+    List epki = new ArrayList(2);
+    epki.add(new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, algId));
+    epki.add(new DERValue(DER.OCTET_STRING, encryptedData));
+    encoded = new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, epki).getEncoded();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanism.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanism.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanism.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanism.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,229 @@
+/* ExemptionMechanism.java -- Generic crypto-weakening mechanism.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.java.security.Engine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * An exemption mechanism, which will conditionally allow cryptography
+ * where it is not normally allowed, implements things such as <i>key
+ * recovery</i>, <i>key weakening</i>, or <i>key escrow</i>.
+ *
+ * <p><b>Implementation note</b>: this class is present for
+ * API-compatibility only; it is not actually used anywhere in this library
+ * and this library does not, in general, support crypto weakening.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class ExemptionMechanism
+{
+
+  // Constants and fields.
+  // ------------------------------------------------------------------------
+
+  private static final String SERVICE = "ExemptionMechanism";
+  private ExemptionMechanismSpi emSpi;
+  private Provider provider;
+  private String mechanism;
+  private boolean virgin;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  protected ExemptionMechanism(ExemptionMechanismSpi emSpi, Provider provider,
+                               String mechanism)
+  {
+    this.emSpi = emSpi;
+    this.provider = provider;
+    this.mechanism = mechanism;
+    virgin = true;
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  public static final ExemptionMechanism getInstance(String mechanism)
+  throws NoSuchAlgorithmException
+  {
+    Provider[] provs = Security.getProviders();
+    String msg = "";
+    for (int i = 0; i < provs.length; i++)
+      {
+        try
+          {
+            return getInstance(mechanism, provs[i]);
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+            msg = nsae.getMessage();
+          }
+      }
+    throw new NoSuchAlgorithmException(msg);
+  }
+
+  public static final ExemptionMechanism getInstance(String mechanism,
+                                                     String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(mechanism, p);
+  }
+
+  public static final ExemptionMechanism getInstance(String mechanism,
+                                                     Provider provider)
+    throws NoSuchAlgorithmException
+  {
+    try
+      {
+        return new ExemptionMechanism((ExemptionMechanismSpi)
+          Engine.getInstance(SERVICE, mechanism, provider),
+          provider, mechanism);
+      }
+    catch (InvocationTargetException ite)
+      {
+        if (ite.getCause() instanceof NoSuchAlgorithmException)
+          throw (NoSuchAlgorithmException) ite.getCause();
+        else
+          throw new NoSuchAlgorithmException(mechanism);
+      }
+    catch (ClassCastException cce)
+      {
+        throw new NoSuchAlgorithmException(mechanism);
+      }
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  public final byte[] genExemptionBlob()
+    throws IllegalStateException, ExemptionMechanismException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return emSpi.engineGenExemptionBlob();
+  }
+
+  public final int genExemptionBlob(byte[] output)
+    throws IllegalStateException, ExemptionMechanismException,
+           ShortBufferException
+  {
+    return genExemptionBlob(output, 0);
+  }
+
+  public final int genExemptionBlob(byte[] output, int outputOffset)
+    throws IllegalStateException, ExemptionMechanismException,
+           ShortBufferException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return emSpi.engineGenExemptionBlob(output, outputOffset);
+  }
+
+  public final String getName()
+  {
+    return mechanism;
+  }
+
+  public final int getOutputSize(int inputLength) throws IllegalStateException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return emSpi.engineGetOutputSize(inputLength);
+  }
+
+  public final Provider getProvider()
+  {
+    return provider;
+  }
+
+  public final void init(Key key)
+    throws ExemptionMechanismException, InvalidKeyException
+  {
+    emSpi.engineInit(key);
+    virgin = false;
+  }
+
+  public final void init(Key key, AlgorithmParameters params)
+    throws ExemptionMechanismException, InvalidAlgorithmParameterException,
+           InvalidKeyException
+  {
+    emSpi.engineInit(key, params);
+    virgin = false;
+  }
+
+  public final void init(Key key, AlgorithmParameterSpec params)
+    throws ExemptionMechanismException, InvalidAlgorithmParameterException,
+           InvalidKeyException
+  {
+    emSpi.engineInit(key, params);
+    virgin = false;
+  }
+
+  public final boolean isCryptoAllowed(Key key)
+    throws ExemptionMechanismException
+  {
+    return true;
+  }
+
+  protected void finalize()
+  {
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* ExemptionMechanismException -- An error in an exemption mechanism.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * Signals a general exception in an {@link ExemptionMechanism}.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class ExemptionMechanismException extends GeneralSecurityException
+{
+
+  // Constant.
+  // ------------------------------------------------------------------------
+
+  /** Compatible with JDK1.4. */
+  private static final long serialVersionUID = 1572699429277957109L;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new exception with no detail message.
+   */
+  public ExemptionMechanismException()
+  {
+    super();
+  }
+
+  /**
+   * Create a new exception with a detail message.
+   *
+   * @param message The detail message.
+   */
+  public ExemptionMechanismException(String message)
+  {
+    super(message);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ExemptionMechanismSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,149 @@
+/* ExemptionMechanismSpi.java -- Exemption mechanism service provider interface.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * The <i>Service Provider Interface</i> (<b>SPI</b>) for the {@link
+ * ExemptionMechanism} class.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public abstract class ExemptionMechanismSpi
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new exemption mechanism SPI.
+   */
+  public ExemptionMechanismSpi()
+  {
+  }
+
+  // Abstract instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Return a key blob for the key that this mechanism was initialized
+   * with.
+   *
+   * @return The key blob.
+   * @throws javax.crypto.ExemptionMechanismException If generating the
+   *         blob fails.
+   */
+  protected abstract byte[] engineGenExemptionBlob()
+    throws ExemptionMechanismException;
+
+  /**
+   * Generate a key blob for the key that this mechanism was initialized
+   * with, storing it into the given byte array.
+   *
+   * @param output       The destination for the key blob.
+   * @param outputOffset The index in the output array to start.
+   * @return The size of the key blob.
+   * @throws javax.crypto.ExemptionMechanismException If generating the
+   *         blob fails.
+   * @throws javax.crypto.ShortBufferException If the output array is
+   *         not large enough for the key blob.
+   */
+  protected abstract int engineGenExemptionBlob(byte[] output, int outputOffset)
+    throws ExemptionMechanismException, ShortBufferException;
+
+  /**
+   * Get the size of the output blob given an input key size. The actual
+   * blob may be shorter than the value returned by this method. Both
+   * values are in bytes.
+   *
+   * @param inputLength The input size.
+   * @return The output size.
+   */
+  protected abstract int engineGetOutputSize(int inputLength);
+
+  /**
+   * Initialize this mechanism with a key.
+   *
+   * @param key The key.
+   * @throws javax.crypto.ExemptionMechanismException If generating the
+   *         blob fails.
+   * @throws java.security.InvalidKeyException If the supplied key
+   *         cannot be used.
+   */
+  protected abstract void engineInit(Key key)
+    throws ExemptionMechanismException, InvalidKeyException;
+
+  /**
+   * Initialize this mechanism with a key and parameters.
+   *
+   * @param key    The key.
+   * @param params The parameters.
+   * @throws javax.crypto.ExemptionMechanismException If generating the
+   *         blob fails.
+   * @throws java.security.InvalidAlgorithmParameterExceptin If the
+   *         supplied parameters are inappropriate.
+   * @throws java.security.InvalidKeyException If the supplied key
+   *         cannot be used.
+   */
+  protected abstract void engineInit(Key key, AlgorithmParameters params)
+    throws ExemptionMechanismException, InvalidAlgorithmParameterException,
+           InvalidKeyException;
+
+  /**
+   * Initialize this mechanism with a key and parameters.
+   *
+   * @param key    The key.
+   * @param params The parameters.
+   * @throws javax.crypto.ExemptionMechanismException If generating the
+   *         blob fails.
+   * @throws java.security.InvalidAlgorithmParameterExceptin If the
+   *         supplied parameters are inappropriate.
+   * @throws java.security.InvalidKeyException If the supplied key
+   *         cannot be used.
+   */
+  protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
+    throws ExemptionMechanismException, InvalidAlgorithmParameterException,
+           InvalidKeyException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/IllegalBlockSizeException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/IllegalBlockSizeException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/IllegalBlockSizeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/IllegalBlockSizeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* IllegalBlockSizeException.java -- Signals illegal block sizes.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * This exception is thrown when finishing encryption without padding or
+ * decryption and the input is not a multiple of the cipher's block
+ * size.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class IllegalBlockSizeException extends GeneralSecurityException
+{
+
+  // Constant.
+  // ------------------------------------------------------------------------
+
+  /** Serialization constant. */
+  private static final long serialVersionUID = -1965144811953540392L;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  public IllegalBlockSizeException()
+  {
+    super();
+  }
+
+  public IllegalBlockSizeException(String message)
+  {
+    super(message);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreement.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreement.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreement.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,372 @@
+/* KeyAgreement.java -- Engine for key agreement methods.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.java.security.Engine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * Key agreement is a method in which two or more parties may agree on a
+ * secret key for symmetric cryptography or message authentication
+ * without transmitting any secrets in the clear. Key agreement
+ * algorithms typically use a public/private <i>key pair</i>, and the
+ * public key (along with some additional information) is sent across
+ * untrusted networks.
+ *
+ * <p>The most common form of key agreement used today is the
+ * <i>Diffie-Hellman key exchange algorithm</i>, described in <a
+ * href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-3/">PKCS #3 -
+ * Diffie Hellman Key Agreement Standard</a>.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see KeyGenerator
+ * @see SecretKey
+ */
+public class KeyAgreement
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  private static final String SERVICE = "KeyAgreement";
+
+  /** The underlying key agreement implementation. */
+  private KeyAgreementSpi kaSpi;
+
+  /** The provider of this implementation. */
+  private Provider provider;
+
+  /** The name of this instance's algorithm. */
+  private String algorithm;
+
+  /** Singnals whether or not this instance has been initialized. */
+  private boolean virgin;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  protected KeyAgreement(KeyAgreementSpi kaSpi, Provider provider,
+                         String algorithm)
+  {
+    this.kaSpi = kaSpi;
+    this.provider = provider;
+    this.algorithm = algorithm;
+    virgin = true;
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get an implementation of an algorithm from the first provider that
+   * implements it.
+   *
+   * @param algorithm The name of the algorithm to get.
+   * @return The proper KeyAgreement instacne, if found.
+   * @throws java.security.NoSuchAlgorithmException If the specified
+   *         algorithm is not implemented by any installed provider.
+   */
+  public static final KeyAgreement getInstance(String algorithm)
+    throws NoSuchAlgorithmException
+  {
+    Provider[] provs = Security.getProviders();
+    String msg = algorithm;
+    for (int i = 0; i < provs.length; i++)
+      {
+        try
+          {
+            return getInstance(algorithm, provs[i]);
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+            msg = nsae.getMessage();
+          }
+      }
+    throw new NoSuchAlgorithmException(msg);
+  }
+
+  /**
+   * Get an implementation of an algorithm from a named provider.
+   *
+   * @param algorithm The name of the algorithm to get.
+   * @param provider  The name of the provider from which to get the
+   *        implementation.
+   * @return The proper KeyAgreement instance, if found.
+   * @throws java.security.NoSuchAlgorithmException If the named provider
+   *         does not implement the algorithm.
+   * @throws java.security.NoSuchProviderException If the named provider
+   *         does not exist.
+   */
+  public static final KeyAgreement getInstance(String algorithm,
+                                               String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(algorithm, p);
+  }
+
+  /**
+   * Get an implementation of an algorithm from a specific provider.
+   *
+   * @param algorithm The name of the algorithm to get.
+   * @param provider  The provider from which to get the implementation.
+   * @return The proper KeyAgreement instance, if found.
+   * @throws java.security.NoSuchAlgorithmException If this provider
+   *         does not implement the algorithm.
+   */
+  public static final KeyAgreement getInstance(String algorithm,
+                                               Provider provider)
+    throws NoSuchAlgorithmException
+  {
+    try
+      {
+        return new KeyAgreement((KeyAgreementSpi)
+          Engine.getInstance(SERVICE, algorithm, provider),
+          provider, algorithm);
+      }
+    catch (InvocationTargetException ite)
+      {
+        if (ite.getCause() == null)
+          throw new NoSuchAlgorithmException(algorithm);
+        if (ite.getCause() instanceof NoSuchAlgorithmException)
+          throw (NoSuchAlgorithmException) ite.getCause();
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+    catch (ClassCastException cce)
+      {
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Do a phase in the key agreement. The number of times this method is
+   * called depends upon the algorithm and the number of parties
+   * involved, but must be called at least once with the
+   * <code>lastPhase</code> flag set to <code>true</code>.
+   *
+   * @param key       The key for this phase.
+   * @param lastPhase Should be <code>true</code> if this will be the
+   *        last phase before generating the shared secret.
+   * @return The intermediate result, or <code>null</code> if there is
+   *         no intermediate result.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized.
+   * @throws java.security.InvalidKeyException If the key is
+   *         inappropriate for this algorithm.
+   */
+  public final Key doPhase(Key key, boolean lastPhase)
+    throws IllegalStateException, InvalidKeyException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return kaSpi.engineDoPhase(key, lastPhase);
+  }
+
+  /**
+   * Generate the shared secret in a new byte array.
+   *
+   * @return The shared secret.
+   * @throws java.lang.IllegalStateException If this instnace has not
+   *         been initialized, or if not enough calls to
+   *         <code>doPhase</code> have been made.
+   */
+  public final byte[] generateSecret() throws IllegalStateException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return kaSpi.engineGenerateSecret();
+  }
+
+  /**
+   * Generate the shared secret and store it into the supplied array.
+   *
+   * @param sharedSecret The array in which to store the secret.
+   * @param offset       The index in <code>sharedSecret</code> to start
+   *                     storing data.
+   * @return The length of the shared secret, in bytes.
+   * @throws java.lang.IllegalStateException If this instnace has not
+   *         been initialized, or if not enough calls to
+   *         <code>doPhase</code> have been made.
+   * @throws javax.crypto.ShortBufferException If the supplied array is
+   *         not large enough to store the result.
+   */
+  public final int generateSecret(byte[] sharedSecret, int offset)
+  throws IllegalStateException, ShortBufferException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return kaSpi.engineGenerateSecret(sharedSecret, offset);
+  }
+
+  /**
+   * Generate the shared secret and return it as an appropriate {@link
+   * SecretKey}.
+   *
+   * @param algorithm The secret key's algorithm.
+   * @return The shared secret as a secret key.
+   * @throws java.lang.IllegalStateException If this instnace has not
+   *         been initialized, or if not enough calls to
+   *         <code>doPhase</code> have been made.
+   * @throws java.security.InvalidKeyException If the shared secret
+   *         cannot be used to make a {@link SecretKey}.
+   * @throws java.security.NoSuchAlgorithmException If the specified
+   *         algorithm does not exist.
+   */
+  public final SecretKey generateSecret(String algorithm)
+  throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    return kaSpi.engineGenerateSecret(algorithm);
+  }
+
+  /**
+   * Return the name of this key-agreement algorithm.
+   *
+   * @return The algorithm name.
+   */
+  public final String getAlgorithm()
+  {
+    return algorithm;
+  }
+
+  /**
+   * Return the provider of the underlying implementation.
+   *
+   * @return The provider.
+   */
+  public final Provider getProvider()
+  {
+    return provider;
+  }
+
+  /**
+   * Initialize this key agreement with a key. This method will use the
+   * highest-priority {@link java.security.SecureRandom} as its source
+   * of randomness.
+   *
+   * @param key The key, usually the user's private key.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         not appropriate.
+   */
+  public final void init(Key key) throws InvalidKeyException
+  {
+    init(key, new SecureRandom());
+  }
+
+  /**
+   * Initialize this key agreement with a key and a source of
+   * randomness.
+   *
+   * @param key    The key, usually the user's private key.
+   * @param random The source of randomness.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         not appropriate.
+   */
+  public final void init(Key key, SecureRandom random)
+    throws InvalidKeyException
+  {
+    kaSpi.engineInit(key, random);
+    virgin = false; // w00t!
+  }
+
+  /**
+   * Initialize this key agreement with a key and parameters. This
+   * method will use the highest-priority {@link
+   * java.security.SecureRandom} as its source of randomness.
+   *
+   * @param key    The key, usually the user's private key.
+   * @param params The algorithm parameters.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are not appropriate.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         not appropriate.
+   */
+  public final void init(Key key, AlgorithmParameterSpec params)
+    throws InvalidAlgorithmParameterException, InvalidKeyException
+  {
+    init(key, params, new SecureRandom());
+  }
+
+  /**
+   * Initialize this key agreement with a key, parameters, and source of
+   * randomness.
+   *
+   * @param key    The key, usually the user's private key.
+   * @param params The algorithm parameters.
+   * @param random The source of randomness.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are not appropriate.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         not appropriate.
+   */
+  public final void init(Key key, AlgorithmParameterSpec params,
+                         SecureRandom random)
+    throws InvalidAlgorithmParameterException, InvalidKeyException
+  {
+    kaSpi.engineInit(key, params, random);
+    virgin = false; // w00t!
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreementSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreementSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreementSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyAgreementSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,160 @@
+/* KeyAgreementSpi.java -- The key agreement service provider interface.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * This is the <i>Service Provider Interface</i> (<b>SPI</b>) for the
+ * {@link javax.crypto.KeyAgreement} class.
+ *
+ * <p>Providers wishing to implement a key agreement algorithm must
+ * subclass this and provide an appropriate implementation for all the
+ * abstract methods below, and provide an appropriate entry in the
+ * master {@link java.security.Provider} class (the service name for key
+ * agreement algorithms is <code>"KeyAgreement"</code>).
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see KeyAgreement
+ * @see SecretKey
+ */
+public abstract class KeyAgreementSpi
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new KeyAgreementSpi instance.
+   */
+  public KeyAgreementSpi()
+  {
+  }
+
+  // Abstract instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Do a phase in the key agreement.
+   *
+   * @param key The key to use for this phase.
+   * @param lastPhase <code>true</code> if this call should be the last
+   *        phase.
+   * @return The intermediate result, or <code>null</code> if there is
+   *         no intermediate result.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         not appropriate.
+   */
+  protected abstract Key engineDoPhase(Key key, boolean lastPhase)
+    throws IllegalStateException, InvalidKeyException;
+
+  /**
+   * Generate the shared secret in a new byte array.
+   *
+   * @return The shared secret in a new byte array.
+   * @throws java.lang.IllegalStateException If this key agreement is
+   *         not ready to generate the secret.
+   */
+  protected abstract byte[] engineGenerateSecret()
+    throws IllegalStateException;
+
+  /**
+   * Generate the shared secret, storing it into the specified array.
+   *
+   * @param sharedSecret The byte array in which to store the secret.
+   * @param offset       The offset into the byte array to start.
+   * @return The size of the shared secret.
+   * @throws java.lang.IllegalStateException If this key agreement is
+   *         not ready to generate the secret.
+   * @throws javax.crypto.ShortBufferException If there is not enough
+   *         space in the supplied array for the shared secret.
+   */
+  protected abstract int engineGenerateSecret(byte[] sharedSecret, int offset)
+    throws IllegalStateException, ShortBufferException;
+
+  /**
+   * Generate the shared secret and return it as a {@link SecretKey}.
+   *
+   * @param algorithm The algorithm with which to generate the secret key.
+   * @return The shared secret as a secret key.
+   * @throws java.lang.IllegalStateException If this key agreement is
+   *         not ready to generate the secret.
+   * @throws java.security.InvalidKeyException If the shared secret
+   *         cannot be made into a {@link SecretKey}.
+   * @throws java.security.NoSuchAlgorithmException If
+   *         <code>algorithm</code> cannot be found.
+   */
+  protected abstract SecretKey engineGenerateSecret(String algorithm)
+    throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException;
+
+  /**
+   * Initialize this key agreement with a key, parameters, and source of
+   * randomness.
+   *
+   * @param key    The key to initialize with, usually a private key.
+   * @param params The parameters to initialize with.
+   * @param random The source of randomness to use.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inappropriate.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         inappropriate.
+   */
+  protected abstract void engineInit(Key key, AlgorithmParameterSpec params,
+                                     SecureRandom random)
+    throws InvalidAlgorithmParameterException, InvalidKeyException;
+
+  /**
+   * Initialize this key agreement with a key and source of randomness.
+   *
+   * @param key    The key to initialize with, usually a private key.
+   * @param random The source of randomness to use.
+   * @throws java.security.InvalidKeyException If the supplied key is
+   *         inappropriate.
+   */
+  protected abstract void engineInit(Key key, SecureRandom random)
+    throws InvalidKeyException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGenerator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGenerator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGenerator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGenerator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,285 @@
+/* KeyGenerator.java -- Interface to a symmetric key generator.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.java.security.Engine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * A generic producer of keys for symmetric cryptography. The keys
+ * returned may be simple wrappers around byte arrays, or, if the
+ * target cipher requires them, more complex objects.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see Cipher
+ * @see Mac
+ */
+public class KeyGenerator
+{
+
+  // Constants and fields.
+  // ------------------------------------------------------------------------
+
+  private static final String SERVICE = "KeyGenerator";
+
+  /** The underlying generator implementation. */
+  private KeyGeneratorSpi kgSpi;
+
+  /** The provider of the implementation. */
+  private Provider provider;
+
+  /** The name of the algorithm. */
+  private String algorithm;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new key generator.
+   *
+   * @param kgSpi     The underlying generator.
+   * @param provider  The provider of this implementation.
+   * @param algorithm The algorithm's name.
+   */
+  protected KeyGenerator(KeyGeneratorSpi kgSpi, Provider provider,
+                         String algorithm)
+  {
+    this.kgSpi = kgSpi;
+    this.provider = provider;
+    this.algorithm = algorithm;
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new key generator, returning the first available
+   * implementation.
+   *
+   * @param algorithm The generator algorithm name.
+   * @throws java.security.NoSuchAlgorithmException If the specified
+   *         algorithm does not exist.
+   */
+  public static final KeyGenerator getInstance(String algorithm)
+    throws NoSuchAlgorithmException
+  {
+    Provider[] provs = Security.getProviders();
+    String msg = algorithm;
+    for (int i = 0; i < provs.length; i++)
+      {
+        try
+          {
+            return getInstance(algorithm, provs[i]);
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+            msg = nsae.getMessage();
+          }
+      }
+    throw new NoSuchAlgorithmException(msg);
+  }
+
+  /**
+   * Create a new key generator from the named provider.
+   *
+   * @param algorithm The generator algorithm name.
+   * @param provider  The name of the provider to use.
+   * @return An appropriate key generator, if found.
+   * @throws java.security.NoSuchAlgorithmException If the specified
+   *         algorithm is not implemented by the named provider.
+   * @throws java.security.NoSuchProviderException If the named provider
+   *         does not exist.
+   */
+  public static final KeyGenerator getInstance(String algorithm, String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(algorithm, p);
+  }
+
+  /**
+   * Create a new key generator from the supplied provider.
+   *
+   * @param algorithm The generator algorithm name.
+   * @param provider  The provider to use.
+   * @return An appropriate key generator, if found.
+   * @throws java.security.NoSuchAlgorithmException If the specified
+   *         algorithm is not implemented by the provider.
+   */
+  public static final KeyGenerator getInstance(String algorithm, Provider provider)
+    throws NoSuchAlgorithmException
+  {
+    try
+      {
+        KeyGenerator instance = new KeyGenerator((KeyGeneratorSpi)
+          Engine.getInstance(SERVICE, algorithm, provider),
+          provider, algorithm);
+        instance.init(new SecureRandom());
+        return instance;
+      }
+    catch (InvocationTargetException ite)
+      {
+        if (ite.getCause() == null)
+          throw new NoSuchAlgorithmException(algorithm);
+        if (ite.getCause() instanceof NoSuchAlgorithmException)
+          throw (NoSuchAlgorithmException) ite.getCause();
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+    catch (ClassCastException cce)
+      {
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Generate a key.
+   *
+   * @return The new key.
+   */
+  public final SecretKey generateKey()
+  {
+    return kgSpi.engineGenerateKey();
+  }
+
+  /**
+   * Return the name of this key generator.
+   *
+   * @return The algorithm name.
+   */
+  public final String getAlgorithm()
+  {
+    return algorithm;
+  }
+
+  /**
+   * Return the provider of the underlying implementation.
+   *
+   * @return The provider.
+   */
+  public final Provider getProvider()
+  {
+    return provider;
+  }
+
+  /**
+   * Initialize this key generator with a set of parameters; the
+   * highest-priority {@link java.security.SecureRandom} implementation
+   * will be used.
+   *
+   * @param params The algorithm parameters.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inapproprate.
+   */
+  public final void init(AlgorithmParameterSpec params)
+    throws InvalidAlgorithmParameterException
+  {
+    init(params, new SecureRandom());
+  }
+
+  /**
+   * Initialize this key generator with a set of parameters and a source
+   * of randomness.
+   *
+   * @param params The algorithm parameters.
+   * @param random The source of randomness.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         supplied parameters are inapproprate.
+   */
+  public final void init(AlgorithmParameterSpec params, SecureRandom random)
+    throws InvalidAlgorithmParameterException
+  {
+    kgSpi.engineInit(params, random);
+  }
+
+  /**
+   * Initialize this key generator with a key size (in bits); the
+   * highest-priority {@link java.security.SecureRandom} implementation
+   * will be used.
+   *
+   * @param keySize The target key size, in bits.
+   * @throws java.security.InvalidParameterException If the
+   *         key size is unsupported.
+   */
+  public final void init(int keySize)
+  {
+    init(keySize, new SecureRandom());
+  }
+
+  /**
+   * Initialize this key generator with a key size (in bits) and a
+   * source of randomness.
+   *
+   * @param keySize The target key size, in bits.
+   * @param random  The source of randomness.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         key size is unsupported.
+   */
+  public final void init(int keySize, SecureRandom random)
+  {
+    kgSpi.engineInit(keySize, random);
+  }
+
+  /**
+   * Initialize this key generator with a source of randomness. The
+   * implementation-specific default parameters (such as key size) will
+   * be used.
+   *
+   * @param random The source of randomness.
+   */
+  public final void init(SecureRandom random)
+  {
+    kgSpi.engineInit(random);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGeneratorSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGeneratorSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGeneratorSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/KeyGeneratorSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* KeyGeneratorSpi.java -- The key generator service provider interface.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * The <i>Service Provider Interface</i> (<b>SPI</b>) for the {@link
+ * KeyGenerator} class.
+ *
+ * <p>Providers wishing to implement a key generator must subclass this
+ * and provide an appropriate implementation for all the abstract
+ * methods below, and provide an appropriate entry in the master {@link
+ * java.security.Provider} class (the service name for key generators is
+ * <code>"KeyGenerator"</code>).
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see KeyGenerator
+ */
+public abstract class KeyGeneratorSpi
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /** Create a new key generator SPI. */
+  public KeyGeneratorSpi()
+  {
+  }
+
+  // Abstract instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Generate a key, returning it as a {@link SecretKey}.
+   *
+   * @return The generated key.
+   */
+  protected abstract SecretKey engineGenerateKey();
+
+  /**
+   * Initialize this key generator with parameters and a source of
+   * randomness.
+   *
+   * @param params The parameters.
+   * @param random The source of randomness.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         parameters are inappropriate for this instance.
+   */
+  protected abstract void engineInit(AlgorithmParameterSpec params,
+                                     SecureRandom random)
+    throws InvalidAlgorithmParameterException;
+
+  /**
+   * Initialize this key generator with a key size (in bits) and a
+   * source of randomness.
+   *
+   * @param keySize The target key size, in bits.
+   * @param random  The source of randomness.
+   * @throws java.security.InvalidParameterException If the
+   *         key size is illogical or unsupported.
+   */
+  protected abstract void engineInit(int keySize, SecureRandom random);
+
+  /**
+   * Initialize this key generator with a source of randomness; the
+   * implementation should use reasonable default parameters (such as
+   * generated key size).
+   *
+   * @param random The source of randomness.
+   */
+  protected abstract void engineInit(SecureRandom random);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Mac.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Mac.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Mac.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/Mac.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,413 @@
+/* Mac.java -- The message authentication code interface.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.java.security.Engine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * This class implements a "message authentication code" (MAC), a method
+ * to ensure the integrity of data transmitted between two parties who
+ * share a common secret key.
+ *
+ * <p>The best way to describe a MAC is as a <i>keyed one-way hash
+ * function</i>, which looks like:
+ *
+ * <blockquote><p><code>D = MAC(K, M)</code></blockquote>
+ *
+ * <p>where <code>K</code> is the key, <code>M</code> is the message,
+ * and <code>D</code> is the resulting digest. One party will usually
+ * send the concatenation <code>M || D</code> to the other party, who
+ * will then verify <code>D</code> by computing <code>D'</code> in a
+ * similar fashion. If <code>D == D'</code>, then the message is assumed
+ * to be authentic.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class Mac implements Cloneable
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  private static final String SERVICE = "Mac";
+
+  /** The underlying MAC implementation. */
+  private MacSpi macSpi;
+
+  /** The provider we got our implementation from. */
+  private Provider provider;
+
+  /** The name of the algorithm. */
+  private String algorithm;
+
+  /** Whether or not we've been initialized. */
+  private boolean virgin;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Creates a new Mac instance.
+   *
+   * @param macSpi    The underlying MAC implementation.
+   * @param provider  The provider of this implementation.
+   * @param algorithm The name of this MAC algorithm.
+   */
+  protected Mac(MacSpi macSpi, Provider provider, String algorithm)
+  {
+    this.macSpi = macSpi;
+    this.provider = provider;
+    this.algorithm = algorithm;
+    virgin = true;
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get an instance of the named algorithm from the first provider with
+   * an appropriate implementation.
+   *
+   * @param algorithm The name of the algorithm.
+   * @return An appropriate Mac instance, if the specified algorithm
+   *         is implemented by a provider.
+   * @throws java.security.NoSuchAlgorithmException If no implementation
+   *         of the named algorithm is installed.
+   */
+  public static final Mac getInstance(String algorithm)
+    throws NoSuchAlgorithmException
+  {
+    Provider[] provs = Security.getProviders();
+    String msg = "";
+    for (int i = 0; i < provs.length; i++)
+      {
+        try
+          {
+            return getInstance(algorithm, provs[i]);
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+            msg = nsae.getMessage();
+          }
+      }
+    throw new NoSuchAlgorithmException(msg);
+  }
+
+  /**
+   * Get an instance of the named algorithm from the named provider.
+   *
+   * @param algorithm The name of the algorithm.
+   * @param provider  The name of the provider.
+   * @return An appropriate Mac instance, if the specified algorithm is
+   *         implemented by the named provider.
+   * @throws java.security.NoSuchAlgorithmException If the named provider
+   *         has no implementation of the algorithm.
+   * @throws java.security.NoSuchProviderException If the named provider
+   *         does not exist.
+   */
+  public static final Mac getInstance(String algorithm, String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(algorithm, p);
+  }
+
+  /**
+   * Get an instance of the named algorithm from a provider.
+   *
+   * @param algorithm The name of the algorithm.
+   * @param provider  The provider.
+   * @return An appropriate Mac instance, if the specified algorithm is
+   *         implemented by the provider.
+   * @throws java.security.NoSuchAlgorithmException If the provider
+   *         has no implementation of the algorithm.
+   */
+  public static final Mac getInstance(String algorithm, Provider provider)
+    throws NoSuchAlgorithmException
+  {
+    try
+      {
+        return new Mac((MacSpi) Engine.getInstance(SERVICE, algorithm, provider),
+                       provider, algorithm);
+      }
+    catch (InvocationTargetException ite)
+      {
+        if (ite.getCause() == null)
+          throw new NoSuchAlgorithmException(algorithm);
+        if (ite.getCause() instanceof NoSuchAlgorithmException)
+          throw (NoSuchAlgorithmException) ite.getCause();
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+    catch (ClassCastException cce)
+      {
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Finishes the computation of a MAC and returns the digest.
+   *
+   * <p>After this method succeeds, it may be used again as just after a
+   * call to <code>init</code>, and can compute another MAC using the
+   * same key and parameters.
+   *
+   * @return The message authentication code.
+   * @throws java.lang.IllegalStateException If this instnace has not
+   *         been initialized.
+   */
+  public final byte[] doFinal() throws IllegalStateException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    byte[] digest = macSpi.engineDoFinal();
+    reset();
+    return digest;
+  }
+
+  /**
+   * Finishes the computation of a MAC with a final byte array (or
+   * computes a MAC over those bytes only) and returns the digest.
+   *
+   * <p>After this method succeeds, it may be used again as just after a
+   * call to <code>init</code>, and can compute another MAC using the
+   * same key and parameters.
+   *
+   * @param input The bytes to add.
+   * @return The message authentication code.
+   * @throws java.lang.IllegalStateException If this instnace has not
+   *         been initialized.
+   */
+  public final byte[] doFinal(byte[] input) throws IllegalStateException
+  {
+    update(input);
+    byte[] digest = macSpi.engineDoFinal();
+    reset();
+    return digest;
+  }
+
+  /**
+   * Finishes the computation of a MAC and places the result into the
+   * given array.
+   *
+   * <p>After this method succeeds, it may be used again as just after a
+   * call to <code>init</code>, and can compute another MAC using the
+   * same key and parameters.
+   *
+   * @param output    The destination for the result.
+   * @param outOffset The index in the output array to start.
+   * @return The message authentication code.
+   * @throws java.lang.IllegalStateException If this instnace has not
+   *         been initialized.
+   * @throws javax.crypto.ShortBufferException If <code>output</code> is
+   *         not large enough to hold the result.
+   */
+  public final void doFinal(byte[] output, int outOffset)
+  throws IllegalStateException, ShortBufferException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    if (output.length - outOffset < getMacLength())
+      {
+        throw new ShortBufferException();
+      }
+    byte[] mac = macSpi.engineDoFinal();
+    System.arraycopy(mac, 0, output, outOffset, getMacLength());
+    reset();
+  }
+
+  /**
+   * Returns the name of this MAC algorithm.
+   *
+   * @return The MAC name.
+   */
+  public final String getAlgorithm()
+  {
+    return algorithm;
+  }
+
+  /**
+   * Get the size of the MAC. This is the size of the array returned by
+   * {@link #doFinal()} and {@link #doFinal(byte[])}, and the minimum
+   * number of bytes that must be available in the byte array passed to
+   * {@link #doFinal(byte[],int)}.
+   *
+   * @return The MAC length.
+   */
+  public final int getMacLength()
+  {
+    return macSpi.engineGetMacLength();
+  }
+
+  /**
+   * Get the provider of the underlying implementation.
+   *
+   * @return The provider.
+   */
+  public final Provider getProvider()
+  {
+    return provider;
+  }
+
+  /**
+   * Initialize this MAC with a key and no parameters.
+   *
+   * @param key The key to initialize this instance with.
+   * @throws java.security.InvalidKeyException If the key is
+   *         unacceptable.
+   */
+  public final void init(Key key) throws InvalidKeyException
+  {
+    try
+      {
+        init(key, null);
+      }
+    catch (InvalidAlgorithmParameterException iape)
+      {
+        throw new IllegalArgumentException(algorithm + " needs parameters");
+      }
+  }
+
+  /**
+   * Initialize this MAC with a key and parameters.
+   *
+   * @param key    The key to initialize this instance with.
+   * @param params The algorithm-specific parameters.
+   * @throws java.security.InvalidAlgorithmParameterException If the
+   *         algorithm parameters are unacceptable.
+   * @throws java.security.InvalidKeyException If the key is
+   *         unacceptable.
+   */
+  public final void init(Key key, AlgorithmParameterSpec params)
+    throws InvalidAlgorithmParameterException, InvalidKeyException
+  {
+    macSpi.engineInit(key, params);
+    virgin = false;                      // w00t!
+  }
+
+  /**
+   * Reset this instance. A call to this method returns this instance
+   * back to the state it was in just after it was initialized.
+   */
+  public final void reset()
+  {
+    macSpi.engineReset();
+  }
+
+  /**
+   * Update the computation with a single byte.
+   *
+   * @param input The next byte.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized.
+   */
+  public final void update(byte input) throws IllegalStateException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    macSpi.engineUpdate(input);
+  }
+
+  /**
+   * Update the computation with a byte array.
+   *
+   * @param input The next bytes.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized.
+   */
+  public final void update(byte[] input) throws IllegalStateException
+  {
+    update(input, 0, input.length);
+  }
+
+  /**
+   * Update the computation with a portion of a byte array.
+   *
+   * @param input  The next bytes.
+   * @param offset The index in <code>input</code> to start.
+   * @param length The number of bytes to update.
+   * @throws java.lang.IllegalStateException If this instance has not
+   *         been initialized.
+   */
+  public final void update(byte[] input, int offset, int length)
+    throws IllegalStateException
+  {
+    if (virgin)
+      {
+        throw new IllegalStateException("not initialized");
+      }
+    macSpi.engineUpdate(input, offset, length);
+  }
+
+  /**
+   * Clone this instance, if the underlying implementation supports it.
+   *
+   * @return A clone of this instance.
+   * @throws java.lang.CloneNotSupportedException If the underlying
+   *         implementation is not cloneable.
+   */
+  public final Object clone() throws CloneNotSupportedException
+  {
+    Mac result = new Mac((MacSpi) macSpi.clone(), provider, algorithm);
+    result.virgin = virgin;
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/MacSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/MacSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/MacSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/MacSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,145 @@
+/* MacSpi.java -- The MAC service provider interface.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * This is the <i>Service Provider Interface</i> (<b>SPI</b>) for the
+ * {@link Mac} class.
+ *
+ * <p>Providers wishing to implement a Mac must subclass this class and
+ * provide appropriate implementations of all its abstract methods,
+ * then provide an entry pointing to this implementation in the master
+ * {@link java.security.Provider} class.
+ *
+ * <p>Implementations may optionally implement the {@link
+ * java.lang.Cloneable} interface.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public abstract class MacSpi
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new MacSpi instance.
+   */
+  public MacSpi()
+  {
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Returns a clone of this instance if cloning is supported.
+   *
+   * @return A clone of this instance.
+   * @throws java.lang.CloneNotSupportedException If this instance does
+   *         not support cloneing.
+   */
+  public Object clone() throws CloneNotSupportedException
+  {
+    return super.clone();
+  }
+
+  // Abstract instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Finalize the computation of this MAC and return the result as a
+   * byte array.
+   *
+   * @return The MAC.
+   */
+  protected abstract byte[] engineDoFinal();
+
+  /**
+   * Return the total length, in bytes, of the computed MAC (the length
+   * of the byte array returned by {@link #doFinal()}.
+   *
+   * @return The MAC length.
+   */
+  protected abstract int engineGetMacLength();
+
+  /**
+   * Initialize (or re-initialize) this instance.
+   *
+   * @param key    The key to use.
+   * @param params The parameters to use.
+   * @throws java.security.InvalidAlgorithmParameterException If this
+   *         instance rejects the specified parameters.
+   * @throws java.security.InvalidKeyException If this instance rejects
+   *         the specified key.
+   */
+  protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
+    throws InvalidAlgorithmParameterException, InvalidKeyException;
+
+  /**
+   * Reset this instance. After this method succeeds, the state of this
+   * instance should be the same as it was before any data was input
+   * (possibly after a call to {@link
+   * #init(java.security.Key,java.security.spec.AlgorithmParameterSpec)},
+   * possibly not).
+   */
+  protected abstract void engineReset();
+
+  /**
+   * Update this MAC with a single byte.
+   *
+   * @param input The next byte.
+   */
+  protected abstract void engineUpdate(byte input);
+
+  /**
+   * Update this MAC with a portion of a byte array.
+   *
+   * @param input  The next bytes.
+   * @param offset The index in <code>input</code> at which to start.
+   * @param length The number of bytes to update.
+   */
+  protected abstract void engineUpdate(byte[] input, int offset, int length);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NoSuchPaddingException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NoSuchPaddingException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NoSuchPaddingException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NoSuchPaddingException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* NoSuchPaddingException.java -- Signals an unknown padding scheme.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * This exception is thrown when a particular padding scheme is
+ * requested but is not available.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class NoSuchPaddingException extends GeneralSecurityException
+{
+
+  // Constant.
+  // ------------------------------------------------------------------------
+
+  /** Serialization constant. */
+  private static final long serialVersionUID = -4572885201200175466L;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  public NoSuchPaddingException()
+  {
+    super();
+  }
+
+  public NoSuchPaddingException(String message)
+  {
+    super(message);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipher.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipher.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipher.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipher.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* NullCipher.java -- The identity cipher.
+   Copyright (C) 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 javax.crypto;
+
+/**
+ * Trivial subclass of Cipher that implements the <i>identity
+ * transformation</i>, where the input is always copied to the output
+ * unchanged. Null ciphers can be instantiated with the public
+ * constructor.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class NullCipher extends Cipher
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new identity cipher.
+   */
+  public NullCipher()
+  {
+    super(new NullCipherImpl(), null, "NULL");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipherImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipherImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipherImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/NullCipherImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,127 @@
+/* NullCipherImpl.java -- implementation of NullCipher.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.AlgorithmParameters;
+import java.security.Key;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * Implementation of the identity cipher.
+ */
+final class NullCipherImpl extends CipherSpi
+{
+
+  // Constructor.
+  // -------------------------------------------------------------------------
+
+  NullCipherImpl()
+  {
+    super();
+  }
+
+  // Instance methods.
+  // -------------------------------------------------------------------------
+
+  protected void engineSetMode(String mode) { }
+  protected void engineSetPadding(String padding) { }
+
+  protected int engineGetBlockSize()
+  {
+    return 1;
+  }
+
+  protected int engineGetOutputSize(int inputLen)
+  {
+    return inputLen;
+  }
+
+  protected byte[] engineGetIV()
+  {
+    return null;
+  }
+
+  protected AlgorithmParameters engineGetParameters()
+  {
+    return null;
+  }
+
+  protected void engineInit(int mode, Key key, SecureRandom random) { }
+  protected void engineInit(int mode, Key key, AlgorithmParameterSpec spec, SecureRandom random) { }
+  protected void engineInit(int mode, Key key, AlgorithmParameters params, SecureRandom random) { }
+
+  protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
+  {
+    if (input == null)
+      return new byte[0];
+    if (inputOffset < 0 || inputLen < 0 || inputOffset + inputLen > input.length)
+      throw new ArrayIndexOutOfBoundsException();
+    byte[] output = new byte[inputLen];
+    System.arraycopy(input, inputOffset, output, 0, inputLen);
+    return output;
+  }
+
+  protected int engineUpdate(byte[] input, int inputOffset, int inputLen,
+                             byte[] output, int outputOffset)
+    throws ShortBufferException
+  {
+    if (input == null)
+      return 0;
+    if (inputOffset < 0 || inputLen < 0 || inputOffset + inputLen > input.length
+        || outputOffset < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    if (output.length - outputOffset < inputLen)
+      throw new ShortBufferException();
+    System.arraycopy(input, inputOffset, output, outputOffset, inputLen);
+    return inputLen;
+  }
+
+  protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
+  {
+    return engineUpdate(input, inputOffset, inputLen);
+  }
+
+  protected int engineDoFinal(byte[] input, int inputOffset, int inputLen,
+                              byte[] output, int outputOffset)
+    throws ShortBufferException
+  {
+    return engineUpdate(input, inputOffset, inputLen, output, outputOffset);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SealedObject.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SealedObject.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SealedObject.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SealedObject.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,355 @@
+/* SealedObject.java -- An encrypted Serializable object.
+   Copyright (C) 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 javax.crypto;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+
+/**
+ * This class allows any {@link java.io.Serializable} object to be
+ * stored in an encrypted form.
+ *
+ * <p>When the sealed object is ready to be unsealed (and deserialized)
+ * the caller may use either
+ *
+ * <ol>
+ * <li>{@link #getObject(javax.crypto.Cipher)}, which uses an
+ * already-initialized {@link javax.crypto.Cipher}.<br>
+ * <br>
+ * or,</li>
+ *
+ * <li>{@link #getObject(java.security.Key)} or {@link
+ * #getObject(java.security.Key,java.lang.String)}, which will
+ * initialize a new cipher instance with the {@link #encodedParams} that
+ * were stored with this sealed object (this is so parameters, such as
+ * the IV, don't need to be known by the one unsealing the object).</li>
+ * </ol>
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class SealedObject implements Serializable
+{
+
+  // Constants and fields.
+  // ------------------------------------------------------------------------
+
+  /** The encoded algorithm parameters. */
+  protected byte[] encodedParams;
+
+  /** The serialized, encrypted object. */
+  private byte[] encryptedContent;
+
+  /** The algorithm used to seal the object. */
+  private String sealAlg;
+
+  /** The parameter type. */
+  private String paramsAlg;
+
+  /** The cipher that decrypts when this object is unsealed. */
+  private transient Cipher sealCipher;
+
+  /** Compatible with JDK1.4. */
+  private static final long serialVersionUID = 4482838265551344752L;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new sealed object from a {@link java.io.Serializable}
+   * object and a cipher.
+   *
+   * @param object The object to seal.
+   * @param cipher The cipher to encrypt with.
+   * @throws java.io.IOException If serializing the object fails.
+   * @throws javax.crypto.IllegalBlockSizeException If the cipher has no
+   *         padding and the size of the serialized representation of the
+   *         object is not a multiple of the cipher's block size.
+   */
+  public SealedObject(Serializable object, Cipher cipher)
+    throws IOException, IllegalBlockSizeException
+  {
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ObjectOutputStream oos = new ObjectOutputStream(baos);
+    oos.writeObject(object);
+    oos.flush();
+    try
+      {
+        encryptedContent = cipher.doFinal(baos.toByteArray());
+      }
+    catch (IllegalStateException ise)
+      {
+        throw new IOException("cipher not in proper state");
+      }
+    catch (BadPaddingException bpe)
+      {
+        throw new IOException(
+          "encrypting but got javax.crypto.BadPaddingException");
+      }
+    sealAlg = cipher.getAlgorithm();
+    encodedParams = cipher.getParameters().getEncoded();
+    paramsAlg = cipher.getParameters().getAlgorithm();
+  }
+
+  /**
+   * Create a new sealed object from another sealed object.
+   *
+   * @param so The other sealed object.
+   */
+  protected SealedObject(SealedObject so)
+  {
+    this.encodedParams = (byte[]) so.encodedParams.clone();
+    this.encryptedContent = (byte[]) so.encryptedContent.clone();
+    this.sealAlg = so.sealAlg;
+    this.paramsAlg = so.paramsAlg;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the name of the algorithm used to seal this object.
+   *
+   * @return The algorithm's name.
+   */
+  public final String getAlgorithm()
+  {
+    return sealAlg;
+  }
+
+  /**
+   * Unseal and deserialize this sealed object with a specified (already
+   * initialized) cipher.
+   *
+   * @param cipher The cipher to decrypt with.
+   * @return The original object.
+   * @throws java.io.IOException If reading fails.
+   * @throws java.lang.ClassNotFoundException If deserialization fails.
+   * @throws javax.crypto.IllegalBlockSizeException If the cipher has no
+   *         padding and the encrypted data is not a multiple of the
+   *         cipher's block size.
+   * @throws javax.crypto.BadPaddingException If the padding bytes are
+   *         incorrect.
+   */
+  public final Object getObject(Cipher cipher)
+    throws IOException, ClassNotFoundException, IllegalBlockSizeException,
+           BadPaddingException
+  {
+    sealCipher = cipher;
+    return unseal();
+  }
+
+  /**
+   * Unseal and deserialize this sealed object with the specified key.
+   *
+   * @param key The key to decrypt with.
+   * @return The original object.
+   * @throws java.io.IOException If reading fails.
+   * @throws java.lang.ClassNotFoundException If deserialization fails.
+   * @throws java.security.InvalidKeyException If the supplied key
+   *         cannot be used to unseal this object.
+   * @throws java.security.NoSuchAlgorithmException If the algorithm
+   *         used to originally seal this object is not available.
+   */
+  public final Object getObject(Key key)
+    throws IOException, ClassNotFoundException, InvalidKeyException,
+           NoSuchAlgorithmException
+  {
+    try
+      {
+        if (sealCipher == null)
+          sealCipher = Cipher.getInstance(sealAlg);
+      }
+    catch (NoSuchPaddingException nspe)
+      {
+        throw new NoSuchAlgorithmException(nspe.getMessage());
+      }
+    AlgorithmParameters params = null;
+    if (encodedParams != null)
+      {
+        params = AlgorithmParameters.getInstance(paramsAlg);
+        params.init(encodedParams);
+      }
+    try
+      {
+        sealCipher.init(Cipher.DECRYPT_MODE, key, params);
+        return unseal();
+      }
+    catch (InvalidAlgorithmParameterException iape)
+      {
+        throw new IOException("bad parameters");
+      }
+    catch (IllegalBlockSizeException ibse)
+      {
+        throw new IOException("illegal block size");
+      }
+    catch (BadPaddingException bpe)
+      {
+        throw new IOException("bad padding");
+      }
+  }
+
+  /**
+   * Unseal and deserialize this sealed object with the specified key,
+   * using a cipher from the named provider.
+   *
+   * @param key      The key to decrypt with.
+   * @param provider The name of the provider to use.
+   * @return The original object.
+   * @throws java.io.IOException If reading fails.
+   * @throws java.lang.ClassNotFoundException If deserialization fails.
+   * @throws java.security.InvalidKeyException If the supplied key
+   *         cannot be used to unseal this object.
+   * @throws java.security.NoSuchAlgorithmException If the algorithm
+   *         used to originally seal this object is not available from
+   *         the named provider.
+   * @throws java.security.NoSuchProviderException If the named provider
+   *         does not exist.
+   */
+  public final Object getObject(Key key, String provider)
+    throws IOException, ClassNotFoundException, InvalidKeyException,
+           NoSuchAlgorithmException, NoSuchProviderException
+  {
+    try
+      {
+        sealCipher = Cipher.getInstance(sealAlg, provider);
+      }
+    catch (NoSuchPaddingException nspe)
+      {
+        throw new NoSuchAlgorithmException(nspe.getMessage());
+      }
+    AlgorithmParameters params = null;
+    if (encodedParams != null)
+      {
+        params = AlgorithmParameters.getInstance(paramsAlg, provider);
+        params.init(encodedParams);
+      }
+    try
+      {
+        sealCipher.init(Cipher.DECRYPT_MODE, key, params);
+        return unseal();
+      }
+    catch (InvalidAlgorithmParameterException iape)
+      {
+        throw new IOException("bad parameters");
+      }
+    catch (IllegalBlockSizeException ibse)
+      {
+        throw new IOException("illegal block size");
+      }
+    catch (BadPaddingException bpe)
+      {
+        throw new IOException("bad padding");
+      }
+  }
+
+  // Own methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Deserialize this object.
+   *
+   * @param ois The input stream.
+   * @throws java.io.IOException If reading fails.
+   * @throws java.lang.ClassNotFoundException If reading fails.
+   */
+  private void readObject(ObjectInputStream ois)
+    throws IOException, ClassNotFoundException
+  {
+    encodedParams = (byte[]) ois.readObject();
+    encryptedContent = (byte[]) ois.readObject();
+    sealAlg = (String) ois.readObject();
+    paramsAlg = (String) ois.readObject();
+  }
+
+  /**
+   * Serialize this object.
+   *
+   * @param oos The output stream.
+   * @throws java.io.IOException If writing fails.
+   */
+  private void writeObject(ObjectOutputStream oos)
+    throws IOException
+  {
+    oos.writeObject(encodedParams);
+    oos.writeObject(encryptedContent);
+    oos.writeObject(sealAlg);
+    oos.writeObject(paramsAlg);
+  }
+
+  /**
+   * Unseal this object, returning it.
+   *
+   * @return The unsealed, deserialized Object.
+   * @throws java.io.IOException If reading fails.
+   * @throws java.io.ClassNotFoundException If reading fails.
+   * @throws javax.crypto.IllegalBlockSizeException If the cipher has no
+   *         padding and the encrypted data is not a multiple of the
+   *         cipher's block size.
+   * @throws javax.crypto.BadPaddingException If the padding bytes are
+   *         incorrect.
+   */
+  private Object unseal()
+    throws IOException, ClassNotFoundException, IllegalBlockSizeException,
+           BadPaddingException
+  {
+    ByteArrayInputStream bais = null;
+    try
+      {
+        bais = new ByteArrayInputStream(sealCipher.doFinal(encryptedContent));
+      }
+    catch (IllegalStateException ise)
+      {
+        throw new IOException("cipher not initialized");
+      }
+    ObjectInputStream ois = new ObjectInputStream(bais);
+    return ois.readObject();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKey.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKey.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* SecretKey.java -- A key for symmetric cryptography.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.Key;
+
+/**
+ * A secret key for symmetric cryptography.
+ *
+ * <p>This interface defines no new methods over {@link
+ * java.security.Key}, but rather is intended to be a <i>marker
+ * interface</i> and to provide type safety for secret keys.</p>
+ *
+ * <p>The format of secret keys should be <code>RAW</code>, as returned
+ * by {@link java.security.Key#getFormat()}.</p>
+ *
+ * <p>Concrete implementations of this interface should override the
+ * {@link java.lang.Object#equals} and {@link java.lang.Object#hashCode}
+ * methods of {@link java.lang.Object} to use the actual key data rather
+ * than the identity-based default methods.</p>
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @see javax.crypto.SecretKeyFactory
+ * @see javax.crypto.Cipher
+ */
+public interface SecretKey extends Key
+{
+  long serialVersionUID = -4795878709595146952L;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactory.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,247 @@
+/* SecretKeyFactory.java -- Factory for creating secret keys.
+   Copyright (C) 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 javax.crypto;
+
+import gnu.java.security.Engine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+
+/**
+ * A secret key factory translates {@link SecretKey} objects to and from
+ * {@link java.security.spec.KeySpec} objects, and can translate between
+ * different vendors' representations of {@link SecretKey} objects (for
+ * security or semantics; whichever applies).
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see SecretKey
+ */
+public class SecretKeyFactory
+{
+
+  // Constants and fields.
+  // ------------------------------------------------------------------------
+
+  private static final String SERVICE = "SecretKeyFactory";
+
+  /** The underlying factory implementation. */
+  private SecretKeyFactorySpi skfSpi;
+
+  /** The provider of the implementation. */
+  private Provider provider;
+
+  /** The name of the algorithm. */
+  private String algorithm;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new secret key factory.
+   *
+   * @param skfSpi   The underlying factory implementation.
+   * @param provider The provider.
+   * @param algorithm The algorithm name.
+   */
+  protected SecretKeyFactory(SecretKeyFactorySpi skfSpi, Provider provider,
+                             String algorithm)
+  {
+    this.skfSpi = skfSpi;
+    this.provider = provider;
+    this.algorithm = algorithm;
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new secret key factory from the first appropriate
+   * instance.
+   *
+   * @param algorithm The algorithm name.
+   * @return The appropriate key factory, if found.
+   * @throws java.security.NoSuchAlgorithmException If no provider
+   *         implements the specified algorithm.
+   */
+  public static final SecretKeyFactory getInstance(String algorithm)
+    throws NoSuchAlgorithmException
+  {
+    Provider[] provs = Security.getProviders();
+    for (int i = 0; i < provs.length; i++)
+      {
+        try
+          {
+            return getInstance(algorithm, provs[i]);
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+          }
+      }
+    throw new NoSuchAlgorithmException(algorithm);
+  }
+
+  /**
+   * Create a new secret key factory from the named provider.
+   *
+   * @param algorithm The algorithm name.
+   * @param provider  The provider name.
+   * @return The appropriate key factory, if found.
+   * @throws java.security.NoSuchAlgorithmException If the named
+   *         provider does not implement the algorithm.
+   * @throws java.security.NoSuchProviderException If the named provider
+   *         does not exist.
+   */
+  public static final SecretKeyFactory getInstance(String algorithm,
+                                                   String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(algorithm, p);
+  }
+
+  /**
+   * Create a new secret key factory from the specified provider.
+   *
+   * @param algorithm The algorithm name.
+   * @param provider  The provider.
+   * @return The appropriate key factory, if found.
+   * @throws java.security.NoSuchAlgorithmException If the provider
+   *         does not implement the algorithm.
+   */
+  public static final SecretKeyFactory getInstance(String algorithm,
+                                                   Provider provider)
+    throws NoSuchAlgorithmException
+  {
+    try
+      {
+        return new SecretKeyFactory((SecretKeyFactorySpi)
+          Engine.getInstance(SERVICE, algorithm, provider),
+          provider, algorithm);
+      }
+    catch (InvocationTargetException ite)
+      {
+        if (ite.getCause() == null)
+          throw new NoSuchAlgorithmException(algorithm);
+        if (ite.getCause() instanceof NoSuchAlgorithmException)
+          throw (NoSuchAlgorithmException) ite.getCause();
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+    catch (ClassCastException cce)
+      {
+        throw new NoSuchAlgorithmException(algorithm);
+      }
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Generate a secret key from a key specification, if possible.
+   *
+   * @param keySpec The key specification.
+   * @return The secret key.
+   * @throws java.security.InvalidKeySpecException If the key specification
+   *         cannot be transformed into a secret key.
+   */
+  public final SecretKey generateSecret(KeySpec keySpec)
+    throws InvalidKeySpecException
+  {
+    return skfSpi.engineGenerateSecret(keySpec);
+  }
+
+  /**
+   * Get the algorithm name.
+   *
+   * @return The algorithm name.
+   */
+  public final String getAlgorithm()
+  {
+    return algorithm;
+  }
+
+  /**
+   * Get the key specification from a secret key.
+   *
+   * @param key     The secret key.
+   * @param keySpec The target key specification class.
+   * @return The key specification.
+   * @throws java.security.spec.InvalidKeySpecException If the secret key cannot
+   *         be transformed into the specified key specification.
+   */
+  public final KeySpec getKeySpec(SecretKey key, Class keySpec)
+    throws InvalidKeySpecException
+  {
+    return skfSpi.engineGetKeySpec(key, keySpec);
+  }
+
+  /**
+   * Get the provider of this implementation.
+   *
+   * @return The provider.
+   */
+  public final Provider getProvider()
+  {
+    return provider;
+  }
+
+  /**
+   * Translate a secret key into another form.
+   *
+   * @param key The key to translate.
+   * @return The translated key.
+   * @throws java.security.InvalidKeyException If the argument cannot be
+   *         translated.
+   */
+  public final SecretKey translateKey(SecretKey key)
+    throws InvalidKeyException
+  {
+    return skfSpi.engineTranslateKey(key);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactorySpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactorySpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactorySpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/SecretKeyFactorySpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* SecretKeyFactorySpi.java -- Secret key factory service provider interface.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.InvalidKeyException;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+
+/**
+ * The <i>Service Provider Interface</i> (<b>SPI</b>) for the {@link
+ * SecretKeyFactory} class.
+ *
+ * <p>Providers wishing to implement a secret key factory must
+ * subclass this and provide an appropriate implementation for all the
+ * abstract methods below, and provide an appropriate entry in the
+ * master {@link java.security.Provider} class (the service name for
+ * secret key factories is <code>"SecretKeyFactory"</code>).
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see SecretKeyFactory
+ */
+public abstract class SecretKeyFactorySpi
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new secret key factory SPI.
+   */
+  public SecretKeyFactorySpi()
+  {
+  }
+
+  // Abstract instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Translate a {@link java.security.KeySpec} into a {@link SecretKey}.
+   *
+   * @param keySpec The key specification.
+   * @return The secret key.
+   * @throws java.security.spec.InvalidKeySpecException If the key specification
+   *         cannot be translated into a secret key.
+   */
+  protected abstract SecretKey engineGenerateSecret(KeySpec keySpec)
+    throws InvalidKeySpecException;
+
+  /**
+   * Translate a {@link SecretKey} into a {@link java.security.KeySpec}.
+   *
+   * @param key     The secret key.
+   * @param keySpec The desired key specification class.
+   * @return The key specification.
+   * @throws java.security.spec.InvalidKeySpecException If the secret key cannot
+   *         be translated into the desired key specification.
+   */
+  protected abstract KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
+    throws InvalidKeySpecException;
+
+  /**
+   * Translate a secret key into a different representation.
+   *
+   * @param key The secret key to translate.
+   * @return The translated key.
+   * @throws java.security.InvalidKeyException If the specified secret
+   *         key cannot be translated.
+   */
+  protected abstract SecretKey engineTranslateKey(SecretKey key)
+    throws InvalidKeyException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ShortBufferException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ShortBufferException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ShortBufferException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/ShortBufferException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* ShortBufferException.java -- Signals a short output buffer.
+   Copyright (C) 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 javax.crypto;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * This exception is thrown on an attempt to transform bytes into a
+ * buffer that is too short to contain the data.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class ShortBufferException extends GeneralSecurityException
+{
+
+  // Constant.
+  // ------------------------------------------------------------------------
+
+  /** Serialization constant. */
+  private static final long serialVersionUID = 8427718640832943747L;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  public ShortBufferException()
+  {
+    super();
+  }
+
+  public ShortBufferException(String message)
+  {
+    super(message);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHKey.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHKey.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* DHKey.java -- General interface for a Diffie-Hellman key.
+   Copyright (C) 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 javax.crypto.interfaces;
+
+import javax.crypto.spec.DHParameterSpec;
+
+/**
+ * This interface marks public/private keys in the Diffie-Hellman key
+ * exchange algorithm. Implementations of Diffie-Hellman keys should
+ * implement this interface, and applications can safely cast keys that
+ * are known to be Diffie-Hellman keys to this interface.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public interface DHKey
+{
+  /**
+   * Returns the Diffie-Hellman parameters for this key, which includes
+   * the generator and the prime.
+   *
+   * @return The Diffie-Hellman parameters.
+   */
+  DHParameterSpec getParams();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPrivateKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPrivateKey.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPrivateKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPrivateKey.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* DHPrivateKey.java -- A Diffie-Hellman private key.
+   Copyright (C) 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 javax.crypto.interfaces;
+
+import java.math.BigInteger;
+import java.security.PrivateKey;
+
+/**
+ * This interface marks a private key in the Diffie-Hellman key exchange
+ * algorithm. It should be treated with as much care as any {@link
+ * java.security.PrivateKey}.
+ *
+ * <p>Implementations of Diffie-Hellman private keys should implement
+ * this interface. Applications that know a particular key is a
+ * Diffie-Hellman private key can safely cast it to this interface.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see DHKey
+ * @see DHPublicKey
+ */
+public interface DHPrivateKey extends DHKey, PrivateKey
+{
+  /** Compatible with JDK1.4. */
+  long serialVersionUID = 2211791113380396553L;
+
+  /**
+   * Returns the private value <i>x</i>.
+   *
+   * @return The private value <i>x</i>.
+   */
+  BigInteger getX();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPublicKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPublicKey.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPublicKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/DHPublicKey.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* DHPublicKey.java -- A Diffie-Hellman public key.
+   Copyright (C) 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 javax.crypto.interfaces;
+
+import java.math.BigInteger;
+import java.security.PublicKey;
+
+/**
+ * This interface marks a public key in the Diffie-Hellman key-exchange
+ * algorithm.
+ *
+ * <p>Implementations of Diffie-Hellman public keys should implement
+ * this interface. Applications that know that a particular key is a
+ * Diffie-Hellman public key it can be safely cast to this interface.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see DHKey
+ * @see DHPrivateKey
+ */
+public interface DHPublicKey extends DHKey, PublicKey
+{
+  /** Compatible with JDK1.4. */
+  long serialVersionUID = -6628103563352519193L;
+
+  /**
+   * Get the public value <i>y</i>.
+   *
+   * @return The public value <i>y</i>.
+   */
+  BigInteger getY();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/PBEKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/PBEKey.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/PBEKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/PBEKey.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* PBEKey.java -- A key derived from a password.
+   Copyright (C) 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 javax.crypto.interfaces;
+
+import javax.crypto.SecretKey;
+
+/**
+ * Interface to a password-derived key for password-based encryption
+ * (PBE). Applications working with a {@link javax.crypto.SecretKey}
+ * that is known to be a password-based key can safely cast such keys to
+ * this interface.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public interface PBEKey extends SecretKey
+{
+  /** Compatible with JDK1.4. */
+  long serialVersionUID = -1430015993304333921L;
+
+  /**
+   * Retruns the iteration count, or 0 if not specified.
+   *
+   * @return The iteration count.
+   */
+  int getIterationCount();
+
+  /**
+   * Returns a copy of the password as a character array. It is the
+   * caller's responsibility to zero-out the password when it is no
+   * longer in use.
+   *
+   * <p>Although it is not specified in the documentation,
+   * implementations should not copy or clone the password array, but
+   * rather return the reference to the array itself, so the caller has
+   * the ability to erase the password.
+   *
+   * @return The password.
+   */
+  char[] getPassword();
+
+  /**
+   * Returns a copy of the salt. It is the caller's responsibility to
+   * zero-out the salt when it is no longer in use.
+   *
+   * <p>Although it is not specified in the documentation,
+   * implementations should not copy or clone the salt array, but
+   * rather return the reference to the array itself, so the caller has
+   * the ability to erase the salt.
+   *
+   * @return The salt.
+   */
+  byte[] getSalt();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/interfaces/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.crypto.interfaces package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.crypto.interfaces</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.crypto package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.crypto</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESKeySpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESKeySpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESKeySpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESKeySpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,220 @@
+/* DESKeySpec -- Keys for DES.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.InvalidKeyException;
+import java.security.spec.KeySpec;
+
+/**
+ * This class is a transparent wrapper for DES keys, which are arrays
+ * of 8 bytes.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class DESKeySpec implements KeySpec
+{
+
+  // Constants.
+  // ------------------------------------------------------------------------
+
+  /**
+   * The length of a DES key, in bytes.
+   */
+  public static final int DES_KEY_LEN = 8;
+
+  /**
+   * The key bytes.
+   */
+  private byte[] key;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new DES key spec, copying the first 8 bytes from the
+   * byte array.
+   *
+   * @param key The key bytes.
+   * @throws java.security.InvalidKeyException If there are less than 8
+   *         bytes in the array.
+   */
+  public DESKeySpec(byte[] key) throws InvalidKeyException
+  {
+    this(key, 0);
+  }
+
+  /**
+   * Create a new DES key spec, starting at <code>offset</code> in
+   * the byte array. The first 8 bytes starting at <code>offset</code>
+   * are copied.
+   *
+   * @param key    The key bytes.
+   * @param offset The offset into the byte array at which to begin.
+   * @throws java.security.InvalidKeyException If there are less than 8
+   *         bytes starting at <code>offset</code>.
+   */
+  public DESKeySpec(byte[] key, int offset) throws InvalidKeyException
+  {
+    if (key.length - offset < DES_KEY_LEN)
+      {
+        throw new InvalidKeyException("DES keys must be 8 bytes long");
+      }
+    this.key = new byte[DES_KEY_LEN];
+    System.arraycopy(key, offset, this.key, 0, DES_KEY_LEN);
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Returns whether or not the given key is <i>parity adjusted</i>;
+   * i.e. every byte in the key has an odd number of "1" bits.
+   *
+   * @param key    The key bytes, considered between <code>[offset,
+   *               offset+7]</code>
+   * @param offset The offset into the byte array at which to begin.
+   * @return True if all bytes have an odd number of "1" bits.
+   * @throws java.security.InvalidKeyException If there are not enough
+   *         bytes in the array.
+   */
+  public static boolean isParityAdjusted(byte[] key, int offset)
+    throws InvalidKeyException
+  {
+    if (key.length - offset < DES_KEY_LEN)
+      {
+        throw new InvalidKeyException("DES keys must be 8 bytes long");
+      }
+    boolean parity = false;
+    boolean oddbits = false;
+    for (int i = 0; i < DES_KEY_LEN; i++)
+      {
+        oddbits = false;
+        for (int j = 0; j < 8; j++)
+          {
+            oddbits ^= (key[i+offset] & 1 << j) != 0;
+          }
+        parity &= oddbits;
+      }
+    return parity;
+  }
+
+  /**
+   * One-half of the weak and semiweak DES keys (the other half are the
+   * complements of these).
+   */
+  private static final byte[][] WEAK_KEYS = new byte[][] {
+    {   0,   0,   0,   0,   0,   0,   0,   0 }, // 0000 0000 0000 0000
+    {  -1,  -1,  -1,  -1,   0,   0,   0,   0 }, // ffff ffff 0000 0000
+    {   1,   1,   1,   1,   1,   1,   1,   1 }, // 0101 0101 0101 0101
+    {  31,  31,  31,  31,  14,  14,  14,  14 }, // 1f1f 1f1f 0e0e 0e0e
+    {   1,  -2,   1,  -2,   1,  -2,   1,  -2 }, // 01fe 01fe 01fe 01fe
+    {  31, -32,  31, -32, -32,  31, -32,  31 }, // 1fe0 1fe0 0e1f 0e1f
+    {   1, -32,   1, -32,   1, -15,   1, -15 }, // 01e0 01e0 01f1 01f1
+    {  31,  -2,  31,  -2,  14,  -2,  14,  -2 }, // 1ffe 1ffe 0efe 0efe
+    {   1,  31,   1,  31,   1,  14,   1,  14 }, // 011f 011f 010e 010e
+    { -32,  -2, -32,  -2, -15,  -2, -15,  -2 }, // e0fe e0fe f1fe f1fe
+  };
+
+  /**
+   * Tests if the bytes between <code>[offset, offset+7]</code>
+   * constitute a weak or semi-weak DES key.
+   *
+   * @param key    The key bytes to check.
+   * @param offset The offset in the byte array to start.
+   * @return true If the key bytes are a weak key.
+   */
+  public static boolean isWeak(byte[] key, int offset)
+    throws InvalidKeyException
+  {
+    if (key.length - offset < DES_KEY_LEN)
+      {
+        throw new InvalidKeyException("DES keys must be 8 bytes long");
+      }
+    for (int i = 0; i < WEAK_KEYS.length; i++)
+      {
+        if (equalsOrComplementEquals(key, offset, WEAK_KEYS[i]))
+          {
+            return true;
+          }
+      }
+    return false;
+  }
+
+  /**
+   * This method returns true if the first 8 bytes starting at
+   * <code>off</code> in <code>a</code> equal the first 8 bytes in
+   * <code>b</code>, or equal the <i>complement</i> of the first 8 bytes
+   * in <code>b</code>.
+   *
+   * @param a   The first byte array.
+   * @param off The index into the first byte array.
+   * @param b   The second byte array.
+   * @return <code>a == b || a == ~b</code>
+   */
+  private static boolean equalsOrComplementEquals(byte[] a, int off, byte[] b)
+  {
+    boolean result = true;
+    for (int i = 0; i < DES_KEY_LEN; i++)
+      {
+        result &= a[off+i] == b[i];
+      }
+    if (result) return true;
+    result = true;
+    for (int i = 0; i < DES_KEY_LEN; i++)
+      {
+        result &= a[off+i] == (~b[i]);
+      }
+    return result;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Return the key as a byte array. This method does not copy the byte
+   * array.
+   *
+   * @return The key bytes.
+   */
+  public byte[] getKey()
+  {
+    return key;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESedeKeySpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESedeKeySpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESedeKeySpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DESedeKeySpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,151 @@
+/* DESedeKeySpec.java -- Keys for triple-DES.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.InvalidKeyException;
+import java.security.spec.KeySpec;
+
+/**
+ * This class is a transparent wrapper for DES-EDE (Triple-DES) keys,
+ * which are arrays of 24 bytes.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class DESedeKeySpec implements KeySpec
+{
+
+  // Constants.
+  // ------------------------------------------------------------------------
+
+  /**
+   * The length of a triple-DES key, in bytes.
+   */
+  public static final int DES_EDE_KEY_LEN = 24;
+
+  /**
+   * The key bytes.
+   */
+  private byte[] key;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new DES-EDE key spec, copying the first 24 bytes from the
+   * byte array.
+   *
+   * @param key The key bytes.
+   * @throws java.security.InvalidKeyException If there are less than 24
+   *         bytes in the array.
+   */
+  public DESedeKeySpec(byte[] key) throws InvalidKeyException
+  {
+    this(key, 0);
+  }
+
+  /**
+   * Create a new DES-EDE key spec, starting at <code>offset</code> in
+   * the byte array. The first 24 bytes starting at <code>offset</code>
+   * are copied.
+   *
+   * @param key    The key bytes.
+   * @param offset The offset into the byte array at which to begin.
+   * @throws java.security.InvalidKeyException If there are less than 24
+   *         bytes starting at <code>offset</code>.
+   */
+  public DESedeKeySpec(byte[] key, int offset) throws InvalidKeyException
+  {
+    if (key.length - offset < DES_EDE_KEY_LEN)
+      {
+        throw new InvalidKeyException("DES-EDE keys must be 24 bytes long");
+      }
+    this.key = new byte[DES_EDE_KEY_LEN];
+    System.arraycopy(key, offset, this.key, 0, DES_EDE_KEY_LEN);
+  }
+
+  // Class methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Returns whether or not the given key is <i>parity adjusted</i>;
+   * i.e. every byte in the key has an odd number of "1" bits.
+   *
+   * @param key    The key bytes, considered between <code>[offset,
+   *               offset+23]</code>
+   * @param offset The offset into the byte array at which to begin.
+   * @return True if all bytes have an odd number of "1" bits.
+   * @throws java.security.InvalidKeyException If there are not enough
+   *         bytes in the array.
+   */
+  public static boolean isParityAdjusted(byte[] key, int offset)
+    throws InvalidKeyException
+  {
+    if (key.length - offset < DES_EDE_KEY_LEN)
+      {
+        throw new InvalidKeyException("DES-EDE keys must be 24 bytes long");
+      }
+    boolean parity = false;
+    boolean oddbits = false;
+    for (int i = 0; i < DES_EDE_KEY_LEN; i++)
+      {
+        oddbits = false;
+        for (int j = 0; j < 8; j++)
+          {
+            oddbits ^= (key[i+offset] & 1 << j) != 0;
+          }
+        parity &= oddbits;
+      }
+    return parity;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Return the key as a byte array. This method does not copy the byte
+   * array.
+   *
+   * @return The key bytes.
+   */
+  public byte[] getKey()
+  {
+    return key;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHGenParameterSpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHGenParameterSpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHGenParameterSpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHGenParameterSpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* DHGenParameterSpec.java -- Diffie-Hellman parameter generator spec.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * This class represents the parameters needed for generating
+ * Diffie-Hellman parameters.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see DHParameterSpec
+ */
+public class DHGenParameterSpec implements AlgorithmParameterSpec
+{
+
+  // Variables.
+  // ------------------------------------------------------------------------
+
+  /** The length of the prime, in bits. */
+  private int primeSize;
+
+  /** The length of the exponent, in bits. */
+  private int exponentSize;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new Diffie-Hellman parameter generator spec.
+   *
+   * @param primeSize The size of the prime, in bits.
+   * @param exponentSize The size of the exponent, in bits.
+   */
+  public DHGenParameterSpec(int primeSize, int exponentSize)
+  {
+    this.primeSize = primeSize;
+    this.exponentSize = exponentSize;
+  }
+
+  // Intance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the size of the exponent, in bits.
+   *
+   * @return The exponent size.
+   */
+  public int getExponentSize()
+  {
+    return exponentSize;
+  }
+
+  /**
+   * Get the size of the prime, in bits.
+   *
+   * @return The prime size.
+   */
+  public int getPrimeSize()
+  {
+    return primeSize;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHParameterSpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHParameterSpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHParameterSpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHParameterSpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* DHParameterSpec.java -- Parameters for Diffie-Hellman keys.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.math.BigInteger;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * The base set of parameters necessary to perform Diffie-Hellman key
+ * exchange. Each party in the key exchange shares these parameters.
+ *
+ * <p>Each set of parameters consists of a <i>base generator</i>
+ * <code>g</code>, a <i>prime modulus</i> <code>p</code>, and an
+ * optional length, in bits, of the private exponent.
+ *
+ * <p>See <a href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-3/">PKCS
+ * #3 - Diffie-Hellman Key Agreement Standard</a> for more information.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see javax.crypto.KeyAgreement
+ */
+public class DHParameterSpec implements AlgorithmParameterSpec
+{
+
+  // Variables.
+  // ------------------------------------------------------------------------
+
+  /** The base generator g. */
+  private BigInteger g;
+
+  /** The prime modulus p. */
+  private BigInteger p;
+
+  /** The length, in bits, of the private exponent. */
+  private int l;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new set of Diffie-Hellman parameters.
+   *
+   * @param p The prime modulus.
+   * @param g The base generator.
+   */
+  public DHParameterSpec(BigInteger p, BigInteger g)
+  {
+    this(p, g, 0);
+  }
+
+  /**
+   * Create a new set of Diffie-Hellman parameters.
+   *
+   * @param p The prime modulus.
+   * @param g The base generator.
+   * @param l The size of the private exponent, in bits.
+   */
+  public DHParameterSpec(BigInteger p, BigInteger g, int l)
+  {
+    this.p = p;
+    this.g = g;
+    this.l = l;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the base generator, <i>g</i>.
+   *
+   * @return The base generator <i>g</i>.
+   */
+  public BigInteger getG()
+  {
+    return g;
+  }
+
+  /**
+   * Get the length of the private exponent, in bits.
+   *
+   * @return The length of the private exponent, in bits, or 0 if this
+   *         has not been explicitly set.
+   */
+  public int getL()
+  {
+    return l;
+  }
+
+  /**
+   * Get the prime modulus, <i>p</i>.
+   *
+   * @return The prime modulus, <i>p</i>.
+   */
+  public BigInteger getP()
+  {
+    return p;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPrivateKeySpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPrivateKeySpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPrivateKeySpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPrivateKeySpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* DHPrivateKeySpec.java -- Wrapper for Diffie-Hellman private keys.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.math.BigInteger;
+import java.security.spec.KeySpec;
+
+/**
+ * A wrapper for Diffie-Hellman private key data.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see DHPublicKeySpec
+ */
+public class DHPrivateKeySpec implements KeySpec
+{
+
+  // Variables.
+  // ------------------------------------------------------------------------
+
+  /** The base generator. */
+  private BigInteger g;
+
+  /** The prime modulus. */
+  private BigInteger p;
+
+  /** The private exponent. */
+  private BigInteger x;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new Diffie-Hellman private key spec.
+   *
+   * @param x The private exponent.
+   * @param p The prime modulus.
+   * @param g The base generator.
+   */
+  public DHPrivateKeySpec(BigInteger x, BigInteger p, BigInteger g)
+  {
+    this.x = x;
+    this.p = p;
+    this.g = g;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the base generator.
+   *
+   * @return The base generator.
+   */
+  public BigInteger getG()
+  {
+    return g;
+  }
+
+  /**
+   * Get the prime modulus.
+   *
+   * @return The prime modulus.
+   */
+  public BigInteger getP()
+  {
+    return p;
+  }
+
+  /**
+   * Get the private exponent.
+   *
+   * @return The private exponent.
+   */
+  public BigInteger getX()
+  {
+    return x;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPublicKeySpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPublicKeySpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPublicKeySpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/DHPublicKeySpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* DHPublicKeySpec.java -- Wrapper for Diffie-Hellman public keys.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.math.BigInteger;
+import java.security.spec.KeySpec;
+
+/**
+ * A wrapper for Diffie-Hellman public key data.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see DHPrivateKeySpec
+ */
+public class DHPublicKeySpec implements KeySpec
+{
+
+  // Variables.
+  // ------------------------------------------------------------------------
+
+  /** The base generator. */
+  private BigInteger g;
+
+  /** The prime modulus. */
+  private BigInteger p;
+
+  /** The public value. */
+  private BigInteger y;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new Diffie-Hellman public key spec.
+   *
+   * @param y The public value.
+   * @param p The prime modulus.
+   * @param g The base generator.
+   */
+  public DHPublicKeySpec(BigInteger y, BigInteger p, BigInteger g)
+  {
+    this.y = y;
+    this.p = p;
+    this.g = g;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the base generator.
+   *
+   * @return The base generator.
+   */
+  public BigInteger getG()
+  {
+    return g;
+  }
+
+  /**
+   * Get the prime modulus.
+   *
+   * @return The prime modulus.
+   */
+  public BigInteger getP()
+  {
+    return p;
+  }
+
+  /**
+   * Get the public value.
+   *
+   * @return The public value.
+   */
+  public BigInteger getY()
+  {
+    return y;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/IvParameterSpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/IvParameterSpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/IvParameterSpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/IvParameterSpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,96 @@
+/* IvParameterSpec.java -- A simple wrapper for initialization vectors.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * A wrapper for an initialization vector. An initialization vector is
+ * necessary for any cipher in any <i>feedback mode</i>, e.g. CBC.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class IvParameterSpec implements AlgorithmParameterSpec
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  /** The IV. */
+  private byte[] iv;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new initialization vector spec from an entire byte array.
+   *
+   * @param iv The IV bytes.
+   */
+  public IvParameterSpec(byte[] iv)
+  {
+    this(iv, 0, iv.length);
+  }
+
+  /**
+   * Create a new initialization vector spec from part of a byte array.
+   *
+   * @param iv  The IV bytes.
+   * @param off The offset into the IV bytes.
+   * @param len The number of IV bytes.
+   */
+  public IvParameterSpec(byte[] iv, int off, int len)
+  {
+    this.iv = new byte[len];
+    System.arraycopy(iv, off, this.iv, 0, len);
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Returns the IV. This method does not copy the byte array.
+   *
+   * @return The IV.
+   */
+  public byte[] getIV()
+  {
+    return iv;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEKeySpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEKeySpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEKeySpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEKeySpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,281 @@
+/* PBEKeySpec.java -- Wrapper for password-based keys.
+   Copyright (C) 2004, 2006  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 javax.crypto.spec;
+
+import java.security.spec.KeySpec;
+
+/**
+ * A wrapper for a password-based key, used for password-based
+ * encryption (PBE).
+ *
+ * <p>Examples of password-based encryption algorithms include:
+ *
+ * <ul>
+ * <li><a href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-5/">PKCS #5
+ * - Password-Based Cryptography Standard</a></li>
+ * <li><a href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-12/">PKCS
+ * #12 - Personal Information Exchange Syntax Standard</a></li>
+ * </ul>
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ * @see javax.crypto.SecretKeyFactory
+ * @see PBEParameterSpec
+ */
+public class PBEKeySpec implements KeySpec
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  /** The iteration count. */
+  private int iterationCount;
+
+  /** The generated key length. */
+  private int keyLength;
+
+  /** The password. */
+  private char[] password;
+
+  /** The salt. */
+  private byte[] salt;
+
+  /** The password state */
+  private boolean passwordValid = true;
+  
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new PBE key spec with just a password.
+   * <p>
+   * A copy of the password argument is stored instead of the argument itself.
+   * 
+   * @param password The password char array.
+   */
+  public PBEKeySpec(char[] password)
+  {
+    setPassword(password);
+    
+    // load the default values for unspecified variables.
+    salt = null;
+    iterationCount = 0;
+    keyLength = 0;
+  }
+
+  /**
+   * Create a PBE key spec with a password, salt, and iteration count.
+   * <p>
+   * A copy of the password and salt arguments are stored instead of the
+   * arguments themselves.
+   * 
+   * @param password The password char array.
+   * @param salt The salt bytes.
+   * @param iterationCount The iteration count.
+   * @throws NullPointerException If salt is null
+   * @throws IllegalArgumentException If salt is an empty array, or
+   *           iterationCount is negative
+   */
+  public PBEKeySpec(char[] password, byte[] salt, int iterationCount)
+  {
+    setPassword(password);
+    setSalt(salt);
+    setIterationCount(iterationCount);
+
+    // load default values into unspecified variables.
+    keyLength = 0;
+  }
+
+  /**
+   * Create a PBE key spec with a password, salt, iteration count, and key
+   * length.
+   * <p>
+   * A copy of the password and salt arguments are stored instead of the
+   * arguments themselves.
+   * 
+   * @param password The password char array.
+   * @param salt The salt bytes.
+   * @param iterationCount The iteration count.
+   * @param keyLength The generated key length.
+   * @throws NullPointerException If salt is null
+   * @throws IllegalArgumentException If salt is an empty array, if
+   *           iterationCount or keyLength is negative
+   */
+  public PBEKeySpec(char[] password, byte[] salt, int iterationCount,
+                    int keyLength)
+  {
+    setPassword(password);
+    setSalt(salt);
+    setIterationCount(iterationCount);
+    setKeyLength(keyLength);
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Clear the password array by filling it with null characters.
+   * <p>
+   * This clears the stored copy of the password, not the original char array
+   * used to create the password.
+   */
+  public final void clearPassword()
+  {
+    if (password == null)
+      return;
+    for (int i = 0; i < password.length; i++)
+      password[i] = '\u0000';
+    
+    // since the password is cleared, it is no longer valid
+    passwordValid = false;
+  }
+
+  /**
+   * Get the iteration count, or 0 if it has not been specified.
+   *
+   * @return The iteration count, or 0 if it has not been specified.
+   */
+  public final int getIterationCount()
+  {
+    return iterationCount;
+  }
+
+  /**
+   * Get the generated key length, or 0 if it has not been specified.
+   *
+   * @return The key length, or 0 if it has not been specified.
+   */
+  public final int getKeyLength()
+  {
+    return keyLength;
+  }
+
+  /**
+   * Get the password character array copy.
+   * <p>
+   * This returns a copy of the password, not the password itself.
+   * 
+   * @return a clone of the password.
+   * @throws IllegalStateException If {@link #clearPassword()} has already been
+   *           called.
+   */
+  public final char[] getPassword()
+  {
+    if (! passwordValid)
+      throw new IllegalStateException("clearPassword() has been called, the "
+                                      + "password is no longer valid");
+    return (char[]) password.clone();
+  }
+
+  /**
+   * Get the salt bytes array copy.
+   * <p>
+   * This returns a copy of the salt, not the salt itself.
+   * 
+   * @return The salt.
+   */
+  public final byte[] getSalt()
+  {
+    if (salt != null)
+      return (byte[]) salt.clone();
+    return null;
+  }
+
+  /**
+   * Set the password char array.
+   * <p>
+   * A copy of the password argument is stored instead of the argument itself.
+   * 
+   * @param password The password to be set
+   */
+  private void setPassword(char[] password)
+  {
+    if (password != null)
+      this.password = (char[]) password.clone();
+    else
+      this.password = new char[0];
+
+    passwordValid = true;
+  }
+
+  /**
+   * Set the salt byte array.
+   * <p>
+   * A copy of the salt arguments is stored instead of the argument itself.
+   * 
+   * @param salt The salt to be set.
+   * @throws NullPointerException If the salt is null.
+   * @throws IllegalArgumentException If the salt is an empty array.
+   */
+  private void setSalt(byte[] salt)
+  {
+    if (salt.length == 0)
+      throw new IllegalArgumentException("salt MUST NOT be an empty byte array");
+
+    this.salt = (byte[]) salt.clone();
+  }
+
+  /**
+   * Set the iterationCount.
+   * 
+   * @param iterationCount The iteration count to be set.
+   * @throws IllegalArgumentException If the iterationCount is negative.
+   */
+  private void setIterationCount(int iterationCount)
+  {
+    if (iterationCount < 0)
+      throw new IllegalArgumentException("iterationCount MUST be positive");
+
+    this.iterationCount = iterationCount;
+  }
+
+  /**
+   * Set the keyLength.
+   * 
+   * @param keyLength The keyLength to be set.
+   * @throws IllegalArgumentException if the keyLength is negative.
+   */
+  private void setKeyLength(int keyLength)
+  {
+    if (keyLength < 0)
+      throw new IllegalArgumentException("keyLength MUST be positive");
+
+    this.keyLength = keyLength;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEParameterSpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEParameterSpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEParameterSpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/PBEParameterSpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* PBEParameterSpec.java -- A wrapper for PBE parameters.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * A wrapper for the parameters used in <a
+ * href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-5/">PKCS #5 -
+ * Password-Based Cryptography Standard</a>.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class PBEParameterSpec implements AlgorithmParameterSpec
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  /** The iteration count. */
+  private int iterationCount;
+
+  /** The salt. */
+  private byte[] salt;
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Creates a new password-based encryption parameter specification.
+   *
+   * @param salt           The salt.
+   * @param iterationCount The iteration count.
+   */
+  public PBEParameterSpec(byte[] salt, int iterationCount)
+  {
+    this.salt = salt;
+    this.iterationCount = iterationCount;
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the iteration count.
+   *
+   * @return The iteration count.
+   */
+  public int getIterationCount()
+  {
+    return iterationCount;
+  }
+
+  /**
+   * Get the salt.
+   *
+   * @return The salt.
+   */
+  public byte[] getSalt()
+  {
+    return salt;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC2ParameterSpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC2ParameterSpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC2ParameterSpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC2ParameterSpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,166 @@
+/* RC2ParameterSpec.java -- Wrapper for RC2 parameters.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * A wrapper for parameters for the <a
+ * href="http://www.rsasecurity.com/rsalabs/faq/3-6-2.html">RC2</a>
+ * block cipher ("RC" means either "Rivest Cipher" or "Ron's Code",
+ * depending upon who you ask and when).
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class RC2ParameterSpec implements AlgorithmParameterSpec
+{
+
+  // Constants and fields.
+  // ------------------------------------------------------------------------
+
+  /** The length of an RC2 IV, in bytes. */
+  private static final int RC2_IV_LENGTH = 8;
+
+  /** The effective key length, in bits. */
+  private int effectiveKeyBits;
+
+  /** The initialization vector. */
+  private byte[] iv;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create RC2 parameters without an IV.
+   *
+   * @param effectiveKeyBits The number of effective key bits.
+   */
+  public RC2ParameterSpec(int effectiveKeyBits)
+  {
+    this.effectiveKeyBits = effectiveKeyBits;
+  }
+
+  /**
+   * Create RC2 parameters with an IV.
+   *
+   * @param effectiveKeyBits The number of effective key bits.
+   * @param iv               The IV; the first eight bytes of this array
+   *                         are used.
+   */
+  public RC2ParameterSpec(int effectiveKeyBits, byte[] iv)
+  {
+    this(effectiveKeyBits, iv, 0);
+  }
+
+  /**
+   * Create RC2 parameters with an IV.
+   *
+   * @param effectiveKeyBits The number of effective key bits.
+   * @param iv               The IV; the first eight bytes of this array
+   *                         after <code>offset</code> are used.
+   * @param offset           From whence to start in the array.
+   */
+  public RC2ParameterSpec(int effectiveKeyBits, byte[] iv, int offset)
+  {
+    if (iv.length - offset < RC2_IV_LENGTH)
+      {
+        throw new IllegalArgumentException("IV too short");
+      }
+    this.effectiveKeyBits = effectiveKeyBits;
+    this.iv = new byte[RC2_IV_LENGTH];
+    System.arraycopy(iv, offset, this.iv, 0, RC2_IV_LENGTH);
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Get the number of effective key bits.
+   *
+   * @return The numer of effective key bits.
+   */
+  public int getEffectiveKeyBits()
+  {
+    return effectiveKeyBits;
+  }
+
+  /**
+   * Return the initialization vector, or <code>null</code> if none was
+   * specified.
+   *
+   * @return The IV, or null.
+   */
+  public byte[] getIV()
+  {
+    return iv;
+  }
+
+  public boolean equals(Object o)
+  {
+    if (this == o) return true;
+    byte[] oiv = ((RC2ParameterSpec) o).getIV();
+    if (iv != oiv)
+      {
+        if (iv == null || oiv == null) return false;
+        if (iv.length != oiv.length) return false;
+        for (int i = 0; i < iv.length; i++)
+          {
+            if (iv[i] != oiv[i])
+              {
+                return false;
+              }
+          }
+      }
+    return effectiveKeyBits == ((RC2ParameterSpec) o).getEffectiveKeyBits();
+  }
+
+  public int hashCode()
+  {
+    int code = effectiveKeyBits;
+    if (iv != null)
+      {
+        for (int i = 0; i < RC2_IV_LENGTH; i++)
+          {
+            code += iv[i];
+          }
+      }
+    return code;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC5ParameterSpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC5ParameterSpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC5ParameterSpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/RC5ParameterSpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,202 @@
+/* RC5ParameterSpec.java -- parameters for RC5.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * A wrapper for parameters to the <a
+ * href="http://www.rsasecurity.com/rsalabs/faq/3-6-4.html">RC5</a>
+ * block cipher.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ * @since 1.4
+ */
+public class RC5ParameterSpec implements AlgorithmParameterSpec
+{
+
+  // Fields.
+  // ------------------------------------------------------------------------
+
+  /** The IV. */
+  private byte[] iv;
+
+  /** The number of rounds. */
+  private int rounds;
+
+  /** The version number. */
+  private int version;
+
+  /** The word size, in bits. */
+  private int wordSize;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create RC5 parameters without an IV.
+   *
+   * @param version  The version number.
+   * @param rounds   The number of rounds.
+   * @param wordSize The size of a word, in bits.
+   */
+  public RC5ParameterSpec(int version, int rounds, int wordSize)
+  {
+    this.version = version;
+    this.rounds = rounds;
+    this.wordSize = wordSize;
+  }
+
+  /**
+   * Create RC5 parameters with an IV. The bytes in <code>iv</code> in
+   * the range <code>[0, 2*(wordSize/8)-1]</code> are used.
+   *
+   * @param version  The version number.
+   * @param rounds   The number of rounds.
+   * @param wordSize The size of a word, in bits.
+   * @param iv       The IV data.
+   */
+  public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv)
+  {
+    this(version, rounds, wordSize, iv, 0);
+  }
+
+  /**
+   * Create RC5 parameters with an IV. The bytes in <code>iv</code> in
+   * the range <code>[off, off+2*(wordSize/8)-1]</code> are used.
+   *
+   * @param version  The version number.
+   * @param rounds   The number of rounds.
+   * @param wordSize The size of a word, in bits.
+   * @param iv       The IV data.
+   * @param off      From where in the array the IV starts.
+   */
+  public
+  RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv, int off)
+  {
+    this(version, rounds, wordSize);
+    int ivLength = 2 * (wordSize / 8);
+    if (off < 0)
+      throw new IllegalArgumentException();
+    if (iv.length - off < ivLength)
+      {
+        throw new IllegalArgumentException("IV too short");
+      }
+    this.iv = new byte[ivLength];
+    System.arraycopy(iv, off, this.iv, 0, ivLength);
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Return the initializaiton vector, or <code>null</code> if none was
+   * specified.
+   *
+   * @return The IV, or null.
+   */
+  public byte[] getIV()
+  {
+    return iv;
+  }
+
+  /**
+   * Get the number of rounds.
+   *
+   * @return The number of rounds.
+   */
+  public int getRounds()
+  {
+    return rounds;
+  }
+
+  /**
+   * Get the version number.
+   *
+   * @return The version number.
+   */
+  public int getVersion()
+  {
+    return version;
+  }
+
+  /**
+   * Get the word size, in bits.
+   *
+   * @return The word size, in bits.
+   */
+  public int getWordSize()
+  {
+    return wordSize;
+  }
+
+  public boolean equals(Object o)
+  {
+    if (this == o) return true;
+    byte[] oiv = ((RC5ParameterSpec) o).getIV();
+    if (iv != oiv)
+      {
+        if (iv == null || oiv == null) return false;
+        if (iv.length != oiv.length) return false;
+        for (int i = 0; i < iv.length; i++)
+          {
+            if (iv[i] != oiv[i])
+              {
+                return false;
+              }
+          }
+      }
+    return rounds   == ((RC5ParameterSpec) o).getRounds()
+        && version  == ((RC5ParameterSpec) o).getVersion()
+        && wordSize == ((RC5ParameterSpec) o).getWordSize();
+  }
+
+  public int hashCode()
+  {
+    int code = rounds + version + wordSize;
+    if (iv != null)
+      {
+        for (int i = 0; i < iv.length; i++)
+          {
+            code += iv[i];
+          }
+      }
+    return code;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/SecretKeySpec.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/SecretKeySpec.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/SecretKeySpec.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/SecretKeySpec.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,163 @@
+/* SecretKeySpec.java -- Wrapper for secret keys.
+   Copyright (C) 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 javax.crypto.spec;
+
+import java.security.spec.KeySpec;
+
+import javax.crypto.SecretKey;
+
+/**
+ * This is a simple wrapper around a raw byte array, for ciphers that do
+ * not require any key parameters other than the bytes themselves.
+ *
+ * <p>Since this class implements {@link javax.crypto.SecretKey}, which
+ * in turn extends {@link java.security.Key}, so instances of this class
+ * may be passed directly to the <code>init()</code> methods of {@link
+ * javax.crypto.Cipher}.
+ *
+ * @see javax.crypto.SecretKey
+ * @see javax.crypto.SecretKeyFactory
+ */
+public class SecretKeySpec implements KeySpec, SecretKey
+{
+
+  // Constants and fields.
+  // ------------------------------------------------------------------------
+
+  /** Compatible with JDK1.4. */
+  private static final long serialVersionUID = 6577238317307289933L;
+
+  /** The key bytes. */
+  private byte[] key;
+
+  /** The algorithm's name. */
+  private String algorithm;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Create a new secret key spec from an entire byte array.
+   *
+   * @param key       The key material.
+   * @param algorithm The name of the algorithm using this key.
+   */
+  public SecretKeySpec(byte[] key, String algorithm)
+  {
+    this(key, 0, key.length, algorithm);
+  }
+
+  /**
+   * Create a new secret key spec from part of a byte array.
+   *
+   * @param key       The key material.
+   * @param off       The offset at which key material begins.
+   * @param len       The length of key material.
+   * @param algorithm The name of the algorithm using this key.
+   */
+  public SecretKeySpec(byte[] key, int off, int len, String algorithm)
+  {
+    this.key = new byte[len];
+    this.algorithm = algorithm;
+    System.arraycopy(key, off, this.key, 0, len);
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Return the name of the algorithm associated with this secret key.
+   *
+   * @return The algorithm's name.
+   */
+  public String getAlgorithm()
+  {
+    return algorithm;
+  }
+
+  /**
+   * Return the key as a byte array.
+   *
+   * @return The key material.
+   */
+  public byte[] getEncoded()
+  {
+    return key;
+  }
+
+  /**
+   * This key's format, which is always "RAW".
+   *
+   * @return "RAW"
+   */
+  public String getFormat()
+  {
+    return "RAW";
+  }
+
+  public boolean equals(Object o)
+  {
+    if (o instanceof SecretKeySpec)
+      {
+        byte[] okey = ((SecretKeySpec) o).getEncoded();
+        if (key.length != okey.length)
+          return false;
+        for (int i = 0; i < key.length; i++)
+          {
+            if (key[i] != okey[i])
+              return false;
+          }
+        return algorithm.equals(((SecretKeySpec) o).getAlgorithm());
+      }
+    else
+      {
+        return false;
+      }
+  }
+
+  public int hashCode()
+  {
+    int code = 0;
+    for (int i = 0; i < key.length; i++)
+      {
+        code ^= (key[i] & 0xff) << (i << 3 & 31);
+      }
+    return code ^ algorithm.hashCode();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/spec/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.crypto.spec package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.crypto.spec</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* IIOException.java --
+   Copyright (C) 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 javax.imageio;
+
+import java.io.IOException;
+
+/**
+ * A runtime exception to indicate image reading and writing failures.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class IIOException extends IOException
+{
+  /**
+   * Create an exception with a descriptive error message.
+   *
+   * @param message The descriptive error message.
+   */
+  public IIOException(String message)
+  {
+    super(message);
+  }
+
+  /**
+   * Create an exception with a descriptive error message.
+   *
+   * @param message The descriptive error message.
+   * @param cause The cause for this exception.
+   */
+  public IIOException(String message, Throwable cause)
+  {
+    super(message);
+    initCause(cause);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOImage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOImage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOImage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOImage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,267 @@
+/* IIOImage.java --
+   Copyright (C) 2003 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 javax.imageio;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.util.List;
+
+import javax.imageio.metadata.IIOMetadata;
+
+/**
+ * IIOImage is a container class for components of an image file that
+ * stores image data, image metadata and thumbnails.
+ *
+ * The image data can be either a RenderedImage or a Raster but not
+ * both.  Image readers that produce IIOImages will always produce
+ * BufferedImages from the RenderedImage field.  Image writers that
+ * accept IIOImages will always accept RenderedImages and may
+ * optionally accept Rasters.
+ *
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ */
+public class IIOImage
+{
+  /**
+   * Image data as a RenderedImage.  null if this IIOImage uses the
+   * Raster representation.
+   */
+  protected RenderedImage image;
+
+  /**
+   * Image metadata.
+   */
+  protected IIOMetadata metadata;
+
+  /**
+   * Image data as a Raster.  null if this IIOImage uses the
+   * RenderedImage representation.
+   */
+  protected Raster raster;
+
+  /**
+   * A list of BufferedImage thumbnails of this image.
+   */
+  // for 1.5 these lists are List<? extends BufferedImage>
+  protected List thumbnails;
+
+  /**
+   * Construct an IIOImage containing raster image data, thumbnails
+   * and metadata.
+   *
+   * @param raster image data
+   * @param thumbnails a list of BufferedImage thumbnails or null
+   * @param metadata image metadata or null
+   *
+   * @exception IllegalArgumentException if raster is null
+   */
+  public IIOImage (Raster raster, List thumbnails, IIOMetadata metadata)
+  {
+    if (raster == null)
+      throw new IllegalArgumentException ("raster may not be null");
+    
+    this.raster = raster;
+    this.thumbnails = thumbnails;
+    this.metadata = metadata;
+  }
+  
+  /**
+   * Construct an IIOImage containing rendered image data, thumbnails
+   * and metadata.
+   *
+   * @param image rendered image data
+   * @param thumbnails a list of BufferedImage thumbnails or null
+   * @param metadata image metadata or null
+   *
+   * @exception IllegalArgumentException if image is null
+   */
+  public IIOImage (RenderedImage image, List thumbnails, IIOMetadata metadata)
+  {
+    if (image == null)
+      throw new IllegalArgumentException ("image may not be null");
+    
+    this.image = image;
+    this.thumbnails = thumbnails;
+    this.metadata = metadata;
+  }
+
+  /**
+   * Retrieve the image metadata or null if there is no metadata
+   * associated with this IIOImage.
+   *
+   * @return image metadata or null
+   */
+  public IIOMetadata getMetadata()
+  {
+    return metadata;
+  }
+
+  /**
+   * Retrieve the number of thumbnails in this IIOImage.
+   *
+   * @return the number of thumbnails
+   */
+  public int getNumThumbnails()
+  {
+    return thumbnails == null ? 0 : thumbnails.size();
+  }
+
+  /**
+   * Retrieve the raster image data stored in this IIOImage or null if
+   * this image stores data using the RenderedImage representation.
+   *
+   * @return the raster image data or null
+   */
+  public Raster getRaster()
+  {
+    return raster;
+  }
+
+  /**
+   * Retrieve the rendered image data stored in this IIOImage or null
+   * if this image stores data using the Raster representation.
+   *
+   * @return the rendered image data or null
+   */
+  public RenderedImage getRenderedImage()
+  {
+    return image;
+  }
+
+  /**
+   * Retrieve the thumbnail stored at the specified index in the
+   * thumbnails list.
+   *
+   * @param index the index of the thumbnail to retrieve
+   *
+   * @return the buffered image thumbnail
+   *
+   * @exception IndexOutOfBoundsException if index is out-of-bounds
+   * @exception ClassCastException if the object returned from the
+   * thumbnails list is not a BufferedImage
+   */
+  public BufferedImage getThumbnail (int index)
+  {
+    // This throws a ClassCastException if the returned object is not
+    // a BufferedImage or an IndexOutOfBoundsException if index is
+    // out-of-bounds.
+    return (BufferedImage) thumbnails.get (index);
+  }
+
+  /**
+   * Retrieve the list of thumbnails or null if there are no
+   * thumbnails associated with this IIOImage.  The returned reference
+   * can be used to update the thumbnails list.
+   *
+   * @return a list of thumbnails or null
+   */
+  public List getThumbnails()
+  {
+    return thumbnails;
+  }
+
+  /**
+   * Check whether this IIOImage stores its image data as a Raster or
+   * as a RenderedImage.
+   *
+   * @return true if this IIOImage uses the Raster representation,
+   * false if it uses the RenderedImage representation.
+   */
+  public boolean hasRaster()
+  {
+    return raster != null;
+  }
+
+  /**
+   * Set this IIOImage's metadata.
+   *
+   * @param metadata the image metadata
+   */
+  public void setMetadata (IIOMetadata metadata)
+  {
+    this.metadata = metadata;
+  }
+
+  /**
+   * Set the raster data for this image.  This disposes of any
+   * existing rendered image data stored in this IIOImage.
+   *
+   * @param raster the image raster data
+   *
+   * @exception IllegalArgumentException if raster is null
+   */
+  public void setRaster (Raster raster)
+  {
+    if (raster == null)
+      throw new IllegalArgumentException ("raster may not be null");
+    
+    this.image = null;
+    this.raster = raster;
+  }
+
+  /**
+   * Set the rendered image data for this image.  This disposes of any
+   * existing raster data stored in this IIOImage.
+   *
+   * @param image the rendered image data
+   *
+   * @exception IllegalArgumentException if image is null
+   */
+  public void setRenderedImage (RenderedImage image)
+  {
+    if (image == null)
+      throw new IllegalArgumentException ("image may not be null");
+
+    this.image = image;
+    this.raster = null;
+  }
+
+  /**
+   * Set the list of thumbnails for this IIOImage to a new list of
+   * BufferedImages or to null.  Any existing thumbnails list is
+   * disposed.
+   *
+   * @param thumbnails a new list of thumbnails or null
+   */
+  public void setThumbnails (List thumbnails)
+  {
+    this.thumbnails = thumbnails;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParam.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParam.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParam.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParam.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,491 @@
+/* IIOParam.java --
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+
+/**
+ * An IIOParam stores parameters used when encoding or decoding image
+ * streams.  ImageReadParam and ImageWriteParam extend this abstract
+ * base class.
+ *
+ * IIOParams allow control over how source pixels converted into
+ * destination pixels.  This conversion can take place between a
+ * stream and in-memory image data, when an image reader is doing the
+ * conversion, or a writer can be doing the conversion from an
+ * in-memory source to a stream destination.
+ *
+ * An image reader can be restricted to only read from a given region;
+ * likewise a writer can be restricted to only write output to a given
+ * region.
+ *
+ * For image readers and writers, IIOParam supports image pixelation
+ * -- where the input image is approximated by the output image using
+ * larger-sized pixel blocks.  For example: FIXME
+ *
+ * IIOParams can control how pixels are combined into larger blocks
+ * using sub-sampling matrices.  For example: FIXME
+ *
+ * They can also control which source bands are read and written; this
+ * example reads the RGBA (red, green, blue, transparency) data from a
+ * PNG image and outputs just the red and transparency bands: FIXME
+ *
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public abstract class IIOParam
+{
+  /**
+   * The controller called by this IIOParam to retrieve parameters.
+   */
+  protected IIOParamController controller = null;
+
+  /**
+   * The default controller called by this IIOParam to retrieve
+   * parameters.
+   */
+  protected IIOParamController defaultController = null;
+
+  /**
+   * The offset in the destination where the upper-left
+   * decoded/encoded pixel should be located.
+   */
+  protected Point destinationOffset = new Point(0, 0);
+
+  /**
+   * Sets the output colour type when writing or the destination image
+   * type when reading.
+   */
+  protected ImageTypeSpecifier destinationType = null;
+
+  /**
+   * An array indicating which source bands will be used or null.
+   */
+  protected int[] sourceBands = null;
+
+  /**
+   * The source pixel region or null.
+   */
+  protected Rectangle sourceRegion = null;
+
+  /**
+   * Sample every sourceXSubsampling'th pixel in the source image when
+   * pixelating the destination image in the horizontal direction.
+   */
+  protected int sourceXSubsampling = 1;
+
+  /**
+   * Sample every sourceYSubsampling'th pixel in the source image when
+   * pixelating the destination image in the vertical direction.
+   */
+  protected int sourceYSubsampling = 1;
+
+  /**
+   * Start sampling at this horizontal offset within the source region
+   * when pixelating the destination image in the horizontal
+   * direction.
+   */
+  protected int subsamplingXOffset = 0;
+
+  /**
+   * Start sampling at this vertical offset within the source region
+   * when pixelating the destination image in the vertical direction.
+   */
+  protected int subsamplingYOffset = 0;
+
+  /**
+   * Indicates whether or not the controller has been explicitly set
+   * to null.
+   */
+  private boolean no_controller = false;
+
+  /**
+   * Constructs an IIOParam object.
+   */
+  protected IIOParam()
+  {
+  }
+
+  /**
+   * Activates the parameter controller by calling its activate method
+   * and passing it this IIOParam.  A true return value indicates that
+   * this IIOParam's values are ready for the next read or write
+   * operation.  A return value of false means that this IIOParam's
+   * values have not been affected because the controller operations
+   * were cancelled.
+   *
+   * @return true if parameters were successfully set, false if
+   * parameters were not changed
+   */
+  public boolean activateController()
+  {
+    if (controller == null)
+      {
+	if (defaultController == null || no_controller)
+	  return false;
+	else
+	  return defaultController.activate (this);
+      }
+    else
+      return controller.activate(this);
+  }
+
+  /**
+   * Retrieve the currently set controller if one has been set, or the
+   * default controller, or null if the controller has been explicitly
+   * set to null.
+   *
+   * @return the currently used controller or null
+   */  
+  public IIOParamController getController()
+  {
+    return controller == null ?
+      (no_controller ? null : defaultController) : controller;
+  }
+
+  /**
+   * Retrieve the default controller regardless of whether or not a
+   * non-default controller has been set.  The default controller may
+   * be null.
+   *
+   * @return the default controller or null
+   */
+  public IIOParamController getDefaultController()
+  {
+    return defaultController;
+  }
+
+  /**
+   * Retrieve the offset in the destination where the upper-left
+   * decoded/encoded pixel should be located. (0, 0) by default.
+   *
+   * @return the destination offset
+   */
+  public Point getDestinationOffset()
+  {
+    return destinationOffset;
+  }
+
+  /**
+   * Retrieve the currently set image-type specifier or null if none
+   * has been set.
+   *
+   * @return the current image-type specifier or null
+   */
+  public ImageTypeSpecifier getDestinationType()
+  {
+    return destinationType;
+  }
+
+  /**
+   * Retrieve the current source band values or null if source band
+   * values have not been set.
+   *
+   * The returned array is a copy of this IIOParam's source band
+   * array.
+   *
+   * @return the current set of source band values or null
+   */
+  public int[] getSourceBands()
+  {
+    if (sourceBands == null)
+      return null;
+
+    int[] sourceBandsCopy = new int[sourceBands.length];
+    System.arraycopy (sourceBands, 0, sourceBandsCopy, 0, sourceBands.length);
+    return sourceBandsCopy;
+  }
+
+  /**
+   * Retrieve the source rectangle from which pixels should be read or
+   * null if no source region has been set.
+   *
+   * @return the current source region or null
+   */
+  public Rectangle getSourceRegion()
+  {
+    return sourceRegion;
+  }
+
+  /**
+   * Retrieve the number of pixel columns to advance before taking a
+   * pixel sample.
+   *
+   * @return the horizontal sub-sampling interval
+   */
+  public int getSourceXSubsampling()
+  {
+    return sourceXSubsampling;
+  }
+  
+  /**
+   * Retrieve the number of pixel rows to advance before taking a
+   * pixel sample.
+   *
+   * @return the vertical sub-sampling interval
+   */
+  public int getSourceYSubsampling()
+  {
+    return sourceYSubsampling;
+  }
+
+  /**
+   * Retrieve the number of pixel columns to advance before taking any
+   * pixel samples.
+   *
+   * @return the horizontal sub-sampling offset
+   */
+  public int getSubsamplingXOffset()
+  {
+    return subsamplingXOffset;
+  }
+
+  /**
+   * Retrieve the number of pixel rows to advance before taking any
+   * pixel samples.
+   *
+   * @return the vertical sub-sampling offset
+   */
+  public int getSubsamplingYOffset()
+  {
+    return subsamplingYOffset;
+  }
+
+  /**
+   * Check if a non-null controller is currently available.
+   *
+   * @return true if getController returns a non-null value, false if
+   * getController returns null
+   */
+  public boolean hasController()
+  {
+    return getController() != null;
+  }
+
+  /**
+   * Sets the controller for this IIOParam.  This is the controller
+   * that will be activated when activateController is called.  The
+   * argument controller overrides this IIOParam's default controller.
+   * If the argument is null then no controller will be set, not even
+   * the default one.  To reset the default controller call
+   * setController(getDefaultController()).
+   *
+   * @param controller the controller to set or null
+   */
+  public void setController(IIOParamController controller)
+  {
+    if (controller == defaultController)
+      {
+	this.controller = null;
+	no_controller = false;
+      }
+    else
+      {
+	no_controller = (controller == null);
+	this.controller = controller;
+      }
+  }
+
+  /**
+   * Set the destination image type.
+   *
+   * If this value is set on an image reader then its read method will
+   * return a new BufferedImage of the specified destination type.  In
+   * this case any destination image set using setDestination() is
+   * ignored.
+   *
+   * If this is set on an image writer then the destination type
+   * affects only the colour model of the destination image.  The
+   * destination type's SampleModel is ignored.  The destination
+   * type's ColorModel will override the source image's colour model.
+   *
+   * @param destinationType the sample and colour models of the
+   * destination image
+   */
+  public void setDestinationType (ImageTypeSpecifier destinationType)
+  {
+    this.destinationType = destinationType;
+  }
+
+  /**
+   * Specify the destination pixel offset.  Image writers are only
+   * affected by this setting when ImageWriter.replacePixels is called
+   * in which case the offset is into the region of pixels being
+   * changed.
+   *
+   * @param destinationOffset the offset where pixel writing should
+   * begin
+   */
+  public void setDestinationOffset(Point destinationOffset)
+  {
+    if (destinationOffset == null)
+      throw new IllegalArgumentException("destinationOffset is null");
+
+    this.destinationOffset = destinationOffset;
+  }
+
+  /**
+   * Set the indices of the source bands to be used.  Duplicate
+   * indices are not allowed.  A value of null means use all source
+   * bands.  The argument array is copied and stored, so subsequent
+   * updates to it will not be reflected in this IIOParam.
+   *
+   * @param sourceBands the array of source bands to use
+   */
+  public void setSourceBands(int[] sourceBands)
+  {
+    int[] sourceBandsCopy = new int[sourceBands.length];
+    System.arraycopy (sourceBands, 0, sourceBandsCopy, 0, sourceBands.length);
+    this.sourceBands = sourceBandsCopy;
+  }
+
+  /**
+   * Set the source region from which to read.  The number of pixels
+   * sampled from the source region depends on the source sub-sampling
+   * settings.  If the combination of this sourceRegion and the
+   * current sub-sampling settings would result in no pixels being
+   * sampled then an IllegalStateException will be thrown.
+   *
+   * The source region is specified in the source image coordinate
+   * system which has point (0, 0) at the top-left and increases down
+   * and to the right.  The argument source region is clipped to the
+   * image boundaries at read-time.
+   *
+   * A null argument sets the source region to null meaning that the
+   * whole image should be read.
+   *
+   * @param sourceRegion the rectangular source region
+   *
+   * @exception IllegalArgumentException if sourceRegion has width or
+   * height <= 0 or x or y < 0
+   * @exception IllegalStateException if the given sourceRegion and
+   * the current sampling settings would produce zero samples
+   */
+  public void setSourceRegion(Rectangle sourceRegion)
+  {
+    if (sourceRegion != null
+	&& (sourceRegion.x < 0
+	    || sourceRegion.y < 0
+	    || sourceRegion.width <= 0
+	    || sourceRegion.height <= 0))
+      throw new IllegalArgumentException("illegal source region");
+
+    if (sourceRegion != null)
+      {
+	int num_rows =
+	  (sourceRegion.height - subsamplingYOffset + sourceYSubsampling - 1)
+	  / sourceYSubsampling;
+
+	int num_columns =
+	  (sourceRegion.width - subsamplingXOffset + sourceXSubsampling - 1)
+	  / sourceXSubsampling;
+
+	if (num_rows <= 0 || num_columns <= 0)
+	  throw new IllegalStateException("zero pixels in source region");
+      }
+
+    this.sourceRegion = sourceRegion;
+  }
+
+  /**
+   * Set the source sampling intervals and offsets.  Every
+   * sourceXSubsampling'th pixel horizontally and
+   * sourceYSubsampling'th pixel vertically will be sampled.  Sampling
+   * will being a the subsamplingXOffset'th column and the
+   * subsamplingYOffset'th row.
+   *
+   * Horizontally, the number of sampled pixels will be:
+   *
+   * floor((width - subsamplingXOffset + sourceXSubsampling - 1) / sourceXSubsampling)
+   *
+   * Vertically:
+   *
+   * floor((height - subsamplingYOffset + sourceYSubsampling - 1) / sourceYSubsampling)
+   *
+   * If the current source region setting is such that the given
+   * sub-sampling arguments would produce zero pixel samples, an
+   * IllegalStateException is thrown.
+   *
+   * The offset parameters can be used to make source regions overlap
+   * when tiling across an image.  This can eliminate seams and
+   * better-tile images whose width or height is not a multiple of the
+   * sampling interval.
+   *
+   * @param sourceXSubsampling the horizontal sampling interval
+   * @param sourceYSubsampling the vertical sampling interval
+   * @param subsamplingXOffset the horizontal offset of the initial
+   * sample
+   * @param subsamplingYOffset the vertical offset of the initial
+   * sample
+   *
+   * @exception IllegalArgumentException if either subsamplingXOffset
+   * or subsamplingYOffset is < 0
+   * @exception IllegalStateException if the current source region
+   * combined with the given sub-sampling parameters would produce
+   * zero pixel samples
+   */
+  public void setSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling,
+				   int subsamplingXOffset, int subsamplingYOffset)
+  {
+    if (subsamplingXOffset < 0 || subsamplingYOffset < 0)
+      throw new IllegalArgumentException("subsampling offset < 0");
+
+    if (sourceRegion != null)
+      {
+	int num_rows =
+	  (sourceRegion.height - subsamplingYOffset + sourceYSubsampling - 1)
+	  / sourceYSubsampling;
+
+	int num_columns =
+	  (sourceRegion.width - subsamplingXOffset + sourceXSubsampling - 1)
+	  / sourceXSubsampling;
+
+	if (num_rows <= 0 || num_columns <= 0)
+	  throw new IllegalStateException("subsampling parameters would"
+					  + " produce zero pixel samples"
+					  + " in source region");
+      }
+
+    this.sourceXSubsampling = sourceXSubsampling;
+    this.sourceYSubsampling = sourceYSubsampling;
+    this.subsamplingXOffset = subsamplingXOffset;
+    this.subsamplingYOffset = subsamplingYOffset;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParamController.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParamController.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParamController.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/IIOParamController.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* IIOParamController.java --
+   Copyright (C) 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 javax.imageio;
+
+/**
+ * An interface to set image parameters.  An IIOParamController may be
+ * a GUI component, a database reader, command-line parser or any
+ * other means of getting parameter settings.  For exampe, a dialog
+ * box could implement IIOParamController to allow a user to adjust
+ * JPEG compression levels.
+ *
+ * The activate method should always behave modally; it should only
+ * return when the action has been either cancelled or completed.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public interface IIOParamController
+{
+  /**
+   * Activates the controller.  A return value of false should mean
+   * that no changes were made to param.  A return value of true
+   * should mean that the image is ready to be read or written.
+   *
+   * @param param the <code>IIOParam</code> to be modified
+   *
+   * @return true if the <code>IIOParam</code> has been modified,
+   * false otherwise
+   * 
+   * @exception IllegalArgumentException if param is null or is not an instance
+   * of the correct class
+   */
+  boolean activate(IIOParam param);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageIO.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageIO.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageIO.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageIO.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1198 @@
+/* ImageIO.java --
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageInputStreamSpi;
+import javax.imageio.spi.ImageOutputStreamSpi;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ImageTranscoderSpi;
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.spi.ServiceRegistry;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
+
+/**
+ * An uninstantiable class that provides static methods for locating
+ * and using image readers and writers.
+ */
+public final class ImageIO
+{
+  /**
+   * Construct an ImageIO.  Private since ImageIO is not instantiable.
+   */
+  private ImageIO()
+  {
+  }
+
+  private static final class ReaderFormatFilter implements ServiceRegistry.Filter
+  {
+    private String formatName;
+
+    public ReaderFormatFilter(String formatName)
+    {
+      this.formatName = formatName;
+    }
+
+    public boolean filter (Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageReaderSpi spi = (ImageReaderSpi) provider;
+          String[] formatNames = spi.getFormatNames();
+
+          for (int i = formatNames.length - 1; i >= 0; --i)
+            if (formatName.equals(formatNames[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+
+  private static final class ReaderMIMETypeFilter implements ServiceRegistry.Filter
+  {
+    private String MIMEType;
+
+    public ReaderMIMETypeFilter(String MIMEType)
+    {
+      this.MIMEType = MIMEType;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageReaderSpi spi = (ImageReaderSpi) provider;
+          String[] mimetypes = spi.getMIMETypes();
+
+          for (int i = mimetypes.length - 1; i >= 0; --i)
+            if (MIMEType.equals(mimetypes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+  
+  private static final class ReaderObjectFilter implements ServiceRegistry.Filter
+  {
+    private Object object;
+
+    public ReaderObjectFilter(Object object)
+    {
+      this.object = object;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageReaderSpi spi = (ImageReaderSpi) provider;
+
+          try
+            {
+              if (spi.canDecodeInput(object))
+                return true;
+            }
+          catch (IOException e)
+            {
+              // Return false in this case
+            }
+        }
+      return false;
+    }
+  }
+
+  private static final class ReaderSuffixFilter implements ServiceRegistry.Filter
+  {
+    private String fileSuffix;
+
+    public ReaderSuffixFilter(String fileSuffix)
+    {
+      this.fileSuffix = fileSuffix;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageReaderSpi)
+        {
+          ImageReaderSpi spi = (ImageReaderSpi) provider;
+          String[] suffixes = spi.getFileSuffixes();
+
+          for (int i = suffixes.length - 1; i >= 0; --i)
+            if (fileSuffix.equals(suffixes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+  
+  private static final class WriterFormatFilter implements ServiceRegistry.Filter
+  {
+    private String formatName;
+
+    public WriterFormatFilter(String formatName)
+    {
+      this.formatName = formatName;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageWriterSpi)
+	{
+	  ImageWriterSpi spi = (ImageWriterSpi) provider;
+	  String[] formatNames = spi.getFormatNames();
+	  
+	  for (int i = formatNames.length - 1; i >= 0; --i)
+            if (formatName.equals(formatNames[i]))
+              return true;
+	}
+
+      return false;
+    }
+  }
+
+  private static final class WriterMIMETypeFilter implements ServiceRegistry.Filter
+  {
+    private String MIMEType;
+
+    public WriterMIMETypeFilter(String MIMEType)
+    {
+      this.MIMEType = MIMEType;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageWriterSpi)
+        {
+          ImageWriterSpi spi = (ImageWriterSpi) provider;
+          String[] mimetypes = spi.getMIMETypes();
+
+          for (int i = mimetypes.length - 1; i >= 0; --i)
+            if (MIMEType.equals(mimetypes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+  
+  private static final class WriterSuffixFilter implements ServiceRegistry.Filter
+  {
+    private String fileSuffix;
+
+    public WriterSuffixFilter(String fileSuffix)
+    {
+      this.fileSuffix = fileSuffix;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageWriterSpi)
+        {
+          ImageWriterSpi spi = (ImageWriterSpi) provider;
+          String[] suffixes = spi.getFileSuffixes();
+
+          for (int i = suffixes.length - 1; i >= 0; --i)
+            if (fileSuffix.equals(suffixes[i]))
+              return true;
+        }
+
+      return false;
+    }
+  }
+
+  private static final class WriterObjectFilter implements ServiceRegistry.Filter
+  {
+    private ImageTypeSpecifier type;
+    private String formatName;
+
+    public WriterObjectFilter(ImageTypeSpecifier type,
+			      String formatName)
+    {
+      this.type = type;
+      this.formatName = formatName;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageWriterSpi)
+        {
+          ImageWriterSpi spi = (ImageWriterSpi) provider;
+
+	  if (spi.canEncodeImage(type))
+	    {
+	      String[] formatNames = spi.getFormatNames();
+	      for (int i = formatNames.length - 1; i >= 0; --i)
+		if (formatName.equals(formatNames[i]))
+		  return true;
+	    }
+        }
+
+      return false;
+    }
+  }
+
+  private static final class TranscoderFilter implements ServiceRegistry.Filter
+  {
+    private ImageReader reader;
+    private ImageWriter writer;
+
+    public TranscoderFilter(ImageReader reader,
+                            ImageWriter writer)
+    {
+      this.reader = reader;
+      this.writer = writer;
+    }
+
+    public boolean filter(Object provider)
+    {
+      if (provider instanceof ImageTranscoderSpi)
+        {
+          ImageTranscoderSpi spi = (ImageTranscoderSpi) provider;
+
+	  if (spi.getReaderServiceProviderName().equals
+	      (reader.getOriginatingProvider().getClass().getName())
+	      && spi.getWriterServiceProviderName().equals
+	      (writer.getOriginatingProvider().getClass().getName()))
+	    return true;
+        }
+
+      return false;
+    }
+  }
+
+  private static final class ImageReaderIterator implements Iterator
+  {
+    Iterator it;
+    Object readerExtension;
+    
+    public ImageReaderIterator(Iterator it, Object readerExtension)
+    {
+      this.it = it;
+      this.readerExtension = readerExtension;
+    }
+
+    public boolean hasNext()
+    {
+      return it.hasNext();
+    }
+
+    public Object next()
+    {
+      try
+        {
+          return ((ImageReaderSpi) it.next()).createReaderInstance(readerExtension);
+        }
+      catch (IOException e)
+        {
+          return null;
+        }
+    }
+
+    public void remove()
+    {
+      throw new UnsupportedOperationException();
+    }
+  }
+
+  private static final class ImageWriterIterator implements Iterator
+  {
+    Iterator it;
+    Object writerExtension;
+    
+    public ImageWriterIterator(Iterator it, Object writerExtension)
+    {
+      this.it = it;
+      this.writerExtension = writerExtension;
+    }
+
+    public boolean hasNext()
+    {
+      return it.hasNext();
+    }
+
+    public Object next()
+    {
+      try
+        {
+          return ((ImageWriterSpi) it.next()).createWriterInstance(writerExtension);
+        }
+      catch (IOException e)
+        {
+          return null;
+        }
+    }
+
+    public void remove()
+    {
+      throw new UnsupportedOperationException();
+    }
+  }
+  
+  private static File cacheDirectory;
+  private static boolean useCache = true;
+
+  private static Iterator getReadersByFilter(Class type,
+                                             ServiceRegistry.Filter filter,
+                                             Object readerExtension)
+  {
+    try
+      {
+        Iterator it = getRegistry().getServiceProviders(type, filter, true);
+        return new ImageReaderIterator(it, readerExtension);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return Collections.EMPTY_SET.iterator();
+      }
+  }
+  
+  private static Iterator getWritersByFilter(Class type,
+					     ServiceRegistry.Filter filter,
+                                             Object writerExtension)
+  {
+    try
+      {
+        Iterator it = getRegistry().getServiceProviders(type, filter, true);
+        return new ImageWriterIterator(it, writerExtension);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return Collections.EMPTY_SET.iterator();
+      }
+  }
+
+  /**
+   * Retrieve the current cache directory.
+   *
+   * @return the current cache directory or null if none is set.
+   */
+  public static File getCacheDirectory()
+  {
+    return cacheDirectory;
+  }
+
+  /**
+   * Retrieve an iterator over all registered readers for the given
+   * format.
+   *
+   * @param formatName an infomal format name (e.g. "jpeg" or "bmp")
+   *
+   * @return an iterator over a collection of image readers
+   *
+   * @exception IllegalArgumentException if formatName is null
+   */
+  public static Iterator getImageReadersByFormatName(String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException("formatName may not be null");
+
+    return getReadersByFilter(ImageReaderSpi.class,
+                              new ReaderFormatFilter(formatName),
+                              formatName);
+  }
+
+  /**
+   * Retrieve an iterator over all registered readers for the given
+   * MIME type.
+   *
+   * @param MIMEType a MIME specification for an image type
+   * (e.g. "image/jpeg" or "image/x-bmp")
+   *
+   * @return an iterator over a collection of image readers
+   *
+   * @exception IllegalArgumentException if MIMEType is null
+   */
+  public static Iterator getImageReadersByMIMEType(String MIMEType)
+  {
+    if (MIMEType == null)
+      throw new IllegalArgumentException("MIMEType may not be null");
+
+    return getReadersByFilter(ImageReaderSpi.class,
+                              new ReaderMIMETypeFilter(MIMEType),
+                              MIMEType);
+  }
+
+  /**
+   * Retrieve an iterator over all registered readers for the given
+   * file suffix.
+   *
+   * @param fileSuffix an image file suffix (e.g. "jpg" or "bmp")
+   *
+   * @return an iterator over a collection of image readers
+   *
+   * @exception IllegalArgumentException if fileSuffix is null
+   */
+  public static Iterator getImageReadersBySuffix(String fileSuffix)
+  {
+    if (fileSuffix == null)
+      throw new IllegalArgumentException("formatName may not be null");
+    
+    return getReadersByFilter(ImageReaderSpi.class,
+                              new ReaderSuffixFilter(fileSuffix),
+                              fileSuffix);
+  }
+
+  /**
+   * Retrieve an iterator over all registered writers for the given
+   * format.
+   *
+   * @param formatName an infomal format name (e.g. "jpeg" or "bmp")
+   *
+   * @return an iterator over a collection of image writers
+   *
+   * @exception IllegalArgumentException if formatName is null
+   */
+  public static Iterator getImageWritersByFormatName(String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException("formatName may not be null");
+    
+    return getWritersByFilter(ImageWriterSpi.class,
+                              new WriterFormatFilter(formatName),
+                              formatName);
+  }
+
+  /**
+   * Retrieve an iterator over all registered writers for the given
+   * MIME type.
+   *
+   * @param MIMEType a MIME specification for an image type
+   * (e.g. "image/jpeg" or "image/x-bmp")
+   *
+   * @return an iterator over a collection of image writers
+   *
+   * @exception IllegalArgumentException if MIMEType is null
+   */
+  public static Iterator getImageWritersByMIMEType(String MIMEType)
+  {
+    if (MIMEType == null)
+      throw new IllegalArgumentException("MIMEType may not be null");
+    
+    return getWritersByFilter(ImageWriterSpi.class,
+                              new WriterMIMETypeFilter(MIMEType),
+                              MIMEType);
+  }
+
+  /**
+   * Retrieve an iterator over all registered writers for the given
+   * file suffix.
+   *
+   * @param fileSuffix an image file suffix (e.g. "jpg" or "bmp")
+   *
+   * @return an iterator over a collection of image writers
+   *
+   * @exception IllegalArgumentException if fileSuffix is null
+   */
+  public static Iterator getImageWritersBySuffix(String fileSuffix)
+  {
+    if (fileSuffix == null)
+      throw new IllegalArgumentException("fileSuffix may not be null");
+    
+    return getWritersByFilter(ImageWriterSpi.class,
+                              new WriterSuffixFilter(fileSuffix),
+                              fileSuffix);
+  }
+
+  /**
+   * Retrieve all the informal format names supported by the
+   * collection of registered image readers.
+   *
+   * @return an array of format names
+   */
+  public static String[] getReaderFormatNames()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageReaderSpi spi = (ImageReaderSpi) it.next();
+	    String[] names = spi.getFormatNames();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+
+  /**
+   * Retrieve all the MIME types supported by the collection of
+   * registered image readers.
+   *
+   * @return an array of MIME types
+   */
+  public static String[] getReaderMIMETypes()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageReaderSpi spi = (ImageReaderSpi) it.next();
+	    String[] names = spi.getMIMETypes();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+
+  private static IIORegistry getRegistry()
+  {
+    return IIORegistry.getDefaultInstance();
+  }
+
+  /**
+   * Check whether or not an on-disk cache is used for image input and
+   * output streams.
+   *
+   * @return true if an on-disk cache is available, false otherwise
+   */
+  public static boolean getUseCache()
+  {
+    return useCache;
+  }
+
+  /**
+   * Retrieve all the informal format names supported by the
+   * collection of registered image writers.
+   *
+   * @return an array of format names
+   */
+  public static String[] getWriterFormatNames()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageWriterSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageWriterSpi spi = (ImageWriterSpi) it.next();
+	    String[] names = spi.getFormatNames();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+
+  /**
+   * Retrieve all the MIME types supported by the collection of
+   * registered image writers.
+   *
+   * @return an array of MIME types
+   */
+  public static String[] getWriterMIMETypes()
+  {
+    try
+      {
+        Iterator it =
+	  getRegistry().getServiceProviders(ImageWriterSpi.class, true);
+	ArrayList result = new ArrayList();
+
+	while (it.hasNext())
+	  {
+	    ImageWriterSpi spi = (ImageWriterSpi) it.next();
+	    String[] names = spi.getMIMETypes();
+
+	    for (int i = names.length - 1; i >= 0; --i)
+	      result.add(names[i]);
+	  }
+
+	return (String[]) result.toArray(new String[result.size()]);
+      }
+    catch (IllegalArgumentException e)
+      {
+        return new String[0];
+      }
+  }
+  
+  /**
+   * Rescans the application classpath for ImageIO service providers
+   * and registers them.
+   */
+  public static void scanForPlugins()
+  {
+    IIORegistry.getDefaultInstance().registerApplicationClasspathSpis();
+  }
+
+  /**
+   * Set the directory to be used for caching image data.  A null
+   * argument means to use the default system temporary directory.
+   * This cache directory is only used if getUseCache returns true.
+   *
+   * @param cacheDirectory the directory where image data should be
+   * cached
+   *
+   * @exception IllegalArgumentException if cacheDirectory is not a
+   * directory
+   */
+  public static void setCacheDirectory(File cacheDirectory)
+  {
+    // FIXME: add SecurityManager call
+    if (cacheDirectory != null)
+      {
+        if (!cacheDirectory.isDirectory())
+          throw new IllegalArgumentException("cacheDirectory must be a directory");
+
+        cacheDirectory.canWrite();
+      }
+    
+    ImageIO.cacheDirectory = cacheDirectory;
+  }
+
+  /**
+   * Control whether or not an on-disk cache is used.  This cache is
+   * used to store input or output data from an image data stream when
+   * data in the stream needs to be re-processed.
+   *
+   * If useCache is false the cache will be stored in memory.  Doing
+   * so eliminates file creation and deletion overhead.  The default
+   * is to use an on-disk cache.
+   *
+   * @param useCache true to use an on-disk cache, false otherwise
+   */
+  public static void setUseCache(boolean useCache)
+  {
+    ImageIO.useCache = useCache;
+  }
+
+  /**
+   * Write an image to a file using a registered writer that supports
+   * the given format, overwriting the file if it already exists.
+   *
+   * @param im the image data to write
+   * @param formatName an informal description of the output format
+   * @param output the file to which the image will be written
+   *
+   * @return false if no registered writer supports the given format,
+   * true otherwise
+   *
+   * @exception IllegalArgumentException if any argument is null
+   * @exception IOException if a writing error occurs
+   */
+  public static boolean write(RenderedImage im,
+                              String formatName,
+                              File output)
+    throws IOException
+  {
+    if (im == null || formatName == null || output == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return write(im, formatName, new FileOutputStream(output));
+  }
+
+  /**
+   * Write an image to an output stream using a registered writer that
+   * supports the given format.
+   *
+   * @param im the image data to write
+   * @param formatName an informal description of the output format
+   * @param output the output stream to which the image will be
+   * written
+   *
+   * @return false if no registered writer supports the given format,
+   * true otherwise
+   *
+   * @exception IllegalArgumentException if any argument is null
+   * @exception IOException if a writing error occurs
+   */
+  public static boolean write(RenderedImage im,
+                              String formatName,
+                              OutputStream output)
+    throws IOException
+  {
+    if (im == null || formatName == null || output == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return write(im, formatName, new MemoryCacheImageOutputStream(output));
+  }
+
+  /**
+   * Write an image to an ImageOutputStream using a registered writer
+   * that supports the given format.  Image data is written starting
+   * at the ImageOutputStream's current stream pointer, overwriting
+   * any existing data.
+   *
+   * @param im the image data to write
+   * @param formatName an informal description of the output format
+   * @param output the image output stream to which the image will be
+   * written
+   *
+   * @return false if no registered writer supports the given format,
+   * true otherwise
+   *
+   * @exception IllegalArgumentException if any argument is null
+   * @exception IOException if a writing error occurs
+   */
+  public static boolean write(RenderedImage im,
+                              String formatName,
+                              ImageOutputStream output)
+    throws IOException
+  {
+    if (im == null || formatName == null || output == null)
+      throw new IllegalArgumentException ("null argument");
+
+    Iterator writers = getImageWritersByFormatName(formatName);
+    IIOImage img = new IIOImage(im, null, null);
+    while (writers.hasNext())
+      {
+        ImageWriter w = (ImageWriter) writers.next();
+        try 
+          {
+            w.setOutput(output);
+          }
+        catch (IllegalArgumentException e)
+          {
+            continue;
+          }
+        
+        w.write(null, img, null);
+        output.close();
+        return true;
+      }
+    return false;
+  }
+
+  /**
+   * Create a buffered image from an image input stream.  An image
+   * reader that supports the given image data is automatically
+   * selected from the collection of registered readers.  If no
+   * registered reader can handle the input format, null is returned.
+   *
+   * @param stream the image input stream from which to read image
+   * data
+   *
+   * @return a new buffered image created from the given image data,
+   * or null
+   *
+   * @exception IllegalArgumentException if stream is null
+   * @exception IOException if a reading error occurs
+   */
+  public static BufferedImage read(ImageInputStream stream)
+    throws IOException
+  {
+    if (stream == null)
+      throw new IllegalArgumentException("null argument");
+
+    Iterator providers = getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+    while (providers.hasNext())
+      {
+        ImageReaderSpi spi = (ImageReaderSpi) providers.next();
+        if (spi.canDecodeInput(stream))
+          {
+            ImageReader reader = spi.createReaderInstance();
+            reader.setInput(stream);
+            return reader.read(0, null);
+          }
+      }
+    return null;
+  }
+
+  /**
+   * Create a buffered image from a URL.  An image reader that
+   * supports the given image data is automatically selected from the
+   * collection of registered readers.  If no registered reader can
+   * handle the input format, null is returned.
+   *
+   * The image data will be cached in the current cache directory if
+   * caching is enabled.
+   *
+   * This method does not locate readers that read data directly from
+   * a URL.  To locate such readers manually, use IIORegistry and
+   * ImageReaderSpi.
+   *
+   * @param input the URL from which to retrieve the image file
+   *
+   * @return a new buffered image created from the given image URL, or
+   * null
+   *
+   * @exception IllegalArgumentException if input is null
+   * @exception IOException if a reading error occurs
+   */
+  public static BufferedImage read(URL input)
+    throws IOException
+  {
+    if (input == null)
+      throw new IllegalArgumentException("null argument");
+
+    return read(input.openStream());
+  }
+
+  /**
+   * Create a buffered image from an input stream.  An image reader
+   * that supports the given image data is automatically selected from
+   * the collection of registered readers.  If no registered reader
+   * can handle the input format, null is returned.
+   *
+   * The image data will be cached in the current cache directory if
+   * caching is enabled.
+   *
+   * This method does not locate readers that read data directly from
+   * an input stream.  To locate such readers manually, use
+   * IIORegistry and ImageReaderSpi.
+   *
+   * @param input the input stream from which to read the image data
+   *
+   * @return a new buffered image created from the given input stream,
+   * or null
+   *
+   * @exception IllegalArgumentException if input is null
+   * @exception IOException if a reading error occurs
+   */
+  public static BufferedImage read(InputStream input)
+    throws IOException
+  {
+    if (input == null)
+      throw new IllegalArgumentException("null argument");
+
+    return read(new MemoryCacheImageInputStream(input));
+  }
+
+  /**
+   * Create a buffered image from a file.  An image reader that
+   * supports the given image data is automatically selected from the
+   * collection of registered readers.  If no registered reader can
+   * handle the input format, null is returned.
+   *
+   * The image data will be cached in the current cache directory if
+   * caching is enabled.
+   *
+   * This method does not locate readers that read data directly from
+   * a file.  To locate such readers manually, use IIORegistry and
+   * ImageReaderSpi.
+   *
+   * @param input the file from which to read image data
+   *
+   * @return a new buffered image created from the given image file,
+   * or null
+   *
+   * @exception IllegalArgumentException if input is null
+   * @exception IOException if a reading error occurs
+   */
+  public static BufferedImage read(File input)
+    throws IOException
+  {
+    if (input == null)
+      throw new IllegalArgumentException("null argument");
+
+    return read(new FileInputStream(input));
+  }
+
+  /**
+   * Create an image input stream from the given object.  The
+   * collection of ImageInputStreamSpis registered with the
+   * IIORegistry is searched for an image input stream that can take
+   * input from the given object.  null is returned if no such SPI is
+   * registered.
+   *
+   * The image data will be cached in the current cache directory if
+   * caching is enabled.
+   *
+   * @param input an object from which to read image data
+   *
+   * @return an ImageInputStream that can read data from input, or
+   * null
+   *
+   * @exception IllegalArgumentException if input is null
+   * @exception IOException if caching is required but not enabled
+   */
+  public static ImageInputStream createImageInputStream (Object input)
+    throws IOException
+  {
+    if (input == null)
+      throw new IllegalArgumentException ("null argument");
+
+    Iterator spis = getRegistry().getServiceProviders
+      (ImageInputStreamSpi.class, true);
+
+    ImageInputStreamSpi foundSpi = null;
+
+    while(spis.hasNext())
+      {
+	ImageInputStreamSpi spi = (ImageInputStreamSpi) spis.next();
+
+	if (input.getClass().equals(spi.getInputClass()))
+	  {
+	    foundSpi = spi;
+	    break;
+	  }
+      }
+
+    return foundSpi == null ? null :
+      foundSpi.createInputStreamInstance (input,
+                                          getUseCache(),
+                                          getCacheDirectory());
+  }
+
+  /**
+   * Create an image output stream from the given object.  The
+   * collection of ImageOutputStreamSpis registered with the
+   * IIORegistry is searched for an image output stream that can send
+   * output to the given object.  null is returned if no such SPI is
+   * registered.
+   *
+   * The image data will be cached in the current cache directory if
+   * caching is enabled.
+   *
+   * @param output an object to which to write image data
+   *
+   * @return an ImageOutputStream that can send data to output, or
+   * null
+   *
+   * @exception IllegalArgumentException if output is null
+   * @exception IOException if caching is required but not enabled
+   */
+  public static ImageOutputStream createImageOutputStream (Object output)
+    throws IOException
+  {
+    if (output == null)
+      throw new IllegalArgumentException ("null argument");
+
+    Iterator spis = getRegistry().getServiceProviders
+      (ImageOutputStreamSpi.class, true);
+
+    ImageOutputStreamSpi foundSpi = null;
+
+    while(spis.hasNext())
+      {
+	ImageOutputStreamSpi spi = (ImageOutputStreamSpi) spis.next();
+
+	if (output.getClass().equals(spi.getOutputClass()))
+	  {
+	    foundSpi = spi;
+	    break;
+	  }
+      }
+
+    return foundSpi == null ? null :
+      foundSpi.createOutputStreamInstance (output,
+                                           getUseCache(),
+                                           getCacheDirectory());
+  }
+
+  /**
+   * Retrieve an image reader corresponding to an image writer, or
+   * null if writer is not registered or if no corresponding reader is
+   * registered.
+   *
+   * @param writer a registered image writer
+   *
+   * @return an image reader corresponding to writer, or null
+   *
+   * @exception IllegalArgumentException if writer is null
+   */
+  public static ImageReader getImageReader (ImageWriter writer)
+  {
+    if (writer == null)
+      throw new IllegalArgumentException ("null argument");
+
+    ImageWriterSpi spi = (ImageWriterSpi) getRegistry()
+      .getServiceProviderByClass(writer.getClass());
+
+    String[] readerSpiNames = spi.getImageReaderSpiNames();
+
+    ImageReader r = null;
+
+    if (readerSpiNames != null)
+      {
+        try
+          {
+            Class readerClass = Class.forName (readerSpiNames[0]);
+            r = (ImageReader) readerClass.newInstance ();
+          }
+        catch (Exception e)
+          {
+            return null;
+          }
+      }
+    return r;
+  }
+
+  /**
+   * Retrieve an iterator over the collection of registered image
+   * readers that support reading data from the given object.
+   *
+   * @param input the object for which to retrieve image readers
+   *
+   * @return an iterator over a collection of image readers
+   */
+  public static Iterator getImageReaders (Object input)
+  {
+    if (input == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return getRegistry().getServiceProviders (ImageReaderSpi.class,
+					      new ReaderObjectFilter(input),
+					      true);
+  }
+
+  /**
+   * Retrieve an iterator over the collection of registered image
+   * writers that support writing images of the given type and in the
+   * given format.
+   *
+   * @param type the output image's colour and sample models
+   * @param formatName the output image format
+   *
+   * @return an iterator over a collection of image writers
+   */
+  public static Iterator getImageWriters (ImageTypeSpecifier type,
+					  String formatName)
+  {
+    if (type == null || formatName == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return getRegistry().getServiceProviders (ImageWriterSpi.class,
+					      new WriterObjectFilter(type,
+                                                                     formatName),
+					      true);
+  }
+
+  /**
+   * Retrieve an image writer corresponding to an image reader, or
+   * null if reader is not registered or if no corresponding writer is
+   * registered.  This method is useful for preserving metadata
+   * without needing to understand its format, since the returned
+   * writer will be able to write, unchanged, the metadata passed to
+   * it by the reader.
+   *
+   * @param reader a registered image reader
+   *
+   * @return an image writer corresponding to reader, or null
+   *
+   * @exception IllegalArgumentException if reader is null
+   */
+  public static ImageWriter getImageWriter (ImageReader reader)
+  {
+    if (reader == null)
+      throw new IllegalArgumentException ("null argument");
+
+    ImageReaderSpi spi = (ImageReaderSpi) getRegistry()
+      .getServiceProviderByClass(reader.getClass());
+
+    String[] writerSpiNames = spi.getImageWriterSpiNames();
+
+    ImageWriter w = null;
+
+    if (writerSpiNames != null)
+      {
+        try
+          {
+            Class writerClass = Class.forName (writerSpiNames[0]);
+            w = (ImageWriter) writerClass.newInstance ();
+          }
+        catch (Exception e)
+          {
+            return null;
+          }
+      }
+    return w;
+  }
+
+  /**
+   * Retrieve an iterator over a collection of image transcoders that
+   * support transcoding from the given image reader's metadata format
+   * to the given writer's metadata format.
+   *
+   * @param reader an image reader
+   * @param writer an image writer
+   *
+   * @return an iterator over a collection of image transcoders
+   *
+   * @exception IllegalArgumentException if either reader or writer is
+   * null
+   */
+  public static Iterator getImageTranscoders (ImageReader reader,
+					      ImageWriter writer)
+  {
+    if (reader == null || writer == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return getRegistry().getServiceProviders (ImageTranscoderSpi.class,
+					      new TranscoderFilter (reader,
+                                                                    writer),
+					      true);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReadParam.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReadParam.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReadParam.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReadParam.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,128 @@
+/* ImageReadParam.java --
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author Michel Koch (konqueror at gmx.de)
+ */
+public class ImageReadParam extends IIOParam
+{
+  protected boolean canSetSourceRenderSize;
+  protected BufferedImage destination;
+  protected int[] destinationBands;
+  protected int minProgressivePass;
+  protected int numProgressivePasses = Integer.MAX_VALUE;
+  protected Dimension sourceRenderSize;
+
+  public ImageReadParam()
+  {
+  }
+
+  public boolean canSetSourceRenderSize()
+  {
+    return canSetSourceRenderSize;
+  }
+
+  public BufferedImage getDestination()
+  {
+    return destination;
+  }
+
+  public int[] getDestinationBands()
+  {
+    return destinationBands;
+  }
+
+  public int getSourceMaxProgressivePass()
+  {
+    if (getSourceNumProgressivePasses() == Integer.MAX_VALUE)
+      return Integer.MAX_VALUE;
+
+    return getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1;
+  }
+
+  public int getSourceMinProgressivePass()
+  {
+    return minProgressivePass;
+  }
+
+  public int getSourceNumProgressivePasses()
+  {
+    return numProgressivePasses;
+  }
+
+  public Dimension getSourceRenderSize()
+  {
+    return sourceRenderSize;
+  }
+
+  public void setDestination(BufferedImage destination)
+  {
+    this.destination = destination;
+  }
+
+  public void setDestinationBands(int[] destinationBands)
+  {
+    this.destinationBands = destinationBands;
+  }
+
+  public void setSourceProgressivePasses(int minPass, int numPasses)
+  {
+    this.minProgressivePass = minPass;
+    this.numProgressivePasses = numPasses;
+  }
+  
+  public void setSourceRenderSize(Dimension size)
+    throws UnsupportedOperationException
+  {
+    if (! canSetSourceRenderSize())
+      throw new UnsupportedOperationException
+	("setting source render size not supported");
+    
+    if (size.width <= 0 || size.height <= 0)
+      throw new IllegalArgumentException("negative dimension not allowed");
+    
+    sourceRenderSize = size;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageReader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,2036 @@
+/* ImageReader.java -- Decodes raster images.
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import java.util.Set;
+
+import javax.imageio.event.IIOReadProgressListener;
+import javax.imageio.event.IIOReadUpdateListener;
+import javax.imageio.event.IIOReadWarningListener;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * A class for decoding images within the ImageIO framework.
+ *
+ * An ImageReader for a given format is instantiated by an
+ * ImageReaderSpi for that format.  ImageReaderSpis are registered
+ * with the IIORegistry.
+ *
+ * The ImageReader API supports reading animated images that may have
+ * multiple frames; to support such images many methods take an index
+ * parameter.
+ *
+ * Images may also be read in multiple passes, where each successive
+ * pass increases the level of detail in the destination image.
+ */
+public abstract class ImageReader
+{
+  private boolean aborted;
+
+  /**
+   * All locales available for localization of warning messages, or
+   * null if localization is not supported.
+   */
+  protected Locale[] availableLocales = null;
+
+  /**
+   * true if the input source does not require metadata to be read,
+   * false otherwise.
+   */
+  protected boolean ignoreMetadata = false;
+
+  /**
+   * An ImageInputStream from which image data is read.
+   */
+  protected Object input = null;
+
+  /**
+   * The current locale used to localize warning messages, or null if
+   * no locale has been set.
+   */
+  protected Locale locale = null;
+
+  /**
+   * The minimum index at which data can be read.  Constantly 0 if
+   * seekForwardOnly is false, always increasing if seekForwardOnly is
+   * true.
+   */
+  protected int minIndex = 0;
+
+  /**
+   * The image reader SPI that instantiated this reader.
+   */
+  protected ImageReaderSpi originatingProvider = null;
+
+  /**
+   * A list of installed progress listeners.  Initially null, meaning
+   * no installed listeners.
+   */
+  protected List progressListeners = null;
+
+  /**
+   * true if this reader should only read data further ahead in the
+   * stream than its current location.  false if it can read backwards
+   * in the stream.  If this is true then caching can be avoided.
+   */
+  protected boolean seekForwardOnly = false;
+
+  /**
+   * A list of installed update listeners.  Initially null, meaning no
+   * installed listeners.
+   */
+  protected List updateListeners = null;
+
+  /**
+   * A list of installed warning listeners.  Initially null, meaning
+   * no installed listeners.
+   */
+  protected List warningListeners = null;
+
+  /**
+   * A list of warning locales corresponding with the list of
+   * installed warning listeners.  Initially null, meaning no locales.
+   */
+  protected List warningLocales = null;
+
+  /**
+   * Construct an image reader.
+   *
+   * @param originatingProvider the provider that is constructing this
+   * image reader, or null
+   */
+  protected ImageReader(ImageReaderSpi originatingProvider)
+  {
+    this.originatingProvider = originatingProvider;
+  }
+
+  /**
+   * Request that reading be aborted.  The unread contents of the
+   * image will be undefined.
+   *
+   * Readers should clear the abort flag before starting a read
+   * operation, then poll it periodically during the read operation.
+   */
+  public void abort()
+  {
+    aborted = true;
+  }
+
+  /**
+   * Check if the abort flag is set.
+   *
+   * @return true if the current read operation should be aborted,
+   * false otherwise
+   */
+  protected boolean abortRequested()
+  {
+    return aborted;
+  }
+
+  /**
+   * Install a read progress listener.  This method will return
+   * immediately if listener is null.
+   *
+   * @param listener a read progress listener or null
+   */
+  public void addIIOReadProgressListener(IIOReadProgressListener listener)
+  {
+    if (listener == null)
+      return;
+    if (progressListeners == null)
+      progressListeners = new ArrayList ();
+    progressListeners.add(listener);
+  }
+
+  /**
+   * Install a read update listener.  This method will return
+   * immediately if listener is null.
+   *
+   * @param listener a read update listener
+   */
+  public void addIIOReadUpdateListener(IIOReadUpdateListener listener)
+  {
+    if (listener == null)
+      return;
+    if (updateListeners == null)
+      updateListeners = new ArrayList ();
+    updateListeners.add(listener);
+  }
+
+  /**
+   * Install a read warning listener.  This method will return
+   * immediately if listener is null.  Warning messages sent to this
+   * listener will be localized using the current locale.  If the
+   * current locale is null then this reader will select a sensible
+   * default.
+   *
+   * @param listener a read warning listener
+   */
+  public void addIIOReadWarningListener(IIOReadWarningListener listener)
+  {
+    if (listener == null)
+      return;
+    if (warningListeners == null)
+      warningListeners = new ArrayList ();
+    warningListeners.add(listener);
+  }
+
+  /**
+   * Check if this reader can handle raster data.  Determines whether
+   * or not readRaster and readTileRaster throw
+   * UnsupportedOperationException.
+   *
+   * @return true if this reader supports raster data, false if not
+   */
+  public boolean canReadRaster()
+  {
+    return false;
+  }
+
+  /**
+   * Clear the abort flag.
+   */
+  protected void clearAbortRequest()
+  {
+    aborted = false;
+  }
+
+  /**
+   * Releases any resources allocated to this object.  Subsequent
+   * calls to methods on this object will produce undefined results.
+   *
+   * The default implementation does nothing; subclasses should use
+   * this method ensure that native resources are released.
+   */
+  public void dispose()
+  {
+    // The default implementation does nothing.
+  }
+
+  /**
+   * Returns the aspect ratio of this image, the ration of its width
+   * to its height.  The aspect ratio is useful when resizing an image
+   * while keeping its proportions constant.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the image's aspect ratio
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public float getAspectRatio(int imageIndex)
+    throws IOException
+  {
+    if (input == null)
+      throw new IllegalStateException("input is null");
+
+    return (float) (getWidth(imageIndex) / getHeight(imageIndex));
+  }
+
+  /**
+   * Retrieve the available locales.  Return null if no locales are
+   * available or a clone of availableLocales.
+   *
+   * @return an array of locales or null
+   */
+  public Locale[] getAvailableLocales()
+  {
+    if (availableLocales == null)
+      return null;
+    
+    return (Locale[]) availableLocales.clone();
+  }
+
+  /**
+   * Retrieve the default read parameters for this reader's image
+   * format.
+   *
+   * The default implementation returns new ImageReadParam().
+   *
+   * @return image reading parameters
+   */
+  public ImageReadParam getDefaultReadParam()
+  {
+    return new ImageReadParam();
+  }
+
+  /**
+   * Retrieve the format of the input source.
+   *
+   * @return the input source format name
+   *
+   * @exception IOException if a read error occurs
+   */
+  public String getFormatName()
+    throws IOException
+  {
+    return originatingProvider.getFormatNames()[0];
+  }
+
+  /**
+   * Get the height of the input image in pixels.  If the input image
+   * is resizable then a default height is returned.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the height of the input image
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public abstract int getHeight(int imageIndex)
+    throws IOException;
+
+  /**
+   * Get the metadata associated with this image.  If the reader is
+   * set to ignore metadata or does not support reading metadata, or
+   * if no metadata is available then null is returned.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return a metadata object, or null
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public abstract IIOMetadata getImageMetadata(int imageIndex)
+    throws IOException;
+
+  /**
+   * Get an iterator over the collection of image types into which
+   * this reader can decode image data.  This method is guaranteed to
+   * return at least one valid image type specifier.
+   *
+   * The elements of the iterator should be ordered; the first element
+   * should be the most appropriate image type for this decoder,
+   * followed by the second-most appropriate, and so on.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return an iterator over a collection of image type specifiers
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public abstract Iterator getImageTypes(int imageIndex)
+    throws IOException;
+
+  /**
+   * Set the input source to the given object, specify whether this
+   * reader should be allowed to read input from the data stream more
+   * than once, and specify whether this reader should ignore metadata
+   * in the input stream.  The input source must be set before many
+   * methods can be called on this reader. (see all ImageReader
+   * methods that throw IllegalStateException).  If input is null then
+   * the current input source will be removed.
+   *
+   * Unless this reader has direct access with imaging hardware, input
+   * should be an ImageInputStream.
+   *
+   * @param input the input source object
+   * @param seekForwardOnly true if this reader should be allowed to
+   * read input from the data stream more than once, false otherwise
+   * @param ignoreMetadata true if this reader should ignore metadata
+   * associated with the input source, false otherwise
+   *
+   * @exception IllegalArgumentException if input is not a valid input
+   * source for this reader and is not an ImageInputStream
+   */
+  public void setInput(Object input,
+                       boolean seekForwardOnly,
+                       boolean ignoreMetadata)
+  {
+    Class[] okClasses = originatingProvider.getInputTypes();
+    if (okClasses == null)
+      {
+        if (!(input instanceof ImageInputStream))
+          throw new IllegalArgumentException();
+      }
+    else
+      {
+        boolean classOk = false;
+        for (int i = 0; i < okClasses.length; ++i)
+          if (okClasses[i].isInstance(input))
+            classOk = true;
+        if (!classOk)
+          throw new IllegalArgumentException();
+      }
+
+    this.input = input;
+    this.seekForwardOnly = seekForwardOnly;
+    this.ignoreMetadata = ignoreMetadata;
+    this.minIndex = 0;
+  }
+
+  /**
+   * Set the input source to the given object and specify whether this
+   * reader should be allowed to read input from the data stream more
+   * than once.  The input source must be set before many methods can
+   * be called on this reader. (see all ImageReader methods that throw
+   * IllegalStateException).  If input is null then the current input
+   * source will be removed.
+   *
+   * @param input the input source object
+   * @param seekForwardOnly true if this reader should be allowed to
+   * read input from the data stream more than once, false otherwise
+   *
+   * @exception IllegalArgumentException if input is not a valid input
+   * source for this reader and is not an ImageInputStream
+   */
+  public void setInput(Object in, boolean seekForwardOnly)
+  {
+    setInput(in, seekForwardOnly, false);
+  }
+
+  /**
+   * Set the input source to the given object.  The input source must
+   * be set before many methods can be called on this reader. (see all
+   * ImageReader methods that throw IllegalStateException).  If input
+   * is null then the current input source will be removed.
+   *
+   * @param input the input source object
+   *
+   * @exception IllegalArgumentException if input is not a valid input
+   * source for this reader and is not an ImageInputStream
+   */
+  public void setInput(Object input)
+  {
+    setInput(input, false, false);
+  }
+
+  /**
+   * Get this reader's image input source.  null is returned if the
+   * image source has not been set.
+   *
+   * @return an image input source object, or null
+   */
+  public Object getInput()
+  {
+    return input;
+  }
+
+  /**
+   * Get this reader's locale.  null is returned if the locale has not
+   * been set.
+   *
+   * @return this reader's locale, or null
+   */
+  public Locale getLocale()
+  {
+    return locale;
+  }
+
+  /**
+   * Return the number of images available from the image input
+   * source, not including thumbnails.  This method will return 1
+   * unless this reader is reading an animated image.
+   *
+   * Certain multi-image formats do not encode the total number of
+   * images.  When reading images in those formats it may be necessary
+   * to repeatedly call read, incrementing the image index at each
+   * call, until an IndexOutOfBoundsException is thrown.
+   *
+   * The allowSearch parameter determines whether all images must be
+   * available at all times.  When allowSearch is false, getNumImages
+   * will return -1 if the total number of images is unknown.
+   * Otherwise this method returns the number of images.
+   *
+   * @param allowSearch true if all images should be available at
+   * once, false otherwise
+   *
+   * @return -1 if allowSearch is false and the total number of images
+   * is currently unknown, or the number of images
+   *
+   * @exception IllegalStateException if input has not been set, or if
+   * seekForwardOnly is true
+   * @exception IOException if a read error occurs
+   */
+  public abstract int getNumImages(boolean allowSearch)
+    throws IOException;
+
+  /**
+   * Get the number of thumbnails associated with an image.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the number of thumbnails associated with this image
+   */
+  public int getNumThumbnails(int imageIndex)
+    throws IOException
+  {
+    return 0;
+  }
+
+  /**
+   * Get the ImageReaderSpi that created this reader or null.
+   *
+   * @return an ImageReaderSpi, or null
+   */
+  public ImageReaderSpi getOriginatingProvider()
+  {
+    return originatingProvider;
+  }
+
+  /**
+   * Get the metadata associated with the image being read.  If the
+   * reader is set to ignore metadata or does not support reading
+   * metadata, or if no metadata is available then null is returned.
+   * This method returns metadata associated with the entirety of the
+   * image data, whereas getImageMetadata(int) returns metadata
+   * associated with a frame within a multi-image data stream.
+   *
+   * @return metadata associated with the image being read, or null
+   *
+   * @exception IOException if a read error occurs
+   */
+  public abstract IIOMetadata getStreamMetadata()
+    throws IOException;
+
+  /**
+   * Get the height of a thumbnail image.
+   *
+   * @param imageIndex the frame index
+   * @param thumbnailIndex the thumbnail index
+   *
+   * @return the height of the thumbnail image
+   *
+   * @exception UnsupportedOperationException if this reader does not
+   * support thumbnails
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if either index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public int getThumbnailHeight(int imageIndex, int thumbnailIndex)
+    throws IOException
+  {
+    return readThumbnail(imageIndex, thumbnailIndex).getHeight();
+  }
+
+  /**
+   * Get the width of a thumbnail image.
+   *
+   * @param imageIndex the frame index
+   * @param thumbnailIndex the thumbnail index
+   *
+   * @return the width of the thumbnail image
+   *
+   * @exception UnsupportedOperationException if this reader does not
+   * support thumbnails
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if either index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public int getThumbnailWidth(int imageIndex, int thumbnailIndex)
+    throws IOException
+  {
+    return readThumbnail(imageIndex, thumbnailIndex).getWidth();
+  }
+
+  /**
+   * Get the X coordinate in pixels of the top-left corner of the
+   * first tile in this image.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the X coordinate of this image's first tile
+   *
+   * @exception IllegalStateException if input is needed but the input
+   * source is not set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public int getTileGridXOffset(int imageIndex)
+    throws IOException
+  {
+    return 0;
+  }
+
+  /**
+   * Get the Y coordinate in pixels of the top-left corner of the
+   * first tile in this image.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the Y coordinate of this image's first tile
+   *
+   * @exception IllegalStateException if input is needed but the input
+   * source is not set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public int getTileGridYOffset(int imageIndex)
+    throws IOException
+  {
+    return 0;
+  }
+
+  /**
+   * Get the height of an image tile.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the tile height for the given image
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public int getTileHeight(int imageIndex)
+    throws IOException
+  {
+    return getHeight(imageIndex);
+  }
+
+  /**
+   * Get the width of an image tile.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return the tile width for the given image
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public int getTileWidth(int imageIndex)
+    throws IOException
+  {
+    return getWidth(imageIndex);
+  }
+
+  /**
+   * Get the width of the input image in pixels.  If the input image
+   * is resizable then a default width is returned.
+   *
+   * @param imageIndex the image's index
+   *
+   * @return the width of the input image
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public abstract int getWidth(int imageIndex)
+    throws IOException;
+
+  /**
+   * Check whether or not the given image has thumbnails associated
+   * with it.
+   *
+   * @return true if the given image has thumbnails, false otherwise
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public boolean hasThumbnails(int imageIndex)
+    throws IOException
+  {
+    return getNumThumbnails(imageIndex) > 0;
+  }
+
+  /**
+   * Check if this image reader ignores metadata.  This method simply
+   * returns the value of ignoreMetadata.
+   *
+   * @return true if metadata is being ignored, false otherwise
+   */
+  public boolean isIgnoringMetadata()
+  {
+    return ignoreMetadata;
+  }
+
+  /**
+   * Check if the given image is sub-divided into equal-sized
+   * non-overlapping pixel rectangles.
+   *
+   * A reader may expose tiling in the underlying format, hide it, or
+   * simulate tiling even if the underlying format is not tiled.
+   *
+   * @return true if the given image is tiled, false otherwise
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public boolean isImageTiled(int imageIndex)
+    throws IOException
+  {
+    return false;
+  }
+
+  /**
+   * Check if all pixels in this image are readily accessible.  This
+   * method should return false for compressed formats.  The return
+   * value is a hint as to the efficiency of certain image reader
+   * operations.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return true if random pixel access is fast, false otherwise
+   *
+   * @exception IllegalStateException if input is null and it is
+   * needed to determine the return value
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds but the frame data must be accessed to determine
+   * the return value
+   * @exception IOException if a read error occurs
+   */
+  public boolean isRandomAccessEasy(int imageIndex)
+    throws IOException
+  {
+    return false;
+  }
+
+  /**
+   * Check if this image reader may only seek forward within the input
+   * stream.
+   *
+   * @return true if this reader may only seek forward, false
+   * otherwise
+   */
+  public boolean isSeekForwardOnly()
+  {
+    return seekForwardOnly;
+  }
+
+  /**
+   * Notifies all installed read progress listeners that image loading
+   * has completed by calling their imageComplete methods.
+   */
+  protected void processImageComplete()
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.imageComplete (this);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read progress listeners that a certain
+   * percentage of the image has been loaded, by calling their
+   * imageProgress methods.
+   *
+   * @param percentageDone the percentage of image data that has been
+   * loaded
+   */
+  protected void processImageProgress(float percentageDone)
+  {
+     if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.imageProgress(this, percentageDone);
+	  }
+      }
+  }
+  /**
+   * Notifies all installed read progress listeners, by calling their
+   * imageStarted methods, that image loading has started on the given
+   * image.
+   *
+   * @param imageIndex the frame index of the image that has started
+   * loading
+   */
+  protected void processImageStarted(int imageIndex)
+  {
+     if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.imageStarted(this, imageIndex);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read update listeners, by calling their
+   * imageUpdate methods, that the set of samples has changed.
+   *
+   * @param image the buffered image that is being updated
+   * @param minX the X coordinate of the top-left pixel in this pass
+   * @param minY the Y coordinate of the top-left pixel in this pass
+   * @param width the total width of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param height the total height of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param periodX the horizontal sample interval
+   * @param periodY the vertical sample interval
+   * @param bands the affected bands in the destination
+   */
+  protected void processImageUpdate(BufferedImage image, int minX, int minY,
+				    int width, int height, int periodX,
+				    int periodY, int[] bands)
+  {
+    if (updateListeners != null)
+      {
+	Iterator it = updateListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+	    listener.imageUpdate(this, image, minX, minY, width, height,
+				 periodX, periodY, bands);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed update progress listeners, by calling
+   * their passComplete methods, that a progressive pass has
+   * completed.
+   *
+   * @param image the image that has being updated
+   */
+  protected void processPassComplete(BufferedImage image)
+  {
+    if (updateListeners != null)
+      {
+	Iterator it = updateListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+	    listener.passComplete(this, image);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read update listeners, by calling their
+   * passStarted methods, that a new pass has begun.
+   *
+   * @param image the buffered image that is being updated
+   * @param pass the current pass number
+   * @param minPass the pass at which decoding will begin
+   * @param maxPass the pass at which decoding will end
+   * @param minX the X coordinate of the top-left pixel in this pass
+   * @param minY the Y coordinate of the top-left pixel in this pass
+   * @param width the total width of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param height the total height of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param periodX the horizontal sample interval
+   * @param periodY the vertical sample interval
+   * @param bands the affected bands in the destination
+   */
+  protected void processPassStarted(BufferedImage image, int pass, int minPass,
+				    int maxPass, int minX, int minY,
+				    int periodX, int periodY, int[] bands)
+  {
+    if (updateListeners != null)
+      {
+	Iterator it = updateListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+	    listener.passStarted(this, image, pass, minPass, maxPass, minX,
+				 minY, periodX, periodY, bands);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read progress listeners that image loading
+   * has been aborted by calling their readAborted methods.
+   */
+  protected void processReadAborted()
+  {
+     if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.readAborted(this);
+	  }
+      }
+  }
+  /**
+   * Notifies all installed read progress listeners, by calling their
+   * sequenceComplete methods, that a sequence of images has completed
+   * loading.
+   */
+  protected void processSequenceComplete()
+  {
+     if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.sequenceComplete(this);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read progress listeners, by calling their
+   * sequenceStarted methods, a sequence of images has started
+   * loading.
+   *
+   * @param minIndex the index of the first image in the sequence
+   */
+  protected void processSequenceStarted(int minIndex)
+  {
+
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.sequenceStarted(this, minIndex);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read progress listeners, by calling their
+   * thumbnailComplete methods, that a thumbnail has completed
+   * loading.
+   */
+  protected void processThumbnailComplete()
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.thumbnailComplete(this);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed update progress listeners, by calling
+   * their thumbnailPassComplete methods, that a progressive pass has
+   * completed on a thumbnail.
+   *
+   * @param thumbnail the thumbnail that has being updated
+   */
+  protected void processThumbnailPassComplete(BufferedImage thumbnail)
+  {
+    if (updateListeners != null)
+      {
+	Iterator it = updateListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+	    listener.thumbnailPassComplete(this, thumbnail);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read update listeners, by calling their
+   * thumbnailPassStarted methods, that a new pass has begun.
+   *
+   * @param thumbnail the thumbnail that is being updated
+   * @param pass the current pass number
+   * @param minPass the pass at which decoding will begin
+   * @param maxPass the pass at which decoding will end
+   * @param minX the X coordinate of the top-left pixel in this pass
+   * @param minY the Y coordinate of the top-left pixel in this pass
+   * @param width the total width of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param height the total height of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param periodX the horizontal sample interval
+   * @param periodY the vertical sample interval
+   * @param bands the affected bands in the destination
+   */
+  protected void processThumbnailPassStarted(BufferedImage thumbnail, int pass,
+					     int minPass, int maxPass, int minX,
+					     int minY, int periodX, int periodY,
+					     int[] bands)
+  {
+    if (updateListeners != null)
+      {
+	Iterator it = updateListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+	    listener.thumbnailPassStarted(this, thumbnail, pass, minPass,
+					  maxPass, minX, minY, periodX,
+					  periodY, bands);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read progress listeners that a certain
+   * percentage of a thumbnail has been loaded, by calling their
+   * thumbnailProgress methods.
+   *
+   * @param percentageDone the percentage of thumbnail data that has
+   * been loaded
+   */
+  protected void processThumbnailProgress(float percentageDone)
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.thumbnailProgress(this, percentageDone);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read progress listeners, by calling their
+   * imageStarted methods, that thumbnail loading has started on the
+   * given thumbnail of the given image.
+   *
+   * @param imageIndex the frame index of the image one of who's
+   * thumbnails has started loading
+   * @param thumbnailIndex the index of the thumbnail that has started
+   * loading
+   */
+  protected void processThumbnailStarted(int imageIndex, int thumbnailIndex)
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadProgressListener listener =
+	      (IIOReadProgressListener) it.next();
+	    listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed read update listeners, by calling their
+   * thumbnailUpdate methods, that the set of samples has changed.
+   *
+   * @param image the buffered image that is being updated
+   * @param minX the X coordinate of the top-left pixel in this pass
+   * @param minY the Y coordinate of the top-left pixel in this pass
+   * @param width the total width of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param height the total height of the rectangle covered by this
+   * pass, including skipped pixels
+   * @param periodX the horizontal sample interval
+   * @param periodY the vertical sample interval
+   * @param bands the affected bands in the destination
+   */
+  protected void processThumbnailUpdate(BufferedImage image, int minX, int minY,
+					int width, int height, int periodX,
+					int periodY, int[] bands)
+  {
+    if (updateListeners != null)
+      {
+	Iterator it = updateListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+	    listener.thumbnailUpdate(this, image, minX, minY, width, height,
+				     periodX, periodY, bands);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed warning listeners, by calling their
+   * warningOccurred methods, that a warning message has been raised.
+   *
+   * @param warning the warning message
+   *
+   * @exception IllegalArgumentException if warning is null
+   */
+  protected void processWarningOccurred(String warning)
+  {
+    if (warning == null)
+      throw new IllegalArgumentException ("null argument");
+    if (warningListeners != null)
+      {
+	Iterator it = warningListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadWarningListener listener =
+	      (IIOReadWarningListener) it.next();
+	    listener.warningOccurred(this, warning);
+	  }
+      }
+  }
+
+  /**
+   * Notify all installed warning listeners, by calling their
+   * warningOccurred methods, that a warning message has been raised.
+   * The warning message is retrieved from a resource bundle, using
+   * the given basename and keyword.
+   *
+   * @param baseName the basename of the resource from which to
+   * retrieve the warning message
+   * @param keyword the keyword used to retrieve the warning from the
+   * resource bundle
+   *
+   * @exception IllegalArgumentException if either baseName or keyword
+   * is null
+   * @exception IllegalArgumentException if no resource bundle is
+   * found using baseName
+   * @exception IllegalArgumentException if the given keyword produces
+   * no results from the resource bundle
+   * @exception IllegalArgumentException if the retrieved object is
+   * not a String
+   */
+  protected void processWarningOccurred(String baseName,
+					String keyword)
+  {
+    if (baseName == null || keyword == null)
+      throw new IllegalArgumentException ("null argument");
+
+    ResourceBundle b = null;
+
+    try
+      {
+	b = ResourceBundle.getBundle(baseName, getLocale());
+      }
+    catch (MissingResourceException e)
+      {
+	throw new IllegalArgumentException ("no resource bundle found");
+      }
+
+    Object str = null;
+
+    try
+      {
+	str = b.getObject(keyword);
+      }
+    catch (MissingResourceException e)
+      {
+	throw new IllegalArgumentException ("no results found for keyword");
+      }
+
+    if (! (str instanceof String))
+      throw new IllegalArgumentException ("retrieved object not a String");
+
+    String warning = (String) str;
+
+    if (warningListeners != null)
+      {
+	Iterator it = warningListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOReadWarningListener listener =
+	      (IIOReadWarningListener) it.next();
+	    listener.warningOccurred(this, warning);
+	  }
+      }
+  }
+
+  /**
+   * Read the given frame into a buffered image using the given read
+   * parameters.  Listeners will be notified of image loading progress
+   * and warnings.
+   *
+   * @param imageIndex the index of the frame to read
+   * @param param the image read parameters to use when reading
+   *
+   * @return a buffered image
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public abstract BufferedImage read(int imageIndex, ImageReadParam param)
+    throws IOException;
+
+  /**
+   * Check if this reader supports reading thumbnails.
+   *
+   * @return true if this reader supports reading thumbnails, false
+   * otherwise
+   */
+  public boolean readerSupportsThumbnails()
+  {
+    return false;
+  }
+
+  /**
+   * Read raw raster data.  The image type specifier in param is
+   * ignored but all other parameters are used.  Offset parameters are
+   * translated into the raster's coordinate space.  This method may
+   * be implemented by image readers that want to provide direct
+   * access to raw image data.
+   *
+   * @param imageIndex the frame index
+   * @param param the image read parameters
+   *
+   * @return a raster containing the read image data
+   *
+   * @exception UnsupportedOperationException if this reader doesn't
+   * support rasters
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public Raster readRaster(int imageIndex, ImageReadParam param)
+    throws IOException
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Read a thumbnail.
+   *
+   * @param imageIndex the frame index
+   * @param thumbnailIndex the thumbnail index
+   *
+   * @return a buffered image of the thumbnail
+   *
+   * @exception UnsupportedOperationException if this reader doesn't
+   * support thumbnails
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if either the frame index or
+   * the thumbnail index is out-of-bounds
+   * @exception IOException if a read error occurs
+   * 
+   */
+  public BufferedImage readThumbnail(int imageIndex, int thumbnailIndex)
+    throws IOException
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Uninstall all read progress listeners.
+   */
+  public void removeAllIIOReadProgressListeners()
+  {
+    progressListeners = null;
+  }
+
+  /**
+   * Uninstall all read update listeners.
+   */
+  public void removeAllIIOReadUpdateListeners()
+  {
+    updateListeners = null;
+  }
+
+  /**
+   * Uninstall all read warning listeners.
+   */
+  public void removeAllIIOReadWarningListeners()
+  {
+    warningListeners = null;
+  }
+
+  /**
+   * Uninstall the given read progress listener.
+   *
+   * @param listener the listener to remove
+   */
+  public void removeIIOReadProgressListener(IIOReadProgressListener listener) 
+  {
+    if (listener == null)
+      return;
+    if (progressListeners != null)
+      {
+	progressListeners.remove(listener);
+      }
+  }
+
+  /**
+   * Uninstall the given read update listener.
+   *
+   * @param listener the listener to remove
+   */
+  public void removeIIOReadUpdateListener(IIOReadUpdateListener listener) 
+  {
+    if (listener == null)
+      return;
+
+    if (updateListeners != null)
+      {
+	updateListeners.remove(listener);
+      }
+  }
+
+  /**
+   * Uninstall the given read warning listener.
+   *
+   * @param listener the listener to remove
+   */
+  public void removeIIOReadWarningListener(IIOReadWarningListener listener)
+  {
+    if (listener == null)
+      return;
+    if (warningListeners != null)
+      {
+	warningListeners.remove(listener);
+      }
+  }
+
+  /**
+   * Set the current locale or use the default locale.
+   *
+   * @param locale the locale to set, or null
+   */
+  public void setLocale(Locale locale)
+  {
+    if (locale != null)
+      {
+	// Check if its a valid locale.
+	boolean found = false;
+
+	if (availableLocales != null)
+	  for (int i = availableLocales.length - 1; i >= 0; --i)
+	    if (availableLocales[i].equals(locale))
+	      found = true;
+
+	if (! found)
+	  throw new IllegalArgumentException("looale not available");
+      }
+
+    this.locale = locale;
+  }
+
+  /**
+   * Check that the given read parameters have valid source and
+   * destination band settings.  If the param.getSourceBands() returns
+   * null, the array is assumed to include all band indices, 0 to
+   * numSrcBands - 1; likewise if param.getDestinationBands() returns
+   * null, it is assumed to be an array containing indices 0 to
+   * numDstBands - 1.  A failure will cause this method to throw
+   * IllegalArgumentException.
+   *
+   * @param param the image parameters to check
+   * @param numSrcBands the number of input source bands
+   * @param numDstBands the number of ouput destination bands
+   *
+   * @exception IllegalArgumentException if either the given source or
+   * destination band indices are invalid
+   */
+  protected static void checkReadParamBandSettings(ImageReadParam param,
+						   int numSrcBands,
+						   int numDstBands)
+  {
+    int[] srcBands = param.getSourceBands();
+    int[] dstBands = param.getDestinationBands();
+    boolean lengthsDiffer = false;
+    boolean srcOOB = false;
+    boolean dstOOB = false;
+
+    if (srcBands == null)
+      {
+        if (dstBands == null)
+          {
+            if (numSrcBands != numDstBands)
+              lengthsDiffer = true;
+          }
+        else
+          {
+            if (numSrcBands != dstBands.length)
+              lengthsDiffer = true;
+
+            for (int i = 0; i < dstBands.length; i++)
+              if (dstBands[i] > numSrcBands - 1)
+                {
+                  dstOOB = true;
+                  break;
+                }
+          }
+      }
+    else
+      {
+        if (dstBands == null)
+          {
+            if (srcBands.length != numDstBands)
+              lengthsDiffer = true;
+
+            for (int i = 0; i < srcBands.length; i++)
+              if (srcBands[i] > numDstBands - 1)
+                {
+                  srcOOB = true;
+                  break;
+                }
+          }
+        else
+          {
+            if (srcBands.length != dstBands.length)
+              lengthsDiffer = true;
+
+            for (int i = 0; i < srcBands.length; i++)
+              if (srcBands[i] > numDstBands - 1)
+                {
+                  srcOOB = true;
+                  break;
+                }
+
+            for (int i = 0; i < dstBands.length; i++)
+              if (dstBands[i] > numSrcBands - 1)
+                {
+                  dstOOB = true;
+                  break;
+                }
+          }
+      }
+
+    if (lengthsDiffer)
+      throw new IllegalArgumentException ("array lengths differ");
+
+    if (srcOOB)
+      throw new IllegalArgumentException ("source band index"
+                                          + " out-of-bounds");
+
+    if (dstOOB)
+      throw new IllegalArgumentException ("destination band index"
+                                          + " out-of-bounds");
+  }
+
+  /**
+   * Calcluate the source and destination regions that will be read
+   * from and written to, given image parameters and/or a destination
+   * buffered image.  The source region will be clipped if any of its
+   * bounds are outside the destination region.  Clipping will account
+   * for subsampling and destination offsets.  Likewise, the
+   * destination region is clipped to the given destination image, if
+   * it is not null, using the given image parameters, if they are not
+   * null.  IllegalArgumentException is thrown if either region will
+   * contain 0 pixels after clipping.
+   *
+   * @param image read parameters, or null
+   * @param srcWidth the width of the source image
+   * @param srcHeight the height of the source image
+   * @param image the destination image, or null
+   * @param srcRegion a rectangle whose values will be set to the
+   * clipped source region
+   * @param destRegion a rectangle whose values will be set to the
+   * clipped destination region
+   *
+   * @exception IllegalArgumentException if either srcRegion or
+   * destRegion is null
+   * @exception IllegalArgumentException if either of the calculated
+   * regions is empty
+   */
+  protected static void computeRegions (ImageReadParam param,
+					int srcWidth,
+					int srcHeight,
+					BufferedImage image,
+					Rectangle srcRegion,
+					Rectangle destRegion)
+  {
+    if (srcRegion == null || destRegion == null)
+      throw new IllegalArgumentException ("null region");
+
+    if (srcWidth == 0 || srcHeight == 0)
+      throw new IllegalArgumentException ("zero-sized region");
+
+    srcRegion = getSourceRegion(param, srcWidth, srcHeight);
+    if (image != null)
+      destRegion = new Rectangle (0, 0, image.getWidth(), image.getHeight());
+    else
+      destRegion = new Rectangle (0, 0, srcWidth, srcHeight);
+
+    if (param != null)
+      {
+        Point offset = param.getDestinationOffset();
+
+        if (offset.x < 0)
+          {
+            srcRegion.x -= offset.x;
+            srcRegion.width += offset.x;
+          }
+        if (offset.y < 0)
+          {
+            srcRegion.y -= offset.y;
+            srcRegion.height += offset.y;
+          }
+
+        srcRegion.width = srcRegion.width > destRegion.width
+          ? destRegion.width : srcRegion.width;
+        srcRegion.height = srcRegion.height > destRegion.height
+          ? destRegion.height : srcRegion.height;
+
+        if (offset.x >= 0)
+          {
+            destRegion.x += offset.x;
+            destRegion.width -= offset.x;
+          }
+        if (offset.y >= 0)
+          {
+            destRegion.y += offset.y;
+            destRegion.height -= offset.y;
+          }
+      }
+
+    if (srcRegion.isEmpty() || destRegion.isEmpty())
+      throw new IllegalArgumentException ("zero-sized region");
+  }
+
+  /**
+   * Return a suitable destination buffered image.  If
+   * param.getDestination() is non-null, then it is returned,
+   * otherwise a buffered image is created using
+   * param.getDestinationType() if it is non-null and also in the
+   * given imageTypes collection, or the first element of imageTypes
+   * otherwise.
+   *
+   * @param param image read parameters from which a destination image
+   * or image type is retrieved, or null
+   * @param imageTypes a collection of legal image types
+   * @param width the width of the source image
+   * @param height the height of the source image
+   *
+   * @return a suitable destination buffered image
+   *
+   * @exception IIOException if param.getDestinationType() does not
+   * return an image type in imageTypes
+   * @exception IllegalArgumentException if imageTypes is null or
+   * empty, or if a non-ImageTypeSpecifier object is retrieved from
+   * imageTypes
+   * @exception IllegalArgumentException if the resulting destination
+   * region is empty
+   * @exception IllegalArgumentException if the product of width and
+   * height is greater than Integer.MAX_VALUE
+   */
+  protected static BufferedImage getDestination (ImageReadParam param,
+						 Iterator imageTypes,
+						 int width,
+						 int height)
+    throws IIOException
+  {
+    if (imageTypes == null || !imageTypes.hasNext())
+      throw new IllegalArgumentException ("imageTypes null or empty");
+
+    if (width < 0 || height < 0)
+      throw new IllegalArgumentException ("negative dimension");
+
+    // test for overflow
+    if (width * height < Math.min (width, height))
+      throw new IllegalArgumentException ("width * height > Integer.MAX_VALUE");
+
+    BufferedImage dest = null;
+    ImageTypeSpecifier destType = null;
+
+    if (param != null)
+      {
+        dest = param.getDestination ();
+        if (dest == null)
+          {
+            ImageTypeSpecifier type = param.getDestinationType();
+            if (type != null)
+              {
+                Iterator it = imageTypes;
+
+                while (it.hasNext())
+                  {
+                    Object o = it.next ();
+                    if (! (o instanceof ImageTypeSpecifier))
+                      throw new IllegalArgumentException ("non-ImageTypeSpecifier object");
+
+                    ImageTypeSpecifier t = (ImageTypeSpecifier) o;
+                    if (t.equals (type))
+                      {
+                        dest = t.createBufferedImage (width, height);
+                        break;
+                      }
+                    if (destType == null)
+                      throw new IIOException ("invalid destination type");
+
+                  }
+              }
+          }
+      }
+    if (dest == null)
+      {
+        Rectangle srcRegion = new Rectangle ();
+        Rectangle destRegion = new Rectangle ();
+
+        computeRegions (param, width, height, null, srcRegion, destRegion);
+
+        if (destRegion.isEmpty())
+          throw new IllegalArgumentException ("destination region empty");
+
+        if (destType == null)
+          {
+            Object o = imageTypes.next();
+            if (! (o instanceof ImageTypeSpecifier))
+              throw new IllegalArgumentException ("non-ImageTypeSpecifier"
+                                                  + " object");
+
+            dest = ((ImageTypeSpecifier) o).createBufferedImage
+              (destRegion.width, destRegion.height);
+          }
+        else
+          dest = destType.createBufferedImage
+            (destRegion.width, destRegion.height);
+      }
+    return dest;
+  }
+
+  /**
+   * Get the metadata associated with this image.  If the reader is
+   * set to ignore metadata or does not support reading metadata, or
+   * if no metadata is available then null is returned.
+   *
+   * This more specific version of getImageMetadata(int) can be used
+   * to restrict metadata retrieval to specific formats and node
+   * names, which can limit the amount of data that needs to be
+   * processed.
+   *
+   * @param imageIndex the frame index
+   * @param formatName the format of metadata requested
+   * @param nodeNames a set of Strings specifiying node names to be
+   * retrieved
+   *
+   * @return a metadata object, or null
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IllegalArgumentException if formatName is null
+   * @exception IllegalArgumentException if nodeNames is null
+   * @exception IOException if a read error occurs
+   */
+  public IIOMetadata getImageMetadata (int imageIndex,
+                                       String formatName,
+                                       Set nodeNames)
+    throws IOException
+  {
+    if (formatName == null || nodeNames == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return getImageMetadata (imageIndex);
+  }
+
+  /**
+   * Get the index at which the next image will be read.  If
+   * seekForwardOnly is true then the returned value will increase
+   * monotonically each time an image frame is read.  If
+   * seekForwardOnly is false then the returned value will always be
+   * 0.
+   *
+   * @return the current frame index
+   */
+  public int getMinIndex()
+  {
+    return minIndex;
+  }
+
+  /**
+   * Get the image type specifier that most closely represents the
+   * internal data representation used by this reader.  This value
+   * should be included in the return value of getImageTypes.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return an image type specifier
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public ImageTypeSpecifier getRawImageType (int imageIndex)
+    throws IOException
+  {
+    return (ImageTypeSpecifier) getImageTypes(imageIndex).next();
+  }
+
+  /**
+   * Calculate a source region based on the given source image
+   * dimensions and parameters.  Subsampling offsets and a source
+   * region are taken from the given image read parameters and used to
+   * clip the given image dimensions, returning a new rectangular
+   * region as a result.
+   *
+   * @param param image parameters, or null
+   * @param srcWidth the width of the source image
+   * @param srcHeight the height of the source image
+   *
+   * @return a clipped rectangle
+   */
+  protected static Rectangle getSourceRegion (ImageReadParam param,
+					      int srcWidth,
+					      int srcHeight)
+  {
+    Rectangle clippedRegion = new Rectangle (0, 0, srcWidth, srcHeight);
+
+    if (param != null)
+      {
+        Rectangle srcRegion = param.getSourceRegion();
+
+        if (srcRegion != null)
+          {
+            clippedRegion.x = srcRegion.x > clippedRegion.x
+              ? srcRegion.x : clippedRegion.x;
+            clippedRegion.y = srcRegion.y > clippedRegion.y
+              ? srcRegion.y : clippedRegion.y;
+            clippedRegion.width = srcRegion.width > clippedRegion.width
+              ? srcRegion.width : clippedRegion.width;
+            clippedRegion.height = srcRegion.height > clippedRegion.height
+              ? srcRegion.height : clippedRegion.height;
+          }
+
+        int xOffset = param.getSubsamplingXOffset();
+
+        clippedRegion.x += xOffset;
+        clippedRegion.width -= xOffset;
+
+        int yOffset = param.getSubsamplingYOffset();
+
+        clippedRegion.y += yOffset;
+        clippedRegion.height -= yOffset;
+      }
+    return clippedRegion;
+  }
+
+  /**
+   * Get the metadata associated with the image being read.  If the
+   * reader is set to ignore metadata or does not support reading
+   * metadata, or if no metadata is available then null is returned.
+   * This method returns metadata associated with the entirety of the
+   * image data, whereas getStreamMetadata() returns metadata
+   * associated with a frame within a multi-image data stream.
+   *
+   * This more specific version of getStreamMetadata() can be used to
+   * restrict metadata retrieval to specific formats and node names,
+   * which can limit the amount of data that needs to be processed.
+   *
+   * @param formatName the format of metadata requested
+   * @param nodeNames a set of Strings specifiying node names to be
+   * retrieved
+   *
+   * @return metadata associated with the image being read, or null
+   *
+   * @exception IllegalArgumentException if formatName is null
+   * @exception IllegalArgumentException if nodeNames is null
+   * @exception IOException if a read error occurs
+   */
+  public IIOMetadata getStreamMetadata (String formatName,
+                                        Set nodeNames)
+    throws IOException
+  {
+    if (formatName == null || nodeNames == null)
+      throw new IllegalArgumentException ("null argument");
+
+    return getStreamMetadata();
+  }
+
+  /**
+   * Read the given frame all at once, using default image read
+   * parameters, and return a buffered image.
+   *
+   * The returned image will be formatted according to the
+   * currently-preferred image type specifier.
+   *
+   * Installed read progress listeners, update progress listeners and
+   * warning listeners will be notified of read progress, changes in
+   * sample sets and warnings respectively.
+   *
+   * @param the index of the image frame to read
+   *
+   * @return a buffered image
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public BufferedImage read (int imageIndex)
+    throws IOException
+  {
+    return read (imageIndex, null);
+  }
+
+  /**
+   * Read the given frame all at once, using the given image read
+   * parameters, and return an IIOImage.  The IIOImage will contain a
+   * buffered image as returned by getDestination.
+   *
+   * Installed read progress listeners, update progress listeners and
+   * warning listeners will be notified of read progress, changes in
+   * sample sets and warnings respectively.
+   *
+   * The source and destination band settings are checked with a call
+   * to checkReadParamBandSettings.
+   *
+   * @param the index of the image frame to read
+   * @param the image read parameters
+   *
+   * @return an IIOImage
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IllegalArgumentException if param.getSourceBands() and
+   * param.getDestinationBands() are incompatible
+   * @exception IllegalArgumentException if either the source or
+   * destination image regions are empty
+   * @exception IOException if a read error occurs
+   */
+  public IIOImage readAll (int imageIndex,
+			   ImageReadParam param)
+    throws IOException
+  {
+    checkReadParamBandSettings (param,
+                                param.getSourceBands().length,
+                                param.getDestinationBands().length);
+
+    List l = new ArrayList ();
+
+    for (int i = 0; i < getNumThumbnails (imageIndex); i++)
+      l.add (readThumbnail(imageIndex, i));
+
+    return new IIOImage (getDestination(param, getImageTypes(imageIndex),
+                                        getWidth(imageIndex),
+                                        getHeight(imageIndex)),
+                         l,
+                         getImageMetadata (imageIndex));
+  }
+
+  /**
+   * Read all image frames all at once, using the given image read
+   * parameters iterator, and return an iterator over a collection of
+   * IIOImages.  Each IIOImage in the collection will contain a
+   * buffered image as returned by getDestination.
+   *
+   * Installed read progress listeners, update progress listeners and
+   * warning listeners will be notified of read progress, changes in
+   * sample sets and warnings respectively.
+   *
+   * Each set of source and destination band settings are checked with
+   * a call to checkReadParamBandSettings.
+   *
+   * @param an iterator over the image read parameters
+   *
+   * @return an IIOImage
+   *
+   * @exception IllegalStateException if input has not been set
+   * @exception IllegalArgumentException if a non-ImageReadParam is
+   * found in params
+   * @exception IllegalArgumentException if param.getSourceBands() and
+   * param.getDestinationBands() are incompatible
+   * @exception IllegalArgumentException if either the source or
+   * destination image regions are empty
+   * @exception IOException if a read error occurs
+   */
+  public Iterator readAll (Iterator params)
+    throws IOException
+  {
+    List l = new ArrayList ();
+    int index = 0;
+
+    while (params.hasNext())
+      {
+        if (params != null && ! (params instanceof ImageReadParam))
+          throw new IllegalArgumentException ("non-ImageReadParam found");
+
+        l.add (readAll(index++, (ImageReadParam) params.next ()));
+      }
+
+    return l.iterator();
+  }
+
+  /**
+   * Read a rendered image.  This is a more general counterpart to
+   * read (int, ImageReadParam).  All image data may not be read
+   * before this method returns and so listeners will not necessarily
+   * be notified.
+   *
+   * @param the index of the image frame to read
+   * @param the image read parameters
+   *
+   * @return a rendered image
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IllegalArgumentException if param.getSourceBands() and
+   * param.getDestinationBands() are incompatible
+   * @exception IllegalArgumentException if either the source or
+   * destination image regions are empty
+   * @exception IOException if a read error occurs
+   */
+  public RenderedImage readAsRenderedImage (int imageIndex,
+					    ImageReadParam param)
+    throws IOException
+  {
+    return read (imageIndex, param);
+  }
+
+  /**
+   * Read the given tile into a buffered image.  If the tile
+   * coordinates are out-of-bounds an exception is thrown.  If the
+   * image is not tiled then the coordinates 0, 0 are expected and the
+   * entire image will be read.
+   *
+   * @param imageIndex the frame index
+   * @param tileX the horizontal tile coordinate
+   * @param tileY the vertical tile coordinate
+   *
+   * @return the contents of the tile as a buffered image
+   *
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IllegalArgumentException if the tile coordinates are
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public BufferedImage readTile (int imageIndex, int tileX, int tileY)
+    throws IOException
+  {
+    if (tileX != 0 || tileY != 0)
+      throw new IllegalArgumentException ("tileX not 0 or tileY not 0");
+
+    return read (imageIndex);
+  }
+
+  /**
+   * Read the given tile into a raster containing the raw image data.
+   * If the tile coordinates are out-of-bounds an exception is thrown.
+   * If the image is not tiled then the coordinates 0, 0 are expected
+   * and the entire image will be read.
+   *
+   * @param imageIndex the frame index
+   * @param tileX the horizontal tile coordinate
+   * @param tileY the vertical tile coordinate
+   *
+   * @return the contents of the tile as a raster
+   *
+   * @exception UnsupportedOperationException if rasters are not
+   * supported
+   * @exception IllegalStateException if input is null
+   * @exception IndexOutOfBoundsException if the frame index is
+   * out-of-bounds
+   * @exception IllegalArgumentException if the tile coordinates are
+   * out-of-bounds
+   * @exception IOException if a read error occurs
+   */
+  public Raster readTileRaster (int imageIndex, int tileX, int tileY)
+    throws IOException
+  {
+    if (!canReadRaster())
+      throw new UnsupportedOperationException ("cannot read rasters");
+
+    if (tileX != 0 || tileY != 0)
+      throw new IllegalArgumentException ("tileX not 0 or tileY not 0");
+
+    return readRaster (imageIndex, null);
+  }
+
+  /**
+   * Reset this reader's internal state.
+   */
+  public void reset ()
+  {
+    setInput (null, false);
+    setLocale (null);
+    removeAllIIOReadUpdateListeners ();
+    removeAllIIOReadWarningListeners ();
+    removeAllIIOReadProgressListeners ();
+    clearAbortRequest ();
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTranscoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTranscoder.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTranscoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTranscoder.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* ImageTranscoder.java -- Image metadata transcoder.
+   Copyright (C) 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 javax.imageio;
+
+import javax.imageio.metadata.IIOMetadata;
+
+/**
+ * An ImageTranscoder translates IIOMetadata objects provided by an
+ * ImageReader into corresponding IIOMetadata objects that can be
+ * understood by a given ImageWriter.
+ *
+ * Usually an ImageWriter will implement ImageTranscoder directly in
+ * which case the conversion methods will return IIOMetadata objects
+ * appropriate for this ImageWriter.
+ *
+ * Independent transcoders are also allowed; they must have knowledge
+ * of both the source IIOMetadata provided by the reader and the
+ * returned IIOMetadata expected by the writer.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public interface ImageTranscoder
+{
+  /**
+   * Converts IIOMetadata from an input reader format, returning an
+   * IIOMetadata suitable for use by an image writer.
+   *
+   * The ImageTypeSpecifier specifies the destination image type.
+   *
+   * An optional ImageWriteParam argument is available in case the
+   * image writing parameters affect the metadata conversion.
+   *
+   * @param inData the metadata coming from an image reader
+   * @param imageType the output image type of the writer
+   * @param param the image writing parameters or null
+   *
+   * @return the converted metadata that should be used by the image
+   * writer, or null if this ImageTranscoder has no knowledge of the
+   * input metadata
+   *
+   * @exception IllegalArgumentException if either inData or imageType
+   * is null
+   */
+  IIOMetadata convertImageMetadata(IIOMetadata inData,
+		                   ImageTypeSpecifier imageType,
+				   ImageWriteParam param);
+
+  /**
+   * Converts IIOMetadata from an input stream format, returning an
+   * IIOMetadata suitable for use by an image writer.
+   *
+   * An optional ImageWriteParam argument is available in case the
+   * image writing parameters affect the metadata conversion.
+   *
+   * @param inData the metadata coming from an input image stream
+   * @param param the image writing parameters or null
+   *
+   * @return the converted metadata that should be used by the image
+   * writer, or null if this ImageTranscoder has no knowledge of the
+   * input metadata
+   *
+   * @exception IllegalArgumentException if inData is null
+   */
+  IIOMetadata convertStreamMetadata(IIOMetadata inData,
+				    ImageWriteParam param);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTypeSpecifier.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTypeSpecifier.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTypeSpecifier.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageTypeSpecifier.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,561 @@
+/* ImageTypeSpecifier.java --
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.DataBuffer;
+import java.awt.image.BandedSampleModel;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.PixelInterleavedSampleModel;
+import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
+
+/**
+ * ImageTypeSpecifier store the color and sample models associated
+ * with an IIOImage.
+ */
+public class ImageTypeSpecifier
+{
+  /**
+   * The image's color model.
+   */
+  protected ColorModel colorModel;
+
+  /**
+   * The image's sample model.
+   */
+  protected SampleModel sampleModel;
+
+  /**
+   * Construct an image type specifier with the given models.
+   *
+   * @param colorModel the color model
+   * @param sampleModel the sample model
+   *
+   * @exception IllegalArgumentException if either model argument is
+   * null
+   * @exception IllegalArgumentException if the models are
+   * incompatible with one another
+   */
+  public ImageTypeSpecifier(ColorModel colorModel, SampleModel sampleModel)
+  {
+    if (colorModel == null)
+      throw new IllegalArgumentException("colorModel may not be null");
+
+    if (sampleModel == null)
+      throw new IllegalArgumentException("sampleModel may not be null");
+
+    if (!colorModel.isCompatibleSampleModel(sampleModel))
+      throw new IllegalArgumentException
+        ("sample Model not compatible with colorModel");
+    
+    this.colorModel = colorModel;
+    this.sampleModel = sampleModel;
+  }
+
+  /**
+   * Construct an image type specifier that describes the given
+   * rendered image.
+   *
+   * @param image a rendered image
+   *
+   * @exception IllegalArgumentException if image is null
+   */
+  public ImageTypeSpecifier(RenderedImage image)
+  {
+    if (image == null)
+      throw new IllegalArgumentException("image may not be null");
+    
+    this.colorModel = image.getColorModel();
+    this.sampleModel = image.getSampleModel();
+  }
+
+  /**
+   * Create an image type specifier for a banded image using a
+   * component color model and a banded sample model.
+   *
+   * @param colorSpace the color space
+   * @param bankIndices the bank indices at which each band will be
+   * stored
+   * @param bandOffsets the starting band offset for each band within
+   * its bank
+   * @param dataType the data type, a DataBuffer constant
+   * @param hasAlpha true if this image type specifier should have an
+   * alpha component, false otherwise
+   * @param isAlphaPremultiplied true if other color components should
+   * be premultiplied by the alpha component, false otherwise
+   *
+   * @return a banded image type specifier
+   *
+   * @exception IllegalArgumentException if any of colorSpace,
+   * bankIndices or bankOffsets is null
+   * @exception IllegalArgumentException if bankIndices and
+   * bankOffsets differ in length
+   * @excpetion IllegalArgumentException if the number of color space
+   * components, including the alpha component if requested, is
+   * different from bandOffsets.length
+   * @exception if dataType is not a valid DataBuffer constant
+   */
+  public static ImageTypeSpecifier createBanded (ColorSpace colorSpace,
+                                                 int[] bankIndices,
+                                                 int[] bankOffsets,
+                                                 int dataType,
+                                                 boolean hasAlpha,
+                                                 boolean isAlphaPremultiplied)
+  {
+    if (colorSpace == null || bankIndices == null || bankOffsets == null)
+      throw new IllegalArgumentException ("null argument");
+
+    if (bankIndices.length != bankOffsets.length)
+      throw new IllegalArgumentException ("array lengths differ");
+
+    if (bankOffsets.length != (colorSpace.getNumComponents() + (hasAlpha ? 1 : 0)))
+      throw new IllegalArgumentException ("invalid bankOffsets length");
+
+    return new ImageTypeSpecifier (new ComponentColorModel (colorSpace,
+                                                            hasAlpha,
+                                                            isAlphaPremultiplied,
+                                                            hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE,
+                                                            dataType),
+                                   new BandedSampleModel (dataType, 1, 1, 1,
+                                                          bankIndices,
+                                                          bankOffsets));
+  }
+
+  /**
+   * Create a buffered image with the given dimensions using that has
+   * the characteristics specified by this image type specifier.
+   *
+   * @param the width of the buffered image, in pixels
+   * @param the height of the buffered image, in pixels
+   *
+   * @return a buffered image
+   *
+   * @exception IllegalArgumentException if either width or height is
+   * less than or equal to zero
+   * @exception IllegalArgumentException if width * height is greater
+   * than Integer.MAX_VALUE or if the storage required is greater than
+   * Integer.MAX_VALUE
+   */
+  public BufferedImage createBufferedImage (int width, int height)
+  {
+    if (width <= 0 || height <= 0)
+      throw new IllegalArgumentException ("dimension <= 0");
+
+    // test for overflow
+    if (width * height < Math.min (width, height))
+      throw new IllegalArgumentException ("width * height > Integer.MAX_VALUE");
+
+    if (width * height * sampleModel.getNumBands() < Math.min (width, height))
+      throw new IllegalArgumentException ("storage required >"
+                                          + " Integer.MAX_VALUE");
+
+    // FIXME: this is probably wrong:
+    return new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
+  }
+
+  /**
+   * Create an image type specifier that describes the given buffered
+   * image type.
+   *
+   * @param bufferedImageType the buffered image type to represent
+   * with the returned image type specifier
+   *
+   * @return a new image type specifier
+   *
+   * @exception IllegalArgumentException if bufferedImageType is not a
+   * BufferedImage constant or is BufferedImage.TYPE_CUSTOM
+   */
+  public static ImageTypeSpecifier createFromBufferedImageType (int bufferedImageType)
+  {
+    if (bufferedImageType <= BufferedImage.TYPE_CUSTOM
+        || bufferedImageType > BufferedImage.TYPE_BYTE_INDEXED)
+      throw new IllegalArgumentException ("invalid buffered image type");
+
+    return new ImageTypeSpecifier (new BufferedImage (1, 1, bufferedImageType));
+  }
+
+  /**
+   * Create an image type specifier that describes the given rendered
+   * image's type.
+   *
+   * @param image the rendered image
+   *
+   * @return a new image type specifier
+   *
+   * @exception IllegalArgumentException if image is null
+   */
+  public static ImageTypeSpecifier createFromRenderedImage (RenderedImage image)
+  {
+    if (image == null)
+      throw new IllegalArgumentException ("image null");
+
+    return new ImageTypeSpecifier (image);
+  }
+
+  /**
+   * Create a grayscale image type specifier, given the number of
+   * bits, data type and whether or not the data is signed.
+   *
+   * @param bits the number of bits used to specify a greyscale value
+   * @param dataType a DataBuffer type constant
+   * @param isSigned true if this type specifier should support
+   * negative values, false otherwise
+   *
+   * @return a greyscal image type specifier
+   *
+   * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or 16
+   * @exception IllegalArgumentException if dataType is not
+   * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+   * DataBuffer.TYPE_USHORT
+   * @exception if bits is larger than the number of bits in the given
+   * data type
+   */
+  public static ImageTypeSpecifier createGrayscale (int bits, int dataType, boolean isSigned)
+  {
+    return createGrayscale (bits, dataType, isSigned, false);
+  }
+
+  /**
+   * Create a grayscale image type specifier, given the number of
+   * bits, data type and whether or not the data is signed.
+   *
+   * @param bits the number of bits used to specify a greyscale value
+   * @param dataType a DataBuffer type constant
+   * @param isSigned true if this type specifier should support
+   * negative values, false otherwise
+   *
+   * @return a greyscal image type specifier
+   *
+   * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
+   * 16
+   * @exception IllegalArgumentException if dataType is not
+   * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+   * DataBuffer.TYPE_USHORT
+   * @exception if bits is larger than the number of bits in the given
+   * data type
+   */
+  public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
+                                                    boolean isSigned,
+                                                    boolean isAlphaPremultiplied)
+  {
+    if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
+      throw new IllegalArgumentException ("invalid bit size");
+
+    if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
+        && dataType != DataBuffer.TYPE_USHORT)
+      throw new IllegalArgumentException ("invalid data type");
+
+    if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
+      throw new IllegalArgumentException ("number of bits too large for data type");
+
+    // FIXME: this is probably wrong:
+    return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
+                                                         0x0, 0xff),
+                                   new MultiPixelPackedSampleModel (dataType,
+                                                                    1, 1,
+                                                                    bits));
+  }
+
+  /**
+   * Return an image type specifier for an image that uses an indexed
+   * colour model where each colour value has the specified number of
+   * bits and type and where the colour tables are those given.
+   *
+   * @param redLUT the red index values
+   * @param greenLUT the green index values
+   * @param blueLUT the blue index values
+   * @param alphaLUT the alpha index values
+   * @param bits the number of bits per index value
+   * @param dataType the type of each index value
+   *
+   * @return an indexed image type specifier
+   *
+   * @exception IllegalArgumentException if any of the colour arrays,
+   * not including alphaLUT, is null
+   * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
+   * 16
+   * @exception IllegalArgumentException if dataType is not
+   * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+   * DataBuffer.TYPE_USHORT
+   * @exception if bits is larger than the number of bits in the given
+   * data type
+   */
+  public static ImageTypeSpecifier createIndexed (byte[] redLUT,
+						  byte[] greenLUT,
+						  byte[] blueLUT,
+						  byte[] alphaLUT,
+						  int bits,
+						  int dataType)
+  {
+    if (redLUT == null || greenLUT == null || blueLUT == null)
+      throw new IllegalArgumentException ("null colour table");
+
+    if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
+      throw new IllegalArgumentException ("invalid bit size");
+
+    if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
+        && dataType != DataBuffer.TYPE_USHORT)
+      throw new IllegalArgumentException ("invalid data type");
+
+    if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
+      throw new IllegalArgumentException ("number of bits too large for data type");
+
+    // FIXME: this is probably wrong:
+    return new ImageTypeSpecifier (new IndexColorModel (bits, redLUT.length,
+                                                        redLUT, greenLUT, blueLUT,
+                                                        alphaLUT),
+                                   new MultiPixelPackedSampleModel (dataType,
+                                                                    1, 1,
+                                                                    bits));
+  }
+
+  /**
+   * Create an image type specifier that uses a component colour model
+   * and a pixel interleaved sample model.  Each pixel component will
+   * be stored in a separate value of the given data type.
+   *
+   * @param colorSpace the colour space used by the colour model
+   * @param bandOffsets the starting band offset for each band within
+   * its bank
+   * @param dataType the type of each pixel value
+   * @param hasAlpha true if an alpha channel should be specified,
+   * false otherwise
+   * @param isAlphaPremultiplied true if other colour channels should
+   * be premultiplied by the alpha value, false otherwise
+   *
+   * @return an interleaved image type specifier
+   *
+   * @exception IllegalArgumentException if either colorSpace or
+   * bandOffsets is null
+   * @excpetion IllegalArgumentException if the number of color space
+   * components, including the alpha component if requested, is
+   * different from bandOffsets.length
+   * @exception if dataType is not a valid DataBuffer constant
+   */
+  public static ImageTypeSpecifier createInterleaved (ColorSpace colorSpace,
+                                                      int[] bandOffsets,
+                                                      int dataType,
+                                                      boolean hasAlpha,
+                                                      boolean isAlphaPremultiplied)
+  {
+    if (colorSpace == null || bandOffsets == null)
+      throw new IllegalArgumentException ("null argument");
+
+    if (bandOffsets.length != (colorSpace.getNumComponents() + (hasAlpha ? 1 : 0)))
+      throw new IllegalArgumentException ("invalid bankOffsets length");
+
+    return new ImageTypeSpecifier (new ComponentColorModel (colorSpace,
+                                                            hasAlpha,
+                                                            isAlphaPremultiplied,
+                                                            hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE,
+                                                            dataType),
+                                   new PixelInterleavedSampleModel (dataType, 1, 1, 1, 1,
+                                                                    bandOffsets));
+  }
+
+  /**
+   * Create an image type specifier using a direct color model and a
+   * packed sample model.  All pixel components will be packed into
+   * one value of the given data type.
+   *
+   * @param colorSpace the color space to use in the color model
+   * @param redMask the bitmask for the red bits 
+   * @param greenMask the bitmask for the green bits 
+   * @param blueMask the bitmask for the blue bits 
+   * @param alphaMask the bitmask for the alpha bits 
+   * @param transferType the data type used to store pixel values
+   * @param isAlphaPremultiplied true if other colour channels should
+   * be premultiplied by the alpha value, false otherwise
+   *
+   * @return a packed image type specifier
+   *
+   * @exception IllegalArgumentException if colorSpace is null
+   * @exception IllegalArgumentException if colorSpace does not have
+   * type ColorSpace.TYPE_RGB
+   * @exception IllegalArgumentException if all masks are 0
+   * @exception IllegalArgumentException if dataType is not
+   * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+   * DataBuffer.TYPE_INT
+   */
+  public static ImageTypeSpecifier createPacked (ColorSpace colorSpace,
+                                                 int redMask,
+                                                 int greenMask,
+                                                 int blueMask,
+                                                 int alphaMask,
+                                                 int transferType,
+                                                 boolean isAlphaPremultiplied)
+  {
+    if (colorSpace == null)
+      throw new IllegalArgumentException ("null color space");
+
+    if (colorSpace.getType() != ColorSpace.TYPE_RGB)
+      throw new IllegalArgumentException ("invalid color space type");
+
+    if (redMask == 0 && greenMask == 0 && blueMask == 0 && alphaMask == 0)
+      throw new IllegalArgumentException ("no non-zero mask");
+
+    if (transferType != DataBuffer.TYPE_BYTE && transferType != DataBuffer.TYPE_USHORT
+        && transferType != DataBuffer.TYPE_INT)
+      throw new IllegalArgumentException ("invalid data type");
+
+    // Assume DataBuffer.TYPE_BYTE.
+    int numBits = 8;
+
+    if (transferType == DataBuffer.TYPE_SHORT)
+      numBits = 16;
+    else if (transferType == DataBuffer.TYPE_INT)
+      numBits = 32;
+
+    return new ImageTypeSpecifier (new DirectColorModel (colorSpace,
+                                                         numBits,
+                                                         redMask,
+                                                         greenMask,
+                                                         blueMask,
+                                                         alphaMask,
+                                                         isAlphaPremultiplied,
+                                                         transferType),
+                                   new MultiPixelPackedSampleModel (transferType,
+                                                                    1, 1, numBits));
+  }
+
+  /**
+   * Get the number of bits per sample in the given band.
+   *
+   * @param band the band from which to get the number of bits
+   *
+   * @return the number of bits in the given band
+   *
+   * @exception IllegalArgumentException if band is out-of-bounds
+   */
+  public int getBitsPerBand (int band)
+  {
+    if (band < 0 || band > sampleModel.getNumBands())
+      throw new IllegalArgumentException ("band out-of-bounds");
+
+    return sampleModel.getSampleSize (band);
+  }
+
+  /**
+   * Get the buffered image constant specified by this image type
+   * specifier.
+   *
+   * @return a buffered image constant
+   */
+  public int getBufferedImageType ()
+  {
+    // FIXME:
+    return BufferedImage.TYPE_INT_RGB;
+  }
+
+  /**
+   * Create a sample model that is compatible with the one specified
+   * by this image type specifier, with the given dimensions.
+   *
+   * @param width the width of the returned sample model
+   * @param height the height of the returned sample model
+   *
+   * @return a sample model compatible with the one in this image type
+   * specifier, with the given dimensions
+   *
+   * @exception IllegalArgumentException if either width or height is
+   * less than or equal to 0
+   * @exception IllegalArgumentException if width * height is greater
+   * than Intere.MAX_VALUE
+   */
+  public SampleModel getSampleModel (int width, int height)
+  {
+    if (width <= 0 || height <= 0)
+      throw new IllegalArgumentException ("invalid dimension");
+
+    // test for overflow
+    if (width * height < Math.min (width, height))
+      throw new IllegalArgumentException ("width * height > Integer.MAX_VALUE");
+
+    return sampleModel.createCompatibleSampleModel (width, height);
+  }
+
+  /**
+   * Get the color model specified by this image type specifier.
+   *
+   * @return the color model
+   */
+  public ColorModel getColorModel()
+  {
+    return colorModel;
+  }
+
+  /**
+   * Get the number of bands specified by this image type specifier's
+   * sample model.
+   *
+   * @return the number of bands in the sample model
+   */
+  public int getNumBands()
+  {
+    return sampleModel.getNumBands();
+  }
+
+  /**
+   * Get the number of components specified by this image type
+   * specifier's color model.
+   *
+   * @return the number of color components per pixel
+   */
+  public int getNumComponents()
+  {
+    return colorModel.getNumComponents();
+  }
+
+  /**
+   * Get the sample model specified by this image type specifier.
+   *
+   * @return the sample model
+   */
+  public SampleModel getSampleModel()
+  {
+    return sampleModel;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriteParam.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriteParam.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriteParam.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriteParam.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,495 @@
+/* ImageWriteParam.java --
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.Dimension;
+import java.util.Locale;
+
+/**
+ * DOCUMENT ME
+ */
+public class ImageWriteParam extends IIOParam
+{
+  
+  /** 
+   * Can be passed to setTilingMode, setProgressiveMode and
+   * setCompressionMode to disable feature.
+   */
+  public static final int MODE_DISABLED = 0;
+  
+  /** 
+   * Can be passed to setTilingMode, setProgressiveMode and 
+   * setCompressionMode to enable feature.
+   */
+  public static final int MODE_DEFAULT = 1;
+  
+  /** 
+   * Can be passed to setTilingMode, setCompressionMode to disable feature.
+   */
+  public static final int MODE_EXPLICIT = 2;
+  
+  /** 
+   * Can be passed to setTilingMode, setProgressiveMode and 
+   * setCompressionMode to enable feature.
+   */
+  public static final int MODE_COPY_FROM_METADATA = 3;
+  
+  /**
+   * True if tiling grid offset parameters can be set.
+   */
+  protected boolean canOffsetTiles;
+  
+  /**
+   * True if this writer can write images using compression.
+   */
+  protected boolean canWriteCompressed;
+  
+  /**
+   * True if images can be written as a progressive sequence
+   * of increasing quality.
+   */
+  protected boolean canWriteProgressive;
+  
+  /**
+   * True if tile width and height parameters can be set.
+   */
+  protected boolean canWriteTiles;
+  
+  /**
+   * Controls compression settings, which must be set to one of the four
+   * MODE_* values.
+   */
+  protected int compressionMode = MODE_COPY_FROM_METADATA;
+  
+  /**
+   * Contains the current compression quality setting.
+   */
+  protected float compressionQuality;
+  
+  /**
+   * Contains the name of the current compression type.
+   */
+  protected String compressionType;
+  
+  /**
+   * Array of the names of the available compression types.
+   */
+  protected String[] compressionTypes;
+  
+  /**
+   * Localizes compression type names and quality descriptions,
+   * or null to use default Locale.
+   */
+  protected Locale locale;
+  
+  /**
+   * Preferred tile size range pairs.
+   */
+  protected Dimension[] preferredTileSizes;
+  
+  /**
+   * The mode controlling progressive encoding, which must
+   * be set to one of the four MODE_* values, except
+   * MODE_EXPLICIT.
+   */
+  protected int progressiveMode = MODE_COPY_FROM_METADATA;
+  
+  /**
+   * The amount by which the tile grid origin should be offset
+   * horizontally from the image origin if tiling has been set.
+   */
+  protected int tileGridXOffset;
+  
+  /**
+   * The amount by which the tile grid origin should be offset
+   * vertically from the image origin if tiling has been set.
+   */
+  protected int tileGridYOffset;
+  
+  /**
+   * The height of each tile if tiling has been set.
+   */
+  protected int tileHeight;
+  
+  /**
+   * The width of each tile if tiling has been set.
+   */
+  protected int tileWidth;
+  
+  /**
+   * The mode controlling tiling settings, which must be
+   * set to one of the four MODE_* values.
+   */
+  protected int tilingMode;
+  
+  /**
+   * True if the tiling parameters have been specified.
+   */
+  protected boolean tilingSet;
+
+  /**
+   * Creates an empty <code>ImageWriteParam</code> object.
+   * The subclass is responsible to initialize all fields.
+   */
+  protected ImageWriteParam()
+  {
+    // Do nothing here.
+  }
+
+  /**
+   * Creates an <code>ImageWriteParam</code> object with the given locale.
+   *
+   * @param locale the locale to use for user visible strings
+   */
+  public ImageWriteParam(Locale locale)
+  {
+    this.locale = locale;
+  }
+
+  public float getBitRate(float quality)
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();
+
+    return -1.0f;
+  }
+
+  private void checkSupportsCompression()
+  {
+    if (! canWriteCompressed())
+      throw new UnsupportedOperationException("compression not supported");
+  }
+
+  private void checkNotExplicitCompression()
+  {
+    if (getCompressionMode() != MODE_EXPLICIT)
+      throw new IllegalStateException("compression mode is not MODE_EXPLICIT");
+  }
+  
+  private void checkCompressionTypesSet()
+  {
+    if (getCompressionType() == null
+	&& getCompressionTypes() != null)
+      throw new IllegalStateException("no compression type set");
+  }
+
+  private void checkSupportsProgressiveEncoding()
+  {
+    if (! canWriteProgressive())
+      throw new UnsupportedOperationException
+	("progressive output not supported");
+  }
+  
+  private void checkSupportsTiling()
+  {
+    if (! canWriteTiles())
+      throw new UnsupportedOperationException("tiling not supported");
+  }
+
+  private void checkNotExplicitTiling()
+  {
+    if (getTilingMode() != MODE_EXPLICIT)
+      throw new IllegalStateException("tiling mode not MODE_EXPLICIT");
+  }
+
+  private void checkTilingInitialized()
+  {
+    if (! tilingSet)
+      throw new IllegalStateException("tiling parameters not set");
+  }
+
+  private void checkMode(int mode)
+  {
+    if (mode < MODE_DISABLED || mode > MODE_COPY_FROM_METADATA)
+      throw new IllegalArgumentException("mode not supported");
+  }
+
+  public boolean canOffsetTiles()
+  {
+    return canOffsetTiles;
+  }
+
+  public boolean canWriteCompressed()
+  {
+    return canWriteCompressed;
+  }
+
+  public boolean canWriteProgressive()
+  {
+    return canWriteProgressive;
+  }
+
+  public boolean canWriteTiles()
+  {
+    return canWriteTiles;
+  }
+
+  public int getCompressionMode()
+  {
+    checkSupportsCompression();
+
+    return compressionMode;
+  }
+
+  public float getCompressionQuality()
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();
+
+    return compressionQuality;
+  }
+
+  public String[] getCompressionQualityDescriptions()
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();;
+    
+    return null;
+  }
+
+  public float[] getCompressionQualityValues()
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();;
+    
+    return null;
+  }
+
+  public String getCompressionType()
+  {
+    checkNotExplicitCompression();
+
+    return compressionType;
+  }
+
+  public String[] getCompressionTypes()
+  {
+    checkSupportsCompression();
+
+    return compressionTypes != null ? (String[]) compressionTypes.clone() : null;
+  }
+
+  public Locale getLocale()
+  {
+    return locale;
+  }
+
+  public String getLocalizedCompressionTypeName()
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();
+
+    return getCompressionType();
+  }
+
+  public Dimension[] getPreferredTileSizes()
+  {
+    checkSupportsTiling();
+
+    return preferredTileSizes;
+  }
+
+  public int getProgressiveMode()
+  {
+    checkSupportsProgressiveEncoding();
+
+    return progressiveMode;
+  }
+
+  public int getTileGridXOffset()
+  {
+    checkNotExplicitTiling();
+    checkTilingInitialized();
+
+    return tileGridXOffset;
+  }
+
+  public int getTileGridYOffset()
+  {
+    checkNotExplicitTiling();
+    checkTilingInitialized();
+
+    return tileGridYOffset;
+  }
+
+  public int getTileHeight()
+  {
+    checkNotExplicitTiling();
+    checkTilingInitialized();
+
+    return tileHeight;
+  }
+
+  public int getTileWidth()
+  {
+    checkNotExplicitTiling();
+    checkTilingInitialized();
+
+    return tileWidth;
+  }
+
+  public int getTilingMode()
+  {
+    checkSupportsTiling();
+
+    return tilingMode;
+  }
+
+  public boolean isCompressionLossless()
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();
+
+    return true;
+  }
+
+  public void setCompressionMode(int mode)
+  {
+    checkSupportsCompression();
+    checkMode(mode);
+    
+    compressionMode = mode;
+    
+    if (mode == MODE_EXPLICIT)
+      unsetCompression();
+  }
+
+  public void setCompressionQuality(float quality)
+  {
+    checkNotExplicitCompression();
+    checkCompressionTypesSet();
+
+    if (quality < 0.0f || quality > 1.0f)
+      throw new IllegalArgumentException("quality out of range");
+
+    compressionQuality = quality;
+  }
+
+  public void setCompressionType(String compressionType)
+  {
+    checkNotExplicitCompression();
+
+    String[] types = getCompressionTypes();
+
+    if (types == null)
+      throw new UnsupportedOperationException("no settable compression types");
+    
+    if (compressionType == null)
+      this.compressionType = null;
+
+    for (int i = types.length - 1; i >= 0; --i)
+      if (types[i].equals(compressionType))
+	{
+	  this.compressionType = compressionType;
+	  return;
+	}
+    
+    throw new IllegalArgumentException("unknown compression type");
+  }
+
+  public void setProgressiveMode(int mode)
+  {
+    checkSupportsProgressiveEncoding();
+    checkMode(mode);
+    
+    progressiveMode = mode;
+  }
+
+  public void setTiling(int tileWidth, int tileHeight,
+		        int tileGridXOffset, int tileGridYOffset)
+  {
+    checkNotExplicitTiling();
+
+    if (! canOffsetTiles
+	&& tileGridXOffset != 0
+	&& tileGridYOffset != 0)
+      throw new UnsupportedOperationException("tile offsets not supported");
+
+    if (tileWidth < 0 || tileHeight < 0)
+      throw new IllegalArgumentException("negative tile dimension");
+
+    if (preferredTileSizes != null)
+      {
+	boolean found = false;
+
+	for (int i = 0; i < preferredTileSizes.length; i += 2)
+	  {
+	    if (tileWidth >= preferredTileSizes[i].width
+		&& tileWidth <= preferredTileSizes[i + 1].width
+		&& tileHeight >= preferredTileSizes[i].height
+		&& tileHeight <= preferredTileSizes[i + 1].height)
+	      found = true;
+	  }
+
+	if (! found)
+          throw new IllegalArgumentException("illegal tile size");
+      }
+
+    this.tilingSet = true;
+    this.tileWidth = tileWidth;
+    this.tileHeight = tileHeight;
+    this.tileGridXOffset = tileGridXOffset;
+    this.tileGridYOffset = tileGridYOffset;
+  }
+
+  public void setTilingMode(int mode)
+  {
+    checkSupportsTiling();
+    checkMode(mode);
+    tilingMode = mode;
+  }
+
+  public void unsetCompression()
+  {
+    checkNotExplicitCompression();
+    
+    compressionType = null;
+    compressionQuality = 1.0F;
+  }
+
+  public void unsetTiling()
+  {
+    checkNotExplicitTiling();
+    
+    tileWidth = 0;
+    tileHeight = 0;
+    tileGridXOffset = 0;
+    tileGridYOffset = 0;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/ImageWriter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1389 @@
+/* ImageWriter.java -- Encodes raster images.
+   Copyright (C) 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 javax.imageio;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+import javax.imageio.event.IIOWriteProgressListener;
+import javax.imageio.event.IIOWriteWarningListener;
+import javax.imageio.metadata.IIOMetadata;
+
+import javax.imageio.spi.ImageWriterSpi;
+
+/**
+ * A class for encoding images within the ImageIO framework.
+ *
+ * An ImageWriter for a given format is instantiated by an
+ * ImageWriterSpi for that format.  ImageWriterSpis are registered
+ * with the IIORegistry.
+ *
+ * The ImageWriter API supports writing animated images that may have
+ * multiple frames; to support such images many methods take an index
+ * parameter.
+ *
+ * Images may also be written in multiple passes, where each
+ * successive pass increases the level of detail in the destination
+ * image.
+ */
+public abstract class ImageWriter
+  implements ImageTranscoder
+{
+  private boolean aborted;
+  
+  /**
+   * All locales available for localization of warning messages, or
+   * null if localization is not supported.
+   */
+  protected Locale[] availableLocales = null;
+
+  /**
+   * The current locale used to localize warning messages, or null if
+   * no locale has been set.
+   */
+  protected Locale locale = null;
+
+  /**
+   * The image writer SPI that instantiated this writer.
+   */
+  protected ImageWriterSpi originatingProvider = null;
+
+  /**
+   * An ImageInputStream to which image data is written.
+   */
+  protected Object output = null;
+
+  /**
+   * A list of installed progress listeners.  Initially null, meaning
+   * no installed listeners.
+   */
+  protected List progressListeners = null;
+
+  /**
+   * A list of installed warning listeners.  Initially null, meaning
+   * no installed listeners.
+   */
+  protected List warningListeners = null;
+
+  /**
+   * A list of warning locales corresponding with the list of
+   * installed warning listeners.  Initially null, meaning no locales.
+   */
+  protected List warningLocales = null;
+
+  /**
+   * Construct an image writer.
+   *
+   * @param originatingProvider the provider that is constructing this
+   * image writer, or null
+   */
+  protected ImageWriter(ImageWriterSpi originatingProvider)
+  {
+    this.originatingProvider = originatingProvider;
+  }
+
+  /**
+   * Throw an IllegalStateException if output is null.
+   *
+   * @exception IllegalStateException if output is null
+   */
+  private void checkOutputSet()
+  {
+    if (output == null)
+      throw new IllegalStateException("no output set");
+  }
+  
+  /**
+   * Request that writing be aborted.  The unwritten portions of the
+   * destination image will be undefined.
+   *
+   * Writers should clear the abort flag before starting a write
+   * operation, then poll it periodically during the write operation.
+   */
+  public void abort()
+  {
+    aborted = true;
+  }
+
+  /**
+   * Check if the abort flag is set.
+   *
+   * @return true if the current write operation should be aborted,
+   * false otherwise
+   */
+  protected boolean abortRequested()
+  {
+    return aborted;
+  }
+
+  /**
+   * Install a write progress listener.  This method will return
+   * immediately if listener is null.
+   *
+   * @param listener a write progress listener or null
+   */
+  public void addIIOWriteProgressListener(IIOWriteProgressListener listener)
+  {
+    if (listener == null)
+      return;
+    if (progressListeners == null)
+      progressListeners = new ArrayList ();
+    progressListeners.add(listener);
+  }
+
+  /**
+   * Install a write warning listener.  This method will return
+   * immediately if listener is null.  Warning messages sent to this
+   * listener will be localized using the current locale.  If the
+   * current locale is null then this writer will select a sensible
+   * default.
+   *
+   * @param listener a write warning listener
+   */
+  public void addIIOWriteWarningListener (IIOWriteWarningListener listener)
+  {
+    if (listener == null)
+      return;
+    if (warningListeners == null)
+      warningListeners = new ArrayList ();
+    warningListeners.add(listener);
+  }
+
+  /**
+   * Check whether a new empty image can be inserted at the given
+   * frame index.  Pixel values may be filled in later using the
+   * replacePixels methods.  Indices greater than the insertion index
+   * will be incremented.  If imageIndex is -1, the image will be
+   * appended at the end of the current image list.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return true if an empty image can be inserted at imageIndex,
+   * false otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IndexOutOfBoundsException if imageIndex is less than
+   * -1 or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public boolean canInsertEmpty(int imageIndex)
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check whether an image can be inserted at the given frame index.
+   * Indices greater than the insertion index will be incremented.  If
+   * imageIndex is -1, the image will be appended at the end of the
+   * current image list.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return true if an image can be inserted at imageIndex, false
+   * otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IndexOutOfBoundsException if imageIndex is less than
+   * -1 or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public boolean canInsertImage(int imageIndex)
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check whether an image can be removed from the given frame index.
+   * Indices greater than the removal index will be decremented.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return true if an image can be removed from imageIndex, false
+   * otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IndexOutOfBoundsException if imageIndex is less than 0
+   * or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public boolean canRemoveImage(int imageIndex)
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check whether the metadata associated the image at the given
+   * frame index can be replaced.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return true if the metadata associated with the image at
+   * imageIndex can be replaced, false otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IndexOutOfBoundsException if imageIndex is less than 0
+   * or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public boolean canReplaceImageMetadata(int imageIndex)
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check whether the pixels within the image at the given index can
+   * be replaced.
+   *
+   * @param imageIndex the frame index
+   *
+   * @return true if the pixels in the image at imageIndex can be
+   * replaced, false otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IndexOutOfBoundsException if imageIndex is less than 0
+   * or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public boolean canReplacePixels(int imageIndex)
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check whether the metadata associated the entire image stream can
+   * be replaced.
+   *
+   * @return true if the stream metadata can be replaced, false
+   * otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IOException if a write error occurs
+   */
+  public boolean canReplaceStreamMetadata()
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check whether an entire empty image, including empty metadata and
+   * empty thumbnails, can be written to the output stream, leaving
+   * pixel values to be filled in later using the replacePixels
+   * methods.
+   *
+   * @return true if an entire empty image can be written before its
+   * contents are filled in, false otherwise
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IOException if a write error occurs
+   */
+  public boolean canWriteEmpty()
+    throws IOException
+  {
+    checkOutputSet();
+    return false;
+  }
+
+  /**
+   * Check if IIOImages containing raster data are supported.
+   *
+   * @return true if raster IIOImages are supported, false otherwise
+   */
+  public boolean canWriteRasters()
+  {
+    return false;
+  }
+
+  /**
+   * Check if an image can be appended at the end of the current list
+   * of images even if prior images have already been written.
+   *
+   * @return true if sequences of images can be written, false
+   * otherwise
+   */
+  public boolean canWriteSequence()
+  {
+    return false;
+  }
+
+  /**
+   * Clear the abort flag.
+   */
+  protected void clearAbortRequest()
+  {
+    aborted = false;
+  }
+
+  /**
+   * Convert IIOMetadata from an input reader format, returning an
+   * IIOMetadata suitable for use by an image writer.
+   *
+   * The ImageTypeSpecifier specifies the destination image type.
+   *
+   * An optional ImageWriteParam argument is available in case the
+   * image writing parameters affect the metadata conversion.
+   *
+   * @param inData the metadata coming from an image reader
+   * @param imageType the output image type of the writer
+   * @param param the image writing parameters or null
+   *
+   * @return the converted metadata that should be used by the image
+   * writer, or null if this ImageTranscoder has no knowledge of the
+   * input metadata
+   *
+   * @exception IllegalArgumentException if either inData or imageType
+   * is null
+   */
+  public abstract IIOMetadata convertImageMetadata (IIOMetadata inData,
+		                                    ImageTypeSpecifier imageType,
+				                    ImageWriteParam param);
+
+  /**
+   * Convert IIOMetadata from an input stream format, returning an
+   * IIOMetadata suitable for use by an image writer.
+   *
+   * An optional ImageWriteParam argument is available in case the
+   * image writing parameters affect the metadata conversion.
+   *
+   * @param inData the metadata coming from an input image stream
+   * @param param the image writing parameters or null
+   *
+   * @return the converted metadata that should be used by the image
+   * writer, or null if this ImageTranscoder has no knowledge of the
+   * input metadata
+   *
+   * @exception IllegalArgumentException if inData is null
+   */
+  public abstract IIOMetadata convertStreamMetadata (IIOMetadata inData,
+					             ImageWriteParam param);
+
+  /**
+   * Releases any resources allocated to this object.  Subsequent
+   * calls to methods on this object will produce undefined results.
+   *
+   * The default implementation does nothing; subclasses should use
+   * this method ensure that native resources are released.
+   */
+  public void dispose()
+  {
+    // The default implementation is empty. Subclasses have to overwrite it.
+  }
+  
+  /**
+   * Retrieve the available locales.  Return null if no locales are
+   * available or a clone of availableLocales.
+   *
+   * @return an array of locales or null
+   */
+  public Locale[] getAvailableLocales()
+  {
+    return availableLocales;
+  }
+
+  /**
+   * Get a metadata object appropriate for encoding an image specified
+   * by the given image type specifier and optional image write
+   * parameters.
+   *
+   * @param imageType an image type specifier
+   * @param param image writing parameters, or null
+   *
+   * @return a metadata object appropriate for encoding an image of
+   * the given type with the given parameters
+   */
+  public abstract IIOMetadata getDefaultImageMetadata (ImageTypeSpecifier imageType, ImageWriteParam param);
+
+  /**
+   * Get a metadata object appropriate for encoding the default image
+   * type handled by this writer, optionally considering image write
+   * parameters.
+   *
+   * @param param image writing parameters, or null
+   *
+   * @return a metadata object appropriate for encoding an image of
+   * the default type with the given parameters
+   */
+  public abstract IIOMetadata getDefaultStreamMetadata (ImageWriteParam param);
+
+  /**
+   * Retrieve the default write parameters for this writer's image
+   * format.
+   *
+   * The default implementation returns new ImageWriteParam().
+   *
+   * @return image writing parameters
+   */
+  public ImageWriteParam getDefaultWriteParam()
+  {
+    return new ImageWriteParam(getLocale());
+  }
+
+  /**
+   * Get this writer's locale.  null is returned if the locale has not
+   * been set.
+   *
+   * @return this writer's locale, or null
+   */
+  public Locale getLocale()
+  {
+    return locale;
+  }
+
+  /**
+   * Get the number of thumbnails supported by this image writer,
+   * based on the given image type, image writing parameters, and
+   * stream and image metadata.  The image writing parameters are
+   * optional, in case they affect the number of thumbnails supported.
+   *
+   * @param imageType an image type specifier, or null
+   * @param param image writing parameters, or null
+   * @param streamMetadata the metadata associated with this stream,
+   * or null
+   * @param imageMetadata the metadata associated with this image, or
+   * null
+   *
+   * @return the number of thumbnails that this writer supports
+   * writing or -1 if the given information is insufficient
+   */
+  public int getNumThumbnailsSupported (ImageTypeSpecifier imageType,
+                                        ImageWriteParam param,
+		                        IIOMetadata streamMetadata,
+                                        IIOMetadata imageMetadata)
+  {
+    return 0;
+  }
+
+  /**
+   * Get the ImageWriterSpi that created this writer or null.
+   *
+   * @return an ImageWriterSpi, or null
+   */
+  public ImageWriterSpi getOriginatingProvider()
+  {
+    return originatingProvider;
+  }
+
+  /**
+   * Get this reader's image output destination.  null is returned if
+   * the image destination has not been set.
+   *
+   * @return an image output destination object, or null
+   */
+  public Object getOutput()
+  {
+    return output;
+  }
+
+  /**
+   * Get the preferred sizes for thumbnails based on the given image
+   * type, image writing parameters, and stream and image metadata.
+   * The preferred sizes are returned in pairs of dimension values;
+   * the first value in the array is a dimension object representing
+   * the minimum thumbnail size, the second value is a dimension
+   * object representing a maximum thumbnail size.  The writer can
+   * select a size within the range given by each pair, or it can
+   * ignore these size hints.
+   *
+   * @param imageType an image type specifier, or null
+   * @param param image writing parameters, or null
+   * @param streamMetadata the metadata associated with this stream,
+   * or null
+   * @param imageMetadata the metadata associated with this image, or
+   * null
+   *
+   * @return an array of dimension pairs whose length is a multiple of
+   * 2, or null if there is no preferred size (any size is allowed) or
+   * if the size is unknown (insufficient information was provided)
+   */
+  public Dimension[] getPreferredThumbnailSizes (ImageTypeSpecifier imageType,
+		                                 ImageWriteParam param,
+						 IIOMetadata streamMetadata,
+						 IIOMetadata imageMetadata)
+  {
+    return null;
+  }
+
+  /**
+   * Notifies all installed write progress listeners that image
+   * loading has completed by calling their imageComplete methods.
+   */
+  protected void processImageComplete()
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.imageComplete(this);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed write progress listeners that a certain
+   * percentage of the image has been loaded, by calling their
+   * imageProgress methods.
+   *
+   * @param percentageDone the percentage of image data that has been
+   * loaded
+   */
+  protected void processImageProgress(float percentageDone)
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.imageProgress(this, percentageDone);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed write progress listeners, by calling their
+   * imageStarted methods, that image loading has started on the given
+   * image.
+   *
+   * @param imageIndex the frame index of the image that has started
+   * loading
+   */
+  protected void processImageStarted(int imageIndex)
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.imageStarted(this, imageIndex);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed write progress listeners, by calling their
+   * thumbnailComplete methods, that a thumbnail has completed
+   * loading.
+   */
+  protected void processThumbnailComplete()
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.thumbnailComplete(this);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed write progress listeners that a certain
+   * percentage of a thumbnail has been loaded, by calling their
+   * thumbnailProgress methods.
+   *
+   * @param percentageDone the percentage of thumbnail data that has
+   * been loaded
+   */
+  protected void processThumbnailProgress(float percentageDone)
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.thumbnailProgress(this, percentageDone);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed write progress listeners, by calling their
+   * imageStarted methods, that thumbnail loading has started on the
+   * given thumbnail of the given image.
+   *
+   * @param imageIndex the frame index of the image one of who's
+   * thumbnails has started loading
+   * @param thumbnailIndex the index of the thumbnail that has started
+   * loading
+   */
+  protected void processThumbnailStarted(int imageIndex, int thumbnailIndex)
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed warning listeners, by calling their
+   * warningOccurred methods, that a warning message has been raised.
+   *
+   * @param imageIndex the index of the image that was being written
+   * when the warning was raised
+   * @param warning the warning message
+   *
+   * @exception IllegalArgumentException if warning is null
+   */
+  protected void processWarningOccurred(int imageIndex, String warning)
+  {
+     if (warningListeners != null)
+      {
+	Iterator it = warningListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteWarningListener listener =
+	      (IIOWriteWarningListener) it.next();
+	    listener.warningOccurred(this, imageIndex, warning);
+	  }
+      }
+  }
+
+  /**
+   * Notify all installed warning listeners, by calling their
+   * warningOccurred methods, that a warning message has been raised.
+   * The warning message is retrieved from a resource bundle, using
+   * the given basename and keyword.
+   *
+   * @param imageIndex the index of the image that was being written
+   * when the warning was raised
+   * @param baseName the basename of the resource from which to
+   * retrieve the warning message
+   * @param keyword the keyword used to retrieve the warning from the
+   * resource bundle
+   *
+   * @exception IllegalArgumentException if either baseName or keyword
+   * is null
+   * @exception IllegalArgumentException if no resource bundle is
+   * found using baseName
+   * @exception IllegalArgumentException if the given keyword produces
+   * no results from the resource bundle
+   * @exception IllegalArgumentException if the retrieved object is
+   * not a String
+   */
+  protected void processWarningOccurred(int imageIndex,
+					String baseName,
+					String keyword)
+  {
+    if (baseName == null || keyword == null)
+      throw new IllegalArgumentException ("null argument");
+
+    ResourceBundle b = null;
+
+    try
+      {
+	b = ResourceBundle.getBundle(baseName, getLocale());
+      }
+    catch (MissingResourceException e)
+      {
+	throw new IllegalArgumentException ("no resource bundle found");
+      }
+
+    Object str = null;
+
+    try
+      {
+	str = b.getObject(keyword);
+      }
+    catch (MissingResourceException e)
+      {
+	throw new IllegalArgumentException ("no results found for keyword");
+      }
+
+    if (! (str instanceof String))
+      throw new IllegalArgumentException ("retrieved object not a String");
+
+    String warning = (String) str;
+
+    if (warningListeners != null)
+      {
+	Iterator it = warningListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteWarningListener listener =
+	      (IIOWriteWarningListener) it.next();
+	    listener.warningOccurred(this, imageIndex, warning);
+	  }
+      }
+  }
+
+  /**
+   * Notifies all installed write progress listeners that image
+   * loading has been aborted by calling their writeAborted methods.
+   */
+  protected void processWriteAborted() 
+  {
+    if (progressListeners != null)
+      {
+	Iterator it = progressListeners.iterator();
+
+	while (it.hasNext())
+	  {
+	    IIOWriteProgressListener listener =
+	      (IIOWriteProgressListener) it.next();
+	    listener.writeAborted(this);
+	  }
+      }
+  }
+
+  /**
+   * Uninstall all write progress listeners.
+   */
+  public void removeAllIIOWriteProgressListeners()
+  {
+    if (progressListeners != null)
+      {
+	progressListeners.clear();
+      }
+  }
+
+  /**
+   * Uninstall all write warning listeners.
+   */
+  public void removeAllIIOWriteWarningListeners()
+  {
+    if (progressListeners != null)
+      {
+	progressListeners.clear();
+      }
+  }
+
+  /**
+   * Uninstall the given write progress listener.
+   *
+   * @param listener the listener to remove
+   */
+  public void removeIIOWriteProgressListener (IIOWriteProgressListener listener)
+  {
+    if (listener == null)
+      return;
+    if (progressListeners != null)
+      {
+	progressListeners.remove(listener);
+      }
+  }
+  /**
+   * Uninstall the given write warning listener.
+   *
+   * @param listener the listener to remove
+   */
+  public void removeIIOWriteWarningListener (IIOWriteWarningListener listener)
+  {
+    if (listener == null)
+      return;
+    if (warningListeners != null)
+      {
+	warningListeners.remove(listener);
+      }
+  }
+  /**
+   * Reset this writer's internal state.
+   */
+  public void reset()
+  {
+    setOutput(null);
+    setLocale(null);
+    removeAllIIOWriteWarningListeners();
+    removeAllIIOWriteProgressListeners();
+    clearAbortRequest();
+  }
+  
+  /**
+   * Set the current locale or use the default locale.
+   *
+   * @param locale the locale to set, or null
+   */
+  public void setLocale(Locale locale)
+  {
+    if (locale != null)
+      {
+	// Check if its a valid locale.
+	boolean found = false;
+
+	if (availableLocales != null)
+	  for (int i = availableLocales.length - 1; i >= 0; --i)
+	    if (availableLocales[i].equals(locale))
+	      found = true;
+
+	if (! found)
+	  throw new IllegalArgumentException("looale not available");
+      }
+
+    this.locale = locale;
+  }
+
+  /**
+   * Set the output destination of the given object.  The output
+   * destination must be set before many methods can be called on this
+   * writer. (see all ImageWriter methods that throw
+   * IllegalStateException).  If input is null then the current input
+   * source will be removed.
+   *
+   * @param input the output destination object
+   *
+   * @exception IllegalArgumentException if input is not a valid input
+   * source for this writer and is not an ImageInputStream
+   */
+  public void setOutput(Object output)
+  {
+    if (output != null)
+      {
+	// Check if its a valid output object.
+	boolean found = false;
+	Class[] types = null;
+
+	if (originatingProvider != null)
+	  types = originatingProvider.getOutputTypes();
+        
+	if (types != null)
+	  for (int i = types.length - 1; i >= 0; --i)
+            if (types[i].isInstance(output))
+              found = true;
+
+	if (! found)
+	  throw new IllegalArgumentException("output type not available");
+      }
+
+    this.output = output;
+  }
+
+  /**
+   * Write an image stream, including thumbnails and metadata to the
+   * output stream.  The output must have been set prior to this
+   * method being called.  Metadata associated with the stream may be
+   * supplied, or it can be left null.  IIOImage may contain raster
+   * data if this writer supports rasters, or it will contain a
+   * rendered image.  Thumbnails are resized if need be.  Image
+   * writing parameters may be specified to affect writing, or may be
+   * left null.
+   *
+   * @param streamMetadata metadata associated with this stream, or
+   * null
+   * @param image an IIOImage containing image data, metadata and
+   * thumbnails to be written
+   * @param param image writing parameters, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if image contains raster
+   * data but this writer does not support rasters
+   * @exception IllegalArgumentException if image is null
+   * @exception IOException if a write error occurs
+   */
+  public abstract void write (IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param)
+    throws IOException;
+
+  /**
+   * Complete inserting an empty image in the output stream.
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if inserting empty
+   * images is not supported
+   * @exception IllegalArgumentException if a call to
+   * prepareInsertEmpty was not called previous to this method being
+   * called (a sequence of prepareInsertEmpty calls must be terminated
+   * by a call to endInsertEmpty)
+   * @exception IllegalArgumentException if prepareWriteEmpty was
+   * called before this method being called (without a terminating
+   * call to endWriteEmpty)
+   * @exception IllegalArgumentException if prepareReplacePixels was
+   * called before this method being called (without a terminating
+   * call to endReplacePixels)
+   * @exception IOException if a write error occurs
+   */
+  public void endInsertEmpty ()
+    throws IOException
+  {
+    if (!canInsertEmpty(0))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Complete replacing pixels in an image in the output stream.
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if replacing pixels is
+   * not supported by this writer
+   * @exception IllegalArgumentException if prepareReplacePixels was
+   * not called before this method being called
+   * @exception IOException if a write error occurs
+   */
+  public void endReplacePixels ()
+    throws IOException
+  {
+    if (!canReplacePixels(0))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Complete writing an empty image to the image output stream.
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if writing empty images
+   * is not supported
+   * @exception IllegalArgumentException if a call to
+   * prepareWriteEmpty was not called previous to this method being
+   * called (a sequence of prepareWriteEmpty calls must be terminated
+   * by a call to endWriteEmpty)
+   * @exception IllegalArgumentException if prepareInsertEmpty was
+   * called before this method being called (without a terminating
+   * call to endInsertEmpty)
+   * @exception IllegalArgumentException if prepareReplacePixels was
+   * called before this method being called (without a terminating
+   * call to endReplacePixels)
+   * @exception IOException if a write error occurs
+   */
+  public void endWriteEmpty ()
+    throws IOException
+  {
+    if (!canWriteEmpty())
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Complete writing a sequence of images to the output stream.  This
+   * method may patch header data and write out footer data.
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IllegalStateException if prepareWriteSequence has not
+   * been called
+   * @exception UnsupportedOperationException if writing a sequence of
+   * images is not supported
+   * @exception IOException if a write error occurs
+   */
+  public void endWriteSequence ()
+    throws IOException
+  {
+    checkOutputSet();
+    if (!canWriteSequence())
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Start inserting an empty image in the image output stream.  All
+   * indices after the specified index are incremented.  An index of
+   * -1 implies that the empty image should be appended to the end of
+   * the current image list.
+   *
+   * The insertion that this method call starts is not complete until
+   * endInsertEmpty is called.  prepareInsertEmpty cannot be called
+   * again until endInsertEmpty is called and calls to
+   * prepareWriteEmpty and prepareInsertEmpty may not be intersperced.
+   *
+   * @param imageIndex the image index
+   * @param imageType the image type specifier
+   * @param width the image width
+   * @param height the image height
+   * @param imageMetadata the image metadata, or null
+   * @param thumbnails a list of thumbnails, or null
+   * @param param image write parameters, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if inserting empty
+   * images is not supported
+   * @exception IndexOutOfBoundsException if imageIndex is less than
+   * -1 or greater than the last index in the current image list
+   * @exception IllegalStateException if a previous call to
+   * prepareInsertEmpty was made (without a terminating call to
+   * endInsertEmpty)
+   * @exception IllegalStateException if a previous call to
+   * prepareWriteEmpty was made (without a terminating call to
+   * endWriteEmpty)
+   * @exception IllegalArgumentException if imageType is null or
+   * thumbnails contain non-BufferedImage objects
+   * @exception IllegalArgumentException if either width or height is
+   * less than 1
+   * @exception IOException if a write error occurs
+   */
+  public void prepareInsertEmpty (int imageIndex, ImageTypeSpecifier imageType,
+                                  int width, int height,
+                                  IIOMetadata imageMetadata,
+                                  List thumbnails,
+                                  ImageWriteParam param)
+    throws IOException
+  {
+    if (!canInsertEmpty(imageIndex))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Start the replacement of pixels within an image in the output
+   * stream.  Output pixels will be clipped to lie within region.
+   *
+   * @param imageIndex the index of the image in which pixels are
+   * being replaced
+   * @param region the rectangle to which to limit pixel replacement
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if replacing pixels is
+   * not supported
+   * @exception IndexOutOfBoundsException if imageIndex is less than 0
+   * or greater than the last index in the current image list
+   * @exception IllegalStateException if a previous call to
+   * prepareReplacePixels was made (without a terminating call to
+   * endReplacePixels)
+   * @exception IllegalArgumentException if either region.width or
+   * region.height is less than 1, or if region is null
+   * @exception IOException if a write error occurs
+   */
+  public void prepareReplacePixels (int imageIndex, Rectangle region)
+    throws IOException
+  {
+    if (canReplacePixels(imageIndex))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Start writing an empty image to the end of the image output
+   * stream.
+   *
+   * The writing that this method call starts is not complete until
+   * endWriteEmpty is called.  prepareWritetEmpty cannot be called
+   * again until endWriteEmpty is called and calls to
+   * prepareWriteEmpty and prepareInsertEmpty may not be intersperced.
+   *
+   * @param streamMetadata metadata associated with the stream, or null
+   * @param imageType the image type specifier
+   * @param width the image width
+   * @param height the image height
+   * @param imageMetadata the image metadata, or null
+   * @param thumbnails a list of thumbnails, or null
+   * @param param image write parameters, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if writing empty images
+   * is not supported
+   * @exception IndexOutOfBoundsException if imageIndex is less than
+   * -1 or greater than the last index in the current image list
+   * @exception IllegalStateException if a previous call to
+   * prepareInsertEmpty was made (without a terminating call to
+   * endInsertEmpty)
+   * @exception IllegalStateException if a previous call to
+   * prepareWriteEmpty was made (without a terminating call to
+   * endWriteEmpty)
+   * @exception IllegalArgumentException if imageType is null or
+   * thumbnails contain non-BufferedImage objects
+   * @exception IllegalArgumentException if either width or height is
+   * less than 1
+   * @exception IOException if a write error occurs
+   */
+  public void prepareWriteEmpty (IIOMetadata streamMetadata,
+                                 ImageTypeSpecifier imageType,
+                                 int width, int height,
+                                 IIOMetadata imageMetadata,
+                                 List thumbnails,
+                                 ImageWriteParam param)
+    throws IOException
+  {
+    if (!canWriteEmpty())
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Start the writing of a sequence of images.
+   *
+   * @param streamMetadata the stream metadata, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if writing sequences of
+   * images is not supported
+   * @exception IOException if a write error occurs
+   */
+  public void prepareWriteSequence (IIOMetadata streamMetadata)
+    throws IOException
+  {
+    checkOutputSet();
+    if (!canWriteSequence())
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Remove the image at the specified index from the output stream.
+   *
+   * @param imageIndex the frame index from which to remove the image
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if removing this image
+   * is not supported
+   * @exception IndexOutOfBoundsException if imageIndex is less than 0
+   * or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public void removeImage (int imageIndex)
+    throws IOException
+  {
+    if (!canRemoveImage(imageIndex))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Replace the metadata associated with the image at the given
+   * index.
+   *
+   * @param imageIndex the index of the image whose metadata should be
+   * replaced
+   * @param imageMetadata the metadata, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if replacing this
+   * image's metadata is not supported
+   * @exception IndexOutOfBoundsException if imageIndex is less than 0
+   * or greater than the last index in the current image list
+   * @exception IOException if a write error occurs
+   */
+  public void replaceImageMetadata (int imageIndex, IIOMetadata imageMetadata)
+    throws IOException
+  {
+    if (!canReplaceImageMetadata(imageIndex))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Replace a region of an image in the output stream with a portion
+   * of the given rendered image.  The image data must be of the same
+   * type as that in the output stream.  The destination region is
+   * given by the image writing parameters and the source region is
+   * the one given to prepareReplacePixels.
+   *
+   * @param image the rendered image with which to overwrite the image
+   * region in the stream
+   * @param param the image writing parameters
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if replacing pixels is
+   * not supported
+   * @exception IllegalStateException if prepareReplacePixels was not
+   * called before this method was called
+   * @exception IllegalArgumentException if image is null or if param
+   * is null or if the overlap of the source and destination regions
+   * contains no pixels or if the image types differ and no conversion
+   * is possible
+   * @exception IOException if a write error occurs
+   */
+  public void replacePixels (RenderedImage image,
+                             ImageWriteParam param)
+    throws IOException
+  {
+    if (!canReplacePixels(0))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Replace a region of an image in the output stream with a portion
+   * of the given raster data.  The image data must be of the same
+   * type as that in the output stream.  The destination region is
+   * given by the image writing parameters and the source region is
+   * the one given to prepareReplacePixels.
+   *
+   * @param raster the raster data with which to overwrite the image
+   * region in the stream
+   * @param param the image writing parameters
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if replacing pixels is
+   * not supported
+   * @exception IllegalStateException if prepareReplacePixels was not
+   * called before this method was called
+   * @exception UnsupportedOperationException if raster data is not
+   * supported
+   * @exception IllegalArgumentException if raster is null or if param
+   * is null or if the overlap of the source and destination regions
+   * contains no pixels or if the image types differ and no conversion
+   * is possible
+   * @exception IOException if a write error occurs
+   */
+  public void replacePixels (Raster raster, ImageWriteParam param)
+    throws IOException
+  {
+    if (!canReplacePixels(0))
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Replace the metadata associated with this image stream.
+   *
+   * @param streamMetadata the stream metadata, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if replacing the stream
+   * metadata is not supported
+   * @exception IOException if a write error occurs
+   */
+  public void replaceStreamMetadata (IIOMetadata streamMetadata)
+    throws IOException
+  {
+    if (!canReplaceStreamMetadata())
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Write a rendered image to the output stream.
+   *
+   * @param image a rendered image containing image data to be written
+   *
+   * @exception IllegalStateException if output is null
+   * @exception IllegalArgumentException if image is null
+   * @exception IOException if a write error occurs
+   */
+  public void write (RenderedImage image)
+    throws IOException
+  {
+    checkOutputSet();
+    write (null, new IIOImage(image, null, null), null);
+  }
+
+  /**
+   * Write a image data, metadata and thumbnails to the output stream.
+   *
+   * @param image image data, metadata and thumbnails to be written
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if image contains raster
+   * data but this writer does not support rasters
+   * @exception IllegalArgumentException if image is null
+   * @exception IOException if a write error occurs
+   */
+  public void write (IIOImage image)
+    throws IOException
+  {
+    checkOutputSet();
+    write (null, image, null);
+  }
+
+  /**
+   * Insert an image into the output stream.  Indices greater than the
+   * specified index are incremented accordingly.  Specifying an index
+   * of -1 causes the image to be appended at the end of the current
+   * image list.
+   *
+   * @param imageIndex the frame index at which to insert the image
+   * @param image the image data, metadata and thumbnails to be
+   * inserted
+   * @param the image write parameters, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if image insertion is
+   * not supported
+   * @exception IllegalArgumentException if image is null
+   * @exception IndexOutOfBoundsException if imageIndex is less than
+   * -1 or greater than the last index in the current image list
+   * @exception UnsupportedOperationException if image contains raster
+   * data but this writer does not support rasters
+   * @exception IOException if a write error occurs
+   */
+  public void writeInsert (int imageIndex, IIOImage image, ImageWriteParam param)
+    throws IOException
+  {
+    if (!canInsertImage(imageIndex))
+      throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Write a sequence of images, including thumbnails and metadata, to
+   * the output stream.  The output must have been set prior to this
+   * method being called.  Metadata associated with the stream may be
+   * supplied, or it can be left null.  IIOImage may contain raster
+   * data if this writer supports rasters, or it will contain a
+   * rendered image.  Thumbnails are resized if need be.  Image
+   * writing parameters may be specified to affect writing, or may be
+   * left null.
+   *
+   * @param streamMetadata metadata associated with this stream, or
+   * null
+   * @param image an IIOImage containing image data, metadata and
+   * thumbnails to be written
+   * @param param image writing parameters, or null
+   *
+   * @exception IllegalStateException if output is null
+   * @exception UnsupportedOperationException if writing sequences of
+   * images is not supported
+   * @exception IllegalArgumentException if image is null
+   * @exception UnsupportedOperationException if image contains raster
+   * data but this writer does not support rasters
+   * @exception IOException if a write error occurs
+   */
+  public void writeToSequence (IIOImage image, ImageWriteParam param)
+    throws IOException
+  {
+    if (!canWriteSequence())
+      throw new UnsupportedOperationException();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadProgressListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadProgressListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadProgressListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadProgressListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* IIOReadProgressListener.java --
+   Copyright (C) 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 javax.imageio.event;
+
+import java.util.EventListener;
+
+import javax.imageio.ImageReader;
+
+public interface IIOReadProgressListener extends EventListener
+{
+  /**
+   * Reports that the current image read operation has completed.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   */
+  void imageComplete(ImageReader source);
+
+  /**
+   * Reports the approximate percentage of completions of this image read
+   * operation.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param percentageDone the approximate percentage of encoding completed
+   */
+  void imageProgress(ImageReader source, float percentageDone);
+
+  /**
+   * Reports that the current image read operation has started.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param imageIndex the index of the image to read
+   */
+  void imageStarted(ImageReader source, int imageIndex);
+
+  /**
+   * Reports that a read operation has been aborted.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   */
+  void readAborted(ImageReader source);
+
+  /**
+   * Reports that a sequence of read operationshas completed.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   */
+  void sequenceComplete(ImageReader source);
+
+  /**
+   * Reports that a sequence of read operations is beginning.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param minIndex the index of the first image to be read
+   */
+  void sequenceStarted(ImageReader source, int minIndex);
+
+  /**
+   * Reports that a thumbnail read operation has completed.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   */
+  void thumbnailComplete(ImageReader source);
+
+  /**
+   * Reports the approximate percentage of completion of a thumbnail read
+   * operation.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param percentageDone the approximate percentage of encoding completed
+   */
+  void thumbnailProgress(ImageReader source, float percentageDone);
+
+  /**
+   * Reports that a thumbnail read operation is beginning.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param imageIndex the index of the image being read
+   * @param thumbnailIndex the index of the thumbnail being read
+   */
+  void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadUpdateListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadUpdateListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadUpdateListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadUpdateListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,133 @@
+/* IIOReadUpdateListener.java --
+   Copyright (C) 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 javax.imageio.event;
+
+import java.awt.image.BufferedImage;
+import java.util.EventListener;
+
+import javax.imageio.ImageReader;
+
+public interface IIOReadUpdateListener extends EventListener
+{
+  /**
+   * Reports that a given region of the image has been updated.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param image the BufferedImage being updated
+   * @param minX the X coordinate of the leftmost updated column of pixels
+   * @param minY the Y coordinate of the uppermost updated row of pixels
+   * @param width the number of updated pixels horizontally
+   * @param height the number of updated pixels vertically
+   * @param periodX the horizontal spacing between updated pixels; a value of 1 means no gaps
+   * @param periodY the vertical spacing between updated pixels; a value of 1 means no gaps
+   * @param bands an array of <code>int</code>s indicating which bands are being updated
+   */
+  void imageUpdate(ImageReader source, BufferedImage image, int minX,
+                   int minY, int width, int height, int periodX, int periodY,
+                   int[] bands);
+
+  /**
+   * Reports that the current read operation has completed a progressive pass.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param image the BufferedImage being updated
+   */
+  void passComplete(ImageReader source, BufferedImage image);
+
+  /**
+   * Reports that the current read operation is about to begin a progressive pass.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param image the BufferedImage being updated
+   * @param pass the numer of the pass that is about to begin, starting with 0
+   * @param minPass the index of the first pass that will be decoded
+   * @param maxPass the index of the last pass that will be decoded
+   * @param minX the X coordinate of the leftmost updated column of pixels
+   * @param minY the Y coordinate of the uppermost updated row of pixels
+   * @param periodX the horizontal spacing between updated pixels; a value of 1 means no gaps
+   * @param periodY the vertical spacing between updated pixels; a value of 1 means no gaps
+   * @param bands an array of <code>int</code>s indicating which bands are being updated
+   */
+  void passStarted(ImageReader source, BufferedImage image, int pass,
+                   int minPass, int maxPass, int minX, int minY, int periodX,
+                   int periodY, int[] bands);
+
+  /**
+   * Reports that the current thumbnail read operation has completed a progressive pass.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param image the BufferedImage being updated
+   */
+  void thumbnailPassComplete(ImageReader source, BufferedImage image);
+
+  /**
+   * Reports that the current thumbnail read operation is about to begin a progressive pass.
+   * 
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param image the BufferedImage being updated
+   * @param pass the numer of the pass that is about to begin, starting with 0
+   * @param minPass the index of the first pass that will be decoded
+   * @param maxPass the index of the last pass that will be decoded
+   * @param minX the X coordinate of the leftmost updated column of pixels
+   * @param minY the Y coordinate of the uppermost updated row of pixels
+   * @param periodX the horizontal spacing between updated pixels; a value of 1 means no gaps
+   * @param periodY the vertical spacing between updated pixels; a value of 1 means no gaps
+   * @param bands an array of <code>int</code>s indicating which bands are being updated
+   */
+  void thumbnailPassStarted(ImageReader source, BufferedImage image, int pass,
+                            int minPass, int maxPass, int minX, int minY,
+                            int periodX, int periodY, int[] bands);
+
+  /**
+   * Reports that a given region of a thumbnail image has been updated.
+   *
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param image the BufferedImage being updated
+   * @param minX the X coordinate of the leftmost updated column of pixels
+   * @param minY the Y coordinate of the uppermost updated row of pixels
+   * @param width the number of updated pixels horizontally
+   * @param height the number of updated pixels vertically
+   * @param periodX the horizontal spacing between updated pixels; a value of 1 means no gaps
+   * @param periodY the vertical spacing between updated pixels; a value of 1 means no gaps
+   * @param bands an array of <code>int</code>s indicating which bands are being updated
+   */
+  void thumbnailUpdate(ImageReader source, BufferedImage image, int minX,
+                       int minY, int width, int height, int periodX,
+                       int periodY, int[] bands);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadWarningListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadWarningListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadWarningListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOReadWarningListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* IIOReadProgressListener.java --
+   Copyright (C) 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 javax.imageio.event;
+
+import java.util.EventListener;
+
+import javax.imageio.ImageReader;
+
+public interface IIOReadWarningListener extends EventListener
+{
+  /**
+   * Reports the occurrence of a non-fatal error in decoding.
+   * Decoding will continue after this method is called.
+   *
+   * @param source the <code>ImageReader</code> object calling this method
+   * @param warning the warning
+   */
+  void warningOccurred(ImageReader source, String warning);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteProgressListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteProgressListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteProgressListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteProgressListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* IIOWriteProgressListener.java --
+   Copyright (C) 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 javax.imageio.event;
+
+import java.util.EventListener;
+
+import javax.imageio.ImageWriter;
+
+public interface IIOWriteProgressListener extends EventListener
+{
+  /**
+   * Reports that an image write operation has completed.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   */
+  void imageComplete(ImageWriter source);
+
+  /**
+   * Reports the approximate percentage of completion of an image write
+   * operation.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   * @param percentageDone the approximate percentage of decoding completed
+   */
+  void imageProgress(ImageWriter source, float percentageDone);
+
+  /**
+   * Reports that a thumbnail write operation has started.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   * @param imageIndex the index of the image being written
+   */
+  void imageStarted(ImageWriter source, int imageIndex);
+
+  /**
+   * Reports that a thumbnail write operation has completed.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   */
+  void thumbnailComplete(ImageWriter source);
+
+  /**
+   * Reports the approximate percentage of completion of a thumbnail write
+   * operation.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   * @param percentageDone the approximate percentage of decoding completed
+   */
+  void thumbnailProgress(ImageWriter source, float percentageDone);
+
+  /**
+   * Reports that a thumbnail write operation is beginning.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   * @param imageIndex the index of the image being written
+   * @param thumnailIndex the index of the thumbnail being written
+   */
+  void thumbnailStarted(ImageWriter source, int imageIndex, int thumnailIndex);
+
+  /**
+   * Reports that an image write operation is aborted.
+   * 
+   * @param source the <code>ImageWriter</code> object calling this method
+   */
+  void writeAborted(ImageWriter source);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteWarningListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteWarningListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteWarningListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/IIOWriteWarningListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* IIOWriteWarningListener.java --
+   Copyright (C) 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 javax.imageio.event;
+
+import java.util.EventListener;
+
+import javax.imageio.ImageWriter;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public interface IIOWriteWarningListener extends EventListener
+{
+  /**
+   * Reports the occurrence of a non-fatal error in encoding.
+   * Encoding will continue after this method is called.
+   *
+   * @param source the <code>ImageWriter</code> object calling this method
+   * @param imageIndex the index of the image generating this warning,
+   * starting with 0
+   * @param warning the warning
+   */
+  void warningOccurred(ImageWriter source, int imageIndex, String warning);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/event/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio.event package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio.event</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOInvalidTreeException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOInvalidTreeException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOInvalidTreeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOInvalidTreeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* IIOInvalidTreeException.java --
+   Copyright (C) 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 javax.imageio.metadata;
+
+import javax.imageio.IIOException;
+
+import org.w3c.dom.Node;
+
+public class IIOInvalidTreeException extends IIOException
+{
+  private static final long serialVersionUID = -1314083172544132777L;
+
+  protected Node offendingNode;
+
+  public IIOInvalidTreeException(String message, Node offendingNode)
+  {
+    super(message);
+    this.offendingNode = offendingNode;
+  }
+
+  public IIOInvalidTreeException(String message, Throwable cause,
+				 Node offendingNode)
+  {
+    super(message, cause);
+    this.offendingNode = offendingNode;
+  }
+
+  public Node getOffendingNode()
+  {
+    return offendingNode;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadata.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadata.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadata.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadata.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,323 @@
+/* IIOMetadata.java --
+   Copyright (C) 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 javax.imageio.metadata;
+
+import org.w3c.dom.Node;
+
+/**
+ * Represents metadata that describe an image or an image stream.
+ * Each ImageIO plugin will represent image data using an opaque
+ * object but all such objects should expose their internal
+ * information as a tree of IIOMetadataNodes.
+ *
+ * There are three formats of metadata that a plugin can support:
+ *
+ * <ul>
+ *   <li>a "native" format</li>
+ *   <li>a custom format</li>
+ *   <li>a standard plugin-neutral format</li>
+ * </ul>
+ *
+ * If a plugin supports more than one format of metadata, the other
+ * formats can be retrieved by calling getMetadataFormatNames.
+ *
+ * The native format is used to transfer metadata from one image to
+ * another image of the same type, losslessly.
+ *
+ * The custom format describes the image metadata and exposes a tree
+ * of IIOMetadataNodes but its internal representation is specific to
+ * this plugin.
+ *
+ * The plugin-neutral format uses a generic tree structure as its
+ * internal representation.
+ *
+ * ImageTranscoders may be used to convert metadata understood by one
+ * plugin to metadata understood by another, however the conversion
+ * may be lossy.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ */
+public abstract class IIOMetadata
+{
+  protected IIOMetadataController controller;
+  protected IIOMetadataController defaultController;
+  protected String[] extraMetadataFormatClassNames;
+  protected String[] extraMetadataFormatNames;
+  protected String nativeMetadataFormatClassName;
+  protected String nativeMetadataFormatName;
+  protected boolean standardFormatSupported;
+
+  /**
+   * Construct an IIOMetadata object.
+   */
+  protected IIOMetadata()
+  {
+    // Do nothing here.
+  }
+
+  /**
+   * Construct an IIOMetadata object.
+   *
+   * @param standardMetadataFormatSupported
+   * @param nativeMetadataFormatName
+   * @param nativeMetadataFormatClassName
+   * @param extraMetadataFormatNames
+   * @param extraMetadataFormatClassNames
+   *
+   * @throws IllegalArgumentException if extraMetadataFormatNames has length of
+   * zero or extraMetadataFormatNames and extraMetadataFormatClassNames are
+   * neither both null, not have the same length
+   */
+  protected IIOMetadata(boolean standardMetadataFormatSupported,
+                        String nativeMetadataFormatName,
+                        String nativeMetadataFormatClassName,
+                        String[] extraMetadataFormatNames,
+                        String[] extraMetadataFormatClassNames)
+  {
+    if (extraMetadataFormatNames != null
+        && extraMetadataFormatNames.length == 0)
+      throw new IllegalArgumentException
+        ("extraMetadataFormatNames may not be empty");
+
+    if (((extraMetadataFormatNames == null)
+         && (extraMetadataFormatClassNames != null))
+        || ((extraMetadataFormatNames != null)
+            && (extraMetadataFormatClassNames == null))
+        || ((extraMetadataFormatNames != null)
+            && (extraMetadataFormatClassNames != null)
+            && (extraMetadataFormatNames.length !=
+                extraMetadataFormatClassNames.length)))
+      throw new IllegalArgumentException
+        ("extraMetadataFormatNames and extraMetadataFormatClassNames " +
+         "have different lengths");
+
+    this.standardFormatSupported = standardMetadataFormatSupported;
+    this.nativeMetadataFormatName = nativeMetadataFormatName;
+    this.nativeMetadataFormatClassName = nativeMetadataFormatClassName;
+    this.extraMetadataFormatNames = extraMetadataFormatNames;
+    this.extraMetadataFormatClassNames = extraMetadataFormatClassNames;
+  }
+
+  public boolean activateController()
+  {
+    if (! hasController())
+      return false;
+
+    return getDefaultController().activate(this);
+  }
+
+  public IIOMetadataController getController()
+  {
+    return controller;
+  }
+
+  public IIOMetadataController getDefaultController()
+  {
+    return defaultController;
+  }
+
+  public String[] getExtraMetadataFormatNames()
+  {
+    return (String[]) extraMetadataFormatNames.clone();
+  }
+
+  public IIOMetadataFormat getMetadataFormat(String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException("formatName may not be null");
+    
+    String formatClassName = null;
+
+    if (isStandardMetadataFormatSupported()
+	&& formatName.equals(nativeMetadataFormatName))
+      formatClassName = nativeMetadataFormatClassName;
+    else
+      {
+	String[] extraFormatNames = getExtraMetadataFormatNames();
+	
+	for (int i = extraFormatNames.length - 1; i >= 0; --i)
+	  if (extraFormatNames[i].equals(formatName))
+	    {
+	      formatClassName = extraFormatNames[i];
+	      break;
+	    }
+      }
+
+    if (formatClassName == null)
+      throw new IllegalArgumentException("unknown format");
+
+    IIOMetadataFormat format;
+    
+    try
+      {
+	format = (IIOMetadataFormat) Class.forName(formatClassName)
+					  .newInstance();
+      }
+    catch (Exception e)
+      {
+	IllegalStateException ise = new IllegalStateException();
+	ise.initCause(e);
+	throw ise;
+      }
+
+    return format;
+  }
+
+  public String[] getMetadataFormatNames()
+  {
+    String[] formatNames = getExtraMetadataFormatNames();
+    
+    if (isStandardMetadataFormatSupported())
+      {
+        // Combine native metadata format name and extra metadata format names
+	// into one String array.
+	String[] tmp = new String[formatNames.length + 1];
+	tmp[0] = getNativeMetadataFormatName();
+
+	for (int i = 1; i < tmp.length; ++i)
+	  tmp[i] = formatNames[i - 1];
+
+	formatNames = tmp;
+      }
+
+    return formatNames;
+  }
+
+  public String getNativeMetadataFormatName()
+  {
+    return nativeMetadataFormatName;
+  }
+
+  public boolean hasController()
+  {
+    return getController() != null;
+  }
+
+  public abstract boolean isReadOnly();
+
+  public boolean isStandardMetadataFormatSupported()
+  {
+    return standardFormatSupported;
+  }
+
+  public abstract void reset();
+
+  public void setController(IIOMetadataController controller)
+  {
+    this.controller = controller;
+  }
+
+  public abstract Node getAsTree (String formatName);
+
+  protected IIOMetadataNode getStandardChromaNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardCompressionNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardDataNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardDimensionNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardDocumentNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardTextNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardTileNode ()
+  {
+    return null;
+  }
+
+  protected IIOMetadataNode getStandardTransparencyNode ()
+  {
+    return null;
+  }
+
+  private void appendChild (IIOMetadataNode node,
+			    IIOMetadataNode child)
+  {
+    if (child != null)
+      node.appendChild(child);
+  }
+
+  protected final IIOMetadataNode getStandardTree ()
+  {
+    IIOMetadataNode node = new IIOMetadataNode();
+
+    appendChild (node, getStandardChromaNode());
+    appendChild (node, getStandardCompressionNode());
+    appendChild (node, getStandardDataNode());
+    appendChild (node, getStandardDimensionNode());
+    appendChild (node, getStandardDocumentNode());
+    appendChild (node, getStandardTextNode());
+    appendChild (node, getStandardTileNode());
+    appendChild (node, getStandardTransparencyNode());
+
+    return node;
+  }
+
+  public abstract void mergeTree (String formatName,
+                                  Node root)
+    throws IIOInvalidTreeException;
+
+  public void setFromTree (String formatName, Node root)
+    throws IIOInvalidTreeException
+  {
+    reset();
+
+    mergeTree (formatName, root);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataController.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataController.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataController.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataController.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* IIOMetadataController.java --
+   Copyright (C) 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 javax.imageio.metadata;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public interface IIOMetadataController
+{
+  boolean activate(IIOMetadata metadata);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,124 @@
+/* IIOMetadataFormat.java --
+   Copyright (C) 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 javax.imageio.metadata;
+
+import java.util.Locale;
+
+import javax.imageio.ImageTypeSpecifier;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public interface IIOMetadataFormat
+{
+  int CHILD_POLICY_ALL = 1;
+  int CHILD_POLICY_CHOICE = 3;
+  int CHILD_POLICY_EMPTY = 0;
+  int CHILD_POLICY_MAX = 5;
+  int CHILD_POLICY_REPEAT = 5;
+  int CHILD_POLICY_SEQUENCE = 4;
+  int CHILD_POLICY_SOME = 2;
+  int DATATYPE_BOOLEAN = 1;
+  int DATATYPE_DOUBLE = 4;
+  int DATATYPE_FLOAT = 3;
+  int DATATYPE_INTEGER = 2;
+  int DATATYPE_STRING = 0;
+  int VALUE_ARBITRARY = 1;
+  int VALUE_ENUMERATION = 16;
+  int VALUE_LIST = 32;
+  int VALUE_NONE = 0;
+  int VALUE_RANGE = 2;
+  int VALUE_RANGE_MAX_INCLUSIVE = 10;
+  int VALUE_RANGE_MAX_INCLUSIVE_MASK = 8;
+  int VALUE_RANGE_MIN_INCLUSIVE = 6;
+  int VALUE_RANGE_MIN_INCLUSIVE_MASK = 4;
+  int VALUE_RANGE_MIN_MAX_INCLUSIVE = 14;
+
+  boolean canNodeAppear (String elementName, ImageTypeSpecifier imageType);
+
+  int getAttributeDataType (String elementName, String attrName);
+
+  String getAttributeDefaultValue (String elementName, String attrName);
+
+  String getAttributeDescription (String elementName, String attrName, Locale locale);
+
+  String[] getAttributeEnumerations (String elementName, String attrName);
+
+  int getAttributeListMaxLength (String elementName, String attrName);
+
+  int getAttributeListMinLength (String elementName, String attrName);
+
+  String getAttributeMaxValue (String elementName, String attrName);
+
+  String getAttributeMinValue (String elementName, String attrName);
+
+  String[] getAttributeNames (String elementName);
+
+  int getAttributeValueType (String elementName, String attrName);
+
+  String[] getChildNames (String elementName);
+
+  int getChildPolicy (String elementName);
+
+  String getElementDescription (String elementName, Locale locale);
+
+  int getElementMaxChildren (String elementName);
+
+  int getElementMinChildren (String elementName);
+
+  int getObjectArrayMaxLength (String elementName);
+
+  int getObjectArrayMinLength (String elementName);
+
+  Class getObjectClass (String elementName);
+
+  Object getObjectDefaultValue (String elementName);
+
+  Object[] getObjectEnumerations (String elementName);
+
+  Comparable getObjectMaxValue (String elementName);
+
+  Comparable getObjectMinValue (String elementName);
+
+  int getObjectValueType (String elementName);
+
+  String getRootName();
+
+  boolean isAttributeRequired (String elementName, String attrName);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormatImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormatImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormatImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataFormatImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,885 @@
+/* IIOMetadataFormatImpl.java --
+   Copyright (C) 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 javax.imageio.metadata;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.UserDataHandler;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import javax.imageio.ImageTypeSpecifier;
+
+public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat
+{
+  /**
+   * The standard metadata format name constant set to
+   * "javax_imageio_1.0".
+   */
+  public static final String standardMetadataFormatName = "javax_imageio_1.0";
+
+  private String rootName;
+
+  // These maps assume that each element name is unique.
+
+  private Map nodes = new HashMap();
+
+  // A mapping from element name to child policy.
+  private Map childPolicies = new HashMap();
+
+  // A mapping from element name to the permissible number of
+  // children.  Values in this map are length-two integer arrays; the
+  // first index is the minimum bound, the second index is the maximum
+  // bound.
+  private Map childRanges = new HashMap();
+
+  private String resourceBaseName;
+
+  // Package-private so that it may be used in IIOMetadataNode.
+  static class IIOMetadataNodeAttr extends IIOMetadataNode
+    implements Attr
+  {
+    protected Element owner;
+    protected String name;
+    protected int dataType;
+    protected boolean required;
+    protected String defaultValue;
+
+    public IIOMetadataNodeAttr (Element owner,
+				String name,
+				String defaultValue)
+    {
+      this (owner, name, IIOMetadataFormat.DATATYPE_STRING,
+            true, defaultValue);
+    }
+
+    public IIOMetadataNodeAttr (Element owner,
+				String name,
+				int dataType,
+				boolean required,
+				String defaultValue)
+    {
+      this.owner = owner;
+      this.name = name;
+      this.dataType = dataType;
+      this.required = required;
+      this.defaultValue = defaultValue;
+    }
+
+    public String getName ()
+    {
+      return name;
+    }
+
+    public Element getOwnerElement ()
+    {
+      return owner;
+    }
+
+    public int getDataType ()
+    {
+      return dataType;
+    }
+
+    public TypeInfo getSchemaTypeInfo ()
+    {
+      return null;
+    }
+
+    public boolean getSpecified ()
+    {
+      return false;
+    }
+
+    public String getValue ()
+    {
+      return defaultValue;
+    }
+
+    public boolean isId()
+    {
+      return false;
+    }
+
+    public void setValue (String value)
+    {
+    }
+
+    // new methods
+
+    public boolean isRequired ()
+    {
+      return required;
+    }
+  }
+
+  private class IIOMetadataNodeAttrEnumerated extends IIOMetadataNodeAttr
+  {
+    protected List enumeratedValues;
+
+    public IIOMetadataNodeAttrEnumerated (Element owner,
+					  String name,
+					  int dataType,
+					  boolean required,
+					  String defaultValue,
+					  List enumeratedValues)
+    {
+      super (owner, name, dataType, required, defaultValue);
+      this.enumeratedValues = new ArrayList (enumeratedValues);
+    }
+
+    public Object[] getEnumerations ()
+    {
+      return enumeratedValues.toArray ();
+    }
+  }
+
+  private class IIOMetadataNodeAttrBounded extends IIOMetadataNodeAttr
+  {
+    protected String minValue;
+    protected String maxValue;
+    protected boolean minInclusive;
+    protected boolean maxInclusive;
+
+    public IIOMetadataNodeAttrBounded (Element owner,
+				       String name,
+				       int dataType,
+				       boolean required,
+				       String defaultValue,
+				       String minValue,
+				       String maxValue,
+				       boolean minInclusive,
+				       boolean maxInclusive)
+    {
+      super (owner, name, dataType, required, defaultValue);
+      this.minValue = minValue;
+      this.maxValue = maxValue;
+      this.minInclusive = minInclusive;
+      this.maxInclusive = maxInclusive;
+    }
+
+    public String getMinValue ()
+    {
+      return minValue;
+    }
+
+    public String getMaxValue ()
+    {
+      return maxValue;
+    }
+  }
+
+  private class IIOMetadataNodeAttrList extends IIOMetadataNodeAttr
+  {
+    protected int listMinLength;
+    protected int listMaxLength;
+
+    public IIOMetadataNodeAttrList (Element owner,
+				    String name,
+				    int dataType,
+				    boolean required,
+				    int listMinLength,
+				    int listMaxLength)
+    {
+      super (owner, name, dataType, required, null);
+      this.listMinLength = listMinLength;
+      this.listMaxLength = listMaxLength;
+    }
+
+    public int getListMinLength ()
+    {
+      return listMinLength;
+    }
+
+    public int getListMaxLength ()
+    {
+      return listMaxLength;
+    }
+  }
+
+  private class NodeObject
+  {
+    protected Element owner;
+    protected Class classType;
+    protected boolean required;
+    protected Object defaultValue;
+    protected int valueType;
+
+    public NodeObject (Element owner,
+                       Class classType,
+                       boolean required,
+                       Object defaultValue)
+    {
+      this.owner = owner;
+      this.classType = classType;
+      this.required = required;
+      this.defaultValue = defaultValue;
+      valueType = IIOMetadataFormat.VALUE_ARBITRARY;
+    }
+
+    public int getValueType ()
+    {
+      return valueType;
+    }
+
+    public Class getClassType ()
+    {
+      return classType;
+    }
+
+    public Element getOwnerElement ()
+    {
+      return owner;
+    }
+
+    public Object getDefaultValue ()
+    {
+      return defaultValue;
+    }
+
+    public boolean isRequired ()
+    {
+      return required;
+    }
+  }
+
+  private class NodeObjectEnumerated extends NodeObject
+  {
+    protected List enumeratedValues;
+
+    public NodeObjectEnumerated (Element owner,
+                                 Class classType,
+                                 boolean required,
+                                 Object defaultValue,
+                                 List enumeratedValues)
+    {
+      super (owner, classType, false, defaultValue);
+      this.enumeratedValues = enumeratedValues;
+      valueType = IIOMetadataFormat.VALUE_ENUMERATION;
+    }
+
+    public Object[] getEnumerations ()
+    {
+      return enumeratedValues.toArray();
+    }
+  }
+
+  private class NodeObjectBounded extends NodeObject
+  {
+    protected Comparable minValue;
+    protected Comparable maxValue;
+    protected boolean minInclusive;
+    protected boolean maxInclusive;
+
+    public NodeObjectBounded (Element owner,
+                              Class classType,
+                              Object defaultValue,
+                              Comparable minValue,
+                              Comparable maxValue,
+                              boolean minInclusive,
+                              boolean maxInclusive)
+    {
+      super (owner, classType, false, defaultValue);
+      this.minValue = minValue;
+      this.maxValue = maxValue;
+      this.minInclusive = minInclusive;
+      this.maxInclusive = maxInclusive;
+      if (minInclusive)
+        {
+          if (maxInclusive)
+            valueType = IIOMetadataFormat.VALUE_RANGE_MIN_MAX_INCLUSIVE;
+          else
+            valueType = IIOMetadataFormat.VALUE_RANGE_MIN_INCLUSIVE;
+        }
+      else
+        {
+          if (maxInclusive)
+            valueType = IIOMetadataFormat.VALUE_RANGE_MAX_INCLUSIVE;
+          else
+            valueType = IIOMetadataFormat.VALUE_RANGE;
+        }
+    }
+
+    public Comparable getMinValue ()
+    {
+      return minValue;
+    }
+
+    public Comparable getMaxValue ()
+    {
+      return maxValue;
+    }
+  }
+
+  private class NodeObjectArray extends NodeObject
+  {
+    protected Integer arrayMinLength;
+    protected Integer arrayMaxLength;
+
+    public NodeObjectArray (Element owner,
+                            Class classType,
+                            int arrayMinLength,
+                            int arrayMaxLength)
+    {
+      super (owner, classType, false, null);
+      this.arrayMinLength = new Integer (arrayMinLength);
+      this.arrayMaxLength = new Integer (arrayMaxLength);
+      valueType = IIOMetadataFormat.VALUE_LIST;
+    }
+
+    public Comparable getArrayMinLength ()
+    {
+      return arrayMinLength;
+    }
+
+    public Comparable getArrayMaxLength ()
+    {
+      return arrayMaxLength;
+    }
+  }
+
+  /**
+   * Construct a blank IIOMetadataFormatImpl with the given root name
+   * and child policy.
+   *
+   * @param rootName the root element name
+   * @param childPolicy the child policy of the root element
+   *
+   * @exception IllegalArgumentException if rootName is null
+   * @exception IllegalArgumentException if childPolicy is
+   * CHILD_POLICY_REPEAT or if childPolicy is not a CHILD_POLICY
+   * constant
+   */
+  public IIOMetadataFormatImpl (String rootName, int childPolicy)
+  {
+    if (rootName == null)
+      throw new IllegalArgumentException ("null argument");
+
+    if (childPolicy < IIOMetadataFormat.CHILD_POLICY_ALL
+	|| childPolicy > IIOMetadataFormat.CHILD_POLICY_SOME
+	|| childPolicy == IIOMetadataFormat.CHILD_POLICY_REPEAT)
+      throw new IllegalArgumentException ("wrong child policy");
+
+    nodes.put (rootName, new IIOMetadataNode (rootName));
+    childPolicies.put (rootName, new Integer (childPolicy));
+    this.rootName = rootName;
+  }
+
+  /**
+   * Construct a blank IIOMetadataFormatImpl with the given root name,
+   * a child policy of CHILD_POLICY_REPEAT and the given minimum and
+   * maximum limits on the number of root element children.
+   *
+   * @param rootName the root element name
+   * @param minChildren the minimum number of children that this node
+   * can have
+   * @param maxChildren the maximum number of children that this node
+   * can have
+   *
+   * @exception IllegalArgumentException if rootName is null
+   * @exception IllegalArgumentException if minChildren is less than
+   * zero or greater than maxChildren
+   */
+  public IIOMetadataFormatImpl (String rootName,
+				int minChildren,
+				int maxChildren)
+  {
+    if (rootName == null)
+      throw new IllegalArgumentException ("null argument");
+
+    if (minChildren < 0 || maxChildren < minChildren)
+      throw new IllegalArgumentException ("invalid min or max children argument");
+
+    nodes.put (rootName, new IIOMetadataNode (rootName));
+    childPolicies.put (rootName, new Integer (IIOMetadataFormat.CHILD_POLICY_REPEAT));
+    childRanges.put (rootName, new int [] { minChildren, maxChildren });
+    this.rootName = rootName;
+  }
+
+  protected void addAttribute (String elementName,
+                               String attrName,
+                               int dataType,
+                               boolean required,
+                               String defaultValue)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    node.setAttributeNode (new IIOMetadataNodeAttr (node,
+						    attrName,
+						    dataType,
+						    required,
+						    defaultValue));
+  }
+
+  protected void addAttribute (String elementName,
+                               String attrName,
+                               int dataType,
+                               boolean required,
+                               String defaultValue,
+                               List enumeratedValues)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    node.setAttributeNode (new IIOMetadataNodeAttrEnumerated (node,
+							      attrName,
+							      dataType,
+							      required,
+							      defaultValue,
+							      enumeratedValues));
+  }
+
+  protected void addAttribute (String elementName,
+                               String attrName,
+                               int dataType,
+                               boolean required,
+                               String defaultValue,
+                               String minValue,
+                               String maxValue,
+                               boolean minInclusive,
+                               boolean maxInclusive)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    node.setAttributeNode (new IIOMetadataNodeAttrBounded (node,
+							   attrName,
+							   dataType,
+							   required,
+							   defaultValue,
+							   minValue,
+							   maxValue,
+							   minInclusive,
+							   maxInclusive));
+  }
+
+  protected void addAttribute (String elementName,
+                               String attrName,
+                               int dataType,
+                               boolean required,
+                               int listMinLength,
+                               int listMaxLength)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    node.setAttributeNode (new IIOMetadataNodeAttrList (node,
+							attrName,
+							dataType,
+							required,
+							listMinLength,
+							listMaxLength));
+  }
+
+  protected void addBooleanAttribute (String elementName,
+                                      String attrName,
+                                      boolean hasDefaultValue,
+                                      boolean defaultValue)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+
+    List enumeratedValues = new ArrayList();
+    enumeratedValues.add ("TRUE");
+    enumeratedValues.add ("FALSE");
+
+    node.setAttributeNode (new IIOMetadataNodeAttrEnumerated (node,
+							      attrName,
+							      IIOMetadataFormat.DATATYPE_BOOLEAN,
+							      hasDefaultValue,
+							      defaultValue ? "TRUE" : "FALSE",
+							      enumeratedValues));
+  }
+
+  protected void addChildElement (String elementName, String parentName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (parentName);
+
+    node.appendChild (new IIOMetadataNode (elementName));
+    childPolicies.put (elementName, new Integer (IIOMetadataFormat.CHILD_POLICY_REPEAT));
+  }
+
+  protected void addElement (String elementName, String parentName, int childPolicy)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (parentName);
+
+    node.appendChild (new IIOMetadataNode (elementName));
+    childPolicies.put (elementName, new Integer (childPolicy));
+  }
+
+  protected void addElement (String elementName, String parentName,
+                             int minChildren, int maxChildren)
+  {
+    addChildElement (elementName, parentName);
+    childRanges.put (elementName, new int [] { minChildren, maxChildren });
+  }
+
+  private void addNodeObject (IIOMetadataNode node, NodeObject o)
+  {
+    node.setUserObject (o);
+  }
+
+  private NodeObject getNodeObject (IIOMetadataNode node)
+  {
+    return (NodeObject) node.getUserObject ();
+  }
+
+  private void removeNodeObject (IIOMetadataNode node)
+  {
+    node.setUserObject (null);
+  }
+
+  protected void addObjectValue (String elementName, Class classType,
+                                 boolean required, Object defaultValue)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    addNodeObject (node, new NodeObject (node,
+                                         classType,
+                                         required,
+                                         defaultValue));
+  }
+
+  protected void addObjectValue (String elementName, Class classType,
+                                 boolean required, Object defaultValue,
+                                 List enumeratedValues)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    addNodeObject (node, new NodeObjectEnumerated (node,
+                                                   classType,
+                                                   required,
+                                                   defaultValue,
+                                                   enumeratedValues));
+  }
+
+  protected void addObjectValue (String elementName, Class classType,
+                                 Object defaultValue,
+                                 Comparable minValue,
+                                 Comparable maxValue,
+                                 boolean minInclusive,
+                                 boolean maxInclusive)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    addNodeObject (node, new NodeObjectBounded (node,
+                                                classType,
+                                                defaultValue,
+                                                minValue,
+                                                maxValue,
+                                                minInclusive,
+                                                maxInclusive));
+  }
+
+  protected void addObjectValue (String elementName, Class classType,
+                                 int arrayMinLength, int arrayMaxLength)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    addNodeObject (node, new NodeObjectArray (node,
+                                              classType,
+                                              arrayMinLength,
+                                              arrayMaxLength));
+  }
+
+  public String getRootName ()
+  {
+    return rootName;
+  }
+
+  protected String getResourceBaseName ()
+  {
+    return resourceBaseName;
+  }
+
+  public static IIOMetadataFormat getStandardFormatInstance ()
+  {
+    // FIXME: populate this with the standard metadata format
+    return new IIOMetadataFormatImpl (standardMetadataFormatName,
+                                      IIOMetadataFormat.CHILD_POLICY_ALL)
+      {
+        public boolean canNodeAppear (String elementName,
+                                      ImageTypeSpecifier specifier)
+        {
+          return true;
+        }
+      };
+  }
+
+  public abstract boolean canNodeAppear (String elementName,
+                                         ImageTypeSpecifier specifier);
+
+  protected void removeAttribute (String elementName,
+                                  String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    node.removeAttribute (attrName);
+  }
+
+  protected void removeElement (String elementName)
+  {
+    nodes.remove (elementName);
+  }
+
+  protected void removeObjectValue (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    removeNodeObject (node);
+  }
+
+  protected void setResourceBaseName (String resourceBaseName)
+  {
+    this.resourceBaseName = resourceBaseName;
+  }
+
+  public int getAttributeDataType (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) node.getAttributeNode (attrName);
+    return attr.getDataType ();
+  }
+
+  public String getAttributeDefaultValue (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) node.getAttributeNode (attrName);
+    return attr.getValue();
+  }
+
+  public String getAttributeDescription (String elementName, String attrName, Locale locale)
+  {
+    return getDescription (elementName + "/" + attrName, locale);
+  }
+
+  public String[] getAttributeEnumerations (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttrEnumerated attr =
+      (IIOMetadataNodeAttrEnumerated) node.getAttributeNode (attrName);
+
+    Object[] attrEnums = attr.getEnumerations();
+
+    String[] attrNames = new String[attrEnums.length];
+
+    for (int i = 0; i < attrEnums.length; i++)
+      {
+        attrNames[i] = (String) attrEnums[i];
+      }
+
+    return attrNames;
+  }
+
+  public int getAttributeListMaxLength (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttrList attr =
+      (IIOMetadataNodeAttrList) node.getAttributeNode (attrName);
+    return attr.getListMaxLength();
+  }
+
+  public int getAttributeListMinLength (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttrList attr =
+      (IIOMetadataNodeAttrList) node.getAttributeNode (attrName);
+    return attr.getListMinLength();
+  }
+
+  public String getAttributeMaxValue (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttrBounded attr =
+      (IIOMetadataNodeAttrBounded) node.getAttributeNode (attrName);
+    return attr.getMaxValue();
+  }
+
+  public String getAttributeMinValue (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttrBounded attr =
+      (IIOMetadataNodeAttrBounded) node.getAttributeNode (attrName);
+    return attr.getMinValue();
+  }
+
+  public String[] getAttributeNames (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+
+    NamedNodeMap attrNodes = node.getAttributes();
+
+    String[] attrNames = new String[attrNodes.getLength()];
+
+    for (int i = 0; i < attrNodes.getLength(); i++)
+      {
+        attrNames[i] = attrNodes.item (i).getLocalName();
+      }
+
+    return attrNames;
+  }
+
+  public int getAttributeValueType (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) node.getAttributeNode (attrName);
+    return attr.getDataType();
+  }
+
+  public String[] getChildNames (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+
+    NodeList childNodes = node.getChildNodes();
+
+    String[] childNames = new String[childNodes.getLength()];
+
+    for (int i = 0; i < childNodes.getLength(); i++)
+      {
+        childNames[i] = childNodes.item (i).getLocalName();
+      }
+
+    return childNames;
+  }
+
+  public int getChildPolicy (String elementName)
+  {
+    return ((Integer) childPolicies.get (elementName)).intValue();
+  }
+
+  private String getDescription (String resourceName, Locale locale)
+  {
+    if (resourceBaseName == null)
+      return null;
+
+    Locale l = locale;
+
+    if (l == null)
+      l = Locale.getDefault();
+
+    ResourceBundle bundle = ResourceBundle.getBundle (resourceBaseName, locale);
+
+    String desc = null;
+
+    if (bundle == null)
+      {
+        try
+          {
+            desc = bundle.getString (resourceName);
+          }
+        catch (MissingResourceException e)
+          {
+            desc = null;
+          }
+      }
+
+    return desc;
+  }
+
+  public String getElementDescription (String elementName, Locale locale)
+  {
+    return getDescription (elementName, locale);
+  }
+
+  public int getElementMaxChildren (String elementName)
+  {
+    return ((int[]) childRanges.get (elementName))[1];
+  }
+
+  public int getElementMinChildren (String elementName)
+  {
+    return ((int[]) childRanges.get (elementName))[0];
+  }
+
+  public int getObjectArrayMaxLength (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return ((Integer) ((NodeObjectArray) getNodeObject (node)).getArrayMaxLength ()).intValue();
+  }
+
+  public int getObjectArrayMinLength (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return ((Integer) ((NodeObjectArray) getNodeObject (node)).getArrayMinLength ()).intValue();
+  }
+
+  public Class getObjectClass (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return getNodeObject (node).getClassType ();
+  }
+
+  public Object getObjectDefaultValue (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return getNodeObject (node).getDefaultValue ();
+  }
+
+  public Object[] getObjectEnumerations (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return ((NodeObjectEnumerated) getNodeObject (node)).getEnumerations ();
+  }
+
+  public Comparable getObjectMaxValue (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return ((NodeObjectBounded) getNodeObject (node)).getMaxValue ();
+  }
+
+  public Comparable getObjectMinValue (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return ((NodeObjectBounded) getNodeObject (node)).getMinValue ();
+  }
+
+  public int getObjectValueType (String elementName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    NodeObject n = getNodeObject (node);
+
+    if (n == null)
+      return IIOMetadataFormat.VALUE_NONE;
+    else
+      return n.getValueType ();
+  }
+
+  public boolean isAttributeRequired (String elementName, String attrName)
+  {
+    IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+    return ((IIOMetadataNodeAttr) node.getAttributeNode (attrName)).isRequired();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataNode.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataNode.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataNode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/IIOMetadataNode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,709 @@
+/* IIOMetadataNode.java --
+   Copyright (C) 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 javax.imageio.metadata;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.UserDataHandler;
+import javax.imageio.metadata.IIOMetadataFormatImpl.IIOMetadataNodeAttr;
+
+public class IIOMetadataNode
+  implements Element, NodeList
+{
+  private String name;
+  private HashMap attrs = new HashMap();
+  private List children = new ArrayList();
+  private IIOMetadataNode parent;
+  private Object obj;
+
+  /**
+   * Simple NamedNodeMap class for IIOMetadataNode.
+   *
+   * @author jlquinn
+   */
+  private class IIONamedNodeMap implements NamedNodeMap
+  {
+    HashMap attrs;
+
+    /**
+     * @param attrs
+     * @param node
+     */
+    public IIONamedNodeMap(HashMap attrs)
+    {
+      this.attrs = attrs;
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#getNamedItem(java.lang.String)
+     */
+    public Node getNamedItem(String name)
+    {
+      return (Node)attrs.get(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#setNamedItem(org.w3c.dom.Node)
+     */
+    public Node setNamedItem(Node arg) throws DOMException
+    {
+      if (arg instanceof IIOMetadataNodeAttr)
+        {
+          IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) arg;
+          // The only code that can successfully do this is in this package.
+          if (attr.owner != null)
+            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, "");
+          return (Node)attrs.put(attr.name, attr);
+        }
+      // Anything else gets treated as an invalid op.
+      throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "");
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#removeNamedItem(java.lang.String)
+     */
+    public Node removeNamedItem(String name) throws DOMException
+    {
+      return (Node)attrs.remove(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#item(int)
+     */
+    public Node item(int index)
+    {
+      return (Node)attrs.values().toArray()[index];
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#getLength()
+     */
+    public int getLength()
+    {
+      return attrs.size();
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#getNamedItemNS(java.lang.String, java.lang.String)
+     */
+    public Node getNamedItemNS(String namespaceURI, String localName)
+    {
+      return getNamedItem(localName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#setNamedItemNS(org.w3c.dom.Node)
+     */
+    public Node setNamedItemNS(Node arg) throws DOMException
+    {
+      return setNamedItem(arg);
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NamedNodeMap#removeNamedItemNS(java.lang.String, java.lang.String)
+     */
+    public Node removeNamedItemNS(String namespaceURI, String localName)
+      throws DOMException
+    {
+      return removeNamedItem(localName);
+    }
+  }
+
+  /**
+   * Simple NodeList implementation for IIOMetadataNode.
+   *
+   * @author jlquinn
+   *
+   */
+  private class IIONodeList implements NodeList
+  {
+    List children = new ArrayList();
+  
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NodeList#item(int)
+     */
+    public Node item(int index)
+    {
+      return (index < children.size()) ? (Node)children.get(index) : null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.w3c.dom.NodeList#getLength()
+     */
+    public int getLength()
+    {
+      return children.size();
+    }
+  }
+
+  public IIOMetadataNode()
+  {
+    // Do nothing here.
+  }
+  
+  public IIOMetadataNode(String nodename)
+  {
+    name = nodename;
+  }
+
+  public Object getUserObject()
+  {
+    return obj;
+  }
+
+  public void setUserObject(Object o)
+  {
+    obj = o;
+  }
+  
+  public short compareDocumentPosition(Node other)
+    throws DOMException
+  {
+    return Element.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getAttribute(java.lang.String)
+   */
+  public String getAttribute(String name)
+  {
+    Attr anode = (Attr) attrs.get(name);
+    return anode != null ? anode.getValue() : null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
+   */
+  public Attr getAttributeNode(String name)
+  {
+    String val = getAttribute(name);
+    if (val != null)
+      return new IIOMetadataNodeAttr(this, name, val);
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+   */
+  public Attr getAttributeNodeNS(String namespaceURI, String localName)
+  {
+    return getAttributeNode(localName);
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
+   */
+  public String getAttributeNS(String namespaceURI, String localName)
+  {
+    return getAttribute(localName);
+  }
+
+  public String getBaseURI()
+  {
+    return null;
+  }
+
+  // Recursive function for assembling a node list.
+  private void getElementsRecurse(IIONodeList list, String name)
+  {
+    for (int i=0; i < children.size(); i++)
+    {
+      if (((Node)children.get(i)).getNodeName().equals(name))
+        list.children.add(children.get(i));
+      getElementsRecurse(list, name);
+    }
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
+   */
+  public NodeList getElementsByTagName(String name)
+  {
+    IIONodeList list = new IIONodeList();
+    getElementsRecurse(list, name);
+    return list;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
+   */
+  public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
+  {
+    IIONodeList list = new IIONodeList();
+    getElementsRecurse(list, name);
+    return list;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#getTagName()
+   */
+  public String getTagName()
+  {
+    return name;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
+   */
+  public boolean hasAttribute(String name)
+  {
+    return attrs.containsKey(name);
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
+   */
+  public boolean hasAttributeNS(String namespaceURI, String localName)
+  {
+    return attrs.containsKey(localName);
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
+   */
+  public void removeAttribute(String name)
+  {
+    attrs.remove(name);
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
+   */
+  public Attr removeAttributeNode(Attr oldAttr)
+  {
+    return (Attr)attrs.remove(oldAttr.getName());
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
+   */
+  public void removeAttributeNS(String namespaceURI, String localName)
+  {
+    removeAttribute(localName);
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
+   */
+  public void setAttribute(String name, String value)
+  {
+    Attr attr = (Attr) getAttributeNode(name);
+    if (attr != null)
+      attr.setValue(value);
+    else
+      attrs.put(name, new IIOMetadataNodeAttr(this, name, value));
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
+   */
+  public Attr setAttributeNode(Attr newAttr)
+  {
+    return (Attr)attrs.put(newAttr.getName(), newAttr);
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
+   */
+  public Attr setAttributeNodeNS(Attr newAttr)
+  {
+    return (Attr)attrs.put(newAttr.getName(), newAttr);
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
+   */
+  public void setAttributeNS(String namespaceURI, String qualifiedName, String value)
+  {
+    setAttribute(qualifiedName, value);    
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.NodeList#getLength()
+   */
+  public int getLength()
+  {
+    return children.size();
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.NodeList#item(int)
+   */
+  public Node item(int index)
+  {
+    if (index < children.size())
+      return (Node)children.get(index);
+    else
+      return null;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
+   */
+  public Node appendChild(Node newChild)
+  {
+    if (newChild == null)
+      throw new IllegalArgumentException("Child node is null");
+    
+    IIOMetadataNode child = (IIOMetadataNode) newChild;
+    
+    children.add(child);
+    child.parent = this;
+    return this;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#cloneNode(boolean)
+   */
+  public Node cloneNode(boolean deep)
+  {
+    IIOMetadataNode newnode = new IIOMetadataNode(name);
+    newnode.parent = null;
+    newnode.obj = obj;
+    if (deep)
+    {
+      for (int i=0; i < children.size(); i++)
+        newnode.children.add(((Node)children.get(i)).cloneNode(deep));
+    }
+    
+    // clone attrs
+    for (Iterator it = attrs.values().iterator(); it.hasNext();)
+    {
+      IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr)it.next();
+      newnode.attrs.put(attr.name, attr.cloneNode(deep));
+      attr.owner = newnode;
+    }
+
+    return newnode;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getAttributes()
+   */
+  public NamedNodeMap getAttributes()
+  {
+    return new IIONamedNodeMap(attrs);
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getChildNodes()
+   */
+  public NodeList getChildNodes()
+  {
+    return this;
+  }
+
+  public Object getFeature(String feature, String version)
+  {
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getFirstChild()
+   */
+  public Node getFirstChild()
+  {
+    return (children.size() > 0) ? (Node)children.get(0) : null;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getLastChild()
+   */
+  public Node getLastChild()
+  {
+    return (children.size() > 0) ? (Node)children.get(children.size() - 1)
+           : null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getLocalName()
+   */
+  public String getLocalName()
+  {
+    return name;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getNamespaceURI()
+   */
+  public String getNamespaceURI()
+  {
+    return null;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getNextSibling()
+   */
+  public Node getNextSibling()
+  {
+    // If this op needs to be faster, add links to prev and next nodes.
+    if (parent == null) return null;
+    int idx = parent.children.indexOf(this);
+    return (idx == parent.children.size() - 1) ? null
+        : (Node)parent.children.get(idx + 1);
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getNodeName()
+   */
+  public String getNodeName()
+  {
+    return name;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getNodeType()
+   */
+  public short getNodeType()
+  {
+    return ELEMENT_NODE;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getNodeValue()
+   */
+  public String getNodeValue()
+  {
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getOwnerDocument()
+   */
+  public Document getOwnerDocument()
+  {
+    // IOMetadataNodes have no owner
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getParentNode()
+   */
+  public Node getParentNode()
+  {
+    return parent;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getPrefix()
+   */
+  public String getPrefix()
+  {
+    return null;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#getPreviousSibling()
+   */
+  public Node getPreviousSibling()
+  {
+    // If this op needs to be faster, add links to prev and next nodes.
+    if (parent == null) return null;
+    int idx = parent.children.indexOf(this);
+    return (idx == 0) ? null
+        : (Node)parent.children.get(idx - 1);
+  }
+
+  public TypeInfo getSchemaTypeInfo()
+  {
+    return null;
+  }
+
+  public String getTextContent()
+    throws DOMException
+  {
+    return null;
+  }
+
+  public Object getUserData(String key)
+  {
+    return null;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#hasAttributes()
+   */
+  public boolean hasAttributes()
+  {
+    return !attrs.isEmpty();
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#hasChildNodes()
+   */
+  public boolean hasChildNodes()
+  {
+    return !children.isEmpty();
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
+   */
+  public Node insertBefore(Node newChild, Node refChild)
+  {
+    if (newChild == null)
+      throw new IllegalArgumentException();
+    
+    int idx = children.indexOf(refChild);
+    if (idx == -1)
+      children.add(newChild);
+    else
+      children.add(idx, newChild);
+    ((IIOMetadataNode)newChild).parent = this;
+    
+    return newChild;
+  }
+
+  public boolean isDefaultNamespace(String namespaceURI)
+  {
+    return true;
+  }
+
+  public boolean isEqualNode(Node arg)
+  {
+    return true;
+  }
+  
+  public boolean isSameNode(Node other)
+  {
+    return this == other;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#isSupported(java.lang.String, java.lang.String)
+   */
+  public boolean isSupported(String feature, String version)
+  {
+    // No DOM features are supported
+    return false;
+  }
+  
+  public String lookupNamespaceURI(String prefix)
+  {
+    return null;
+  }
+  
+  public String lookupPrefix(String namespaceURI)
+  {
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#normalize()
+   */
+  public void normalize()
+  {
+    // No text nodes so no action
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
+   */
+  public Node removeChild(Node oldChild)
+  {
+    if (oldChild == null)
+      throw new IllegalArgumentException();
+    children.remove(oldChild);
+    ((IIOMetadataNode)oldChild).parent = null;
+
+    return oldChild;
+  }
+
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
+   */
+  public Node replaceChild(Node newChild, Node oldChild)
+  {
+    if (newChild == null)
+      throw new IllegalArgumentException();
+    children.set(children.indexOf(oldChild), newChild);
+    ((IIOMetadataNode)oldChild).parent = null;
+    return oldChild;
+  }
+  
+  public void setIdAttribute(String name, boolean isId)
+    throws DOMException
+  {
+  }
+
+  public void setIdAttributeNode(Attr idAttr, boolean isId)
+    throws DOMException
+  {
+  }
+
+  public void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
+    throws DOMException
+  {
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
+   */
+  public void setNodeValue(String nodeValue) throws DOMException
+  {
+  }
+  
+  /* (non-Javadoc)
+   * @see org.w3c.dom.Node#setPrefix(java.lang.String)
+   */
+  public void setPrefix(String prefix)
+  {
+  }
+
+  public void setTextContent(String textContent)
+    throws DOMException
+  {
+  }
+  
+  public Object setUserData(String key, Object data, UserDataHandler handler)
+  {
+    return null;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/metadata/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio.metadata package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio.metadata</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio</title></head>
+
+<body>
+<p>
+This package provides image input/output APIs.
+</p>
+<p>
+The standard class library provides other ways of loading images (@see
+java.awt.Toolkit, @see java.awt.Component)) but the ImageIO package is
+more powerful.
+</p>
+<p>
+The static ImageIO class supports reading and writing images in many
+different formats along with most other basic image I/O operations.
+</p>
+<p>
+Other classes provide finer control of image-related operations;
+reading is controlled by ImageReader, ImageReadParam and
+ImageTypeSpecifyer, writing by ImageWriter and ImageWriteParam.
+ImageTranscoder allows fine-grained control over how images are
+converted between formats and IIOException reports errors.  IIOImage
+describes an image file in detail including metadata and thumbnails.
+</p>
+<h2>Supported Formats</h2>
+<p>
+The default GNU Classpath ImageIO backend uses ImageMagick and so
+supports the following formats:
+<table>
+<tr>
+<th></th> <th>Read</th> <th>Write</th>
+</tr>
+<tr><td>JPEG</td><td>yes</td><td>yes</td></tr>
+<tr><td>PNG</td><td>yes</td><td>yes</td></tr>
+<tr><td>BMP</td><td>yes</td><td>yes</td></tr>
+<tr><td>WBMP</td><td>yes</td><td>yes</td></tr>
+<tr><td>GIF</td><td>yes</td><td>yes</td></tr>
+<tr><td>TIFF</td><td>yes</td><td>yes</td></tr>
+<tr><td>XPM</td><td>yes</td><td>yes</td></tr>
+<tr><td>TGA</td><td>yes</td><td>yes</td></tr>
+<tr><td>PDF</td><td>yes</td><td>no</td></tr>
+<tr><td>SVG</td><td>yes</td><td>no</td></tr>
+<table>
+</p>
+<p>
+ at since 1.4
+</p>
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/bmp/BMPImageWriteParam.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/bmp/BMPImageWriteParam.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/bmp/BMPImageWriteParam.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/bmp/BMPImageWriteParam.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* BMPImageWriteParam.java -- 
+   Copyright (C) 2006 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 javax.imageio.plugins.bmp;
+
+import java.util.Locale;
+
+import javax.imageio.ImageWriteParam;
+
+/**
+ * A class to encode images in the BMP format. 
+ * By default, the data layout is bottom-up, such that the pixels are stored in
+ * bottom-up order. 
+ * 
+ * The compression scheme can be specified by using setCompressionType() 
+ * appropriate type string. The compression scheme specified will be honored
+ * if it is compatible with the type of image being written. If the 
+ * compression scheme is not compatible with the type of image being written,
+ * then an IOException will be thrown by the BMP image writer. If the 
+ * compression type is not set, then getCompressionType() will return null.
+ * In this case the BMP image writer will select a compression type that 
+ * supports encoding of the given image without loss of the color resolution. 
+ * 
+ * The compression type strings and the image type each supports are: 
+ * Uncompressed RLE: BI_RGB, image type: <= 8-bits/sample.  
+ * 8-bit Run Length Encoding: BI_RLE8, image type: <= 8-bits/sample 
+ * 4-bit Run Length Encoding: BI_RLE4, image type: <= 4-bits/sample 
+ * Packed data: BI_BITFIELDS, image type: 16 or 32 bits/sample
+ * 
+ * @author Lillian Angel (langel at redhat dot com)
+ */
+public class BMPImageWriteParam
+    extends ImageWriteParam
+{
+
+  /**
+   * This boolean is true if the data will be written in a topdown manner.
+   */
+  private boolean topDown;
+  
+  /**
+   * Compression type strings.
+   */
+  String rgb = "BI_RGB";
+  String rle8 = "BI_RLE8";
+  String rle4 = "BI_RLE4";
+  String bitfields = "BI_BITFIELDS";
+  
+  /**
+   * Constants to represent image types.
+   */
+  static final int BI_RGB = 0;
+  static final int BI_RLE8 = 1;
+  static final int BI_RLE4 = 2;
+  static final int BI_BITFIELDS = 3;
+  
+  /**
+   * Constructs an <code>BMPImageWriteParam</code> object with default values
+   * and a <code>null Locale</code>.
+   */
+  public BMPImageWriteParam()
+  {
+    this(null);
+  }
+
+  /**
+   * Constructs a <code>BMPImageWriteParam</code> set to use a given
+   * <code>Locale</code> and with default values for all parameters.
+   * 
+   * @param locale - a <code>Locale</code> to be used to localize compression
+   *          type names and quality descriptions, or <code>null</code>.
+   */
+  public BMPImageWriteParam(Locale locale)
+  {
+    super(locale);
+    topDown = false;
+    canWriteCompressed = true;
+    
+    compressionTypes = new String[4];
+    compressionTypes[BI_RGB] = rgb;
+    compressionTypes[BI_RLE8] = rle8;
+    compressionTypes[BI_RLE4] = rle4;
+    compressionTypes[BI_BITFIELDS] = bitfields;
+    
+    compressionType = compressionTypes[BI_RGB];
+  }
+
+  /**
+   * If set, the data will be written out in a top-down manner, the first
+   * scanline being written first.
+   * 
+   * @param topDown - whether the data are written in top-down order.
+   */
+  public void setTopDown(boolean topDown)
+  {
+    this.topDown = topDown;
+  }
+
+  /**
+   * Returns the value of the <code>topDown</code> parameter. The default is
+   * false.
+   * 
+   * @return whether the data are written in top-down order.
+   */
+  public boolean isTopDown()
+  {
+    return topDown;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGHuffmanTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,280 @@
+/* JPEGHuffmanTable.java --
+ Copyright (C)  2006  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 javax.imageio.plugins.jpeg;
+
+/**
+ * The JPEGHuffmanTable class represents a Huffman table read from a
+ * JPEG image file.  The standard JPEG AC and DC chrominance and
+ * luminance values are provided as static fields.
+ */
+public class JPEGHuffmanTable
+{
+  /**
+   * Huffman code lengths.
+   */
+  private short[] lengths;
+
+  /**
+   * Huffman values.
+   */
+  private short[] values;
+
+  // The private constructors are used for these final fields to avoid
+  // unnecessary copying.
+  /**
+   * The standard JPEG AC chrominance Huffman table.
+   */
+  public static final JPEGHuffmanTable StdACChrominance =
+      new JPEGHuffmanTable(new short[] { 0, 2, 1, 2, 4, 4, 3, 4, 7, 5,
+                                         4, 4, 0, 1, 2, 0x77 },
+                           new short[]  { 0x00, 0x01, 0x02, 0x03, 0x11,
+                                          0x04, 0x05, 0x21, 0x31, 0x06,
+                                          0x12, 0x41, 0x51, 0x07, 0x61,
+                                          0x71, 0x13, 0x22, 0x32, 0x81,
+                                          0x08, 0x14, 0x42, 0x91, 0xa1,
+                                          0xb1, 0xc1, 0x09, 0x23, 0x33,
+                                          0x52, 0xf0, 0x15, 0x62, 0x72,
+                                          0xd1, 0x0a, 0x16, 0x24, 0x34,
+                                          0xe1, 0x25, 0xf1, 0x17, 0x18,
+                                          0x19, 0x1a, 0x26, 0x27, 0x28,
+                                          0x29, 0x2a, 0x35, 0x36, 0x37,
+                                          0x38, 0x39, 0x3a, 0x43, 0x44,
+                                          0x45, 0x46, 0x47, 0x48, 0x49,
+                                          0x4a, 0x53, 0x54, 0x55, 0x56,
+                                          0x57, 0x58, 0x59, 0x5a, 0x63,
+                                          0x64, 0x65, 0x66, 0x67, 0x68,
+                                          0x69, 0x6a, 0x73, 0x74, 0x75,
+                                          0x76, 0x77, 0x78, 0x79, 0x7a,
+                                          0x82, 0x83, 0x84, 0x85, 0x86,
+                                          0x87, 0x88, 0x89, 0x8a, 0x92,
+                                          0x93, 0x94, 0x95, 0x96, 0x97,
+                                          0x98, 0x99, 0x9a, 0xa2, 0xa3,
+                                          0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
+                                          0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
+                                          0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
+                                          0xba, 0xc2, 0xc3, 0xc4, 0xc5,
+                                          0xc6, 0xc7, 0xc8, 0xc9, 0xca,
+                                          0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+                                          0xd7, 0xd8, 0xd9, 0xda, 0xe2,
+                                          0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+                                          0xe8, 0xe9, 0xea, 0xf2, 0xf3,
+                                          0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+                                          0xf9, 0xfa }, false);
+
+  /**
+   * The standard JPEG AC luminance Huffman table.
+   */
+  public static final JPEGHuffmanTable StdACLuminance =
+      new JPEGHuffmanTable(new short[] { 0, 2, 1, 3, 3, 2, 4, 3, 5, 5,
+                                         4, 4, 0, 0, 1, 0x7d },
+                           new short[] { 0x01, 0x02, 0x03, 0x00, 0x04,
+                                         0x11, 0x05, 0x12, 0x21, 0x31,
+                                         0x41, 0x06, 0x13, 0x51, 0x61,
+                                         0x07, 0x22, 0x71, 0x14, 0x32,
+                                         0x81, 0x91, 0xa1, 0x08, 0x23,
+                                         0x42, 0xb1, 0xc1, 0x15, 0x52,
+                                         0xd1, 0xf0, 0x24, 0x33, 0x62,
+                                         0x72, 0x82, 0x09, 0x0a, 0x16,
+                                         0x17, 0x18, 0x19, 0x1a, 0x25,
+                                         0x26, 0x27, 0x28, 0x29, 0x2a,
+                                         0x34, 0x35, 0x36, 0x37, 0x38,
+                                         0x39, 0x3a, 0x43, 0x44, 0x45,
+                                         0x46, 0x47, 0x48, 0x49, 0x4a,
+                                         0x53, 0x54, 0x55, 0x56, 0x57,
+                                         0x58, 0x59, 0x5a, 0x63, 0x64,
+                                         0x65, 0x66, 0x67, 0x68, 0x69,
+                                         0x6a, 0x73, 0x74, 0x75, 0x76,
+                                         0x77, 0x78, 0x79, 0x7a, 0x83,
+                                         0x84, 0x85, 0x86, 0x87, 0x88,
+                                         0x89, 0x8a, 0x92, 0x93, 0x94,
+                                         0x95, 0x96, 0x97, 0x98, 0x99,
+                                         0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
+                                         0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
+                                         0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+                                         0xb7, 0xb8, 0xb9, 0xba, 0xc2,
+                                         0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+                                         0xc8, 0xc9, 0xca, 0xd2, 0xd3,
+                                         0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
+                                         0xd9, 0xda, 0xe1, 0xe2, 0xe3,
+                                         0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
+                                         0xe9, 0xea, 0xf1, 0xf2, 0xf3,
+                                         0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+                                         0xf9, 0xfa }, false);
+
+  /**
+   * The standard JPEG DC chrominance Huffman table.
+   */
+  public static final JPEGHuffmanTable StdDCChrominance =
+      new JPEGHuffmanTable(new short[] { 0, 3, 1, 1, 1, 1, 1, 1, 1, 1,
+                                         1, 0, 0, 0, 0, 0 },
+                           new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+                                         10, 11 }, false);
+
+  /**
+   * The standard JPEG DC luminance Huffman table.
+   */
+  public static final JPEGHuffmanTable StdDCLuminance =
+      new JPEGHuffmanTable(new short[] { 0, 1, 5, 1, 1, 1, 1, 1, 1, 0,
+                                         0, 0, 0, 0, 0, 0 },
+                           new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+                                         10, 11 }, false);
+
+  /**
+   * Construct and initialize a Huffman table. Copies are created of
+   * the array arguments. lengths[index] stores the number of Huffman
+   * values with Huffman codes of length index + 1. The values array
+   * stores the Huffman values in order of increasing code length.
+   * 
+   * @param lengths an array of Huffman code lengths
+   * @param values a sorted array of Huffman values
+   * @throws IllegalArgumentException if either parameter is null, if
+   * lengths.length > 16 or values.length > 256, if any value in
+   * length or values is negative, or if the parameters do not
+   * describe a valid Huffman table
+   */
+  public JPEGHuffmanTable(short[] lengths, short[] values)
+  {
+    // Create copies of the lengths and values arguments.
+    this(checkLengths(lengths), checkValues(values, lengths), true);
+  }
+
+  /**
+   * Private constructor that avoids unnecessary copying and argument
+   * checking.
+   *
+   * @param lengths an array of Huffman code lengths
+   * @param values a sorted array of Huffman values
+   * @param copy true if copies should be created of the given arrays
+   */
+  private JPEGHuffmanTable(short[] lengths, short[] values, boolean copy)
+  {
+    this.lengths = copy ? (short[]) lengths.clone() : lengths;
+    this.values = copy ? (short[]) values.clone() : values;
+  }
+
+  private static short[] checkLengths(short[] lengths)
+  {
+    if (lengths == null || lengths.length > 16)
+      throw new IllegalArgumentException("invalid length array");
+
+    for (int i = 0; i < lengths.length; i++)
+      {
+        if (lengths[i] < 0)
+          throw new IllegalArgumentException("negative length");
+      }
+
+    int sum = 0;
+    for (int i = 0; i < lengths.length; i++)
+      {
+        if (lengths[i] > ((1 << (i + 1)) - 1))
+          throw new IllegalArgumentException("invalid number of codes"
+                                             + " for code length " + (i + 1));
+        sum += lengths[i];
+      }
+
+    return lengths;
+  }
+
+  private static short[] checkValues(short[] values, short[] lengths)
+  {
+    if (values == null || values.length > 256)
+      throw new IllegalArgumentException("invalid values array");
+
+    for (int i = 0; i < values.length; i++)
+      {
+        if (values[i] < 0)
+          throw new IllegalArgumentException("negative value");
+      }
+    // lengths is known-valid by this point.
+    int sum = 0;
+    for (int i = 0; i < lengths.length; i++)
+      sum += lengths[i];
+
+    if (values.length != sum)
+      throw new IllegalArgumentException("invalid number of values"
+                                         + " for number of codes");
+
+    return values;
+  }
+
+  /**
+   * Retrieve a copy of the array of Huffman code lengths.  If the
+   * returned array is called lengthcount, there are
+   * lengthcount[index] codes of length index + 1.
+   *
+   * @return a copy of the array of Huffman code lengths
+   */
+  public short[] getLengths()
+  {
+    return (short[]) lengths.clone();
+  }
+
+  /**
+   * Retrieve a copy of the array of Huffman values, sorted in order
+   * of increasing code length.
+   *
+   * @return a copy of the array of Huffman values
+   */
+  public short[] getValues()
+  {
+    return (short[]) values.clone();
+  }
+
+  /**
+   * Create a string representation of this JPEG Huffman table.
+   *
+   * @return a string representation of this JPEG Huffman table.
+   */
+  public String toString()
+  {
+    StringBuffer buffer = new StringBuffer();
+    
+    buffer.append("JPEGHuffmanTable:\nlengths:");
+    
+    for (int i = 0; i < lengths.length; i++)
+      buffer.append(" " + lengths[i]);
+    
+    buffer.append("\nvalues:");
+    
+    for (int i = 0; i < values.length; i++)
+      buffer.append(" " + values[i]);
+    
+    return buffer.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageReadParam.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageReadParam.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageReadParam.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageReadParam.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,161 @@
+/* JPEGImageReadParam.java --
+ Copyright (C)  2006  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 javax.imageio.plugins.jpeg;
+
+import javax.imageio.ImageReadParam;
+
+/**
+ * The JPEGImageReadParam class is only used to set JPEG decoding
+ * tables for streams that do not provide their own tables.  If a
+ * stream does not provide tables and a custom JPEGImageReadParam is
+ * not provided, then the standard JPEG tables are used from the
+ * JPEGQTable and JPEGHuffmanTable classes.  If a stream does provide
+ * decoding tables then JPEGImageReadParam will be ignored.
+ * JPEGImageReadParam cannot be used to retrieve the tables from a
+ * stream.  Instead, use IIOMetadata for this purpose.
+ *
+ * A JPEGImageReadParam instance is retrieved from the built-in JPEG
+ * ImageReader using the getDefaultImageReadParam method.
+ */
+public class JPEGImageReadParam
+  extends ImageReadParam
+{
+  private JPEGQTable[] qTables;
+  private JPEGHuffmanTable[] DCHuffmanTables;
+  private JPEGHuffmanTable[] ACHuffmanTables;
+
+  /**
+   * Construct a JPEGImageReadParam.
+   */
+  public JPEGImageReadParam()
+  {
+    super();
+  }
+
+  /**
+   * Check if the decoding tables are set.
+   *
+   * @return true if the decoding tables are set, false otherwise
+   */
+  public boolean areTablesSet()
+  {
+    // If qTables is not null then all tables are set.
+    return (qTables != null);
+  }
+
+  /**
+   * Set the quantization and Huffman tables that will be used to
+   * decode the stream.  Copies are created of the array arguments.
+   * The number of Huffman tables must be the same in both Huffman
+   * table arrays.  No argument may be null and no array may be longer
+   * than four elements.
+   *
+   * @param qTables JPEG quantization tables
+   * @param DCHuffmanTables JPEG DC Huffman tables
+   * @param ACHuffmanTables JPEG AC Huffman tables
+   *
+   * @throws IllegalArgumentException if any argument is null, if any
+   * of the arrays are longer than four elements, or if the Huffman
+   * table arrays do not have the same number of elements
+   */
+  public void setDecodeTables(JPEGQTable[] qTables,
+                              JPEGHuffmanTable[] DCHuffmanTables,
+                              JPEGHuffmanTable[] ACHuffmanTables)
+  {
+    if (qTables == null || DCHuffmanTables == null || ACHuffmanTables == null)
+      throw new IllegalArgumentException("null argument");
+
+    if (qTables.length > 4 || DCHuffmanTables.length > 4
+        || ACHuffmanTables.length > 4)
+      throw new IllegalArgumentException("argument has too many elements");
+
+    if (DCHuffmanTables.length != ACHuffmanTables.length)
+      throw new IllegalArgumentException("Huffman table arrays differ in length");
+
+    // Do a shallow copy.  JPEGQTable's data is not directly
+    // modifyable since JPEGQTable.getTable returns a copy.  Therefore
+    // it is safe to have multiple references to a single JPEGQTable.
+    // Likewise for JPEGHuffmanTable.
+    this.qTables = (JPEGQTable[]) qTables.clone();
+    this.DCHuffmanTables = (JPEGHuffmanTable[]) DCHuffmanTables.clone();
+    this.ACHuffmanTables = (JPEGHuffmanTable[]) ACHuffmanTables.clone();
+  }
+
+  /**
+   * Clear the quantization and Huffman decoding tables.
+   */
+  public void unsetDecodeTables()
+  {
+    qTables = null;
+    DCHuffmanTables = null;
+    ACHuffmanTables = null;
+  }
+
+  /**
+   * Retrieve the quantization tables.
+   *
+   * @returns an array of JPEG quantization tables
+   */
+  public JPEGQTable[] getQTables()
+  {
+    return qTables == null ? qTables : (JPEGQTable[]) qTables.clone();
+  }
+
+  /**
+   * Retrieve the DC Huffman tables.
+   *
+   * @return an array of JPEG DC Huffman tables
+   */
+  public JPEGHuffmanTable[] getDCHuffmanTables()
+  {
+    return DCHuffmanTables == null ? DCHuffmanTables
+      : (JPEGHuffmanTable[]) DCHuffmanTables.clone();
+  }
+
+  /**
+   * Retrieve the AC Huffman tables.
+   *
+   * @return an array of JPEG AC Huffman tables
+   */
+  public JPEGHuffmanTable[] getACHuffmanTables()
+  {
+    return ACHuffmanTables == null ? ACHuffmanTables
+      : (JPEGHuffmanTable[]) ACHuffmanTables.clone();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,293 @@
+/* JPEGImageWriteParam.java --
+ Copyright (C)  2006  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 javax.imageio.plugins.jpeg;
+
+import java.util.Locale;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+import javax.imageio.ImageWriteParam;
+
+/**
+ * The JPEGImageWriteParam class can be used to specify tables and
+ * settings used in the JPEG encoding process.  Encoding tables are
+ * taken from the metadata associated with the output stream, and
+ * failing that (if the metadata tables are null) from an instance of
+ * JPEGImageWriteParam.  The default metadata uses the standard JPEG
+ * tables from the JPEGQTable and JPEGHuffmanTable classes.  Non-null
+ * metadata tables override JPEGImageWriteParam tables.  Compression
+ * settings range from 1.0, best compression, through 0.75, default
+ * compression, to 0.0, worst compression.
+ *
+ * A JPEGImageWriteParam instance is retrieved from the built-in JPEG
+ * ImageWriter using the getDefaultImageWriteParam method.
+ */
+public class JPEGImageWriteParam
+  extends ImageWriteParam
+{
+  private JPEGQTable[] qTables;
+  private JPEGHuffmanTable[] DCHuffmanTables;
+  private JPEGHuffmanTable[] ACHuffmanTables;
+  private boolean optimize;
+  private String[] compressionQualityDescriptions;
+  private float[] compressionQualityValues;
+
+  /**
+   * Localized messages are stored in separate files.
+   */
+  private ResourceBundle messages;
+
+  /**
+   * Construct a JPEGImageWriteParam with the following state: tiling
+   * is not supported, progressive mode is supported, initial
+   * progressive mode is MODE_DISABLED, compression is supported, one
+   * compression type named "JPEG" is supported and the default
+   * compression quality is 0.75f.  Compression type names and
+   * compression quality descriptions are localized to the given
+   * locale.
+   *
+   * @param locale the locale used for message localization
+   */
+  public JPEGImageWriteParam(Locale locale)
+  {
+    super(locale);
+
+    // Get localized compression type and compression quality
+    // description strings for the given locale.
+    messages = PropertyResourceBundle.getBundle
+      ("javax/imageio/plugins/jpeg/MessagesBundle", locale);
+
+    // Initialize inherited ImageWriter fields.
+    canWriteTiles = false;
+    canWriteProgressive = true;
+    progressiveMode = MODE_DISABLED;
+    canWriteCompressed = true;
+    compressionTypes = new String[]
+      {
+        messages.getString("compression.types.jpeg")
+      };
+    compressionType = compressionTypes[0];
+    compressionQuality = 0.75f;
+  }
+
+  /**
+   * Reset the compression quality to 0.75f.
+   */
+  public void unsetCompression()
+  {
+    compressionQuality = 0.75f;
+  }
+
+  /**
+   * Check if compression algorithm is lossless.  JPEGImageWriteParam
+   * overrides this ImageWriteParam method to always return false
+   * since JPEG compression is inherently lossy.
+   *
+   * @return false
+   */
+  public boolean isCompressionLossless()
+  {
+    return false;
+  }
+
+  /**
+   * Retrieve an array of compression quality descriptions.  These
+   * messages are localized using the locale provided upon
+   * construction.  Each compression quality description in the
+   * returned array corresponds to the compression quality value at
+   * the same index in the array returned by
+   * getCompressionQualityValues.
+   *
+   * @return an array of strings each of which describes a compression
+   * quality value
+   */
+  public String[] getCompressionQualityDescriptions()
+  {
+    // Make sure exceptions are thrown when this image write param is
+    // in the wrong state.
+    super.getCompressionQualityDescriptions();
+
+    if (compressionQualityDescriptions == null)
+      {
+        compressionQualityDescriptions = new String[]
+          {
+            messages.getString("compression.minimum"),
+            messages.getString("compression.default"),
+            messages.getString("compression.maximum")
+          };
+      }
+
+    return compressionQualityDescriptions;
+  }
+
+  /**
+   * Retrieve an array of compression quality values, ordered from
+   * lowest quality to highest quality.
+   *
+   * @return an array of compressions quality values
+   */
+  public float[] getCompressionQualityValues()
+  {
+    // Make sure exceptions are thrown when this image write param is
+    // in the wrong state.
+    super.getCompressionQualityValues();
+
+    if (compressionQualityValues == null)
+      compressionQualityValues = new float[] { 0.05f, 0.75f, 0.95f };
+
+    return compressionQualityValues;
+  }
+
+  /**
+   * Check if the encoding tables are set.
+   *
+   * @return true if the encoding tables are set, false otherwise
+   */
+  public boolean areTablesSet()
+  {
+    // If qTables is not null then all tables are set.
+    return (qTables != null);
+  }
+
+  /**
+   * Set the quantization and Huffman tables that will be used to
+   * encode the stream.  Copies are created of the array arguments.
+   * The number of Huffman tables must be the same in both Huffman
+   * table arrays.  No argument may be null and no array may be longer
+   * than four elements.
+   *
+   * @param qTables JPEG quantization tables
+   * @param DCHuffmanTables JPEG DC Huffman tables
+   * @param ACHuffmanTables JPEG AC Huffman tables
+   *
+   * @throws IllegalArgumentException if any argument is null, if any
+   * of the arrays are longer than four elements, or if the Huffman
+   * table arrays do not have the same number of elements
+   */
+  public void setEncodeTables(JPEGQTable[] qTables,
+                              JPEGHuffmanTable[] DCHuffmanTables,
+                              JPEGHuffmanTable[] ACHuffmanTables)
+  {
+    if (qTables == null || DCHuffmanTables == null || ACHuffmanTables == null)
+      throw new IllegalArgumentException("null argument");
+
+    if (qTables.length > 4 || DCHuffmanTables.length > 4
+        || ACHuffmanTables.length > 4)
+      throw new IllegalArgumentException("argument has too many elements");
+
+    if (DCHuffmanTables.length != ACHuffmanTables.length)
+      throw new IllegalArgumentException("Huffman table arrays differ in length");
+
+    // Do a shallow copy.  JPEGQTable's data is not directly
+    // modifyable since JPEGQTable.getTable returns a copy.  Therefore
+    // it is safe to have multiple references to a single JPEGQTable.
+    // Likewise for JPEGHuffmanTable.
+    this.qTables = (JPEGQTable[]) qTables.clone();
+    this.DCHuffmanTables = (JPEGHuffmanTable[]) DCHuffmanTables.clone();
+    this.ACHuffmanTables = (JPEGHuffmanTable[]) ACHuffmanTables.clone();
+  }
+
+  /**
+   * Clear the quantization and Huffman encoding tables.
+   */
+  public void unsetEncodeTables()
+  {
+    qTables = null;
+    DCHuffmanTables = null;
+    ACHuffmanTables = null;
+  }
+
+  /**
+   * Retrieve the quantization tables.
+   *
+   * @returns an array of JPEG quantization tables
+   */
+  public JPEGQTable[] getQTables()
+  {
+    return qTables == null ? qTables : (JPEGQTable[]) qTables.clone();
+  }
+
+  /**
+   * Retrieve the DC Huffman tables.
+   *
+   * @return an array of JPEG DC Huffman tables
+   */
+  public JPEGHuffmanTable[] getDCHuffmanTables()
+  {
+    return DCHuffmanTables == null ? DCHuffmanTables
+      : (JPEGHuffmanTable[]) DCHuffmanTables.clone();
+  }
+
+  /**
+   * Retrieve the AC Huffman tables.
+   *
+   * @return an array of JPEG AC Huffman tables
+   */
+  public JPEGHuffmanTable[] getACHuffmanTables()
+  {
+    return ACHuffmanTables == null ? ACHuffmanTables
+      : (JPEGHuffmanTable[]) ACHuffmanTables.clone();
+  }
+
+  /**
+   * Specify whether or not Huffman tables written to the output
+   * stream should be optimized.  Every image encoded with this flag
+   * set will contain a Huffman table, and the generated Huffman
+   * tables will override those specified in the metadata.
+   *
+   * @param optimize true to generate optimized Huffman tables, false
+   * otherwise
+   */
+  public void setOptimizeHuffmanTables(boolean optimize)
+  {
+    this.optimize = optimize;
+  }
+
+  /**
+   * Check whether or not Huffman tables written to the output stream
+   * will be optimized.  Unless otherwise set using
+   * setOptimizeHuffmanTables, this returns false.
+   *
+   * @return true Huffman tables written to the output stream will be
+   * optimized, false otherwise
+   */
+  public boolean getOptimizeHuffmanTables()
+  {
+    return optimize;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/plugins/jpeg/JPEGQTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,196 @@
+/* JPEGQTable.java --
+ Copyright (C)  2006  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 javax.imageio.plugins.jpeg;
+
+/**
+ * The JPEGQTable class represents a quantization table that can be
+ * used to encode or decode a JPEG stream.  The standard JPEG
+ * luminance and chrominance quantization tables are provided as
+ * static fields.  Table entries are stored in natural order, not
+ * zig-zag order.
+ */
+public class JPEGQTable
+{
+  /**
+   * The table entries, stored in natural order.
+   */
+  private int[] table;
+
+  /**
+   * The standard JPEG luminance quantization table.  Values are
+   * stored in natural order.
+   */
+  public static final JPEGQTable K1Luminance = new JPEGQTable(new int[]
+      {
+        16, 11, 10, 16,  24,  40,  51,  61,
+        12, 12, 14, 19,  26,  58,  60,  55,
+        14, 13, 16, 24,  40,  57,  69,  56,
+        14, 17, 22, 29,  51,  87,  80,  62,
+        18, 22, 37, 56,  68, 109, 103,  77,
+        24, 35, 55, 64,  81, 104, 113,  92,
+        49, 64, 78, 87, 103, 121, 120, 101,
+        72, 92, 95, 98, 112, 100, 103,  99
+      }, false);
+
+  /**
+   * The standard JPEG luminance quantization table, scaled by
+   * one-half.  Values are stored in natural order.
+   */
+  public static final JPEGQTable K1Div2Luminance =
+    K1Luminance.getScaledInstance(0.5f, true);
+
+  /**
+   * The standard JPEG chrominance quantization table.  Values are
+   * stored in natural order.
+   */
+  public static final JPEGQTable K2Chrominance = new JPEGQTable(new int[]
+      {
+        17, 18, 24, 47, 99, 99, 99, 99,
+        18, 21, 26, 66, 99, 99, 99, 99,
+        24, 26, 56, 99, 99, 99, 99, 99,
+        47, 66, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99
+      }, false);
+
+  /**
+   * The standard JPEG chrominance quantization table, scaled by
+   * one-half.  Values are stored in natural order.
+   */
+  public static final JPEGQTable K2Div2Chrominance =
+    K2Chrominance.getScaledInstance(0.5f, true);
+
+  /**
+   * Construct a new JPEG quantization table.  A copy is created of
+   * the table argument.
+   *
+   * @param table the 64-element value table, stored in natural order
+   *
+   * @throws IllegalArgumentException if the table is null or if
+   * table's length is not equal to 64.
+   */
+  public JPEGQTable(int[] table)
+  {
+    this(checkTable(table), true);
+  }
+
+  /**
+   * Private constructor that avoids unnecessary copying and argument
+   * checking.
+   *
+   * @param table the 64-element value table, stored in natural order
+   * @param copy true if a copy should be created of the given table
+   */
+  private JPEGQTable(int[] table, boolean copy)
+  {
+    this.table = copy ? (int[]) table.clone() : table;
+  }
+
+  private static int[] checkTable(int[] table)
+  {
+    if (table == null || table.length != 64)
+      throw new IllegalArgumentException("invalid JPEG quantization table");
+
+    return table;
+  }
+
+  /**
+   * Retrieve a copy of the quantization values for this table.
+   *
+   * @return a copy of the quantization value array
+   */
+  public int[] getTable()
+  {
+    return (int[]) table.clone();
+  }
+
+  /**
+   * Retrieve a copy of this JPEG quantization table with every value
+   * scaled by the given scale factor, and clamped from 1 to 255
+   * baseline or from 1 to 32767 otherwise.
+   *
+   * @param scaleFactor the factor by which to scale this table
+   * @param forceBaseline clamp scaled values to a maximum of 255 if
+   * true, 32767 if false
+   *
+   * @return a new scaled JPEG quantization table
+   */
+  public JPEGQTable getScaledInstance(float scaleFactor,
+                                      boolean forceBaseline)
+  {
+    int[] scaledTable = getTable();
+    int max = forceBaseline ? 255 : 32767;
+
+    for (int i = 0; i < scaledTable.length; i++)
+      {
+        scaledTable[i] = Math.round (scaleFactor * (float) scaledTable[i]);
+        if (scaledTable[i] < 1)
+          scaledTable[i] = 1;
+        else if (scaledTable[i] > max)
+          scaledTable[i] = max;
+      }
+
+    // Do not copy scaledTable.  It is already a copy because we used
+    // getTable to retrieve it.
+    return new JPEGQTable(scaledTable, false);
+  }
+
+  /**
+   * Create a string representing this JPEG quantization table.
+   */
+  public String toString()
+  {
+    StringBuffer buffer = new StringBuffer();
+
+    buffer.append("JPEGQTable:\n");
+    for (int i = 0; i < 8; i++)
+      {
+        buffer.append("        ");
+        for (int j = 0; j < 8; j++)
+          {
+            buffer.append(table[i * 8 + j] + " ");
+          }
+        buffer.append("\n");
+      }
+
+    return buffer.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIORegistry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIORegistry.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIORegistry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIORegistry.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,119 @@
+/* IIORegistry.java --
+   Copyright (C) 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 javax.imageio.spi;
+
+import gnu.classpath.ServiceFactory;
+import gnu.java.awt.ClasspathToolkit;
+
+import java.awt.Toolkit;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import gnu.javax.imageio.bmp.BMPImageReaderSpi;
+import gnu.javax.imageio.bmp.BMPImageWriterSpi;
+import gnu.javax.imageio.gif.GIFImageReaderSpi;
+import gnu.javax.imageio.png.PNGImageReaderSpi;
+
+public final class IIORegistry extends ServiceRegistry
+{
+  private static final HashSet defaultCategories = new HashSet();
+  
+  private static HashMap instances = new HashMap();
+
+  static
+  {
+    defaultCategories.add(ImageReaderSpi.class);
+    defaultCategories.add(ImageWriterSpi.class);
+    defaultCategories.add(ImageTranscoderSpi.class);
+    defaultCategories.add(ImageInputStreamSpi.class);
+    defaultCategories.add(ImageOutputStreamSpi.class);
+  }
+  
+  public static synchronized IIORegistry getDefaultInstance()
+  {
+    // XXX: This leaks memory if a ThreadGroup isn't available anymore.
+    ThreadGroup group = Thread.currentThread().getThreadGroup();
+    IIORegistry registry = (IIORegistry) instances.get(group);
+    
+    if (registry == null)
+      {
+        registry = new IIORegistry();
+        instances.put(group, registry);
+      }
+    
+    return registry;
+  }
+
+  private IIORegistry()
+  {
+    super(defaultCategories.iterator());
+
+    // XXX: Register built-in Spis here.
+    registerServiceProvider(new PNGImageReaderSpi()); // Register PNG decoder.
+    registerServiceProvider(new GIFImageReaderSpi()); // Register GIF decoder.
+    registerServiceProvider(new BMPImageReaderSpi());
+    registerServiceProvider(new BMPImageWriterSpi());
+
+    Toolkit toolkit = Toolkit.getDefaultToolkit();
+    if (toolkit instanceof ClasspathToolkit)
+      ((ClasspathToolkit)toolkit).registerImageIOSpis(this);
+    
+    registerApplicationClasspathSpis();
+  }
+
+  /**
+   * Registers all available service providers found on the application
+   * classpath.
+   */
+  public void registerApplicationClasspathSpis()
+  {
+    ClassLoader loader = Thread.currentThread().getContextClassLoader();
+    Iterator categories = getCategories();
+
+    while (categories.hasNext())
+      {
+	Class category = (Class) categories.next();
+	Iterator providers = ServiceFactory.lookupProviders(category, loader);
+
+	while (providers.hasNext())
+	  registerServiceProvider((IIOServiceProvider) providers.next());
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIOServiceProvider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIOServiceProvider.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIOServiceProvider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/IIOServiceProvider.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,163 @@
+/* IIOServiceProvider.java -- General service provider for image I/O.
+   Copyright (C) 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 javax.imageio.spi;
+
+import java.util.Locale;
+
+
+/**
+ * An abstract superclass for service providers that perform image I/O.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class IIOServiceProvider
+  implements RegisterableService
+{
+  /**
+   * The vendor of this service provider, or <code>null</code> if the
+   * subclass constructor did not set this field.
+   *
+   * @see #getVendorName()
+   */
+  protected String vendorName;
+
+
+  /**
+   * The version of this service provider, or <code>null</code> if the
+   * subclass constructor did not set this field.
+   *
+   * @see #getVersion()
+   */
+  protected String version;
+
+
+  /**
+   * Constructs a general <code>IIOServiceProvider</code>, given the
+   * vendor name and a version string.
+   *
+   * @throws IllegalArgumentException if <code>vendorName</code>
+   * or <code>version</code> is <code>null</code>.
+   */
+  public IIOServiceProvider(String vendorName, String version)
+  {
+    if (vendorName == null || version == null)
+      throw new IllegalArgumentException();
+
+    this.vendorName = vendorName;
+    this.version = version;
+  }
+
+
+  /**
+   * Constructs a general <code>IIOServiceProvider</code> without
+   * specifying a vendor name and a version string. The subclass
+   * constructor should set the {@link #vendorName} and {@link
+   * #version} to non-null values.
+   */
+  public IIOServiceProvider()
+  {
+  }
+
+
+  /**
+   * Informs this service provider that it has been registered in a
+   * {@link ServiceRegistry}. If this provider gets registered as an
+   * implementor for several service categories, its
+   * <code>onRegistration</code> method will be called multiple times.
+   * The default implementation does nothing.
+   *
+   * @param registry the registry to which this service provider has
+   * been added.
+   *
+   * @param category the service category for which this provider has
+   * been registered as an implementor.
+   */
+  public void onRegistration(ServiceRegistry registry, Class category)
+  {
+  }
+
+
+  /**
+   * Informs this service provider that it has been de-registered from
+   * a {@link ServiceRegistry}. If this provider had been registered
+   * as an implementor for several service categories, its
+   * <code>onDeregistration</code> method will be called multiple
+   * times. The default implementation does nothing.
+   *
+   * @param registry the registry from which this service provider has
+   * been removed.
+   *
+   * @param category the service category for which this provider has
+   * been registered as an implementor.
+   */
+  public void onDeregistration(ServiceRegistry registry, Class category)
+  {
+  }
+
+
+  /**
+   * Returns the name of the vendor of this service provider.
+   */
+  public String getVendorName()
+  {
+    return vendorName;
+  }
+
+
+  /**
+   * Returns an identifier string for the version of this service
+   * provider.
+   */
+  public String getVersion()
+  {
+    return version;
+  }
+
+
+  /**
+   * Returns a short description of this service provider that can be
+   * presented to a human user.
+   *
+   * @param locale the locale for which the description string should
+   * be localized.
+   */
+  public abstract String getDescription(Locale locale);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageInputStreamSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageInputStreamSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageInputStreamSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageInputStreamSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* ImageInputStreamSpi.java -- Service provider for image input streams.
+   Copyright (C) 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 javax.imageio.spi;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * An abstract superclass for service providers that create
+ * {@linkplain javax.imageio.stream.ImageInputStream image input
+ * streams} for a file, URL, byte array or any other source.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ImageInputStreamSpi
+  extends IIOServiceProvider
+{
+  /**
+   * Indicates which kind of input is processable by the streams
+   * created by {@link #createInputStreamInstance(Object)}.
+   */
+  protected Class inputClass;
+
+
+  /**
+   * Constructs a service provider for image input streams, given no
+   * parameters. It is up to the sub-class to set {@link #vendorName},
+   * {@link #version} and {@link #inputClass} to non-null values.
+   */
+  protected ImageInputStreamSpi()
+  {
+  }
+
+
+  /**
+   * Constructs a service provider for image input streams, given the
+   * vendor name and a version string.
+   *
+   * @throws IllegalArgumentException if <code>vendorName</code>
+   * or <code>version</code> is <code>null</code>.
+   */
+  public ImageInputStreamSpi(String vendorName, String version,
+                             Class inputClass)
+  {
+    super(vendorName, version);
+    this.inputClass = inputClass;
+  }
+
+
+  /**
+   * Determines which kind of input is processable by the streams
+   * created by {@link #createInputStreamInstance(Object)}.
+   */
+  public Class getInputClass()
+  {
+    return inputClass;
+  }
+
+
+  /**
+   * Determines whether <code>ImageInputStreams</code> created
+   * by this service provider benefit from using a cache file.
+   *
+   * <p>The default behavior is to return <code>false</code>.
+   *
+   * @return <code>true</code> if the created streams are faster or
+   * need less memory when a cache file is being used;
+   * <code>false</code> if no positive effect results from the cache
+   * file.
+   */
+  public boolean canUseCacheFile()
+  {
+    return false;
+  }
+
+
+  /**
+   * Determines whether <code>ImageInputStreams</code> created
+   * by this service provider require the use of a cache file.
+   *
+   * <p>The default behavior is to return <code>false</code>.
+   *
+   * @return <code>true</code> if the created streams can only work
+   * when a cache file is being used; <code>false</code> if no cache
+   * file is needed.
+   */
+  public boolean needsCacheFile()
+  {
+    return false;
+  }
+
+
+  public abstract ImageInputStream createInputStreamInstance(Object input,
+                                                             boolean useCache,
+                                                             File cacheDir)
+    throws IOException;
+
+
+  public ImageInputStream createInputStreamInstance(Object input)
+    throws IOException
+  {
+    return createInputStreamInstance(input, canUseCacheFile(), null);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageOutputStreamSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageOutputStreamSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageOutputStreamSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageOutputStreamSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,143 @@
+/* ImageOutputStreamSpi.java -- Service provider for image output streams.
+   Copyright (C) 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 javax.imageio.spi;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.stream.ImageOutputStream;
+
+/**
+ * An abstract superclass for service providers that create
+ * {@linkplain javax.imageio.stream.ImageOutputStream image output
+ * streams} for a file, URL, byte array or any other target.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ImageOutputStreamSpi
+  extends IIOServiceProvider
+{
+  /**
+   * Indicates which kind of output is produced by the streams
+   * created by {@link #createOutputStreamInstance(Object)}.
+   */
+  protected Class outputClass;
+
+
+  /**
+   * Constructs a service provider for image output streams, given no
+   * parameters. It is up to the sub-class to set {@link #vendorName},
+   * {@link #version} and {@link #outputClass} to non-null values.
+   */
+  protected ImageOutputStreamSpi()
+  {
+  }
+
+
+  /**
+   * Constructs a service provider for image output streams, given the
+   * vendor name, a version string and the kind of producable output.
+   *
+   * @throws IllegalArgumentException if <code>vendorName</code>
+   * or <code>version</code> is <code>null</code>.
+   */
+  public ImageOutputStreamSpi(String vendorName, String version,
+                              Class outputClass)
+  {
+    super(vendorName, version);
+    this.outputClass = outputClass;
+  }
+
+
+  /**
+   * Determines which kind of output is produced by the streams
+   * created by {@link #createOutputStreamInstance(Object)}.
+   */
+  public Class getOutputClass()
+  {
+    return outputClass;
+  }
+
+
+  /**
+   * Determines whether <code>ImageOutputStreams</code> created
+   * by this service provider benefit from using a cache file.
+   *
+   * <p>The default behavior is to return <code>false</code>.
+   *
+   * @return <code>true</code> if the created streams are faster or
+   * need less memory when a cache file is being used;
+   * <code>false</code> if no positive effect results from the cache
+   * file.
+   */
+  public boolean canUseCacheFile()
+  {
+    return false;
+  }
+
+
+  /**
+   * Determines whether <code>ImageOutputStreams</code> created
+   * by this service provider require the use of a cache file.
+   *
+   * <p>The default behavior is to return <code>false</code>.
+   *
+   * @return <code>true</code> if the created streams can only work
+   * when a cache file is being used; <code>false</code> if no cache
+   * file is needed.
+   */
+  public boolean needsCacheFile()
+  {
+    return false;
+  }
+
+
+  public abstract ImageOutputStream createOutputStreamInstance(
+    Object output, boolean useCache, File cacheDir)
+    throws IOException;
+
+
+  public ImageOutputStream createOutputStreamInstance(Object output)
+    throws IOException
+  {
+    return createOutputStreamInstance(output, canUseCacheFile(), null);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* ImageReaderSpi.java --
+   Copyright (C) 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 javax.imageio.spi;
+
+import java.io.IOException;
+
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public abstract class ImageReaderSpi extends ImageReaderWriterSpi
+{
+  public static final Class[] STANDARD_INPUT_TYPE =
+    { ImageInputStream.class };
+
+  protected Class[] inputTypes;
+  protected String[] writerSpiNames;
+
+  protected ImageReaderSpi()
+  {
+    // Do nothing here.
+  }
+
+  public ImageReaderSpi(String vendorName, String version, String[] names,
+                        String[] suffixes, String[] MIMETypes,
+                        String readerClassName, Class[] inputTypes,
+                        String[] writerSpiNames,
+                        boolean supportsStandardStreamMetadataFormat,
+                        String nativeStreamMetadataFormatName,
+                        String nativeStreamMetadataFormatClassName,
+                        String[] extraStreamMetadataFormatNames,
+                        String[] extraStreamMetadataFormatClassNames,
+                        boolean supportsStandardImageMetadataFormat,
+                        String nativeImageMetadataFormatName,
+                        String nativeImageMetadataFormatClassName,
+                        String[] extraImageMetadataFormatNames,
+                        String[] extraImageMetadataFormatClassNames)
+  {
+    super(vendorName, version, names, suffixes, MIMETypes, readerClassName,
+          supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName,
+          nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames,
+          extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat,
+          nativeImageMetadataFormatName, nativeImageMetadataFormatClassName,
+          extraImageMetadataFormatNames, extraImageMetadataFormatClassNames);
+
+    if (inputTypes == null
+        || inputTypes.length == 0)
+      throw new IllegalArgumentException("inputTypes may not be null or empty");
+    
+    this.inputTypes = inputTypes;
+    this.writerSpiNames = writerSpiNames;
+  }
+
+  public abstract boolean canDecodeInput(Object source)
+    throws IOException;
+
+  public ImageReader createReaderInstance()
+    throws IOException
+  {
+    return createReaderInstance(null);
+  }
+
+  public abstract ImageReader createReaderInstance(Object extension)
+    throws IOException;
+
+  public String[] getImageWriterSpiNames()
+  {
+    return writerSpiNames;
+  }
+
+  public Class[] getInputTypes()
+  {
+    return inputTypes;
+  }
+
+  public boolean isOwnReader(ImageReader reader)
+  {
+    if (reader == null)
+      throw new IllegalArgumentException("reader may not be null");
+    
+    return pluginClassName.equals(reader.getClass().getName());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderWriterSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderWriterSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderWriterSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageReaderWriterSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,511 @@
+/* ImageReaderWriterSpi.java -- Superclass for image reader and writer spis.
+   Copyright (C) 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 javax.imageio.spi;
+
+import javax.imageio.metadata.IIOMetadataFormat;
+import javax.imageio.metadata.IIOMetadataFormatImpl;
+
+/**
+ * An abstract superclass that contains the common parts of {@link
+ * javax.imageio.spi.ImageReaderSpi} and {@link
+ * javax.imageio.spi.ImageWriterSpi}.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ImageReaderWriterSpi
+  extends IIOServiceProvider
+{
+  /**
+   * The human-readable, localized names of the supported image
+   * formats. This value should be non-<code>null</code> after
+   * construction.
+   *
+   * @see #getFormatNames()
+   */
+  protected String[] names;
+
+
+  /**
+   * The file suffixes of the supported image formats. This value
+   * should be non-<code>null</code> after construction.
+   *
+   * @see #getFileSuffixes()
+   */
+  protected String[] suffixes;
+
+
+  /**
+   * The MIME types of the supported image formats.  This value
+   * should be non-<code>null</code> after construction.
+   *
+   * @see #getMIMETypes()
+   */
+  protected String[] MIMETypes;
+
+
+  /**
+   * The fully qualified name of the class that implements the {@link
+   * javax.imageio.ImageReader} or {@link javax.imageio.ImageWriter}
+   * interface.  This value should be non-<code>null</code> after
+   * construction.
+   *
+   * @see #getPluginClassName()
+   */
+  protected String pluginClassName;
+
+
+  /**
+   * Indicates whether the per-stream {@linkplain
+   * javax.imageio.metadata.IIOMetadata metadata objects} associated
+   * with this plug-in support format
+   * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
+   * <code>getAsTree</code> and <code>setAsTree</code> methods.
+   *
+   * @see #isStandardStreamMetadataFormatSupported()
+   */
+  protected boolean supportsStandardStreamMetadataFormat;
+
+
+  /**
+   * The name of the format that allows encoding all stream metadata
+   * without loss, or <code>null</code> if this plug-in does not
+   * provide a format that preserves all stream metadata.
+   */
+  protected String nativeStreamMetadataFormatName;
+
+  protected String nativeStreamMetadataFormatClassName;
+
+
+  /**
+   * The names of additional formats for encoding stream metadata,
+   * other than the {@linkplain
+   * #isStandardStreamMetadataFormatSupported() standard} and the
+   * {@linkplain #getNativeStreamMetadataFormatName() native} formats,
+   * or <code>null</code> if this plug-in does not provide any extra
+   * formats.
+   */
+  protected String[] extraStreamMetadataFormatNames;
+
+
+  protected String[] extraStreamMetadataFormatClassNames;
+
+
+  /**
+   * Indicates whether the per-image {@linkplain
+   * javax.imageio.metadata.IIOMetadata metadata objects} associated
+   * with this plug-in support format
+   * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
+   * <code>getAsTree</code> and <code>setAsTree</code> methods.
+   *
+   * @see #isStandardImageMetadataFormatSupported()
+   */
+  protected boolean supportsStandardImageMetadataFormat;
+
+
+  /**
+   * The name of the format that allows encoding all image metadata
+   * without loss, or <code>null</code> if this plug-in does not
+   * provide a format that preserves all image metadata.
+   */
+  protected String nativeImageMetadataFormatName;
+
+  protected String nativeImageMetadataFormatClassName;
+
+
+  /**
+   * The names of additional formats for encoding image metadata,
+   * other than the {@linkplain
+   * #isStandardImageMetadataFormatSupported() standard} and the
+   * {@linkplain #getNativeImageMetadataFormatName() native} formats,
+   * or <code>null</code> if this plug-in does not provide any extra
+   * formats.
+   */
+  protected String[] extraImageMetadataFormatNames;
+
+
+  protected String[] extraImageMetadataFormatClassNames;
+
+
+  /**
+   * Constructs an <code>ImageReaderWriteSpi</code> instance, without
+   * specifying a number of parameters. Constructors of concrete
+   * subclasses must ensure that they set all inherited fields to
+   * meaningful values.
+   */
+  public ImageReaderWriterSpi()
+  {
+  }
+
+
+  /**
+   * Constructs an <code>ImageReaderWriteSpi</code> instance,
+   * specifying a number of parameters.
+   *
+   * @param names the human-readable, localized names of the supported
+   * image formats, for example <code>[&#x201c;Tagged Image File
+   * Format&#x201d;, &#x201c;Portable Network
+   * Graphics&#x201d;]</code>.
+   *
+   * @param suffixes the file suffixes of the supported image formats,
+   * for example <code>[&#x201c;tiff&#x201d;, &#x201c;tif&#x201d;,
+   * &#x201c;png&#x201d;]</code>.
+   *
+   * @param MIMETypes the MIME types of the supported image formats,
+   * for example <code>[&#x201c;image/tiff&#x201d;,
+   * &#x201c;image/png&#x201d;]</code>.
+   *
+   * @param pluginClassName the fully qualified name of the class that
+   * implements the {@link javax.imageio.ImageReader} or {@link
+   * javax.imageio.ImageWriter} interface.
+   *
+   * @param supportsStandardStreamMetadataFormat whether the
+   * per-stream {@linkplain javax.imageio.metadata.IIOMetadata
+   * metadata objects} associated with this plug-in support format
+   * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
+   * <code>getAsTree</code> and <code>setAsTree</code> methods.
+   *
+   * @param nativeStreamMetadataFormatName the name of the format that
+   * allows encoding all stream metadata without loss, or
+   * <code>null</code> if this plug-in does not provide a format that
+   * preserves all stream metadata.
+   *
+   * @param extraStreamMetadataFormatNames the names of additional
+   * formats for encoding stream metadata, other than the {@linkplain
+   * #isStandardStreamMetadataFormatSupported() standard} and the
+   * {@linkplain #getNativeStreamMetadataFormatName() native} formats,
+   * or <code>null</code> if this plug-in does not provide any extra
+   * formats.
+   *
+   * @param supportsStandardImageMetadataFormat whether the per-image
+   * {@linkplain javax.imageio.metadata.IIOMetadata metadata objects}
+   * associated with this plug-in support format
+   * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
+   * <code>getAsTree</code> and <code>setAsTree</code> methods.
+   *
+   * @param nativeImageMetadataFormatName the name of the format that
+   * allows encoding all image metadata without loss, or
+   * <code>null</code> if this plug-in does not provide a format that
+   * preserves all image metadata.
+   *
+   * @param extraImageMetadataFormatNames the names of additional
+   * formats for encoding image metadata, other than the {@linkplain
+   * #isStandardImageMetadataFormatSupported() standard} and the
+   * {@linkplain #getNativeImageMetadataFormatName() native} formats,
+   * or <code>null</code> if this plug-in does not provide any extra
+   * formats.
+   *
+   * @throws IllegalArgumentException if <code>vendorName</code>
+   * or <code>version</code> is <code>null</code>.
+   */
+  public ImageReaderWriterSpi(String vendorName, String version,
+                              String[] names, String[] suffixes,
+                              String[] MIMETypes, String pluginClassName,
+                              boolean supportsStandardStreamMetadataFormat,
+                              String nativeStreamMetadataFormatName,
+                              String nativeStreamMetadataFormatClassName,
+                              String[] extraStreamMetadataFormatNames,
+                              String[] extraStreamMetadataFormatClassNames,
+                              boolean supportsStandardImageMetadataFormat,
+                              String nativeImageMetadataFormatName,
+                              String nativeImageMetadataFormatClassName,
+                              String[] extraImageMetadataFormatNames,
+                              String[] extraImageMetadataFormatClassNames)
+  {
+    /* The inherited constructor will throw IllegalArgumentException
+     * if one of its arguments is null.
+     */
+    super(vendorName, version);
+
+    if (names == null || names.length == 0 || pluginClassName == null)
+      throw new IllegalArgumentException();
+
+    this.names = names;
+    this.suffixes = suffixes;
+    this.MIMETypes = MIMETypes;
+    this.pluginClassName = pluginClassName;
+
+    this.supportsStandardStreamMetadataFormat
+      = supportsStandardStreamMetadataFormat;
+
+    this.nativeStreamMetadataFormatName
+      = nativeStreamMetadataFormatName;
+
+    this.nativeStreamMetadataFormatClassName
+      = nativeStreamMetadataFormatClassName;
+
+    this.extraStreamMetadataFormatNames
+      = extraStreamMetadataFormatNames;
+
+    this.extraStreamMetadataFormatClassNames
+      = extraStreamMetadataFormatClassNames;
+
+    this.supportsStandardImageMetadataFormat
+      = supportsStandardImageMetadataFormat;
+
+    this.nativeImageMetadataFormatName
+      = nativeImageMetadataFormatName;
+
+    this.nativeImageMetadataFormatClassName
+      = nativeImageMetadataFormatClassName;
+
+    this.extraImageMetadataFormatNames
+      = extraImageMetadataFormatNames;
+
+    this.extraImageMetadataFormatClassNames
+      = extraImageMetadataFormatClassNames;
+  }
+
+
+  /**
+   * Returns the human-readable, localized names of the supported
+   * image formats. For example, a plug-in might return an array with
+   * the elements <code>[&#x201c;Tagged Image File Format&#x201d;,
+   * &#x201c;Portable Network Graphics&#x201d;]</code>.
+   */
+  public String[] getFormatNames()
+  {
+    return (String[]) names.clone();
+  }
+
+
+  /**
+   * Returns the file suffixes of the supported image formats, for
+   * example <code>[&#x201c;tiff&#x201d;, &#x201c;tif&#x201d;,
+   * &#x201c;png&#x201d;]</code>.
+   */
+  public String[] getFileSuffixes()
+  {
+    return suffixes;
+  }
+
+
+  /**
+   * Returns the MIME types of the supported image formats, for
+   * example <code>[&#x201c;image/tiff&#x201d;,
+   * &#x201c;image/png&#x201d;]</code>.
+   *
+   * @return an array of MIME type strings, or <code>null</code> if
+   * none of the supported formats has an associated MIME type.
+   */
+  public String[] getMIMETypes()
+  {
+    return MIMETypes;
+  }
+
+
+  /**
+   * Returns the fully qualified name of the class that implements the
+   * {@link javax.imageio.ImageReader} or {@link
+   * javax.imageio.ImageWriter} interface.
+   */
+  public String getPluginClassName()
+  {
+    return pluginClassName;
+  }
+
+
+  /**
+   * Returns whether the per-stream {@linkplain
+   * javax.imageio.metadata.IIOMetadata metadata objects} associated
+   * with this plug-in support format
+   * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
+   * <code>getAsTree</code> and <code>setAsTree</code> methods.
+   */
+  public boolean isStandardStreamMetadataFormatSupported()
+  {
+    return supportsStandardStreamMetadataFormat;
+  }
+
+
+  /**
+   * Returns the name of the format that allows encoding all stream
+   * metadata without loss, or <code>null</code> if this plug-in does
+   * not provide a format that preserves all stream metadata.
+   *
+   * @see #getNativeImageMetadataFormatName()
+   */
+  public String getNativeStreamMetadataFormatName()
+  {
+    return nativeStreamMetadataFormatName;
+  }
+
+
+  /**
+   * Returns the names of additional formats for encoding stream
+   * metadata, other than the {@linkplain
+   * #isStandardStreamMetadataFormatSupported() standard} and the
+   * {@linkplain #getNativeStreamMetadataFormatName() native} formats,
+   * or <code>null</code> if this plug-in does not provide any extra
+   * formats.
+   *
+   * @see #getExtraImageMetadataFormatNames()
+   */
+  public String[] getExtraStreamMetadataFormatNames()
+  {
+    return extraStreamMetadataFormatNames;
+  }
+
+
+  /**
+   * Returns whether the per-image {@linkplain
+   * javax.imageio.metadata.IIOMetadata metadata objects} associated
+   * with this plug-in support format
+   * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
+   * <code>getAsTree</code> and <code>setAsTree</code> methods.
+   */
+  public boolean isStandardImageMetadataFormatSupported()
+  {
+    return supportsStandardImageMetadataFormat;
+  }
+
+
+  /**
+   * Returns the name of the format that allows encoding all image
+   * metadata without loss, or <code>null</code> if this plug-in does
+   * not provide a format that preserves all image metadata.
+   *
+   * @see #getNativeStreamMetadataFormatName()
+   */
+  public String getNativeImageMetadataFormatName()
+  {
+    return nativeImageMetadataFormatName;
+  }
+
+
+  /**
+   * Returns the names of additional formats for encoding image
+   * metadata, other than the {@linkplain
+   * #isStandardImageMetadataFormatSupported() standard} and the
+   * {@linkplain #getNativeImageMetadataFormatName() native} formats,
+   * or <code>null</code> if this plug-in does not provide any extra
+   * formats.
+   *
+   * @see #getExtraStreamMetadataFormatNames()
+   */
+  public String[] getExtraImageMetadataFormatNames()
+  {
+    return extraImageMetadataFormatNames;
+  }
+
+  /**
+   * Returns an IIOMetadataFormat object that represents the requested
+   * stream metadata format or null if the given format is supported
+   * but no IIOMetadataFormat can be created for it.
+   *
+   * @param formatName the requested stream metadata format name
+   *
+   * @return an IIOMetadataFormat object or null
+   *
+   * @throws IllegalArgumentException if formatName is null or is not
+   * one of the standard metadata format or this provider's native or
+   * extra stream metadata formats
+   */
+  public IIOMetadataFormat getStreamMetadataFormat (String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException ("null stream metadata format name");
+
+    if (!formatName.equals (getNativeStreamMetadataFormatName())
+        && !formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+      {
+        String[] extraNames = getExtraStreamMetadataFormatNames ();
+        boolean foundName = false;
+        for (int i = 0; i < extraNames.length; i++)
+          {
+            if (formatName.equals(extraNames[i]))
+              {
+                foundName = true;
+                break;
+              }
+          }
+        if (!foundName)
+          throw new IllegalArgumentException ("unsupported stream metadata format name");
+      }
+
+    if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+      return IIOMetadataFormatImpl.getStandardFormatInstance ();
+    else
+      // Default implementation returns null.
+      return null;
+  }
+
+  /**
+   * Returns an IIOMetadataFormat object that represents the requested
+   * image metadata format or null if the given format is supported
+   * but no IIOMetadataFormat can be created for it.
+   *
+   * @param formatName the requested image metadata format name
+   *
+   * @return an IIOMetadataFormat object or null
+   *
+   * @throws IllegalArgumentException if formatName is null or is not
+   * one of the standard metadata format or this provider's native or
+   * extra image metadata formats
+   */
+  public IIOMetadataFormat getImageMetadataFormat (String formatName)
+  {
+    if (formatName == null)
+      throw new IllegalArgumentException ("null image metadata format name");
+
+    if (!formatName.equals (getNativeImageMetadataFormatName())
+        && !formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+      {
+        String[] extraNames = getExtraImageMetadataFormatNames ();
+        boolean foundName = false;
+        for (int i = 0; i < extraNames.length; i++)
+          {
+            if (formatName.equals(extraNames[i]))
+              {
+                foundName = true;
+                break;
+              }
+          }
+        if (!foundName)
+          throw new IllegalArgumentException ("unsupported image metadata format name");
+      }
+
+    if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+      return IIOMetadataFormatImpl.getStandardFormatInstance ();
+    else
+      // Default implementation returns null.
+      return null;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageTranscoderSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageTranscoderSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageTranscoderSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageTranscoderSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* ImageTranscoderSpi.java -- Factory for image metadata transcoders.
+   Copyright (C) 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 javax.imageio.spi;
+
+import javax.imageio.ImageTranscoder;
+
+
+/**
+ * An abstract superclass for service providers that create
+ * {@linkplain javax.imageio.ImageTranscoder image metadata
+ * transcoders}.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public abstract class ImageTranscoderSpi
+  extends IIOServiceProvider
+{
+  /**
+   * Constructs a service provider for image metadata transcoders,
+   * given no parameters. It is up to the sub-class to set {@link
+   * #vendorName} and {@link #version} to non-null values.
+   */
+  protected ImageTranscoderSpi()
+  {
+  }
+
+
+  /**
+   * Constructs a service provider for image metadata transcoders,
+   * given the vendor name and a version string.
+   *
+   * @throws IllegalArgumentException if <code>vendorName</code>
+   * or <code>version</code> is <code>null</code>.
+   */
+  public ImageTranscoderSpi(String vendorName, String version)
+  {
+    super(vendorName, version);
+  }
+
+
+  public abstract String getReaderServiceProviderName();
+
+  public abstract String getWriterServiceProviderName();
+
+  public abstract ImageTranscoder createTranscoderInstance();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageWriterSpi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageWriterSpi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageWriterSpi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ImageWriterSpi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* ImageWriterSpi.java --
+   Copyright (C) 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 javax.imageio.spi;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public abstract class ImageWriterSpi extends ImageReaderWriterSpi
+{
+  public static final Class[] STANDARD_OUTPUT_TYPE =
+    { ImageOutputStream.class };
+
+  protected Class[] outputTypes;
+  protected String[] readerSpiNames;
+
+  protected ImageWriterSpi()
+  {
+    // Do nothing here.
+  }
+
+  public ImageWriterSpi(String vendorName, String version, String[] names,
+                        String[] suffixes, String[] MIMETypes,
+                        String writerClassName, Class[] outputTypes,
+                        String[] readerSpiNames,
+                        boolean supportsStandardStreamMetadataFormat,
+                        String nativeStreamMetadataFormatName,
+                        String nativeStreamMetadataFormatClassName,
+                        String[] extraStreamMetadataFormatNames,
+                        String[] extraStreamMetadataFormatClassNames,
+                        boolean supportsStandardImageMetadataFormat,
+                        String nativeImageMetadataFormatName,
+                        String nativeImageMetadataFormatClassName,
+                        String[] extraImageMetadataFormatNames,
+                        String[] extraImageMetadataFormatClassNames)
+  {
+    super(vendorName, version, names, suffixes, MIMETypes, writerClassName,
+          supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName,
+          nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames,
+          extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat,
+          nativeImageMetadataFormatName, nativeImageMetadataFormatClassName,
+          extraImageMetadataFormatNames, extraImageMetadataFormatClassNames);
+
+    if (writerClassName == null)
+      throw new IllegalArgumentException("writerClassName is null");
+
+    if (outputTypes == null
+        || outputTypes.length == 0)
+      throw new IllegalArgumentException("outputTypes may not be null or empty");
+    
+    this.outputTypes = outputTypes;
+    this.readerSpiNames = readerSpiNames;    
+  }
+
+  public abstract boolean canEncodeImage(ImageTypeSpecifier type);
+
+  public boolean canEncodeImage(RenderedImage image)
+  {
+    return canEncodeImage (new ImageTypeSpecifier(image));
+  }
+
+  public ImageWriter createWriterInstance()
+    throws IOException
+  {
+    return createWriterInstance(null);
+  }
+
+  public abstract ImageWriter createWriterInstance(Object extension)
+    throws IOException;
+
+  public String[] getImageReaderSpiNames()
+  {
+    return readerSpiNames;
+  }
+
+  public Class[] getOutputTypes()
+  {
+    return outputTypes;
+  }
+
+  public boolean isFormatLossless()
+  {
+    return true;
+  }
+
+  public boolean isOwnWriter(ImageWriter writer)
+  {
+    if (writer == null)
+      throw new IllegalArgumentException("writer may not be null");
+
+    return pluginClassName.equals(writer.getClass().getName());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/RegisterableService.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/RegisterableService.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/RegisterableService.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/RegisterableService.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* RegisterableService.java -- An interface for service providers.
+   Copyright (C) 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 javax.imageio.spi;
+
+
+/**
+ * An interface which service providers may optionally implement in
+ * order to get notified when they are added or removed from a {@link
+ * ServiceRegistry}.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public interface RegisterableService
+{
+  /**
+   * Informs this service provider that it has been registered in a
+   * {@link ServiceRegistry}. If this provider gets registered as an
+   * implementor for several service categories, its
+   * <code>onRegistration</code> method will be called multiple times.
+   *
+   * @param registry the registry to which this service provider has
+   * been added.
+   *
+   * @param category the service category for which this provider has
+   * been registered as an implementor.
+   */
+  void onRegistration(ServiceRegistry registry, Class category);
+
+
+  /**
+   * Informs this service provider that it has been de-registered from
+   * a {@link ServiceRegistry}. If this provider had been registered
+   * as an implementor for several service categories, its
+   * <code>onDeregistration</code> method will be called multiple
+   * times.
+   *
+   * @param registry the registry from which this service provider has
+   * been removed.
+   *
+   * @param category the service category for which this provider has
+   * been registered as an implementor.
+   */
+  void onDeregistration(ServiceRegistry registry, Class category);
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ServiceRegistry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ServiceRegistry.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ServiceRegistry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/ServiceRegistry.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,961 @@
+/* ServiceRegistry.java -- A simple registry for service providers.
+   Copyright (C) 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 javax.imageio.spi;
+
+import gnu.classpath.ServiceFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * A registry for service providers.
+ *
+ * @since 1.4
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class ServiceRegistry
+{
+  // Package-private to avoid a trampoline.
+  /**
+   * The service categories of this registry.
+   *
+   * <p>Note that we expect that only very few categories will
+   * typically be used with a registry. The most common case will be
+   * one, it seems unlikely that any registry would contain more than
+   * five or six categories. Therefore, we intentionally avoid the
+   * overhead of a HashMap.
+   *
+   * @see #providers
+   */
+  final Class[] categories;
+
+
+  /**
+   * The registered providers for each service category, indexed by
+   * the same index as the {@link #categories} array. If no provider
+   * is registered for a category, the array entry will be
+   * <code>null</code>.
+   *
+   * <p>Note that we expect that only very few providers will
+   * typically be registered for a category. The most common case will
+   * be one or two. Therefore, we intentionally avoid the overhead of
+   * a HashMap.
+   */
+  private final LinkedList[] providers;
+
+
+  /**
+   * The ordring constaints for each service category, indexed by the
+   * same index as the {@link #categories} array. The constraints for
+   * a service category are stored as a <code>Map<Object,
+   * Set<Object>></code>, where the Map&#x2019;s values are
+   * those providers that need to come after the key.  If no
+   * constraints are imposed on the providers of a category, the array
+   * entry will be <code>null</code>. If no constraints have been set
+   * whatsoever, <code>constraints</code> will be <code>null</code>.
+   *
+   * <p>Note that we expect that only very few constraints will
+   * typically be imposed on a category. The most common case will
+   * be zero.
+   */
+  private IdentityHashMap[] constraints;
+
+  
+  /**
+   * Constructs a <code>ServiceRegistry</code> for the specified
+   * service categories.
+   * 
+   * @param categories the categories to support
+   *
+   * @throws IllegalArgumentException if <code>categories</code> is
+   * <code>null</code>, or if its {@link Iterator#next()} method
+   * returns <code>null</code>.
+   *
+   * @throws ClassCastException if <code>categories</code> does not
+   * iterate over instances of {@link java.lang.Class}.
+   */
+  public ServiceRegistry(Iterator categories)
+  {
+    ArrayList cats = new ArrayList(/* expected size */ 10);
+
+    if (categories == null)
+      throw new IllegalArgumentException();
+
+    while (categories.hasNext())
+      {
+        Class cat = (Class) categories.next();
+        if (cat == null)
+          throw new IllegalArgumentException();
+        cats.add(cat);
+      }
+
+    int numCats = cats.size();
+    this.categories = (Class[]) cats.toArray(new Class[numCats]);
+    this.providers = new LinkedList[numCats];
+  }
+
+
+  /**
+   * Finds service providers that are implementing the specified
+   * Service Provider Interface.
+   *
+   * <p><b>On-demand loading:</b> Loading and initializing service
+   * providers is delayed as much as possible. The rationale is that
+   * typical clients will iterate through the set of installed service
+   * providers until one is found that matches some criteria (like
+   * supported formats, or quality of service). In such scenarios, it
+   * might make sense to install only the frequently needed service
+   * providers on the local machine. More exotic providers can be put
+   * onto a server; the server will only be contacted when no suitable
+   * service could be found locally.</p>
+   *
+   * <p><b>Security considerations:</b> Any loaded service providers
+   * are loaded through the specified ClassLoader, or the system
+   * ClassLoader if <code>classLoader</code> is
+   * <code>null</code>. When <code>lookupProviders</code> is called,
+   * the current {@link java.security.AccessControlContext} gets
+   * recorded. This captured security context will determine the
+   * permissions when services get loaded via the <code>next()</code>
+   * method of the returned <code>Iterator</code>.</p>
+   *
+   * @param spi the service provider interface which must be
+   * implemented by any loaded service providers.
+   *
+   * @param loader the class loader that will be used to load the
+   * service providers, or <code>null</code> for the system class
+   * loader. For using the context class loader, see {@link
+   * #lookupProviders(Class)}.
+   *
+   * @return an iterator over instances of <code>spi</code>.
+   *
+   * @throws IllegalArgumentException if <code>spi</code> is
+   * <code>null</code>.
+   */
+  public static Iterator lookupProviders(Class spi,
+                                         ClassLoader loader)
+  {
+    return ServiceFactory.lookupProviders(spi, loader);
+  }
+
+
+  /**
+   * Finds service providers that are implementing the specified
+   * Service Provider Interface, using the context class loader
+   * for loading providers.
+   *
+   * @param spi the service provider interface which must be
+   * implemented by any loaded service providers.
+   *
+   * @return an iterator over instances of <code>spi</code>.
+   *
+   * @throws IllegalArgumentException if <code>spi</code> is
+   * <code>null</code>.
+   *
+   * @see #lookupProviders(Class, ClassLoader)
+   */
+  public static Iterator lookupProviders(Class spi)
+  {
+    return ServiceFactory.lookupProviders(spi);
+  }
+
+
+  /**
+   * Returns an iterator over all service categories.
+   *
+   * @return an unmodifiable {@link
+   * java.util.Iterator}<{@link java.lang.Class}>.
+   */
+  public Iterator getCategories()
+  {
+    return new Iterator()
+      {
+        int index = -1;
+
+        public boolean hasNext()
+        {
+          return index < categories.length - 1;
+        }
+
+        public Object next()
+        {
+          if (!hasNext())
+            throw new NoSuchElementException();
+
+          return categories[++index];
+        }
+
+        public void remove()
+        {
+          throw new UnsupportedOperationException();
+        }
+      };
+  }
+
+
+  /**
+   * Registers a provider for a service category which is specified by
+   * the class-internal category ID.
+   *
+   * @param provider the service provider to be registered.
+   *
+   * @param cat the service category, which is identified by an index
+   * into the {@link #categories} array.
+   *
+   * @return <code>true</code> if <code>provider</code> is the first
+   * provider that gets registered for the specified service category;
+   * <code>false</code> if other providers have already been
+   * registered for the same servide category.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>.
+   *
+   * @throws ClassCastException if <code>provider</code> does not
+   * implement the specified service provider interface.
+   */
+  private synchronized boolean registerServiceProvider(Object provider,
+                                                       int cat)
+  {
+    LinkedList provs;
+    boolean result;
+    Class category;
+
+    if (provider == null)
+      throw new IllegalArgumentException();
+
+    category = categories[cat];
+    if (!category.isInstance(provider))
+      throw new ClassCastException(category.getName());
+
+    provs = providers[cat];
+    if (provs == null)
+    {
+      result = true;
+      provs = providers[cat] = new LinkedList();
+    }
+    else
+      result = false;
+
+    provs.add(provider);
+    if (provider instanceof RegisterableService)
+      ((RegisterableService) provider).onRegistration(this, category);
+
+    return result;
+  }
+
+
+  /**
+   * Registers a provider for the specified service category.
+   *
+   * <p>If <code>provider</code> implements the {@link
+   * RegisterableService} interface, its {@link
+   * RegisterableService#onRegistration onRegistration} method is
+   * invoked in order to inform the provider about the addition to
+   * this registry.
+   *
+   * @param provider the service provider to be registered.
+   *
+   * @param category the service category under which
+   * <code>provider</code> shall be registered.
+   *
+   * @return <code>true</code> if <code>provider</code> is the first
+   * provider that gets registered for the specified service category;
+   * <code>false</code> if other providers have already been
+   * registered for the same servide category.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>, or if <code>category</code> is not among the
+   * categories passed to the {@linkplain #ServiceRegistry(Iterator)
+   * constructor} of this ServiceRegistry.
+   *
+   * @throws ClassCastException if <code>provider</code> does not
+   * implement <code>category</code>.
+   */
+  public synchronized boolean registerServiceProvider(Object provider,
+                                                      Class category)
+  {
+    for (int i = 0; i < categories.length; i++)
+      if (categories[i] == category)
+        return registerServiceProvider(provider, i);
+    throw new IllegalArgumentException();
+  }
+
+
+  /**
+   * Registers a provider under all service categories it
+   * implements.
+   *
+   * <p>If <code>provider</code> implements the {@link
+   * RegisterableService} interface, its {@link
+   * RegisterableService#onRegistration onRegistration} method is
+   * invoked in order to inform the provider about the addition to
+   * this registry. If <code>provider</code> implements several
+   * service categories, <code>onRegistration</code> gets called
+   * multiple times.
+   *
+   * @param provider the service provider to be registered.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>, or if <code>provider</code> does not implement
+   * any of the service categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this ServiceRegistry.
+   */
+  public synchronized void registerServiceProvider(Object provider)
+  {
+    boolean ok = false;
+
+    if (provider == null)
+      throw new IllegalArgumentException();
+
+    for (int i = 0; i < categories.length; i++)
+      if (categories[i].isInstance(provider))
+        {
+          ok = true;
+          registerServiceProvider(provider, i);
+        }
+
+    if (!ok)
+      throw new IllegalArgumentException();
+  }
+
+
+  /**
+   * Registers a number of providers under all service categories they
+   * implement.
+   *
+   * <p>If a provider implements the {@link RegisterableService}
+   * interface, its {@link RegisterableService#onRegistration
+   * onRegistration} method is invoked in order to inform the provider
+   * about the addition to this registry. If <code>provider</code>
+   * implements several service categories,
+   * <code>onRegistration</code> gets called multiple times.
+   *
+   * @throws IllegalArgumentException if <code>providers</code> is
+   * <code>null</code>, if any iterated provider is <code>null</code>,
+   * or if some iterated provider does not implement any of the
+   * service categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this
+   * <code>ServiceRegistry</code>.
+   */
+  public synchronized void registerServiceProviders(Iterator providers)
+  {
+    if (providers == null)
+      throw new IllegalArgumentException();
+
+    while (providers.hasNext())
+      registerServiceProvider(providers.next());
+  }
+
+
+  /**
+   * De-registers a provider for a service category which is specified
+   * by the class-internal category ID.
+   *
+   * @param provider the service provider to be registered.
+   *
+   * @param cat the service category, which is identified by an index
+   * into the {@link #categories} array.
+   *
+   * @return <code>true</code> if <code>provider</code> was previously
+   * registered for the specified service category; <code>false</code>
+   * if if the provider had not been registered.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>.
+   *
+   * @throws ClassCastException if <code>provider</code> does not
+   * implement the specified service provider interface.
+   */
+  private synchronized boolean deregisterServiceProvider(Object provider,
+                                                         int cat)
+  {
+    LinkedList provs;
+    boolean result;
+    Class category;
+
+    if (provider == null)
+      throw new IllegalArgumentException();
+
+    category = categories[cat];
+    if (!category.isInstance(provider))
+      throw new ClassCastException(category.getName());
+
+    provs = providers[cat];
+    if (provs == null)
+      return false;
+
+    result = provs.remove(provider);
+    if (provs.isEmpty())
+      providers[cat] = null;
+
+    if (result && (provider instanceof RegisterableService))
+      ((RegisterableService) provider).onDeregistration(this, category);
+
+    return result;
+  }
+
+
+  /**
+   * De-registers a provider for the specified service category.
+   *
+   * <p>If <code>provider</code> implements the {@link
+   * RegisterableService} interface, its {@link
+   * RegisterableService#onDeregistration onDeregistration} method is
+   * invoked in order to inform the provider about the removal from
+   * this registry.
+   *
+   * @param provider the service provider to be de-registered.
+   *
+   * @param category the service category from which
+   * <code>provider</code> shall be de-registered.
+   *
+   * @return <code>true</code> if <code>provider</code> was previously
+   * registered for the specified service category; <code>false</code>
+   * if if the provider had not been registered.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>, or if <code>category</code> is not among the
+   * categories passed to the {@linkplain #ServiceRegistry(Iterator)
+   * constructor} of this ServiceRegistry.
+   *
+   * @throws ClassCastException if <code>provider</code> does not
+   * implement <code>category</code>.
+   */
+  public synchronized boolean deregisterServiceProvider(Object provider,
+                                                        Class category)
+  {
+    for (int i = 0; i < categories.length; i++)
+      if (categories[i] == category)
+        return deregisterServiceProvider(provider, i);
+    throw new IllegalArgumentException();
+  }
+  
+  
+  /**
+   * De-registers a provider from all service categories it
+   * implements.
+   *
+   * <p>If <code>provider</code> implements the {@link
+   * RegisterableService} interface, its {@link
+   * RegisterableService#onDeregistration onDeregistration} method is
+   * invoked in order to inform the provider about the removal from
+   * this registry. If <code>provider</code> implements several
+   * service categories, <code>onDeregistration</code> gets called
+   * multiple times.</p>
+   *
+   * @param provider the service provider to be de-registered.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>, or if <code>provider</code> does not implement
+   * any of the service categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this
+   * <code>ServiceRegistry</code>.
+   */
+  public synchronized void deregisterServiceProvider(Object provider)
+  {
+    boolean ok = false;
+
+    if (provider == null)
+      throw new IllegalArgumentException();
+
+    for (int i = 0; i < categories.length; i++)
+      if (categories[i].isInstance(provider))
+        {
+          ok = true;
+          deregisterServiceProvider(provider, i);
+        }
+
+    if (!ok)
+      throw new IllegalArgumentException();
+  }
+
+
+  /**
+   * De-registers all providers which have been registered for the
+   * specified service category.
+   *
+   * <p>If a provider implements the {@link RegisterableService}
+   * interface, its {@link RegisterableService#onDeregistration
+   * onDeregistration} method is invoked in order to inform the
+   * provider about the removal from this registry. If the provider
+   * implements several service categories,
+   * <code>onDeregistration</code> gets called multiple times.
+   *
+   * @param category the category whose registered providers will be
+   * de-registered.
+   *
+   * @throws IllegalArgumentException if <code>category</code> is not
+   * among the categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this
+   * <code>ServiceRegistry</code>.
+   */
+  public synchronized void deregisterAll(Class category)
+  {
+    boolean ok = false;
+
+    for (int i = 0; i < categories.length; i++)
+      {
+        if (categories[i] != category)
+          continue;
+
+        ok = true;
+        while (providers[i] != null)
+          deregisterServiceProvider(providers[i].get(0), i);
+      }
+
+    if (!ok)
+      throw new IllegalArgumentException();
+  }
+
+
+  /**
+   * De-registers all service providers.
+   *
+   * <p>If a provider implements the {@link RegisterableService}
+   * interface, its {@link RegisterableService#onDeregistration
+   * onDeregistration} method is invoked in order to inform the
+   * provider about the removal from this registry. If the provider
+   * implements several service categories,
+   * <code>onDeregistration</code> gets called multiple times.
+   */
+  public synchronized void deregisterAll()
+  {
+    for (int i = 0; i < categories.length; i++)
+      while (providers[i] != null)
+        deregisterServiceProvider(providers[i].get(0), i);
+  }
+
+
+  /**
+   * Called by the Virtual Machine when it detects that this
+   * <code>ServiceRegistry</code> has become garbage. De-registers all
+   * service providers, which will cause those that implement {@link
+   * RegisterableService} to receive a {@link
+   * RegisterableService#onDeregistration onDeregistration}
+   * notification.
+   */
+  public void finalize()
+    throws Throwable
+  {
+    super.finalize();
+    deregisterAll();
+  }
+
+
+  /**
+   * Determines whether a provider has been registered with this
+   * registry.
+   *
+   * @return <code>true</code> if <code>provider</code> has been
+   * registered under any service category; <code>false</code> if
+   * it is not registered.
+   *
+   * @throws IllegalArgumentException if <code>provider</code> is
+   * <code>null</code>.
+   */
+  public synchronized boolean contains(Object provider)
+  {
+    if (provider == null)
+      throw new IllegalArgumentException();
+
+    // Note that contains is rather unlikely to be ever called,
+    // so it would be wasteful to keep a special data structure
+    // (such as a HashSet) for making it a fast operation.
+    for (int i = 0; i < providers.length; i++)
+      {
+        // If provider does not implement categories[i],
+        // it would not have been possible to register it there.
+        // In that case, it would be pointless to look there.
+        if (!categories[i].isInstance(provider))
+          continue;
+
+        // But if the list of registered providers contains provider,
+        // we have found it.
+        LinkedList p = providers[i];
+        if (p != null && p.contains(provider))
+          return true;
+      }
+
+    return false;
+  }
+
+
+  /**
+   * Returns the index in {@link #categories} occupied by the
+   * specified service category.
+   *
+   * @throws IllegalArgumentException if <code>category</code> is not
+   * among the categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this ServiceRegistry.
+   */
+  private int getCategoryID(Class category)
+  {
+    for (int i = 0; i < categories.length; i++)
+      if (categories[i] == category)
+        return i;
+
+    throw new IllegalArgumentException();
+  }
+
+
+  /**
+   * Retrieves all providers that have been registered for the
+   * specified service category.
+   *
+   * @param category the service category whose providers are
+   * to be retrieved.
+   *
+   * @param useOrdering <code>true</code> in order to retrieve the
+   * providers in an order imposed by the {@linkplain #setOrdering
+   * ordering constraints}; <code>false</code> in order to retrieve
+   * the providers in any order.
+   *
+   * @throws IllegalArgumentException if <code>category</code> is not
+   * among the categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this
+   * <code>ServiceRegistry</code>.
+   *
+   * @see #getServiceProviders(Class, Filter, boolean)
+   */
+  public Iterator getServiceProviders(Class category, boolean useOrdering)
+  {
+    return getServiceProviders(category, null, useOrdering);
+  }
+
+
+  /**
+   * Retrieves all providers that have been registered for the
+   * specified service category and that satisfy the criteria
+   * of a custom filter.
+   *
+   * @param category the service category whose providers are
+   * to be retrieved.
+   *
+   * @param filter a custom filter, or <code>null</code> to
+   * retrieve all registered providers for the specified
+   * category.
+   *
+   * @param useOrdering <code>true</code> in order to retrieve the
+   * providers in an order imposed by the {@linkplain #setOrdering
+   * ordering constraints}; <code>false</code> in order to retrieve
+   * the providers in any order.
+   *
+   * @throws IllegalArgumentException if <code>category</code> is not
+   * among the categories passed to the {@linkplain
+   * #ServiceRegistry(Iterator) constructor} of this
+   * <code>ServiceRegistry</code>.
+   */
+  public synchronized Iterator getServiceProviders(Class category,
+                                                   Filter filter,
+                                                   boolean useOrdering)
+  {
+    int catid;
+    LinkedList provs;
+    ArrayList result;
+
+    catid = getCategoryID(category);
+    provs = providers[catid];
+    if (provs == null)
+      return Collections.EMPTY_LIST.iterator();
+    
+    result = new ArrayList(provs.size());
+    for (Iterator iter = provs.iterator(); iter.hasNext();)
+      {
+        Object provider = iter.next();
+        if (filter == null || filter.filter(provider))
+          result.add(provider);
+      }
+
+    // If we are supposed to obey ordering constraints, and
+    // if any constraints have been imposed on the specified
+    // service category, sort the result.
+    if (useOrdering && constraints != null)
+      {
+        final Map cons = constraints[catid];
+        if (cons != null)
+          Collections.sort(result, new Comparator()
+            {
+              public int compare(Object o1, Object o2)
+              {
+                Set s;
+
+                if (o1 == o2)
+                  return 0;
+                
+                s = (Set) cons.get(o1);
+                if (s != null && s.contains(o2))
+                  return -1;  // o1 < o2
+
+                s = (Set) cons.get(o2);
+                if (s != null && s.contains(o1))
+                  return 1;  // o1 > o2
+
+                return 0; // o1 == o2
+              }
+            });
+      }
+
+    return result.iterator();
+  }
+
+
+  /**
+   * Returns one of the service providers that is a subclass of the
+   * specified class.
+   * 
+   * @param providerClass a class to search for.
+   */
+  public synchronized Object getServiceProviderByClass(Class providerClass)
+  {
+    if (providerClass == null)
+      throw new IllegalArgumentException();
+
+    // Note that the method getServiceProviderByClass is rather
+    // unlikely to be ever called, so it would be wasteful to keep a
+    // special data structure for making it a fast operation.
+    for (int cat = 0; cat < categories.length; cat++)
+      {
+        if (!categories[cat].isAssignableFrom(providerClass))
+          continue;
+        
+        LinkedList provs = providers[cat];
+        if (provs == null)
+          continue;
+
+        for (Iterator iter = provs.iterator(); iter.hasNext();)
+          {
+            Object provider = iter.next();
+            if (providerClass.isInstance(provider))
+              return provider;
+          }
+      }
+
+    return null;
+  }
+
+
+  /**
+   * Adds an ordering constraint on service providers.
+   *
+   * @param category the service category to which an ordering
+   * constraint is to be added.
+   *
+   * @param first the provider which is supposed to come before
+   * <code>second</code>.
+   *
+   * @param second the provider which is supposed to come after
+   * <code>first</code>.
+   *
+   * @throws IllegalArgumentException if <code>first</code> and
+   * <code>second</code> are referring to the same object, or if one
+   * of them is <code>null</code>.
+   *
+   * @see #unsetOrdering
+   * @see #getServiceProviders(Class, Filter, boolean)
+   */
+  public synchronized boolean setOrdering(Class category,
+                                          Object firstProvider,
+                                          Object secondProvider)
+  {
+    return addConstraint(getCategoryID(category), firstProvider,
+                         secondProvider);
+  }
+
+
+  /**
+   * Removes an ordering constraint on service providers.
+   *
+   * @param category the service category from which an ordering
+   * constraint is to be removed.
+   *
+   * @param first the provider which is supposed to come before
+   * <code>second</code>.
+   *
+   * @param second the provider which is supposed to come after
+   * <code>first</code>.
+   *
+   * @throws IllegalArgumentException if <code>first</code> and
+   * <code>second</code> are referring to the same object, or if one
+   * of them is <code>null</code>.
+   *
+   * @see #setOrdering
+   */
+  public synchronized boolean unsetOrdering(Class category,
+                                            Object firstProvider,
+                                            Object secondProvider)
+  {
+    return removeConstraint(getCategoryID(category),
+                            firstProvider, secondProvider);
+  }
+
+
+  /**
+   * Adds an ordering constraint on service providers.
+   *
+   * @param catid the service category ID, which is the
+   * category&#x2019;s index into the {@link #categories} array.
+   *
+   * @param first the provider which is supposed to come before
+   * <code>second</code>.
+   *
+   * @param second the provider which is supposed to come after
+   * <code>first</code>.
+   *
+   * @throws IllegalArgumentException if <code>first</code> and
+   * <code>second</code> are referring to the same object, or if one
+   * of them is <code>null</code>.
+   */
+  private boolean addConstraint(int catid, Object first, Object second)
+  {
+    Set s;
+    IdentityHashMap cons;
+
+    // Also checks argument validity.
+    removeConstraint(catid, second, first);
+
+    if (constraints == null)
+      constraints = new IdentityHashMap[categories.length];
+    cons = constraints[catid];
+    if (cons == null)
+      cons = constraints[catid] = new IdentityHashMap();
+
+    s = (Set) cons.get(first);
+    if (s == null)
+      cons.put(first, s = new HashSet());
+    return s.add(second);
+  }
+
+
+  /**
+   * Removes an ordering constraint on service providers.
+   *
+   * @param catid the service category ID, which is the
+   * category&#x2019;s index into the {@link #categories} array.
+   *
+   * @param first the provider which is supposed to come before
+   * <code>second</code>.
+   *
+   * @param second the provider which is supposed to come after
+   * <code>first</code>.
+   *
+   * @throws IllegalArgumentException if <code>first</code> and
+   * <code>second</code> are referring to the same object, or if one
+   * of them is <code>null</code>.
+   */
+  private boolean removeConstraint(int catid, Object first, Object second)
+  {
+    Collection s;
+    IdentityHashMap cons;
+
+    if (first == null || second == null || first == second)
+      throw new IllegalArgumentException();
+
+    if (constraints == null)
+      return false;
+
+    cons = constraints[catid];
+    if (cons == null)
+      return false;
+
+    s = (Collection) cons.get(first);
+    if (s == null)
+      return false;
+
+    if (!s.remove(second))
+      return false;
+
+    // If we removed the last constraint for a service category,
+    // we can get free some memory.
+    if (cons.isEmpty())
+      {
+        constraints[catid] = null;
+        boolean anyConstraints = false;
+        for (int i = 0; i < constraints.length; i++)
+          {
+            if (constraints[i] != null)
+              {
+                anyConstraints = true;
+                break;
+              }
+          }
+        if (!anyConstraints)
+          constraints = null;
+      }
+
+    return true;
+  }
+
+
+  /**
+   * A filter for selecting service providers that match custom
+   * criteria.
+   *
+   * @see ServiceRegistry#getServiceProviders(Class, Filter,
+   * boolean)
+   *
+   * @since 1.4
+   *
+   * @author Michael Koch (konqueror at gmx.de)
+   * @author Sascha Brawer (brawer at dandelis.ch)
+   */
+  public static interface Filter
+  {
+    /**
+     * Checks whether the specified service provider matches the
+     * constraints of this Filter.
+     *
+     * @param provider the service provider in question.
+     *
+     * @return <code>true</code> if <code>provider</code> matches the
+     * criteria; <code>false</code> if it does not match.
+     */
+    boolean filter(Object provider);
+  };
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/spi/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio.spi package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio.spi</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* FileCacheImageInputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class FileCacheImageInputStream extends ImageInputStreamImpl
+{
+  private InputStream stream;
+  private File cacheDir;
+  
+  public FileCacheImageInputStream(InputStream stream, File cacheDir)
+    throws IOException
+  {
+    super();
+    this.stream = stream;
+    // FIXME: We do not support caching yet.
+    this.cacheDir = cacheDir;
+  }
+
+  public void close()
+    throws IOException
+  {
+    if (stream != null)
+      {
+	stream.close();
+	stream = null;
+      }
+  }
+
+  private void checkStreamClosed()
+    throws IOException
+  {
+    if (stream == null)
+      throw new IOException("stream closed");
+  }
+
+  public boolean isCached()
+  {
+    return true;
+  }
+
+  public boolean isCachedFile()
+  {
+    return true;
+  }
+  
+  public boolean isCachedMemory()
+  {
+    return false;
+  }
+
+  public int read()
+    throws IOException
+  {
+    checkStreamClosed();
+    setBitOffset(0);
+    return stream.read();
+  }
+
+  public int read(byte[] data, int offset, int len)
+    throws IOException
+  {
+    checkStreamClosed();
+    setBitOffset(0);
+    return stream.read(data, offset, len);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileCacheImageOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,125 @@
+/* FileCacheImageOutputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import gnu.classpath.NotImplementedException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class FileCacheImageOutputStream extends ImageOutputStreamImpl
+{
+  private OutputStream stream;
+  private File cacheDir;
+  
+  public FileCacheImageOutputStream(OutputStream stream, File cacheDir)
+    throws IOException
+  {
+    super();
+    this.stream = stream;
+    // FIXME: We do not support caching yet.
+    this.cacheDir = cacheDir;
+  }
+
+  public void close()
+    throws IOException
+  {
+    if (stream != null)
+      {
+	stream.close();
+	stream = null;
+      }
+  }
+
+  private void checkStreamClosed()
+    throws IOException
+  {
+    if (stream == null)
+      throw new IOException("stream closed");
+  }
+
+  public boolean isCached()
+  {
+    return true;
+  }
+
+  public boolean isCachedFile()
+  {
+    return true;
+  }
+  
+  public boolean isCachedMemory()
+  {
+    return false;
+  }
+  
+  public int read()
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public int read(byte[] data, int offset, int len)
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public void write(byte[] data, int offset, int len)
+    throws IOException
+  {
+    checkStreamClosed();
+    // FIXME: Flush pending bits.
+    stream.write(data, offset, len);
+  }
+
+  public void write(int value)
+    throws IOException
+  {
+    checkStreamClosed();
+    // FIXME: Flush pending bits.
+    stream.write(value);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* FileImageInputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class FileImageInputStream extends ImageInputStreamImpl
+{
+  private RandomAccessFile file;
+  
+  public FileImageInputStream(File file)
+    throws FileNotFoundException, IOException
+  {
+    if (file == null)
+      throw new IllegalArgumentException ("file may not be null");
+
+    this.file = new RandomAccessFile(file, "r");
+  }
+
+  public FileImageInputStream(RandomAccessFile file)
+  {
+    if (file == null)
+      throw new IllegalArgumentException ("file may not be null");
+
+    this.file = file;
+  }
+
+  public void close()
+    throws IOException
+  {
+    file.close();
+  }
+
+  public long length()
+  {
+    try
+      {
+        return file.length();
+      }
+    catch (IOException e)
+      {
+        return -1L;
+      }
+  }
+
+  public int read()
+    throws IOException
+  {
+    setBitOffset(0);
+    return file.read();
+  }
+
+  public int read(byte[] data, int offset, int len)
+    throws IOException
+  {
+    setBitOffset(0);
+    return file.read(data, offset, len);
+  }
+
+  public void seek(long position)
+    throws IOException
+  {
+    super.seek(position);
+    file.seek(position);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/FileImageOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,133 @@
+/* FileImageOutputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class FileImageOutputStream extends ImageOutputStreamImpl
+{
+  private RandomAccessFile file;
+  
+  public FileImageOutputStream(File file)
+    throws FileNotFoundException, IOException
+  {
+    if (file == null)
+      throw new IllegalArgumentException("file may not be null");
+
+    // Do security check.
+    file.canRead();
+
+    this.file = new RandomAccessFile(file, "r");
+  }
+
+  public FileImageOutputStream(RandomAccessFile file)
+  {
+    if (file == null)
+      throw new IllegalArgumentException("file may not be null");
+
+    this.file = file;
+  }
+
+  public void close()
+    throws IOException
+  {
+    file.close();
+  }
+
+  public long length()
+  {
+    try
+      {
+        return file.length();
+      }
+    catch (IOException e)
+      {
+        return -1L;
+      }
+  }
+
+  public int read()
+    throws IOException
+  {
+    checkClosed();
+    
+    setBitOffset(0);
+    return file.read();
+  }
+
+  public int read(byte[] data, int offset, int len)
+    throws IOException
+  {
+    checkClosed();
+    
+    setBitOffset(0);
+    return file.read(data, offset, len);
+  }
+
+  public void seek(long position)
+    throws IOException
+  {
+    super.seek(position);
+    file.seek(position);
+  }
+
+  public void write(byte[] data, int offset, int len)
+    throws IOException
+  {
+    checkClosed();
+    
+    flushBits();
+    file.write(data, offset, len);
+  }
+
+  public void write(int value)
+    throws IOException
+  {
+    checkClosed();
+    
+    // FIXME: Flush pending bits.
+    file.write(value);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/IIOByteBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/IIOByteBuffer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/IIOByteBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/IIOByteBuffer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,94 @@
+/* IIOByteBuffer.java
+   Copyright (C) 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 javax.imageio.stream;
+
+/**
+ * A data structure for holding a reference to a byte array, an index
+ * into that array, and a number of bytes, that can be passed to one
+ * specific variant of the {@link
+ * javax.imageio.stream.ImageInputStream#readBytes(IIOByteBuffer, int)
+ * readBytes} method.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public class IIOByteBuffer
+{
+  private byte[] data;
+  private int offset;
+  private int length;
+
+  public IIOByteBuffer(byte[] data, int offset, int length)
+  {
+    this.data = data;
+    this.offset = offset;
+    this.length = length;
+  }
+
+  public byte[] getData()
+  {
+    return data;
+  }
+
+  public void setData(byte[] data)
+  {
+    this.data = data;
+  }
+
+  public int getOffset()
+  {
+    return offset;
+  }
+
+  public void setOffset(int offset)
+  {
+    this.offset = offset;
+  }
+
+  public int getLength()
+  {
+    return length;
+  }
+
+  public void setLength(int length)
+  {
+    this.length = length;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,651 @@
+/* ImageInputStream.java
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.DataInput;
+import java.io.EOFException;
+import java.io.IOException;
+import java.nio.ByteOrder;
+
+
+/**
+ * An input stream for use by {@link javax.imageio.ImageReader
+ * ImageReaders}.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public interface ImageInputStream
+  extends DataInput
+{
+  void setByteOrder(ByteOrder order);
+
+  ByteOrder getByteOrder();
+  
+  int read()
+    throws IOException;
+
+  int read(byte[] b)
+    throws IOException;
+
+  int read(byte[] b, int offset, int length)
+    throws IOException;
+
+
+  /**
+   * Reads up to a specified number of bytes, and modifies a
+   * {@link IIOByteBuffer} to hold the read data.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   *
+   * @param buf an <code>IIOByteBuffer</code> that will hold the read
+   * data.
+   *
+   * @param numBytes the maximum number of bytes to read.
+   *
+   * @throws IndexOutOfBoundsException if <code>numBytes</code> is
+   * negative.
+   *
+   * @throws NullPointerException if <code>buf</code> is
+   * <code>null</code>.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   */
+  void readBytes(IIOByteBuffer buf, int numBytes)
+    throws IOException;
+
+
+  /**
+   * Reads a byte and checks whether or not its value is zero.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before the byte is read.
+   *
+   * @throws EOFException if the input stream is at its end.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readBit()
+   * @see #readByte()
+   * @see #readFully(byte[], int, int)
+   */
+  boolean readBoolean()
+    throws IOException;
+
+
+  /**
+   * Reads a signed byte.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   *
+   * @throws EOFException if the input stream is at its end.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readUnsignedByte()
+   * @see #readFully(byte[], int, int)
+   */
+  byte readByte()
+    throws IOException;
+
+
+  /**
+   * Reads an unsigned byte.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   *
+   * @throws EOFException if the input stream is at its end.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readByte()
+   * @see #readFully(byte[], int, int)
+   */
+  int readUnsignedByte()
+    throws IOException;
+
+
+  /**
+   * Reads an signed 16-bit integer. If necessary, the value gets
+   * converted from the stream&#x2019;s {@linkplain #getByteOrder()
+   * current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @throws EOFException if the input stream ends before all two
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readUnsignedShort()
+   * @see #readChar()
+   * @see #readFully(short[], int, int)
+   */
+  short readShort()
+    throws IOException;
+
+
+  /**
+   * Reads an unsigned 16-bit integer. If necessary, the value gets
+   * converted from the stream&#x2019;s {@linkplain #getByteOrder()
+   * current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * <p>This method does the same as {@link #readChar()}.
+   *
+   * @throws EOFException if the input stream ends before all two
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readShort()
+   * @see #readChar()
+   * @see #readFully(char[], int, int)
+   */
+  int readUnsignedShort()
+    throws IOException;
+
+
+  /**
+   * Reads an unsigned 16-bit integer. If necessary, the value gets
+   * converted from the stream&#x2019;s {@linkplain #getByteOrder()
+   * current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * <p>This method does the same as {@link #readUnsignedShort()}.
+   *
+   * @throws EOFException if the input stream ends before all two
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readFully(char[], int, int)
+   */
+  char readChar()
+    throws IOException;
+
+
+  /**
+   * Reads a signed 32-bit integer. If necessary, the value gets
+   * converted from the stream&#x2019;s {@linkplain #getByteOrder()
+   * current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @throws EOFException if the input stream ends before all four
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readUnsignedInt()
+   * @see #readFully(int[], int, int)
+   */
+  int readInt()
+    throws IOException;
+
+
+  /**
+   * Reads an unsigned 32-bit integer. If necessary, the value gets
+   * converted from the stream&#x2019;s {@linkplain #getByteOrder()
+   * current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @throws EOFException if the input stream ends before all four
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readInt()
+   * @see #readFully(int[], int, int)
+   */
+  long readUnsignedInt()
+    throws IOException;
+
+
+  /**
+   * Reads a signed 64-bit integer. If necessary, the value gets
+   * converted from the stream&#x2019;s {@linkplain #getByteOrder()
+   * current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @throws EOFException if the input stream ends before all eight
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readFully(long[], int, int)
+   */
+  long readLong()
+    throws IOException;
+
+
+  /**
+   * Reads an IEEE 32-bit single-precision floating point number. If
+   * necessary, the value gets converted from the stream&#x2019;s
+   * {@linkplain #getByteOrder() current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @throws EOFException if the input stream ends before all four
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readFully(float[], int, int)
+   */
+  float readFloat()
+    throws IOException;
+
+
+  /**
+   * Reads an IEEE 64-bit double-precision floating point number. If
+   * necessary, the value gets converted from the stream&#x2019;s
+   * {@linkplain #getByteOrder() current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @throws EOFException if the input stream ends before all eight
+   * bytes were read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readFully(double[], int, int)
+   */
+  double readDouble()
+    throws IOException;
+
+  String readLine()
+    throws IOException;
+
+  String readUTF()
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of signed 8-bit integers into a
+   * <code>byte[]</code> array.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param b an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>b</code>
+   * that will hold read data.
+   *
+   * @param numBytes the number of bytes to read.
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numBytes</code> is negative, or if <code>offset +
+   * numBytes</code> exceeds <code>b.length</code>.
+   *
+   * @throws NullPointerException if <code>b</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readByte()
+   */
+  void readFully(byte[] b, int offset, int numBytes)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of signed 8-bit integers into a
+   * <code>byte[]</code> array.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param b an array for storing the read values.
+   *
+   * @throws NullPointerException if <code>b</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readByte()
+   * @see #readFully(byte[], int, int)
+   */
+  void readFully(byte[] b)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of signed 16-bit integers into a
+   * <code>short[]</code> array.  If necessary, values are converted
+   * from the stream&#x2019;s {@linkplain #getByteOrder() current byte
+   * order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param s an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>s</code>
+   * that will hold read data.
+   *
+   * @param numShorts the number of signed 16-bit integers to read
+   * (which is one half of the number of bytes).
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numShorts</code> is negative, or if <code>offset +
+   * numShorts</code> exceeds <code>s.length</code>.
+   *
+   * @throws NullPointerException if <code>s</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readShort()
+   */
+  void readFully(short[] s, int offset, int numShorts)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of unsigned 16-bit integers into a
+   * <code>char[]</code> array.  If necessary, values are converted
+   * from the stream&#x2019;s {@linkplain #getByteOrder() current byte
+   * order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param c an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>c</code>
+   * that will hold read data.
+   *
+   * @param numChars the number of unsigned 16-bit integers to read
+   * (which is one half of the number of bytes).
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numChars</code> is negative, or if <code>offset +
+   * numChars</code> exceeds <code>c.length</code>.
+   *
+   * @throws NullPointerException if <code>c</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readChar()
+   */
+  void readFully(char[] c, int offset, int numChars)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of signed 32-bit integers into a
+   * <code>long[]</code> array.  If necessary, values are converted
+   * from the stream&#x2019;s {@linkplain #getByteOrder() current byte
+   * order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param i an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>i</code>
+   * that will hold read data.
+   *
+   * @param numLongs the number of signed 32-bit integers to read
+   * (which is one fourth of the number of bytes).
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numInts</code> is negative, or if <code>offset +
+   * numInts</code> exceeds <code>i.length</code>.
+   *
+   * @throws NullPointerException if <code>i</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readInt()
+   */
+  void readFully(int[] i, int offset, int numInts)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of signed 64-bit integers into a
+   * <code>long[]</code> array.  If necessary, values are converted
+   * from the stream&#x2019;s {@linkplain #getByteOrder() current byte
+   * order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param l an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>l</code>
+   * that will hold read data.
+   *
+   * @param numLongs the number of signed 64-bit integers to read
+   * (which is one eight of the number of bytes).
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numLongs</code> is negative, or if <code>offset +
+   * numLongs</code> exceeds <code>l.length</code>.
+   *
+   * @throws NullPointerException if <code>l</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readLong()
+   */
+  void readFully(long[] l, int offset, int numLongs)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of IEEE 32-bit single-precision floating point
+   * numbers into a <code>float[]</code> array.  If necessary, values
+   * are converted from the stream&#x2019;s {@linkplain
+   * #getByteOrder() current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param d an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>d</code>
+   * that will hold read data.
+   *
+   * @param numFloats the number of IEEE 32-bit single-precision
+   * floating point numbers to read (which is one fourth of the number
+   * of bytes).
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numFloats</code> is negative, or if <code>offset +
+   * numFloats</code> exceeds <code>f.length</code>.
+   *
+   * @throws NullPointerException if <code>f</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readFloat()
+   */
+  void readFully(float[] f, int offset, int numFloats)
+    throws IOException;
+
+
+  /**
+   * Reads a sequence of IEEE 64-bit double-precision floating point
+   * numbers into a <code>double[]</code> array.  If necessary, values
+   * are converted from the stream&#x2019;s {@linkplain
+   * #getByteOrder() current byte order}.
+   *
+   * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
+   * before any data is read.
+   * 
+   * @param d an array for storing the read values.
+   *
+   * @param offset the index of the first element in <code>d</code>
+   * that will hold read data.
+   *
+   * @param numDoubles the number of IEEE 64-bit double-precision
+   * floating point numbers to read (which is one eight of the number
+   * of bytes).
+   *
+   * @throws IndexOutOfBoundsException if <code>offset</code> or
+   * <code>numDoubles</code> is negative, or if <code>offset +
+   * numDoubles</code> exceeds <code>d.length</code>.
+   *
+   * @throws NullPointerException if <code>d</code> is
+   * <code>null</code>.
+   *
+   * @throws EOFException if the input stream ends before all content
+   * was read.
+   *
+   * @throws IOException if some general problem happens with
+   * accessing data.
+   *
+   * @see #readDouble()
+   */
+  void readFully(double[] d, int offset, int numDoubles)
+    throws IOException;
+
+  long getStreamPosition()
+    throws IOException;
+
+  int getBitOffset()
+    throws IOException;
+
+  void setBitOffset(int bitOffset)
+    throws IOException;
+
+  int readBit()
+    throws IOException;
+
+  long readBits(int numBits)
+    throws IOException;
+
+  long length()
+    throws IOException;
+
+  int skipBytes(int numBytes)
+    throws IOException;
+
+  long skipBytes(long numBytes)
+    throws IOException;
+
+  void seek(long pos)
+    throws IOException;
+
+  void mark();
+
+  void reset()
+    throws IOException;
+
+  void flushBefore(long pos)
+    throws IOException;
+
+  void flush()
+    throws IOException;
+
+  long getFlushedPosition();
+
+  boolean isCached();
+
+  boolean isCachedMemory();
+
+  boolean isCachedFile();
+
+  void close()
+    throws IOException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,540 @@
+/* ImageInputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.nio.ByteOrder;
+import java.util.Stack;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public abstract class ImageInputStreamImpl implements ImageInputStream
+{
+  private boolean closed;
+  private Stack markStack = new Stack();
+  
+  byte[] buffer = new byte[8];
+  
+  protected int bitOffset;
+  protected ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+  protected long flushedPos;
+  protected long streamPos;
+
+  public ImageInputStreamImpl()
+  {
+    // Do nothing here.
+  }
+
+  protected final void checkClosed()
+    throws IOException
+  {
+    if (closed)
+      throw new IOException("stream closed");
+  }
+
+  public void close()
+    throws IOException
+  {
+    checkClosed();
+    closed = true;
+  }
+  
+  protected void finalize()
+    throws Throwable
+  {
+    if (!closed)
+      close();
+  }
+
+  public void flush()
+    throws IOException
+  {
+    flushBefore(getStreamPosition());
+  }
+
+  public void flushBefore(long position)
+    throws IOException
+  {
+    if (position < flushedPos)
+      throw new IndexOutOfBoundsException();
+
+    if (position > streamPos)
+      throw new IndexOutOfBoundsException();
+
+    flushedPos = position;
+  }
+
+  public int getBitOffset()
+    throws IOException
+  {
+    checkClosed();
+    return bitOffset;
+  }
+
+  public ByteOrder getByteOrder()
+  {
+    return byteOrder;
+  }
+
+  public long getFlushedPosition()
+  {
+    return flushedPos;
+  }
+
+  public long getStreamPosition()
+    throws IOException
+  {
+    checkClosed();
+    return streamPos;
+  }
+
+  public boolean isCached()
+  {
+    return false;
+  }
+
+  public boolean isCachedFile()
+  {
+    return false;
+  }
+
+  public boolean isCachedMemory()
+  {
+    return false;
+  }
+
+  public long length()
+  {
+    return -1L;
+  }
+
+  public void mark()
+  {
+    try
+      {
+	markStack.push(new Long(getStreamPosition()));
+      }
+    catch (IOException e)
+      {
+        throw new RuntimeException(e);
+      }
+  }
+
+  public abstract int read()
+    throws IOException;
+
+  public abstract int read(byte[] data, int offset, int len)
+    throws IOException;
+
+  public int read(byte[] data)
+    throws IOException
+  {
+    return read(data, 0, data.length);
+  }
+
+  public int readBit()
+    throws IOException
+  {
+    checkClosed();
+
+    // Calculate new bit offset here as readByte clears it.
+    int newOffset = (bitOffset + 1) & 0x7;
+
+    // Clears bitOffset.
+    byte data = readByte();
+
+    // If newOffset is 0 it means we just read the 8th bit in a byte
+    // and therefore we want to advance to the next byte.  Otherwise
+    // we want to roll back the stream one byte so that future readBit
+    // calls read bits from the same current byte.
+    if (newOffset != 0)
+      {
+        seek(getStreamPosition() - 1);
+        data = (byte) (data >> (8 - newOffset));
+      }
+    
+    bitOffset = newOffset;
+    return data & 0x1;
+  }
+
+  public long readBits(int numBits)
+    throws IOException
+  {
+    checkClosed();
+
+    if (numBits < 0 || numBits > 64)
+      throw new IllegalArgumentException();
+
+    long bits = 0L;
+
+    for (int i = 0; i < numBits; i++)
+      {
+	bits <<= 1;
+	bits |= readBit();
+      }
+    return bits;
+  }
+
+  public boolean readBoolean()
+    throws IOException
+  {
+    byte data = readByte();
+
+    return data != 0;
+  }
+
+  public byte readByte()
+    throws IOException
+  {
+    checkClosed();
+
+    int data = read();
+
+    if (data == -1)
+      throw new EOFException();
+
+    return (byte) data;
+  }
+
+  public void readBytes(IIOByteBuffer buffer, int len)
+    throws IOException
+  {
+    readFullyPrivate(buffer.getData(), buffer.getOffset(), len);
+
+    buffer.setLength(len);
+  }
+
+  public char readChar()
+    throws IOException
+  {
+    return (char) readShort();
+  }
+
+  public double readDouble()
+    throws IOException
+  {
+    return Double.longBitsToDouble(readLong());
+  }
+
+  public float readFloat()
+    throws IOException
+  {
+    return Float.intBitsToFloat(readInt());
+  }
+
+  public void readFully(byte[] data)
+    throws IOException
+  {
+    readFully(data, 0, data.length);
+  }
+
+  public void readFully(byte[] data, int offset, int len)
+    throws IOException
+  {
+    readFullyPrivate(data, offset, len);
+  }
+
+  public void readFully(char[] data, int offset, int len)
+    throws IOException
+  {
+    for (int i = 0; i < len; ++i)
+      data[offset + i] = readChar();
+  }
+
+  public void readFully(double[] data, int offset, int len)
+    throws IOException
+  {
+    for (int i = 0; i < len; ++i)
+      data[offset + i] = readDouble();
+  }
+
+  public void readFully(float[] data, int offset, int len)
+    throws IOException
+  {
+    for (int i = 0; i < len; ++i)
+      data[offset + i] = readFloat();
+  }
+
+  public void readFully(int[] data, int offset, int len)
+    throws IOException
+  {
+    for (int i = 0; i < len; ++i)
+      data[offset + i] = readInt();
+  }
+
+  public void readFully(long[] data, int offset, int len)
+    throws IOException
+  {
+    for (int i = 0; i < len; ++i)
+      data[offset + i] = readLong();
+  }
+
+  public void readFully(short[] data, int offset, int len)
+    throws IOException
+  {
+    for (int i = 0; i < len; ++i)
+      data[offset + i] = readShort();
+  }
+
+  public int readInt()
+    throws IOException
+  {
+    readFullyPrivate(buffer, 0, 4);
+
+    if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
+      return (int)
+        (((int) (buffer[0] & 0xff) << 0)
+         | ((int) (buffer[1] & 0xff) << 8)
+         | ((int) (buffer[2] & 0xff) << 16)
+         | ((int) (buffer[3] & 0xff) << 24));
+
+    return (int)
+      (((int) (buffer[0] & 0xff) << 24)
+       + ((int) (buffer[1] & 0xff) << 16)
+       + ((int) (buffer[2] & 0xff) << 8)
+       + ((int) (buffer[3] & 0xff) << 0));
+  }
+
+  public String readLine()
+    throws IOException
+  {
+    checkClosed();
+
+    int c = -1;
+    boolean eol = false;
+    StringBuffer buffer = new StringBuffer();
+
+    c = read();
+    if (c == -1)
+      return null;
+
+    while (!eol)
+      {
+	switch(c)
+	  {
+	  case '\r':
+            // Check for following '\n'.
+            long oldPosition = getStreamPosition();
+            c = read();
+            if (c == -1 || c == '\n')
+              eol = true;
+            else
+              {
+                seek(oldPosition);
+                eol = true;
+              }
+            continue;
+
+	  case '\n':
+	    eol = true;
+            continue;
+
+	  default:
+	    buffer.append((char) c);
+	    break;
+	  }
+        c = read();
+        if (c == -1)
+          eol = true;
+      }
+
+    return buffer.toString();
+  }
+
+  public long readLong()
+    throws IOException
+  {
+    readFullyPrivate(buffer, 0, 8);
+
+    if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
+      return (long)
+        (((long) (buffer[0] & 0xff) << 0)
+         | ((long) (buffer[1] & 0xff) << 8)
+         | ((long) (buffer[2] & 0xff) << 16)
+         | ((long) (buffer[3] & 0xff) << 24)
+         | ((long) (buffer[4] & 0xff) << 32)
+         | ((long) (buffer[5] & 0xff) << 40)
+         | ((long) (buffer[6] & 0xff) << 48)
+         | ((long) (buffer[7] & 0xff) << 56));
+
+    return  (long)
+      (((long) (buffer[0] & 0xff) << 56)
+       | ((long) (buffer[1] & 0xff) << 48)
+       | ((long) (buffer[2] & 0xff) << 40)
+       | ((long) (buffer[3] & 0xff) << 32)
+       | ((long) (buffer[4] & 0xff) << 24)
+       | ((long) (buffer[5] & 0xff) << 16)
+       | ((long) (buffer[6] & 0xff) << 8)
+       | ((long) (buffer[7] & 0xff) << 0));
+  }
+
+  public short readShort()
+    throws IOException
+  {
+    readFullyPrivate(buffer, 0, 2);
+
+    if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
+      return (short)
+        (((short) (buffer[0] & 0xff) << 0)
+         | ((short) (buffer[1] & 0xff) << 8));
+
+    return (short)
+      (((short) (buffer[0] & 0xff) << 8)
+       | ((short) (buffer[1] & 0xff) << 0));
+  }
+
+  public int readUnsignedByte()
+    throws IOException
+  {
+    return (int) readByte() & 0xff;
+  }
+
+  public long readUnsignedInt()
+    throws IOException
+  {
+    return (long) readInt() & 0xffffffffL;
+  }
+
+  public int readUnsignedShort()
+    throws IOException
+  {
+    return (int) readShort() & 0xffff;
+  }
+
+  public String readUTF()
+    throws IOException
+  {
+    checkClosed();
+
+    String data;
+    ByteOrder old = getByteOrder();
+    // Strings are always big endian.
+    setByteOrder(ByteOrder.BIG_ENDIAN);
+
+    try
+      {
+	data = DataInputStream.readUTF(this);
+      }
+    finally
+      {
+	setByteOrder(old);
+      }
+    
+    return data;
+  }
+
+  public void reset()
+    throws IOException
+  {
+    checkClosed();
+    
+    long mark = ((Long) markStack.pop()).longValue();
+    seek(mark);
+  }
+
+  public void seek(long position)
+    throws IOException
+  {
+    checkClosed();
+
+    if (position < getFlushedPosition())
+      throw new IndexOutOfBoundsException("position < flushed position");
+
+    streamPos = position;
+    bitOffset = 0;
+  }
+
+  public void setBitOffset (int bitOffset)
+    throws IOException
+  {
+    checkClosed();
+    
+    if (bitOffset < 0 || bitOffset > 7)
+      throw new IllegalArgumentException("bitOffset not between 0 and 7 inclusive");
+
+    this.bitOffset = bitOffset;
+  }
+
+  public void setByteOrder(ByteOrder byteOrder)
+  {
+    this.byteOrder = byteOrder;
+  }
+
+  public int skipBytes(int num)
+    throws IOException
+  {
+    checkClosed();
+    
+    seek(getStreamPosition() + num);
+    bitOffset = 0;
+    return num;
+  }
+
+  public long skipBytes(long num)
+    throws IOException
+  {
+    checkClosed();
+    
+    seek(getStreamPosition() + num);
+    bitOffset = 0;
+    return num;
+  }
+
+  private void readFullyPrivate (byte[] buf, int offset, int len) throws IOException
+  {
+    checkClosed();
+
+    if (len < 0)
+      throw new IndexOutOfBoundsException("Negative length: " + len);
+
+    while (len > 0)
+      {
+	// read will block until some data is available.
+	int numread = read (buf, offset, len);
+	if (numread < 0)
+	  throw new EOFException ();
+	len -= numread;
+	offset += numread;
+      }
+    bitOffset = 0;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,269 @@
+/* ImageOutputStream.java
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+
+/**
+ * An output stream for use by {@link javax.imageio.ImageWriter
+ * ImageWriters}.
+ *
+ * @since 1.4
+ *
+ * @author Sascha Brawer (brawer at dandelis.ch)
+ */
+public interface ImageOutputStream
+  extends ImageInputStream, DataOutput
+{
+  /**
+   * @param position
+   *
+   * @throws IOException if an errror occurs
+   */
+  void flushBefore(long position) throws IOException;
+
+  /**
+   * Writes an array into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void write(byte[] data) throws IOException;
+
+  /**
+   * Writes a region of data from an array into the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the length in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void write(byte[] data, int offset, int len) throws IOException;
+
+  /**
+   * Writes an <code>int</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void write(int data) throws IOException;
+
+  /**
+   * Writes a bit value to the stream.
+   *
+   * @throws IOException if an error occurs
+   */
+  void writeBit(int bit) throws IOException;
+
+  /**
+   * Writes a number of bit values to the stream.
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeBits(long bits, int numBits) throws IOException;
+
+  /**
+   * Writes a <code>boolean</code> value into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeBoolean(boolean data) throws IOException;
+
+  /**
+   * Writes a <code>byte</code> value into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeByte(int data) throws IOException;
+
+  /**
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeBytes(String data) throws IOException;
+
+  /**
+   * Writes a character into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeChar(int data) throws IOException;
+
+  /**
+   * Writes characters to the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the lenth in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeChars(char[] data, int offset, int len) throws IOException;
+
+  /**
+   * Writes characters from a given <code>String</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeChars(String data) throws IOException;
+
+  /**
+   * Writes a <code>double</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeDouble(double data) throws IOException;
+
+  /**
+   * Writes an array of <code>double</code> into the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the lenth in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeDoubles(double[] data, int offset, int len)
+    throws IOException;
+
+  /**
+   * Writes a <code>float</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeFloat(float data) throws IOException;
+
+  /**
+   * Writes an array of <code>float</code> into the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the lenth in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeFloats(float[] data, int offset, int len) throws IOException;
+
+  /**
+   * Writes a <code>int</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeInt(int data) throws IOException;
+
+  /**
+   * Writes an array of <code>int</code> into the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the lenth in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeInts(int[] data, int offset, int len) throws IOException;
+
+  /**
+   * Writes a <code>long</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeLong(long data) throws IOException;
+
+  /**
+   * Writes an array of <code>long</code> into the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the lenth in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeLongs(long[] data, int offset, int len) throws IOException;
+
+  /**
+   * Writes a <code>short</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeShort(int data) throws IOException;
+
+  /**
+   * Writes an array of <code>short</code> into the stream.
+   *
+   * @param data the data to be written
+   * @param offset the offset in the array
+   * @param len the lenth in the array
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeShorts(short[] data, int offset, int len) throws IOException;
+
+  /**
+   * Writes a <code>String</code> into the stream.
+   *
+   * @param data the data to be written
+   *
+   * @throws IOException if an errror occurs
+   */
+  void writeUTF(String data) throws IOException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStreamImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStreamImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStreamImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/ImageOutputStreamImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,296 @@
+/* ImageOutputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import gnu.classpath.NotImplementedException;
+
+import java.io.IOException;
+import java.io.UTFDataFormatException;
+import java.nio.ByteOrder;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public abstract class ImageOutputStreamImpl extends ImageInputStreamImpl
+  implements ImageOutputStream
+{
+  public ImageOutputStreamImpl()
+  {
+    // Do nothing here.
+  }
+
+  protected final void flushBits()
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public void write(byte[] data)
+    throws IOException
+  {
+    write(data, 0, data.length);
+  }
+
+  public abstract void write(byte[] data, int offset, int len)
+    throws IOException;
+
+  public abstract void write(int value)
+    throws IOException;
+
+  public void writeBit(int bit)
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public void writeBits(long bits, int numBits)
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public void writeBoolean(boolean value)
+    throws IOException
+  {
+    writeByte(value ? 1 : 0);
+  }
+
+  public void writeByte(int value)
+    throws IOException
+  {
+    write(value & 0xff);
+  }
+
+  public void writeBytes(String data)
+    throws IOException
+  {
+    // This is bogus, but it is how the method is specified.
+    // Sun ought to deprecate this method.
+    int len = data.length();
+    for (int i = 0; i < len; ++i)
+      writeByte(data.charAt(i));
+  }
+
+  public void writeChar(int value)
+    throws IOException
+  {
+    writeShort(value);
+  }
+
+  public void writeChars(char[] data, int offset, int len)
+    throws IOException
+  {
+    for(int i = 0; i < len; ++len)
+      writeChar(data[offset + i]);
+  }
+
+  public void writeChars(String data)
+    throws IOException
+  {
+    int len = data.length();
+    for (int i = 0; i < len; ++i)
+      writeChar(data.charAt(i));
+  }
+
+  public void writeDouble(double value)
+    throws IOException
+  {
+    writeLong(Double.doubleToLongBits(value));
+  }
+
+  public void writeDoubles(double[] data, int offset, int len)
+    throws IOException
+  {
+    for(int i = 0; i < len; ++len)
+      writeDouble(data[offset + i]);
+  }
+  
+  public void writeFloat(float value)
+    throws IOException
+  {
+    writeInt(Float.floatToIntBits(value));
+  }
+  
+  public void writeFloats(float[] data, int offset, int len)
+    throws IOException
+  {
+    for(int i = 0; i < len; ++len)
+      writeFloat(data[offset + i]);
+  }
+  
+  public void writeInt(int value)
+    throws IOException
+  {
+    if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
+      {
+        buffer[0] = ((byte) value);
+        buffer[1] = ((byte) (value >> 8));
+        buffer[2] = ((byte) (value >> 16));
+        buffer[3] = ((byte) (value >> 24));
+      }
+    else
+      {
+        buffer[0] = ((byte) (value >> 24));
+        buffer[1] = ((byte) (value >> 16));
+        buffer[2] = ((byte) (value >> 8));
+        buffer[3] = ((byte) value);
+      }
+    
+    write(buffer, 0, 4);
+  }
+  
+  public void writeInts(int[] data, int offset, int len)
+    throws IOException
+  {
+    for(int i = 0; i < len; ++len)
+      writeInt(data[offset + i]);
+  }
+  
+  public void writeLong(long value)
+    throws IOException
+  {
+    if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
+      {
+        buffer[0] = ((byte) value);
+        buffer[1] = ((byte) (value >> 8));
+        buffer[2] = ((byte) (value >> 16));
+        buffer[3] = ((byte) (value >> 24));
+        buffer[4] = ((byte) (value >> 32));
+        buffer[5] = ((byte) (value >> 40));
+        buffer[6] = ((byte) (value >> 48));
+        buffer[7] = ((byte) (value >> 56));
+      }
+    else
+      {
+        buffer[0] = ((byte) (value >> 56));
+        buffer[1] = ((byte) (value >> 48));
+        buffer[2] = ((byte) (value >> 40));
+        buffer[3] = ((byte) (value >> 32));
+        buffer[4] = ((byte) (value >> 24));
+        buffer[5] = ((byte) (value >> 16));
+        buffer[6] = ((byte) (value >> 8));
+        buffer[7] = ((byte) value);
+      }
+    
+    write(buffer, 0, 8);
+  }
+  
+  public void writeLongs(long[] data, int offset, int len)
+    throws IOException
+  {
+    for(int i = 0; i < len; ++len)
+      writeLong(data[offset + i]);
+  }
+  
+  public void writeShort(int value)
+    throws IOException
+  {
+    if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
+      {
+        buffer[0] = ((byte) value);
+        buffer[1] = ((byte) (value >> 8));
+      }
+    else
+      {
+        buffer[0] = ((byte) (value >> 8));
+        buffer[1] = ((byte) value);
+      }
+    
+    write(buffer, 0, 2);
+  }
+  
+  public void writeShorts(short[] data, int offset, int len)
+    throws IOException
+  {
+    for(int i = 0; i < len; ++len)
+      writeShort(data[offset + i]);
+  }
+  
+  public void writeUTF(String value)
+    throws IOException
+  {
+    // NOTE: this code comes directly from DataOutputStream.
+    int len = value.length();
+    int sum = 0;
+
+    for (int i = 0; i < len && sum <= 65535; ++i)
+      {
+        char c = value.charAt(i);
+        if (c >= '\u0001' && c <= '\u007f')
+          sum += 1;
+        else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
+          sum += 2;
+        else
+          sum += 3;
+      }
+
+    if (sum > 65535)
+      throw new UTFDataFormatException ();
+
+    int pos = 0;
+    byte[] buf = new byte[sum];
+
+    for (int i = 0; i < len; ++i)
+      {
+        char c = value.charAt(i);
+        if (c >= '\u0001' && c <= '\u007f')
+          buf[pos++] = (byte) c;
+        else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
+          {
+            buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
+            buf[pos++] = (byte) (0x80 | (0x3f & c));
+          }
+        else
+          {
+            // JSL says the first byte should be or'd with 0xc0, but
+            // that is a typo.  Unicode says 0xe0, and that is what is
+            // consistent with DataInputStream.
+            buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
+            buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
+            buf[pos++] = (byte) (0x80 | (0x3f & c));
+          }
+      }
+    
+    writeShort (sum);
+    write(buf, 0, sum);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,129 @@
+/* MemoryCacheImageInputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class MemoryCacheImageInputStream extends ImageInputStreamImpl
+{
+  private InputStream stream;
+  private BufferedInputStream buffer;
+
+  private int READLIMIT = 2048;
+  
+  public MemoryCacheImageInputStream(InputStream stream)
+  {
+    this.stream = stream;
+    buffer = new BufferedInputStream(stream);
+    buffer.mark(READLIMIT);
+  }
+
+  public void close()
+    throws IOException
+  {
+    super.close();
+    stream.close();
+  }
+
+  public void flushBefore(long position)
+    throws IOException
+  {
+    long prevFlushedPosition = getFlushedPosition();
+    super.flushBefore(position);
+    buffer.reset();
+    buffer.skip(getFlushedPosition() - prevFlushedPosition);
+    buffer.mark(READLIMIT);
+  }
+
+  public boolean isCached()
+  {
+    return true;
+  }
+
+  public boolean isCachedFile()
+  {
+    return false;
+  }
+  
+  public boolean isCachedMemory()
+  {
+    return true;
+  }
+
+  public int read()
+    throws IOException
+  {
+    setBitOffset(0);
+    int retval = buffer.read();
+    
+    if (retval != -1)
+      streamPos++;
+
+    return retval;
+  }
+
+  public int read(byte[] data, int offset, int len)
+    throws IOException
+  {
+    setBitOffset(0);
+    int retval = buffer.read(data, offset, len);
+
+    if (retval != -1)
+      {
+        streamPos += retval;
+      }
+
+    return retval; 
+  }
+  
+  public void seek(long position)
+  throws IOException
+  {
+    super.seek(position);
+    buffer.reset();
+    buffer.skip(position - getFlushedPosition());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/MemoryCacheImageOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,114 @@
+/* MemoryCacheImageOutputStream.java --
+   Copyright (C) 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 javax.imageio.stream;
+
+import gnu.classpath.NotImplementedException;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class MemoryCacheImageOutputStream extends ImageOutputStreamImpl
+{
+  private OutputStream stream;
+
+  public MemoryCacheImageOutputStream(OutputStream stream)
+  {
+    this.stream = stream;
+  }
+
+  public void close()
+    throws IOException
+  {
+    super.close();
+    stream.close();
+  }
+
+  public void flushBefore(long position)
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public boolean isCached()
+  {
+    return true;
+  }
+
+  public boolean isCachedFile()
+  {
+    return false;
+  }
+  
+  public boolean isCachedMemory()
+  {
+    return true;
+  }
+
+  public int read()
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public int read (byte[] data, int offset, int len)
+    throws IOException, NotImplementedException
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
+  public void write(byte[] data, int offset, int len)
+    throws IOException
+  {
+    // FIXME: Flush pending bits.
+    stream.write(data, offset, len);
+  }
+
+  public void write(int value)
+    throws IOException
+  {
+    // FIXME: Flush pending bits.
+    stream.write(value);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/imageio/stream/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio.stream package.
+   Copyright (C) 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio.stream</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Attribute.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Attribute.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Attribute.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Attribute.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,143 @@
+/* Attribute.java --
+   Copyright (C) 2006 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 javax.management;
+
+import java.io.Serializable;
+
+/**
+ * Represents an MBean attribute, having the name and the assigned value. The
+ * MBean objects use this class to get and set attributes values.
+ * 
+ * @since 1.5
+ * 
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Attribute
+  implements Serializable
+{
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 2484220110589082382L;
+
+  /**
+   * The attribute name.
+   */
+  final String m_name;
+
+  /**
+   * The attribute value.
+   */
+  final Object m_value;
+
+  /**
+   * Create the attribute with the given name and value.
+   * 
+   * @param name the attribute name
+   * @param value the attribute value
+   */
+  public Attribute(String name, Object value)
+  {
+    m_name = name;
+    m_value = value;
+  }
+
+  /**
+   * Compares the attribute with another attribute.
+   * 
+   * @param other the other object to compare with
+   * 
+   * @return true if both value and object are equal, false otherwise.
+   */
+  public boolean equals(Object other)
+  {
+    if (other instanceof Attribute)
+      {
+        Attribute oa = (Attribute) other;
+        boolean n, v;
+        if (oa.m_name == null || m_name == null)
+          n = oa.m_name == m_name;
+        else
+          n = oa.m_name.equals(m_name);
+
+        if (oa.m_value == null || m_value == null)
+          v = oa.m_value == m_value;
+        else
+          v = oa.m_value.equals(m_value);
+        
+        return n && v;
+
+      }
+    else
+      return false;
+  }
+
+  /**
+   * Returns the attribute name.
+   * 
+   * @return the attribute name
+   */
+  public String getName()
+  {
+    return m_name;
+  }
+
+  /**
+   * Returns the attribute value.
+   * 
+   * @return the attribute value.
+   */
+  public Object getValue()
+  {
+    return m_value;
+  }
+
+  /**
+   * Need to override as {@link #equals} is overridden.
+   * 
+   * @return the expression, dependent of the object and name hashcodes.
+   */
+  public int hashCode()
+  {
+    int n = m_name == null ? 0 : m_name.hashCode();
+    int v = m_value == null ? 0 : m_value.hashCode();
+    
+    return n ^ v;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeList.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeList.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeList.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeList.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,220 @@
+/* AttributeList.java -- A list of MBean attributes.
+   Copyright (C) 2006 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 javax.management;
+
+import java.util.ArrayList;
+
+/**
+ * Represents a list of MBean {@link Attribute}s, with their
+ * names and values.  This is implemented as an
+ * {@link java.util.ArrayList} extension, with additional
+ * methods typed to only allow the addition of {@link Attribute}s.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class AttributeList
+  extends ArrayList
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -4077085769279709076L;
+
+  /**
+   * Constructs an empty list with an initial capacity of ten.
+   *
+   * @see java.util.ArrayList#ArrayList()
+   */
+  public AttributeList()
+  {
+    super();
+  }
+
+  /**
+   * Constructs an {@link AttributeList} using the contents
+   * of an existing list.  The initial capacity is 110% of the
+   * size of the specified list.
+   *
+   * @param list the list to use to fill this list.
+   * @see java.util.ArrayList#ArrayList(java.util.Collection)
+   */
+  public AttributeList(AttributeList list)
+  {
+    super(list);
+  }
+
+  /**
+   * Constructs an empty list with the specified initial capacity.
+   *
+   * @param capacity the initial capacity of the list.
+   * @see java.util.ArrayList#ArrayList(int)
+   */
+  public AttributeList(int capacity)
+  {
+    super(capacity);
+  }
+
+  /**
+   * Adds the specified {@link Attribute} to the end of the list.
+   *
+   * @param attribute the attribute to add.
+   * @see java.util.Arraylist#add(Object)
+   */
+  public void add(Attribute attribute)
+  {
+    super.add(attribute);
+  }
+
+  /**
+   * <p>
+   * Adds the specified {@link Attribute} at the supplied index.
+   * Any attribute already at that index is moved up one place
+   * in the list to the position <code>(index + 1)</code>.
+   * Likewise, the attribute at <code>(index + 1)</code> is
+   * also moved up one place, continuing until the final
+   * attribute in the list moves to a new position, increasing
+   * the size of the list.
+   * </p>
+   * <p>
+   * If the index is invalid (i.e. it is smaller than zero, or
+   * greater than the current size of the list), a
+   * @link{RuntimeOperationsException} is thrown, which wraps
+   * the @link{IndexOutOfBoundsException} from the underlying
+   * array list.
+   * </p>
+   * 
+   * @param index the index at which to place the new attribute.
+   * @param attribute the new attribute to add.
+   * @throws RuntimeOperationsException if <code>index < 0</code>
+   *                                    or <code>index > size()</code>
+   * @see java.util.ArrayList#add(int, Object)
+   */
+  public void add(int index, Attribute attribute)
+  {
+    try
+      {
+	super.add(index, attribute);
+      }
+    catch (IndexOutOfBoundsException e)
+      {
+	throw new RuntimeOperationsException(e, "Invalid index.");
+      }
+  }
+
+  /**
+   * Adds all the {@link Attribute}s from the supplied list
+   * to the end of this list, in the order they are returned
+   * by the list's {@link java.util.Iterator}.
+   *
+   * @param list the list of attributes to add.
+   * @return true if the list changed.
+   * @see java.util.ArrayList#addAll(Collection)
+   */
+  public boolean addAll(AttributeList list)
+  {
+    return super.addAll(list);
+  }
+
+  /**
+   * <p>
+   * Adds all the {@link Attribute}s from the supplied list
+   * to this list, at the specified index.  The attributes
+   * are added in the order they are returned by the
+   * list's {@link java.util.Iterator}.  Any attribute already
+   * at that index is moved up one place in the list to the
+   * position <code>(index + list.size())</code>.
+   * Likewise, the attribute at <code>(index + list.size())</code>
+   * is also moved up one place, continuing until the final
+   * attribute in the original list.
+   * </p>
+   * <p>
+   * If the index is invalid (i.e. it is smaller than zero, or
+   * greater than the current size of the list), a
+   * @link{RuntimeOperationsException} is thrown, which wraps
+   * the @link{IndexOutOfBoundsException} from the underlying
+   * array list.
+   * </p>
+   * 
+   * @param index the index at which to place the new attribute.
+   * @param list the list of attributes to add.
+   * @return true if the list changed.
+   * @throws RuntimeOperationsException if <code>index < 0</code>
+   *                                    or <code>index > size()</code>
+   * @see java.util.ArrayList#addAll(int, Collection)
+   */
+  public boolean addAll(int index, AttributeList list)
+  {
+    try
+      {
+	return super.addAll(index, list);
+      }
+    catch (IndexOutOfBoundsException e)
+      {
+	throw new RuntimeOperationsException(e, "Invalid index.");
+      }
+  }
+
+  /**
+   * Replaces the attribute at the specified index with the one
+   * supplied. If the index is invalid (i.e. it is smaller than
+   * zero, or greater than the current size of the list), a
+   * @link{RuntimeOperationsException} is thrown, which wraps
+   * the @link{IndexOutOfBoundsException} from the underlying
+   * array list.
+   *
+   * @param index the index at which to place the new attribute.
+   * @param attribute the new attribute to add.
+   * @throws RuntimeOperationsException if <code>index < 0</code>
+   *                                    or <code>index > size()</code>
+   * @see java.util.ArrayList#set(int, Object)
+   */
+  public void set(int index, Attribute attribute)
+  {
+    try
+      {
+	super.set(index, attribute);
+      }
+    catch (IndexOutOfBoundsException e)
+      {
+	throw new RuntimeOperationsException(e, "Invalid index.");
+      }
+  }
+    
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeNotFoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeNotFoundException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeNotFoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/AttributeNotFoundException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* AttributeNotFoundException.java -- Thrown by unknown attributes.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Thrown when a attribute is requested but can not be
+ * found.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class AttributeNotFoundException
+  extends OperationsException
+{
+
+  /**
+   * Constructs a new <code>AttributeNotFoundException</code>.
+   */
+  public AttributeNotFoundException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>AttributeNotFoundException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public AttributeNotFoundException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/DynamicMBean.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/DynamicMBean.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/DynamicMBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/DynamicMBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,162 @@
+/* DynamicMBean.java -- A management bean with a dynamic interface.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Represents a management bean that provides a
+ * dynamic interface.  Users of a {@link DynamicMBean}
+ * may retrieve information about its attributes at
+ * runtime and use this information to dynamically
+ * obtain the corresponding values of these attributes.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface DynamicMBean
+{
+  
+  /**
+   * Obtains the value of the specified attribute of the
+   * management bean.  The management bean should perform
+   * a lookup for the named attribute, and return its value
+   * by calling the appropriate getter method, if possible.
+   *
+   * @param name the name of the attribute to retrieve.
+   * @return the value of the specified attribute.
+   * @throws AttributeNotFoundException if the name does not
+   *                                    correspond to an attribute
+   *                                    of the bean.
+   * @throws MBeanException if retrieving the attribute causes
+   *                        the bean to throw an exception (which
+   *                        becomes the cause of this exception).
+   * @throws ReflectionException if an exception occurred in trying
+   *                             to use the reflection interface
+   *                             to lookup the attribute.  The
+   *                             thrown exception is the cause of
+   *                             this exception.
+   * @see #setAttribute(String)
+   */
+  Object getAttribute(String name)
+    throws AttributeNotFoundException, MBeanException,
+	   ReflectionException;
+
+  /**
+   * Obtains the values of each of the specified attributes
+   * of the management bean.  The returned list includes
+   * those attributes that were retrieved and their
+   * corresponding values.
+   *
+   * @param names the names of the attributes to retrieve.
+   * @return a list of the retrieved attributes.
+   * @see #setAttributes(AttributeList)
+   */
+  AttributeList getAttributes(String[] names);
+
+  /**
+   * Returns an information object which lists the attributes
+   * and actions associated with the management bean.
+   *
+   * @return a description of the management bean, including
+   *         all exposed attributes and actions.
+   */
+  MBeanInfo getMBeanInfo();
+
+  /**
+   * Invokes the specified action on the management bean using
+   * the supplied parameters.  The signature of the action is
+   * specified by a {@link String} array, which lists the classes
+   * corresponding to each parameter.  The class loader used to
+   * load these classes is the same as that used for loading the
+   * management bean itself.
+   * 
+   * @param name the name of the action to invoke.
+   * @param params the parameters used to call the action.
+   * @param signature the signature of the action.
+   * @return the return value of the action.
+   * @throws MBeanException if the action throws an exception.  The
+   *                        thrown exception is the cause of this
+   *                        exception.
+   * @throws ReflectionException if an exception occurred in trying
+   *                             to use the reflection interface
+   *                             to invoke the action.  The
+   *                             thrown exception is the cause of
+   *                             this exception.
+   */
+  Object invoke(String name, Object[] params, String[] signature)
+    throws MBeanException, ReflectionException;
+
+  /**
+   * Sets the value of the specified attribute of the
+   * management bean.  The management bean should perform
+   * a lookup for the named attribute, and sets its value
+   * using the associated setter method, if possible.
+   *
+   * @param attribute the attribute to set.
+   * @throws AttributeNotFoundException if the attribute does not
+   *                                    correspond to an attribute
+   *                                    of the bean.
+   * @throws InvalidAttributeValueException if the value is invalid
+   *                                        for this particular
+   *                                        attribute of the bean.
+   * @throws MBeanException if setting the attribute causes
+   *                        the bean to throw an exception (which
+   *                        becomes the cause of this exception).
+   * @throws ReflectionException if an exception occurred in trying
+   *                             to use the reflection interface
+   *                             to lookup the attribute.  The
+   *                             thrown exception is the cause of
+   *                             this exception.
+   * @see #getAttribute(String)
+   */
+  void setAttribute(Attribute attribute)
+    throws AttributeNotFoundException, InvalidAttributeValueException,
+	   MBeanException, ReflectionException;
+
+  /**
+   * Sets the value of each of the specified attributes
+   * to that supplied by the {@link Attribute} object.
+   * The returned list contains the attributes that were
+   * set and their new values.
+   *
+   * @param attributes the attributes to set.
+   * @return a list of the changed attributes.
+   * @see #getAttributes(AttributeList)
+   */
+  AttributeList setAttributes(AttributeList attributes);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/IntrospectionException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/IntrospectionException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/IntrospectionException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/IntrospectionException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* IntrospectionException.java -- Thrown by bean introspection methods.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * A general for all exceptions thrown during introspection
+ * operations on management beans.  For example, such an
+ * exception may be thrown while constructing one of
+ * the <code>MBeanXXXInfo</code> classes.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class IntrospectionException
+  extends OperationsException
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 1054516935875481725L;
+
+  /**
+   * Constructs a new <code>IntrospectionException</code>.
+   */
+  public IntrospectionException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>IntrospectionException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public IntrospectionException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/InvalidAttributeValueException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/InvalidAttributeValueException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/InvalidAttributeValueException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/InvalidAttributeValueException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* InvalidAttributeValueException.java -- Thrown by invalid values.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Thrown when a value is given for an attribute which
+ * is invalid.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class InvalidAttributeValueException
+  extends OperationsException
+{
+
+  /**
+   * Constructs a new <code>InvalidAttributeValueException</code>.
+   */
+  public InvalidAttributeValueException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>InvalidAttributeValueException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public InvalidAttributeValueException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* JMException.java -- Thrown by the management classes.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * A general superclass for all non-runtime management
+ * exceptions.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class JMException
+  extends Exception
+{
+
+  /**
+   * Constructs a new <code>JMException</code>.
+   */
+  public JMException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>JMException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public JMException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMRuntimeException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMRuntimeException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMRuntimeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/JMRuntimeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* JMRuntimeException.java -- Thrown by the management classes.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * A general superclass for all runtime management
+ * exceptions.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class JMRuntimeException
+  extends RuntimeException
+{
+
+  /**
+   * Constructs a new <code>JMRuntimeException</code>.
+   */
+  public JMRuntimeException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>JMRuntimeException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public JMRuntimeException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ListenerNotFoundException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ListenerNotFoundException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ListenerNotFoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ListenerNotFoundException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* ListenerNotFoundException.java -- Thrown when a listener does not exist.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Thrown when a requested listener does not exist.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class ListenerNotFoundException
+  extends OperationsException
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -7242605822448519061L;
+
+  /**
+   * Constructs a new <code>ListenerNotFoundException</code>.
+   */
+  public ListenerNotFoundException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>ListenerNotFoundException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public ListenerNotFoundException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanAttributeInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanAttributeInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanAttributeInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanAttributeInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,301 @@
+/* MBeanAttributeInfo.java -- Information about an attribute of a bean.
+   Copyright (C) 2006 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 javax.management;
+
+import java.lang.reflect.Method;
+
+/**
+ * Describes the attributes of a management bean.
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanAttributeInfo
+  extends MBeanFeatureInfo
+  implements Cloneable
+{
+
+  /**
+   * The type of the attribute.
+   *
+   * @serial the attribute type.
+   */
+  private String attributeType;
+
+  /**
+   * True if the attribute's value can be changed.
+   *
+   * @serial true if the value can be changed.
+   */
+  private boolean isWrite;
+
+  /**
+   * True if the attribute's value can be read.
+   *
+   * @serial true if the value can be read.
+   */
+  private boolean isRead;
+
+  /**
+   * True if the attribute is a boolean and thus
+   * has a isXXX accessor rather than a getXXX accessor.
+   *
+   * @serial true if the attribute has an isXXX accessor.
+   */
+  private boolean is;
+
+  /**
+   * Constructs a new {@link MBeanAttributeInfo} using the specified
+   * name and description, with the given accessor and mutator
+   * methods.  A <code>null</code> value for the accessor method
+   * indicates that the value can not be read.  A <code>null</code>
+   * value for the mutator method indicates that the value can not be
+   * changed.
+   *
+   * @param name the name of the attribute.
+   * @param desc a description of the attribute.
+   * @param getter the accessor method, or <code>null</code> if the value
+   *               can not be read.
+   * @param setter the mutator method, or <code>null</code> if the value
+   *               can not be changed.
+   * @throws IntrospectionException if both the accessor and mutator method
+   *                                are <code>null</code>.
+   */
+  public MBeanAttributeInfo(String name, String desc, 
+			    Method getter, Method setter)
+    throws IntrospectionException
+  {
+    super(name, desc);
+    if (getter == null && setter == null)
+      throw new IntrospectionException("Both the getter and setter methods can " +
+				       "not be null.");
+    if (getter == null)
+      {
+	attributeType = setter.getParameterTypes()[0].getName();
+	isRead = false;
+	is = false;
+      }
+    else
+      {
+	attributeType = getter.getReturnType().getName();
+	isRead = true;
+	is = getter.getName().startsWith("is");
+      }
+    if (setter != null)
+      isWrite = true;
+  }
+
+  /**
+   * Constructs a new {@link MBeanAttributeInfo} using the specified
+   * name, description and type with the given settings for the accessor
+   * and mutator methods.  
+   *
+   * @param name the name of the attribute.
+   * @param type the type of the attribute, in the form of its class name.
+   * @param desc a description of the attribute.
+   * @param isReadable true if the attribute's value can be read.
+   * @param isWritable true if the attribute's value can be changed.
+   * @param isIs true if the attribute uses an accessor of the form isXXX.
+   * @throws IllegalArgumentException if the attribute is both unreadable
+   *                                  and unwritable.
+   */
+  public MBeanAttributeInfo(String name, String type, String desc,
+			    boolean isReadable, boolean isWritable,
+			    boolean isIs)
+  {
+    super(name, desc);
+    if (!isReadable && !isWritable)
+      throw new IllegalArgumentException("The attribute can not be both " +
+					 "unreadable and unwritable.");
+    attributeType = type;
+    isRead = isReadable;
+    isWrite = isWritable;
+    is = isIs;
+  }
+
+  /**
+   * Returns a clone of this instance.  The clone is created
+   * using just the method provided by {@link java.lang.Object}.
+   * Thus, the clone is just a shallow clone as returned by
+   * that method, and does not contain any deeper cloning based
+   * on the subject of this class.
+   *
+   * @return a clone of this instance.
+   * @see java.lang.Cloneable
+   */
+  public Object clone()
+  {
+    try
+      {
+	return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	/* This shouldn't happen; we implement Cloneable */
+	throw new IllegalStateException("clone() called on " +
+					"non-cloneable object.");
+      }
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This
+   * returns true iff the object is an instance of
+   * {@link MBeanAttributeInfo}, {@link Object#equals()}
+   * returns true for a comparison of both the name and
+   * description of this attribute  with that of the specified
+   * object (performed by the superclass), and the type and
+   * boolean flags of the two instances are equal.
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanAttributeInfo}
+   *         instance, 
+   *         <code>name.equals(object.getName())</code>,
+   *         <code>description.equals(object.getDescription())</code>,
+   *         <code>attributeType.equals(object.getType())</code>,
+   *         <code>isRead == object.isReadable()</code>,
+   *         <code>isWrite == object.isWritable()</code>,
+   *         <code>is == object.isIs()</code>
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof MBeanAttributeInfo))
+      return false;
+    if (!(super.equals(obj)))
+      return false;
+    MBeanAttributeInfo o = (MBeanAttributeInfo) obj;
+    return (attributeType.equals(o.getType()) &&
+	    isRead == o.isReadable() &&
+	    isWrite == o.isWritable() &&
+	    is == o.isIs());
+  }
+
+  /**
+   * Returns the type of this attribute, in the form of its class name.
+   *
+   * @return the type of this attribute.
+   */
+  public String getType()
+  {
+    return attributeType;
+  }
+
+  /**
+   * Returns the hashcode of the attribute information as the sum of
+   * the hashcode of the superclass, the hashcode of the type,
+   * the hashcode of {@link #isReadable()}, twice the hashcode
+   * of {@link #isWritable()} and four times the hashcode
+   * of {@link #isIs()}.
+   *
+   * @return the hashcode of the attribute information.
+   */
+  public int hashCode()
+  {
+    return super.hashCode() + attributeType.hashCode()
+      + Boolean.valueOf(isRead).hashCode()
+      + (2 * Boolean.valueOf(isWrite).hashCode())
+      + (4 * Boolean.valueOf(is).hashCode());
+  }
+
+  /**
+   * Returns true if the accessor method of this attribute
+   * is of the form <code>isXXX</code>.
+   *
+   * @return true if the accessor takes the form <code>isXXX</code>.
+   */
+  public boolean isIs()
+  {
+    return is;
+  }
+
+  /**
+   * Returns true if value of this attribute can be read.
+   *
+   * @return true if the value of the attribute can be read.
+   */
+  public boolean isReadable()
+  {
+    return isRead;
+  }
+
+  /**
+   * Returns true if the value of this attribute can be changed.
+   *
+   * @return true if the value of the attribute can be changed.
+   */
+  public boolean isWritable()
+  {
+    return isWrite;
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanAttributeInfo</code>),
+   * the name, description and type of the attribute and the 
+   * current settings of the {@link #isReadable()}, 
+   * {@link #isWritable()} and {@link #isIs()} properties.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      {
+	super.toString();
+	string = string.substring(0, string.length() - 1) 
+	  + ",type=" + attributeType
+	  + ",isReadable=" + (isRead ? "yes" : "no")
+	  + ",isWritable=" + (isWrite ? "yes" : "no")
+	  + ",isIs=" + (is ? "yes" : "no")
+	  + "]";
+      }
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanConstructorInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanConstructorInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanConstructorInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanConstructorInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,228 @@
+/* MBeanConstructorInfo.java -- Information about a bean's constructor.
+   Copyright (C) 2006 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 javax.management;
+
+import java.lang.reflect.Constructor;
+
+import java.util.Arrays;
+
+/**
+ * Describes the constructors of a management bean.
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanConstructorInfo
+  extends MBeanFeatureInfo
+  implements Cloneable
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 4433990064191844427L;
+
+  /**
+   * The signature of the constructor i.e. the argument types.
+   */
+  private MBeanParameterInfo[] signature;
+
+  /**
+   * Constructs a @link{MBeanConstructorInfo} with the specified
+   * description using the given constructor.  Each parameter is
+   * described merely by its type; the name and description are
+   * <code>null</code>.
+   *
+   * @param desc a description of the attribute.
+   * @param cons the constructor.
+   */
+  public MBeanConstructorInfo(String desc, Constructor cons)
+  {
+    super(cons.getName(), desc);
+    Class[] paramTypes = cons.getParameterTypes();
+    signature = new MBeanParameterInfo[paramTypes.length];
+    for (int a = 0; a < paramTypes.length; ++a)
+      signature[a] = new MBeanParameterInfo(null,
+					    paramTypes[a].getName(),
+					    null);
+  }
+
+  /**
+   * Constructs a @link{MBeanConstructorInfo} with the specified
+   * name, description and parameter information. A <code>null</code>
+   * value for the parameter information is the same as passing in
+   * an empty array.
+   *
+   * @param name the name of the constructor.
+   * @param desc a description of the attribute.
+   * @param sig the signature of the constructor, as a series
+   *            of {@link MBeanParameterInfo} objects, one for
+   *            each parameter.
+   */
+  public MBeanConstructorInfo(String name, String desc,
+			      MBeanParameterInfo[] sig)
+  {
+    super(name, desc);
+    if (sig == null)
+      signature = new MBeanParameterInfo[0];
+    else
+      signature = sig;
+  }
+
+  /**
+   * Returns a clone of this instance.  The clone is created
+   * using just the method provided by {@link java.lang.Object}.
+   * Thus, the clone is just a shallow clone as returned by
+   * that method, and does not contain any deeper cloning based
+   * on the subject of this class.
+   *
+   * @return a clone of this instance.
+   * @see java.lang.Cloneable
+   */
+  public Object clone()
+  {
+    try
+      {
+	return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	/* This shouldn't happen; we implement Cloneable */
+	throw new IllegalStateException("clone() called on " +
+					"non-cloneable object.");
+      }
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This returns
+   * true iff the object is an instance of {@link
+   * MBeanConstructorInfo}, {@link Object#equals()} returns true for a
+   * comparison of both the name and description of this notification
+   * with that of the specified object (performed by the superclass),
+   * and the two signature arrays contain the same elements in the
+   * same order (but one may be longer than the other).
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanConstructorInfo}
+   *         instance, 
+   *         <code>name.equals(object.getName())</code>,
+   *         <code>description.equals(object.getDescription())</code>
+   *         and the corresponding elements of the signature arrays are
+   *         equal.
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof MBeanConstructorInfo))
+      return false;
+    if (!(super.equals(obj)))
+      return false;
+    MBeanConstructorInfo o = (MBeanConstructorInfo) obj;
+    MBeanParameterInfo[] sig = o.getSignature();
+    for (int a = 0; a < signature.length; ++a)
+      {
+	if (a == sig.length)
+	  return true;
+	if (!(signature[a].equals(sig[a])))
+	  return false;
+      }
+    return true;
+  }
+  
+  /**
+   * Returns the constructor's signature, in the form of
+   * information on each parameter.  Each parameter is
+   * described by an instance of {@link MBeanParameterInfo}.
+   * The returned array is a shallow copy of the array used
+   * by this instance, so changing which elements are stored
+   * in the array won't affect the array used by this, but
+   * changing the actual elements will affect the ones used
+   * here.
+   *
+   * @return an array of {@link MBeanParameterInfo} objects,
+   *         describing the constructor parameters.
+   */
+  public MBeanParameterInfo[] getSignature()
+  {
+    return (MBeanParameterInfo[]) signature.clone();
+  }
+
+  /**
+   * Returns the hashcode of the constructor information as the sum
+   * of the hashcode of the superclass and the hashcode of the parameter
+   * array.
+   *
+   * @return the hashcode of the constructor information.
+   */
+  public int hashCode()
+  {
+    return super.hashCode() + Arrays.hashCode(signature);
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanConstructorInfo</code>),
+   * the name and description of the constructor and the 
+   * contents of the array of parameters.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      {
+	super.toString();
+	string = string.substring(0, string.length() - 1) 
+	  + ",signature=" + Arrays.toString(signature)
+	  + "]";
+      }
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* MBeanException.java -- A user-defined management exception.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Represents an arbitrary exception thrown by a management
+ * bean.  When a management bean executes code that causes
+ * an exception to be thrown, the resulting exception is
+ * wrapped inside an {@link MBeanException}.  Calling
+ * {@link getTargetException()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanException
+  extends JMException
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 4066342430588744142L;
+
+  /* Sun re-implemented causality -- don't know why, but
+     serialization demands we do too... */
+
+  /**
+   * The target exception.
+   *
+   * @serial the target exception.
+   */
+  private Exception exception;
+
+  /**
+   * Constructs a new <code>MBeanException</code> wrapping
+   * the specified exception.
+   *
+   * @param e the exception to be wrapped.
+   */
+  public MBeanException(Exception e)
+  {
+    super();
+    exception = e;
+  }
+
+  /**
+   * Constructs a new <code>MBeanException</code> wrapping
+   * the specified exception and using the supplied message.
+   *
+   * @param e the exception to be wrapped.
+   * @param message the error message to give to the user.
+   */
+  public MBeanException(Exception e, String message)
+  {
+    super(message);
+    exception = e;
+  }
+
+  /**
+   * Returns the true cause of this exception, the wrapped
+   * exception.
+   *
+   * @return the wrapped exception.
+   */
+  public Throwable getCause()
+  {
+    return exception;
+  }
+
+  /**
+   * Returns the true cause of this exception, the wrapped
+   * exception.
+   *
+   * @return the wrapped exception.
+   */
+  public Exception getTargetException()
+  {
+    return exception;
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanFeatureInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanFeatureInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanFeatureInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanFeatureInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,186 @@
+/* MBeanFeatureInfo.java -- Information about a bean feature.
+   Copyright (C) 2006 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 javax.management;
+
+import java.io.Serializable;
+
+/**
+ * A general superclass for the description of features
+ * of management beans.  This allows the user to access
+ * the feature dynamically, without knowing the details
+ * beforehand.  The information is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanFeatureInfo
+  implements Serializable
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 3952882688968447265L;
+
+  /**
+   * A description of the feature in human-readable form.
+   * Subclasses should access this via the {@link #getDescription()}
+   * function rather than using the value directly.
+   *
+   * @serial a description of the feature.
+   */
+  protected String description;
+
+  /**
+   * The name of the feature.  Subclasses should access this
+   * via the {@link #getName()} function rather than using the
+   * value directly.
+   *
+   * @serial the name of the feature.
+   */
+  protected String name;
+
+  /**
+   * The <code>toString()</code> result of this instance.
+   */
+  protected transient String string;
+
+  /**
+   * Constructs a new {@link MBeanFeatureInfo} with the specified
+   * name and description.
+   *
+   * @param name the name of the management bean feature.
+   * @param description the description of the feature.
+   */
+  public MBeanFeatureInfo(String name, String description)
+  {
+    this.name = name;
+    this.description = description;
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This
+   * returns true iff the object is an instance of
+   * {@link MBeanFeatureInfo} and {@link Object#equals()}
+   * returns true for a comparison of both the name and
+   * description of this feature with that of the specified
+   * object.
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanFeatureInfo}
+   *         instance, 
+   *         <code>name.equals(object.getName())</code> and
+   *         <code>description.equals(object.getDescription</code>.
+   */
+  public boolean equals(Object obj)
+  {
+    if (obj instanceof MBeanFeatureInfo)
+      {
+	MBeanFeatureInfo o = (MBeanFeatureInfo) obj;
+	return ((name == null ? 
+		 o.getName() == null : 
+		 name.equals(o.getName())) &&
+		(description == null ?
+		 o.getDescription() == null :
+		 description.equals(o.getDescription())));
+      }
+    else
+      return false;
+  }
+
+  /**
+   * Returns a description of this feature.
+   *
+   * @return a human-readable description.
+   */
+  public String getDescription()
+  {
+    return description;
+  }
+
+  /**
+   * Returns the name of this feature.
+   *
+   * @return the name of the feature.
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Returns the hashcode of the feature as
+   * the sum of the hashcodes of its name
+   * and description.
+   *
+   * @return the hashcode of this feature.
+   */
+  public int hashCode()
+  {
+    return (name == null ? -1 : name.hashCode())
+      + (description == null ? -1 : description.hashCode());
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanFeatureInfo</code>) and
+   * the name and description of the feature.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      string = getClass().getName()
+	+ "[name=" + name 
+	+ ",desc=" + description 
+	+ "]";
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,397 @@
+/* MBeanInfo.java -- Information about a management bean.
+   Copyright (C) 2006 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 javax.management;
+
+import java.io.Serializable;
+
+import java.util.Arrays;
+
+/**
+ * <p>
+ * Describes the interface of a management bean.  This allows
+ * the user to access the bean dynamically, without knowing
+ * the details of any of its attributes, operations,
+ * constructors or notifications beforehand.  The information
+ * is immutable as standard.  Of course, subclasses may change
+ * this, but this behaviour is not recommended.
+ * </p>
+ * <p>
+ * The contents of this class, for standard management beans,
+ * are dynamically compiled using reflection.
+ * {@link #getClassName()} and {@link #getConstructors()}
+ * return the name of the class and its constructors, respectively.
+ * This is much the same as could be obtained by reflection on the
+ * bean.  {@link #getAttributes()} and {@link #getOperations()},
+ * however, do something more in splitting the methods of the
+ * class into two sets.  Those of the form, <code>getXXX</code>,
+ * <code>setXXX</code> and <code>isXXX</code> are taken to be
+ * the accessors and mutators of a series of attributes, with
+ * <code>XXX</code> being the attribute name.  These are returned
+ * by {@link getAttributes()} and the {@link Attribute} class can
+ * be used to manipulate them.  The remaining methods are classified
+ * as operations and returned by {@link getOperations()}.
+ * </p>
+ * <p>
+ * Beans can also broadcast notifications.  If the bean provides this
+ * facility, by implementing the {@link NotificationBroadcaster}
+ * interface, then an array of {@link MBeanNotificationInfo} objects
+ * may be obtained from {@link #getNotifications()}, which describe
+ * the notifications emitted.
+ * </p>
+ * <p>
+ * Model management beans and open management beans also supply an
+ * instance of this class, as part of implementing the
+ * {@link DynamicMBean#getMBeanInfo()} method of {@link DynamicMBean}.
+ * </p>
+ * 
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanInfo
+  implements Cloneable, Serializable
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -6451021435135161911L;
+
+  /**
+   * A description of the bean.
+   * 
+   * @serial The bean's description.
+   */
+  private String description;
+
+  /**
+   * The class name of the management bean.
+   *
+   * @serial The bean's class name.
+   */
+  private String className;
+
+  /**
+   * Descriptions of the attributes provided by the bean.
+   */
+  private MBeanAttributeInfo[] attributes;
+
+  /**
+   * Descriptions of the operations provided by the bean.
+   */
+  private MBeanOperationInfo[] operations;
+
+  /**
+   * Descriptions of the bean's constructors.
+   */
+  private MBeanConstructorInfo[] constructors;
+
+  /**
+   * Descriptions of the notifications emitted by the bean.
+   *
+   * @serial The bean's notifications.
+   */
+  private MBeanNotificationInfo[] notifications;
+
+  /**
+   * The <code>toString()</code> result of this instance.
+   */
+  private transient String string;
+
+  /**
+   * Constructs a new {@link MBeanInfo} using the supplied
+   * class name and description with the given attributes,
+   * operations, constructors and notifications.  The class
+   * name does not have to actually specify a valid class that
+   * can be loaded by the MBean server or class loader; it merely
+   * has to be a syntactically correct class name.  Any of the
+   * arrays may be <code>null</code>; this will be treated as if
+   * an empty array was supplied.
+   *
+   * @param name the name of the class this instance describes.
+   * @param desc a description of the bean.
+   * @param attribs the attribute descriptions for the bean,
+   *                or <code>null</code>.
+   * @param cons the constructor descriptions for the bean,
+   *             or <code>null</code>.
+   * @param ops the operation descriptions for the bean,
+   *            or <code>null</code>.
+   * @param notifs the notification descriptions for the bean,
+   *               or <code>null</code>.
+   */
+  public MBeanInfo(String name, String desc, MBeanAttributeInfo[] attribs,
+		   MBeanConstructorInfo[] cons, MBeanOperationInfo[] ops,
+		   MBeanNotificationInfo[] notifs)
+  {
+    className = name;
+    description = desc;
+    if (attribs == null)
+      attributes = new MBeanAttributeInfo[0];
+    else
+      attributes = attribs;
+    if (cons == null)
+      constructors = new MBeanConstructorInfo[0];
+    else
+      constructors = cons;
+    if (ops == null)
+      operations = new MBeanOperationInfo[0];
+    else
+      operations = ops;
+    if (notifs == null)
+      notifications = new MBeanNotificationInfo[0];
+    else
+      notifications = notifs;
+  }
+
+  /**
+   * Returns a shallow clone of the information.  This is
+   * simply a new copy of each string and a clone
+   * of each array, which still references the same objects,
+   * as obtained by the {@link Object} implementation of
+   * {@link Object#clone()}.  As the fields can not be
+   * changed, this method is only really of interest to
+   * subclasses which may add new mutable fields or make
+   * the existing ones mutable.
+   *
+   * @return a shallow clone of this {@link MBeanInfo}.
+   */
+  public Object clone()
+  {
+    MBeanInfo clone = null;
+    try
+      {
+	clone = (MBeanInfo) super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	/* This won't happen as we implement Cloneable */
+      }
+    return clone;
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This returns
+   * true iff the object is an instance of {@link MBeanInfo} and
+   * {@link Object#equals()} returns true for a comparison of the
+   * class name and description, and the arrays each contain the same
+   * elements in the same order (but one may be longer than the
+   * other).
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanInfo}
+   *         instance, 
+   *         <code>className.equals(object.getClassName())</code>,
+   *         <code>description.equals(object.getDescription())</code>
+   *         and the corresponding elements of the arrays are
+   *         equal.
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof MBeanInfo))
+      return false;
+    if (!(super.equals(obj)))
+      return false;
+    MBeanInfo o = (MBeanInfo) obj;
+    MBeanAttributeInfo[] attr = o.getAttributes();
+    for (int a = 0; a < attributes.length; ++a)
+      {
+	if (a == attr.length)
+	  return true;
+	if (!(attributes[a].equals(attr[a])))
+	  return false;
+      }
+    MBeanConstructorInfo[] cons = o.getConstructors();
+    for (int a = 0; a < constructors.length; ++a)
+      {
+	if (a == cons.length)
+	  return true;
+	if (!(constructors[a].equals(cons[a])))
+	  return false;
+      }
+    MBeanOperationInfo[] ops = o.getOperations();
+    for (int a = 0; a < operations.length; ++a)
+      {
+	if (a == ops.length)
+	  return true;
+	if (!(operations[a].equals(ops[a])))
+	  return false;
+      }
+    MBeanNotificationInfo[] notifs = o.getNotifications();
+    for (int a = 0; a < notifications.length; ++a)
+      {
+	if (a == notifs.length)
+	  return true;
+	if (!(notifications[a].equals(notifs[a])))
+	  return false;
+      }
+    return (className.equals(o.getClassName()) &&
+	    description.equals(o.getDescription()));
+  }
+
+  /**
+   * Returns descriptions of each of the attributes provided
+   * by this management bean.  The returned value is a shallow
+   * copy of the attribute array maintained by this instance.
+   * Hence, changing the elements of the returned array will not
+   * affect the attribute array, and the elements (instances
+   * of the {@link MBeanAttributeInfo} class) are immutable.
+   *
+   * @return an array of {@link MBeanAttributeInfo} objects,
+   *         representing the attributes emitted by this
+   *         management bean.
+   */
+  public MBeanAttributeInfo[] getAttributes()
+  {
+    return (MBeanAttributeInfo[]) attributes.clone();
+  }
+
+  /**
+   * Returns the class name of the management bean.
+   *
+   * @return the bean's class name.
+   */
+  public String getClassName()
+  {
+    return className;
+  }
+
+  /**
+   * Returns descriptions of each of the constructors provided
+   * by this management bean.  The returned value is a shallow
+   * copy of the constructor array maintained by this instance.
+   * Hence, changing the elements of the returned array will not
+   * affect the constructor array, and the elements (instances
+   * of the {@link MBeanConstructorInfo} class) are immutable.
+   *
+   * @return an array of {@link MBeanConstructorInfo} objects,
+   *         representing the constructors emitted by this
+   *         management bean.
+   */
+  public MBeanConstructorInfo[] getConstructors()
+  {
+    return (MBeanConstructorInfo[]) constructors.clone();
+  }
+
+  /**
+   * Returns a description of the management bean.
+   *
+   * @return the bean's description.
+   */
+  public String getDescription()
+  {
+    return description;
+  }
+
+  /**
+   * Returns descriptions of each of the notifications emitted
+   * by this management bean.  The returned value is a shallow
+   * copy of the notification array maintained by this instance.
+   * Hence, changing the elements of the returned array will not
+   * affect the notification array, and the elements (instances
+   * of the {@link MBeanNotificationInfo} class) are immutable.
+   *
+   * @return an array of {@link MBeanNotificationInfo} objects,
+   *         representing the notifications emitted by this
+   *         management bean.
+   */
+  public MBeanNotificationInfo[] getNotifications()
+  {
+    return (MBeanNotificationInfo[]) notifications.clone();
+  }
+
+  /**
+   * Returns descriptions of each of the operations provided
+   * by this management bean.  The returned value is a shallow
+   * copy of the operation array maintained by this instance.
+   * Hence, changing the elements of the returned array will not
+   * affect the operation array, and the elements (instances
+   * of the {@link MBeanOperationInfo} class) are immutable.
+   *
+   * @return an array of {@link MBeanOperationInfo} objects,
+   *         representing the operations emitted by this
+   *         management bean.
+   */
+  public MBeanOperationInfo[] getOperations()
+  {
+    return (MBeanOperationInfo[]) operations.clone();
+  }
+
+  /**
+   * Returns the hashcode of the information as the sum of the
+   * hashcode of the classname, description and each array.
+   *
+   * @return the hashcode of the information.
+   */
+  public int hashCode()
+  {
+    return className.hashCode() + description.hashCode()
+      + Arrays.hashCode(attributes) + Arrays.hashCode(constructors)
+      + Arrays.hashCode(operations) + Arrays.hashCode(notifications);
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanInfo</code>),
+   * the name and description of the bean and the contents
+   * of the four arrays.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      string = getClass().getName()
+	+ "[name=" + className 
+	+ ",desc=" + description 
+	+ ",attributes=" + Arrays.toString(attributes)
+	+ ",constructors=" + Arrays.toString(constructors)
+	+ ",operations=" + Arrays.toString(operations)
+	+ ",notifications=" + Arrays.toString(notifications)
+	+ "]";
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanNotificationInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanNotificationInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanNotificationInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanNotificationInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,227 @@
+/* MBeanNotificationInfo.java -- Information about a bean's notification.
+   Copyright (C) 2006 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 javax.management;
+
+import java.util.Arrays;
+
+/**
+ * <p>
+ * Describes the notifications emitted by a management bean.
+ * An instance of this class is specific to notifications
+ * involving a particular type of object.  A new instance
+ * should be created for each Java class used for notifications,
+ * and the Java class name forms the name of the instance.
+ * Each instance lists a number of notification types; these
+ * are not types in the sense of different Java classes, but
+ * instead form the names of notifications following the same
+ * syntax as Java property and package names.
+ * </p>
+ * <p>
+ * For instance, a management bean may emit two notifications
+ * containing {@link java.lang.String} objects.  Both would be described
+ * using one instance of this class, with a member of the array
+ * returned by {@link #getNotifTypes()} for each one.  If another
+ * notification containing a {@link java.util.Date} object were to
+ * be added, this would require a new instance of this class.
+ * </p>
+ * <p>
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanNotificationInfo
+  extends MBeanFeatureInfo
+  implements Cloneable
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -3888371564530107064L;
+
+  /**
+   * The types of notification described by this instance.
+   *
+   * @serial the types of notification.
+   */
+  private String[] types;
+
+  /**
+   * Constructs a new {@link MBeanNotificationInfo} with the
+   * specified name, description and notification types. The
+   * notification types array may be <code>null</code> or of
+   * zero length, in order to indicate the absence of any types.
+   *
+   * @param types an array of {@link java.lang.String} objects,
+   *              containing the names of the notifications emitted
+   *              of this Java type.  The names use the dot notation
+   *              familiar from Java property and package names.
+   * @param name the name of the Java class the notifications described
+   *             by this object are instances of.
+   * @param description a description of the data.
+   * @throws IllegalArgumentException for some reason...
+   */
+  public MBeanNotificationInfo(String[] types, String name,
+			       String description)
+  {
+    super(name, description);
+    this.types = types;
+  }
+
+  /**
+   * Returns a clone of this instance.  The clone is created
+   * using just the method provided by {@link java.lang.Object}.
+   * Thus, the clone is just a shallow clone as returned by
+   * that method, and does not contain any deeper cloning based
+   * on the subject of this class.
+   *
+   * @return a clone of this instance.
+   * @see java.lang.Cloneable
+   */
+  public Object clone()
+  {
+    try
+      {
+	return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	/* This shouldn't happen; we implement Cloneable */
+	throw new IllegalStateException("clone() called on " +
+					"non-cloneable object.");
+      }
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This returns
+   * true iff the object is an instance of {@link
+   * MBeanNotificationInfo}, {@link Object#equals()} returns true for
+   * a comparison of both the name and description of this
+   * notification with that of the specified object, and the two
+   * notification type arrays contain the same elements in the same
+   * order (but one may be longer than the other).
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanNotificationInfo}
+   *         instance, 
+   *         <code>name.equals(object.getName())</code>,
+   *         <code>description.equals(object.getDescription())</code>
+   *         and the corresponding elements of the type arrays are
+   *         equal.
+   */
+  public boolean equals(Object obj)
+  {
+    if (obj instanceof MBeanNotificationInfo)
+      {
+	if (!(super.equals(obj)))
+	  return false;
+	MBeanNotificationInfo o = (MBeanNotificationInfo) obj;
+	String[] oTypes = o.getNotifTypes();
+	for (int a = 0; a < types.length; ++a)
+	  {
+	    if (a == oTypes.length)
+	      return true;
+	    if (!(types[a].equals(oTypes[a])))
+	      return false;
+	  }
+	return true;
+      }
+    else
+      return false;
+  }
+
+  /**
+   * Returns the notification types that the management bean may emit.
+   * The notification types are strings using the dot notation
+   * familiar from Java property and package names.  Changing the
+   * returned array does not affect the values retained by this
+   * instance.
+   *
+   * @return the notification types.
+   */
+  public String[] getNotifTypes()
+  {
+    return types;
+  }
+
+  /**
+   * Returns the hashcode of the notification information as the sum
+   * of the hashcode of the superclass and the hashcode of the types
+   * array.
+   *
+   * @return the hashcode of the notification information.
+   */
+  public int hashCode()
+  {
+    return super.hashCode() + Arrays.hashCode(types);
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanNotificationInfo</code>),
+   * the name and description of the notification and the 
+   * contents of the array of types.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      {
+	super.toString();
+	string = string.substring(0, string.length() - 1) 
+	  + ",types=" + Arrays.toString(types)
+	  + "]";
+      }
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanOperationInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanOperationInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanOperationInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanOperationInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,344 @@
+/* MBeanOperationInfo.java -- Information about a bean's operations.
+   Copyright (C) 2006 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 javax.management;
+
+import java.lang.reflect.Method;
+
+import java.util.Arrays;
+
+/**
+ * Describes the operations of a management bean.
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanOperationInfo
+  extends MBeanFeatureInfo
+  implements Cloneable
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -6178860474881375330L;
+
+  /**
+   * Used to signify that the operation merely provides information
+   * (akin to an accessor).
+   */
+  public static final int INFO = 0;
+
+  /**
+   * Used to signify that the operation makes some change to the
+   * state of the bean (akin to a mutator).
+   */
+  public static final int ACTION = 1;
+
+  /**
+   * Used to signify that the operation makes some state change
+   * to the bean and also returns information.
+   */
+  public static final int ACTION_INFO = 2;
+
+  /**
+   * Used to signify that the behaviour of the operation is
+   * unknown.
+   */
+  public static final int UNKNOWN = 3;
+
+  /**
+   * The return type of the method, in the form of its class name.
+   */
+  private String type;
+
+  /**
+   * The signature of the constructor i.e. the argument types.
+   */
+  private MBeanParameterInfo[] signature;
+
+  /**
+   * The impact of the method, as one of {@link #INFO}, {@link #ACTION},
+   * {@link #ACTION_INFO} and {@link #UNKNOWN}.
+   */
+  private int impact;
+
+  /**
+   * Constructs a @link{MBeanOperationInfo} with the specified
+   * description using the given method.  Each parameter is
+   * described merely by its type; the name and description are
+   * <code>null</code>.  The return type and impact of the
+   * method are determined from the {@link Method} instance.
+   *
+   * @param desc a description of the attribute.
+   * @param method the method.
+   */
+  public MBeanOperationInfo(String desc, Method method)
+  {
+    super(method.getName(), desc);
+    Class[] paramTypes = method.getParameterTypes();
+    signature = new MBeanParameterInfo[paramTypes.length];
+    for (int a = 0; a < paramTypes.length; ++a)
+      signature[a] = new MBeanParameterInfo(null,
+					    paramTypes[a].getName(),
+					    null);
+    type = method.getReturnType().getName();
+    if (method.getReturnType() == Void.TYPE)
+      {
+	if (paramTypes.length == 0)
+	  impact = UNKNOWN;
+	else
+	  impact = ACTION;
+      }
+    else
+      {
+	if (paramTypes.length == 0)
+	  impact = INFO;
+	else
+	  impact = ACTION_INFO;
+      }
+  }
+
+  /**
+   * Constructs a @link{MBeanOperationInfo} with the specified name,
+   * description, parameter information, return type and impact. A
+   * <code>null</code> value for the parameter information is the same
+   * as passing in an empty array.
+   *
+   * @param name the name of the constructor.
+   * @param desc a description of the attribute.
+   * @param sig the signature of the method, as a series
+   *            of {@link MBeanParameterInfo} objects, one for
+   *            each parameter.
+   * @param type the return type of the method, as the class name.
+   * @param impact the impact of performing the operation.
+   */
+  public MBeanOperationInfo(String name, String desc,
+			    MBeanParameterInfo[] sig, String type,
+			    int impact)
+  {
+    super(name, desc);
+    if (sig == null)
+      signature = new MBeanParameterInfo[0];
+    else
+      signature = sig;
+    this.type = type;
+    this.impact = impact;
+  }
+
+  /**
+   * Returns a clone of this instance.  The clone is created
+   * using just the method provided by {@link java.lang.Object}.
+   * Thus, the clone is just a shallow clone as returned by
+   * that method, and does not contain any deeper cloning based
+   * on the subject of this class.
+   *
+   * @return a clone of this instance.
+   * @see java.lang.Cloneable
+   */
+  public Object clone()
+  {
+    try
+      {
+	return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	/* This shouldn't happen; we implement Cloneable */
+	throw new IllegalStateException("clone() called on " +
+					"non-cloneable object.");
+      }
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This returns
+   * true iff the object is an instance of {@link
+   * MBeanConstructorInfo}, {@link Object#equals()} returns true for a
+   * comparison of both the name and description of this notification
+   * with that of the specified object (performed by the superclass),
+   * the return type and impact are equal and the two signature arrays
+   * contain the same elements in the same order (but one may be
+   * longer than the other).
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanOperationInfo}
+   *         instance, 
+   *         <code>name.equals(object.getName())</code>,
+   *         <code>description.equals(object.getDescription())</code>,
+   *         <code>type.equals(object.getReturnType())</code>,
+   *         <code>impact == object.getImpact()</code>,
+   *         and the corresponding elements of the signature arrays are
+   *         equal.
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof MBeanOperationInfo))
+      return false;
+    if (!(super.equals(obj)))
+      return false;
+    MBeanOperationInfo o = (MBeanOperationInfo) obj;
+    MBeanParameterInfo[] sig = o.getSignature();
+    for (int a = 0; a < signature.length; ++a)
+      {
+	if (a == sig.length)
+	  return true;
+	if (!(signature[a].equals(sig[a])))
+	  return false;
+      }
+    return (type.equals(o.getReturnType()) &&
+	    impact == o.getImpact());
+  }
+  
+  /**
+   * <p>
+   * Returns the impact of performing this operation.
+   * The value is equal to one of the following:
+   * </p>
+   * <ol>
+   * <li>{@link #INFO} — the method just returns
+   * information (akin to an accessor).</li>
+   * <li>{@link #ACTION} — the method just alters
+   * the state of the bean, without returning a value
+   * (akin to a mutator).</li>
+   * <li>{@link #ACTION_INFO} — the method both makes
+   * state changes and returns a value.</li>
+   * <li>{@link #UNKNOWN} — the behaviour of the operation
+   * is unknown.</li>
+   * </ol>
+   *
+   * @return the impact of performing the operation.
+   */
+  public int getImpact()
+  {
+    return impact;
+  }
+
+  /**
+   * Returns the return type of the operation, as the class
+   * name.
+   *
+   * @return the return type.
+   */
+  public String getReturnType()
+  {
+    return type;
+  }
+
+  /**
+   * Returns the operation's signature, in the form of
+   * information on each parameter.  Each parameter is
+   * described by an instance of {@link MBeanParameterInfo}.
+   * The returned array is a shallow copy of the array used
+   * by this instance, so changing which elements are stored
+   * in the array won't affect the array used by this, but
+   * changing the actual elements will affect the ones used
+   * here.
+   *
+   * @return an array of {@link MBeanParameterInfo} objects,
+   *         describing the operation parameters.
+   */
+  public MBeanParameterInfo[] getSignature()
+  {
+    return (MBeanParameterInfo[]) signature.clone();
+  }
+
+  /**
+   * Returns the hashcode of the operation information as the sum of
+   * the hashcode of the superclass, the parameter array, the return
+   * type and the impact factor.
+   *
+   * @return the hashcode of the operation information.
+   */
+  public int hashCode()
+  {
+    return super.hashCode() + Arrays.hashCode(signature)
+      + type.hashCode() + Integer.valueOf(impact).hashCode();
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanOperationInfo</code>),
+   * the name, description, return type and impact of the
+   * operation and the contents of the array of parameters.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      {
+	String impactString;
+	switch (impact)
+	  {
+	  case INFO:
+	    impactString = "INFO";
+	    break;
+	  case ACTION:
+	    impactString = "ACTION";
+	    break;
+	  case ACTION_INFO:
+	    impactString = "ACTION_INFO";
+	    break;
+	  case UNKNOWN:
+	    impactString = "UNKNOWN";
+	    break;
+	  default:
+	    impactString = "ERRONEOUS VALUE";
+	  }
+	super.toString();
+	string = string.substring(0, string.length() - 1) 
+	  + ",returnType=" + type
+	  + ",impact=" + impactString 
+	  + ",signature=" + Arrays.toString(signature)
+	  + "]";
+      }
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanParameterInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanParameterInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanParameterInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/MBeanParameterInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,176 @@
+/* MBeanParameterInfo.java -- Information about an operation's parameters.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Describes the parameters of a constructor or operation associated
+ * with a management bean.  The information in this class is immutable
+ * as standard.  Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanParameterInfo
+  extends MBeanFeatureInfo
+  implements Cloneable
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 7432616882776782338L;
+
+  /**
+   * The type of the parameter, represented by the class name.
+   */
+  private String type;
+
+  /**
+   * Constructs a new {@link MBeanParameterInfo} using the specified
+   * name, description and type.  
+   *
+   * @param name the name of the attribute.
+   * @param type the type of the attribute, in the form of its class name.
+   * @param desc a description of the attribute.
+   */
+  public MBeanParameterInfo(String name, String type, String desc)
+  {
+    super(name, desc);
+    this.type = type;
+  }
+
+  /**
+   * Returns a clone of this instance.  The clone is created
+   * using just the method provided by {@link java.lang.Object}.
+   * Thus, the clone is just a shallow clone as returned by
+   * that method, and does not contain any deeper cloning based
+   * on the subject of this class.
+   *
+   * @return a clone of this instance.
+   * @see java.lang.Cloneable
+   */
+  public Object clone()
+  {
+    try
+      {
+	return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	/* This shouldn't happen; we implement Cloneable */
+	throw new IllegalStateException("clone() called on " +
+					"non-cloneable object.");
+      }
+  }
+
+  /**
+   * Compares this feature with the supplied object.  This returns
+   * true iff the object is an instance of {@link MBeanParameterInfo},
+   * {@link Object#equals()} returns true for a comparison of both the
+   * name and description of this parameter with that of the specified
+   * object (performed by the superclass), and the type of the two
+   * instances is equal.
+   *
+   * @param obj the object to compare.
+   * @return true if the object is a {@link MBeanParameterInfo}
+   *         instance, 
+   *         <code>name.equals(object.getName())</code>,
+   *         <code>description.equals(object.getDescription())</code>,
+   *         and <code>type.equals(object.getType())</code>.
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof MBeanParameterInfo))
+      return false;
+    if (!(super.equals(obj)))
+      return false;
+    MBeanParameterInfo o = (MBeanParameterInfo) obj;
+    return type.equals(o.getType());
+  }
+
+  /**
+   * Returns the type of this attribute, in the form of its class name.
+   *
+   * @return the type of this attribute.
+   */
+  public String getType()
+  {
+    return type;
+  }
+
+  /**
+   * Returns the hashcode of the parameter information as the sum of
+   * the hashcode of the superclass and the hashcode of the type.
+   *
+   * @return the hashcode of the parameter information.
+   */
+  public int hashCode()
+  {
+    return super.hashCode() + type.hashCode();
+  }
+
+  /**
+   * <p>
+   * Returns a textual representation of this instance.  This
+   * is constructed using the class name
+   * (<code>javax.management.MBeanParameterInfo</code>) along
+   * with the name, description and type of the parameter.
+   * </p>
+   * <p>
+   * As instances of this class are immutable, the return value
+   * is computed just once for each instance and reused
+   * throughout its life.
+   * </p>
+   *
+   * @return a @link{java.lang.String} instance representing
+   *         the instance in textual form.
+   */
+  public String toString()
+  {
+    if (string == null)
+      {
+	super.toString();
+	string = string.substring(0, string.length() - 1) 
+	  + ",type=" + type
+	  + "]";
+      }
+    return string;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotCompliantMBeanException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotCompliantMBeanException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotCompliantMBeanException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotCompliantMBeanException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* NotCompliantMBeanException.java -- Thrown due to a non-compliant bean.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Thrown when a management bean is passed to a method
+ * (e.g. to an MBean server to be registered) and it
+ * fails to comply with the specifications for such
+ * a bean.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class NotCompliantMBeanException
+  extends OperationsException
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 5175579583207963577L;
+
+  /**
+   * Constructs a new <code>NotCompliantMBeanException</code>.
+   */
+  public NotCompliantMBeanException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>NotCompliantMBeanException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public NotCompliantMBeanException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Notification.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Notification.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Notification.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/Notification.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,314 @@
+/* Notification.java -- A notification emitted by a bean.
+   Copyright (C) 2006 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 javax.management;
+
+import java.util.Date;
+import java.util.EventObject;
+
+/**
+ * <p>
+ * A notification message that may be emitted by a bean.
+ * Notifications have both a message and a type, so individual
+ * notifications can be grouped by type.  They also incorporate
+ * sequencing, so that the recipient can order the delivered
+ * messages correctly (there is no guarantee that they will
+ * be delivered in order).
+ * </p>
+ * <p>
+ * Notifications also include a reference to the source of
+ * the notification.  The source bean is represented either
+ * by an {@link ObjectName} or by a direct reference to the
+ * bean.  The former is preferable, and notifications emitted
+ * via a {@link MBeanServer} will automatically have the source
+ * transformed into an {@link ObjectName}.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class Notification
+  extends EventObject
+{
+
+  /**
+   * The notification message.
+   *
+   * @serial the notification message.
+   */
+  private String message;
+
+  /**
+   * The notification's sequence number, relative to the notifications
+   * emitted by the bean.
+   *
+   * @serial the notification sequence number.
+   */
+  private long sequenceNumber;
+
+  /**
+   * The source of the notification.  This is redeclared in order to
+   * replace the <code>source</code> variable in {@link java.util.EventObject}
+   * with a non-transient version.
+   *
+   * @serial the notification source.
+   */
+  protected Object source;
+
+  /**
+   * The time the notification was generated.
+   *
+   * @serial the notification timestamp.
+   */
+  private long timeStamp;
+
+  /**
+   * The type of notification sent.  This utilises the same style
+   * as Java property and package names.  For example,
+   * <code>gnu.gcj.compiler</code> may be one type of notifications.
+   *
+   * @serial the notification type.
+   */
+  private String type;
+
+  /**
+   * The user data associated with the notification.  This includes
+   * any additional data which should be transmitted with the notification,
+   * but can't be achieved using the {@link java.lang.String} format
+   * of the <code>message</code>.
+   *
+   * @serial the notification user data.
+   */
+  private Object userData;
+
+  /**
+   * Creates a new {@link Notification} object with the specified type,
+   * source and sequence number.  The timestamp is created using the
+   * current date and time.
+   *
+   * @param type the type of the notification.
+   * @param source the source of the notification.
+   * @param sequenceNumber the sequence number of the notifcation.
+   */
+  public Notification(String type, Object source, long sequenceNumber)
+  {
+    this(type, source, sequenceNumber, new Date().getTime());
+  }
+
+  /**
+   * Creates a new {@link Notification} object with the specified type,
+   * source, sequence number and timestamp.  
+   *
+   * @param type the type of the notification.
+   * @param source the source of the notification.
+   * @param sequenceNumber the sequence number of the notifcation.
+   * @param timeStamp the time the notification was emitted.
+   */
+  public Notification(String type, Object source, long sequenceNumber,
+		      long timeStamp)
+  {
+    this(type, source, sequenceNumber, timeStamp, null);
+  }
+
+  /**
+   * Creates a new {@link Notification} object with the specified type,
+   * source, sequence number, timestamp and message.  
+   *
+   * @param type the type of the notification.
+   * @param source the source of the notification.
+   * @param sequenceNumber the sequence number of the notifcation.
+   * @param timeStamp the time the notification was emitted.
+   * @param message the message contained in the notification.
+   */
+  public Notification(String type, Object source, long sequenceNumber,
+		      long timeStamp, String message)
+  {
+    super(source);
+    this.type = type;
+    this.sequenceNumber = sequenceNumber;
+    this.timeStamp = timeStamp;
+    this.message = message;
+  }
+
+  /**
+   * Creates a new {@link Notification} object with the specified type,
+   * source, sequence number and message.  The timestamp is created using
+   * the current date and time.
+   *
+   * @param type the type of the notification.
+   * @param source the source of the notification.
+   * @param sequenceNumber the sequence number of the notifcation.
+   * @param message the message contained in the notification.
+   */
+  public Notification(String type, Object source, long sequenceNumber,
+		      String message)
+  {
+    this(type, source, sequenceNumber, new Date().getTime(), message);
+  }
+
+  /**
+   * Returns the message contained in this notification.  The message
+   * is in {@link java.lang.String} form, and is thus intended for
+   * display to the end-user.  Data transferred as part of the notification
+   * which shouldn't be displayed is included in the <code>userData</code>
+   * field.
+   *
+   * @return the notification message.
+   * @see #getUserData()
+   * @see #setUserData(java.lang.Object)
+   */
+  public String getMessage()
+  {
+    return message;
+  }
+
+  /**
+   * Returns the sequence number of this notification.  This
+   * can be used to determine the order in which notifications
+   * were emitted by the broadcasting bean.
+   *
+   * @return the sequence number.
+   * @see #setSequenceNumber(long)
+   */
+  public long getSequenceNumber()
+  {
+    return sequenceNumber;
+  }
+
+  /**
+   * Returns the date and time at which this notification was
+   * emitted.
+   *
+   * @return the notification timestamp.
+   * @see #setTimeStamp(long)
+   */
+  public long getTimeStamp()
+  {
+    return timeStamp;
+  }
+
+  /**
+   * Returns the type of this notification.  Types take the same
+   * form as Java package and property names.
+   *
+   * @return the type of the notification.
+   */
+  public String getType()
+  {
+    return type;
+  }
+
+  /**
+   * Returns the additional user data associated with the notification.
+   * This is used to attach additional non-textual information to the
+   * notification.
+   *
+   * @return the user data associated with the notification.
+   * @see #setUserData(java.lang.Object)
+   */
+  public Object getUserData()
+  {
+    return userData;
+  }
+
+  /**
+   * Sets the sequence number to the value specified.
+   *
+   * @param sequenceNumber the new sequence number.
+   * @see #getSequenceNumber()
+   */
+  public void setSequenceNumber(long sequenceNumber)
+  {
+    this.sequenceNumber = sequenceNumber;
+  }
+
+  /**
+   * Sets the source of this notification to the value
+   * specified.
+   *
+   * @param source the new source of the notification.
+   * @see java.util.EventSource#getSource()
+   */
+  public void setSource(Object source)
+  {
+    this.source = source;
+  }
+
+  /**
+   * Sets the date and time at which this notification
+   * was emitted.
+   *
+   * @param timeStamp the new time stamp of the notification.
+   * @see #getTimeStamp()
+   */
+  public void setTimeStamp(long timeStamp)
+  {
+    this.timeStamp = timeStamp;
+  }
+
+  /**
+   * Sets the additional user data associated with the notification
+   * to the specified value.  This is used to attach additional
+   * non-textual information to the notification.
+   *
+   * @param userData the new user data associated with the notification.
+   * @see #getUserData()
+   */
+  public void setUserData(Object userData)
+  {
+    this.userData = userData;
+  }
+
+  /**
+   * A textual representation of the notification.
+   * 
+   * @return the notification in {@link java.lang.String} form.
+   */
+  public String toString()
+  {
+    return getClass().getName()
+      + "[message=" + message 
+      + ", sequenceNumber=" + sequenceNumber 
+      + ", source=" + source 
+      + ", timeStamp=" + timeStamp
+      + ", type=" + type
+      + ", userData=" + userData
+      + "]";
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationBroadcaster.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationBroadcaster.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationBroadcaster.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationBroadcaster.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* NotificationBroadcaster.java -- Interface for broadcasters.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * <p>
+ * Represents a bean that can emit notifications when
+ * events occur.  Other beans can use this interface
+ * to add themselves to the list of recipients of such
+ * notifications.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: New classes should use
+ * {@link NotificationEmitter}, a subinterface of this,
+ * in preference to using this interface directly.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationBroadcaster
+{
+  
+  /**
+   * Registers the specified listener as a new recipient of
+   * notifications from this bean.  If non-null, the filter
+   * argument will be used to select which notifications are
+   * delivered.  The supplied object will also be passed to
+   * the recipient with each notification.  This should not
+   * be modified by the broadcaster, but instead should be
+   * passed unmodified to the listener.
+   *
+   * @param listener the new listener, who will receive
+   *                 notifications from this broadcasting bean.
+   * @param filter a filter to determine which notifications are
+   *               delivered to the listener, or <code>null</code>
+   *               if no filtering is required.
+   * @param passback an object to be passed to the listener with
+   *                 each notification.
+   * @throws IllegalArgumentException if <code>listener</code> is
+   *                                  <code>null</code>.
+   * @see #removeNotificationListener(NotificationListener)
+   */
+  void addNotificationListener(NotificationListener listener,
+			       NotificationFilter filter,
+			       Object passback)
+    throws IllegalArgumentException;
+
+  /**
+   * Returns an array describing the notifications this
+   * bean may send to its registered listeners.  Ideally, this
+   * array should be complete, but in some cases, this may
+   * not be possible.  However, be aware that some listeners
+   * may expect this to be so.
+   *
+   * @return the array of possible notifications.
+   */
+  MBeanNotificationInfo[] getNotificationInfo();
+
+  /**
+   * Removes the specified listener from the list of recipients
+   * of notifications from this bean.  This includes all combinations
+   * of filters and passback objects registered for this listener.
+   * For more specific removal of listeners, see the subinterface
+   * {@link NotificationEmitter}.
+   *
+   * @param listener the listener to remove.
+   * @throws ListenerNotFoundException if the specified listener
+   *                                   is not registered with this bean.
+   * @see #addNotificationListener(NotificationListener, NotificationFilter,
+   *                               java.lang.Object)
+   */
+  void removeNotificationListener(NotificationListener listener)
+    throws ListenerNotFoundException;
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationEmitter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationEmitter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationEmitter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationEmitter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* NotificationEmitter.java -- Refined interface for broadcasters.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Represents a bean that can emit notifications when
+ * events occur.  Other beans can use this interface
+ * to add themselves to the list of recipients of such
+ * notifications.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationEmitter
+  extends NotificationBroadcaster
+{
+  
+  /**
+   * Removes the specified listener from the list of recipients
+   * of notifications from this bean.  Only the first instance with
+   * the supplied filter and passback object is removed.
+   * <code>null</code> is used as a valid value for these parameters,
+   * rather than as a way to remove all registration instances for
+   * the specified listener; for this behaviour instead, see the details
+   * of the same method in {@link NotificationBroadcaster}.
+   *
+   * @param listener the listener to remove.
+   * @param filter the filter of the listener to remove.
+   * @param passback the passback object of the listener to remove.
+   * @throws ListenerNotFoundException if the specified listener
+   *                                   is not registered with this bean.
+   * @see #addNotificationListener(NotificationListener, NotificationFilter,
+   *                               java.lang.Object)
+   */
+  void removeNotificationListener(NotificationListener listener,
+				  NotificationFilter filter,
+				  Object passback)
+    throws ListenerNotFoundException;
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationFilter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationFilter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationFilter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationFilter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* NotificationFilter.java -- Interface for notification filters.
+   Copyright (C) 2006 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 javax.management;
+
+import java.io.Serializable;
+
+/**
+ * Represents a object that acts as a filter for notifications.
+ * Implementations of this class are used to determine which
+ * notifications should be passed to a receiving bean, and which
+ * should not.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationFilter
+  extends Serializable
+{
+  
+  /**
+   * Returns true if the specified notification should be passed
+   * on to the listener.
+   *
+   * @param notification the notification being delivered.
+   * @return true if the notification should be passed to the
+   *         listener, false otherwise.
+   */
+  boolean isNotificationEnabled(Notification notification);
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/NotificationListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* NotificationListener.java -- Interface for receivers of notifications.
+   Copyright (C) 2006 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 javax.management;
+
+import java.util.EventListener;
+
+/**
+ * Represents a object that can receive notifications from
+ * a bean.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationListener
+  extends EventListener
+{
+  
+  /**
+   * Invoked by the notifying bean when a notification is to
+   * be delivered to the recipient.  As the transmission of
+   * notifications takes place sequentially, implementors of
+   * this method should avoid performing lengthy operations,
+   * as the notifying bean will stall until the method is
+   * complete.
+   *
+   * @param notification the notification from the bean.
+   * @param passback the object that was passed to the notifying
+   *                 bean as part of the registration process.
+   * @see NotificationBroadcaster#addListener(NotificationListener,
+   *      NotificationFilter, Object)
+   */
+  void handleNotification(Notification notification, Object passback);
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/OperationsException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/OperationsException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/OperationsException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/OperationsException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* OperationsException.java -- Thrown by management operations.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * A general superclass for all exceptions thrown by
+ * operations on management beans.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class OperationsException
+  extends JMException
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -4967597595580536216L;
+
+  /**
+   * Constructs a new <code>OperationsException</code>.
+   */
+  public OperationsException()
+  {
+    super();
+  }
+
+  /**
+   * Constructs a new <code>OperationsException</code>
+   * with the specified message.
+   *
+   * @param message the error message to give to the user.
+   */
+  public OperationsException(String message)
+  {
+    super(message);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ReflectionException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ReflectionException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ReflectionException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/ReflectionException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* ReflectionException.java -- A reflection-based management exception.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Represents one of the reflection exceptions thrown by a
+ * management bean.  When a management bean tries to perform
+ * a lookup using the reflection API and encounters an exception,
+ * it gets wrapped inside an {@link ReflectionException}.
+ * Calling {@link getTargetException()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class ReflectionException
+  extends JMException
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 9170809325636915553L;
+
+  /* Sun re-implemented causality -- don't know why, but
+     serialization demands we do too... */
+
+  /**
+   * The target exception.
+   *
+   * @serial the target exception.
+   */
+  private Exception exception;
+
+  /**
+   * Constructs a new <code>ReflectionException</code> wrapping
+   * the specified exception.
+   *
+   * @param e the exception to be wrapped.
+   */
+  public ReflectionException(Exception e)
+  {
+    super();
+    exception = e;
+  }
+
+  /**
+   * Constructs a new <code>ReflectionException</code> wrapping
+   * the specified exception and using the supplied message.
+   *
+   * @param e the exception to be wrapped.
+   * @param message the error message to give to the user.
+   */
+  public ReflectionException(Exception e, String message)
+  {
+    super(message);
+    exception = e;
+  }
+
+  /**
+   * Returns the true cause of this exception, the wrapped
+   * exception.
+   *
+   * @return the wrapped exception.
+   */
+  public Throwable getCause()
+  {
+    return exception;
+  }
+
+  /**
+   * Returns the true cause of this exception, the wrapped
+   * exception.
+   *
+   * @return the wrapped exception.
+   */
+  public Exception getTargetException()
+  {
+    return exception;
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/management/RuntimeOperationsException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/management/RuntimeOperationsException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/management/RuntimeOperationsException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/management/RuntimeOperationsException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* RuntimeOperationsException.java -- A wrapped run-time exception.
+   Copyright (C) 2006 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 javax.management;
+
+/**
+ * Represents a runtime exception thrown by a management
+ * bean operation.  When a management bean executes code
+ * that causes a runtime exception to be thrown, the
+ * resulting exception is wrapped inside an
+ * {@link RuntimeOperationsException}. Calling
+ * {@link getTargetException()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class RuntimeOperationsException
+  extends JMRuntimeException
+{
+ 
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -8408923047489133588L;
+  
+  /* Sun re-implemented causality -- don't know why, but
+     serialization demands we do too... */
+
+  /**
+   * The target exception.
+   *
+   * @serial the target exception.
+   */
+  private RuntimeException runtimeException;
+
+  /**
+   * Constructs a new <code>RuntimeOperationsException</code>
+   * wrapping the specified exception.
+   *
+   * @param e the exception to be wrapped.
+   */
+  public RuntimeOperationsException(RuntimeException e)
+  {
+    super();
+    runtimeException = e;
+  }
+
+  /**
+   * Constructs a new <code>RuntimeOperationsException</code>
+   *  wrapping the specified exception and using the supplied
+   * message.
+   *
+   * @param e the exception to be wrapped.
+   * @param message the error message to give to the user.
+   */
+  public RuntimeOperationsException(RuntimeException e,
+				    String message)
+  {
+    super(message);
+    runtimeException = e;
+  }
+
+  /**
+   * Returns the true cause of this exception, the wrapped
+   * exception.
+   *
+   * @return the wrapped exception.
+   */
+  public Throwable getCause()
+  {
+    return runtimeException;
+  }
+
+  /**
+   * Returns the true cause of this exception, the wrapped
+   * exception.
+   *
+   * @return the wrapped exception.
+   */
+  public RuntimeException getTargetException()
+  {
+    return runtimeException;
+  }
+
+}
+





More information about the llvm-commits mailing list