[llvm-commits] [llvm-gcc-4.2] r43913 [28/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/gnu/javax/print/CupsServer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/CupsServer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/CupsServer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/CupsServer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,288 @@
+/* CupsServer.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 gnu.javax.print;
+
+import gnu.javax.print.ipp.IppException;
+import gnu.javax.print.ipp.IppPrintService;
+import gnu.javax.print.ipp.IppRequest;
+import gnu.javax.print.ipp.IppResponse;
+import gnu.javax.print.ipp.attribute.RequestedAttributes;
+import gnu.javax.print.ipp.attribute.supported.PrinterUriSupported;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * <code>CupsServer</code> represents a host running a cups
+ * compatible server. It mainly consists of its URI and optional
+ * user and password combination if access is restricted.
+ * <p>
+ * It provides methods for retrival of valid CUPS printer uris 
+ * that are used to construct IppPrintService objects.
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class CupsServer
+{
+  /** 
+   * The URI of the CUPS server.
+   * This is something like: http://localhost:631
+   */
+  private transient URI uri;
+  
+  /**
+   * The optional username.
+   */
+  private transient String username;
+  
+  /**
+   * The optional password for the user.
+   */
+  private transient String password;
+
+  /**
+   * Creates a <code>CupsServer</code> object which
+   * tries to connect to a cups server. 
+   *
+   * If <code>gnu.javax.print.server</code> is explicitly set, then
+   * that hostname will be used. Otherwise it will default to localhost.
+   * 
+   * @param username the username
+   * @param password the password for the username.
+   */
+  public CupsServer(String username, String password)
+  {
+    this.username = username;
+    this.password = password;
+
+    this.uri = null;
+    try
+      {
+	String serv = System.getProperty("gnu.javax.print.server");
+	if( serv != null )
+	  this.uri = new URI("http://"+serv+":631");
+      }
+    catch(URISyntaxException use)
+      {
+	throw new RuntimeException("gnu.javax.print.CupsServer value is not a valid hostname.");
+      }
+    catch(SecurityException se)
+      {
+      }
+
+    try
+      {
+	if( this.uri == null )
+	  this.uri = new URI("http://localhost:631");
+      }
+    catch (URISyntaxException e)
+      {
+        // does not happen
+      }
+  }
+ 
+  /**
+   * Creates a <code>CupsServer</code> object which
+   * tries to connect to a running cups server on the
+   * given URI.
+   * 
+   * @param uri the URI of the server.
+   * @param username the username
+   * @param password the password for the username.
+   */
+  public CupsServer(URI uri, String username, String password)
+  {
+    this.uri = uri;
+    this.username = username;
+    this.password = password;
+  }
+  
+  /**
+   * Requests the default printer from this CUPS server.
+   * This is always returned as IppPrintService.
+   * 
+   * @return The default printer.
+   * @throws IppException if problems during request/response processing occur.
+   */
+  public IppPrintService getDefaultPrinter() throws IppException
+  {   
+    IppResponse response = null;
+   
+    try
+      {
+        IppRequest request = new IppRequest(uri, username, password);    
+        request.setOperationID((short)CupsIppOperation.CUPS_GET_DEFAULT);        
+        request.setOperationAttributeDefaults();    
+        
+        RequestedAttributes requestedAttrs 
+         = new RequestedAttributes("printer-uri-supported");
+        request.addOperationAttribute(requestedAttrs);
+        
+        response = request.send();
+      }   
+    catch (IOException e)
+      {
+        throw new IppException("IOException in IPP request/response.", e);
+      }    
+        
+    Map printerAttributes = (Map) response.getPrinterAttributes().get(0);
+    Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
+    PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
+    
+    IppPrintService service 
+      = new CupsPrintService(uri.getURI(), username, password);
+    
+    return service;
+  }
+  
+  /**
+   * Requests all printers from this CUPS server.
+   * 
+   * @return The list of available printers.
+   * @throws IppException if problems during request/response processing occur.
+   */
+  public List getAllPrinters() throws IppException
+  {   
+    IppResponse response = null;
+   
+    try
+      {
+        IppRequest request = new IppRequest(uri, username, password);    
+        request.setOperationID((short)CupsIppOperation.CUPS_GET_PRINTERS);        
+        request.setOperationAttributeDefaults();
+        
+        RequestedAttributes requestedAttrs 
+          = new RequestedAttributes("printer-uri-supported");
+        request.addOperationAttribute(requestedAttrs);
+        
+        response = request.send();
+      }   
+    catch (IOException e)
+      {
+        throw new IppException("IOException in IPP request/response.", e);
+      }    
+
+    List prAttr = response.getPrinterAttributes();
+    List services = new ArrayList();
+    
+    for (int i=0; i < prAttr.size(); i++)
+      {
+        Map printerAttributes = (Map) prAttr.get(i);
+        Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
+        PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
+
+        try
+          {
+            CupsPrintService cups = new CupsPrintService(uri.getURI(),
+                                                         username, password);
+            services.add(cups);
+          }
+        catch (IppException e)
+          {
+            // do nothing, we only catch the IppException which could be
+            // thrown during instantiation as single printers may be discovered
+            // correctly but not usable due to other security restrictions
+          }       
+      }    
+                     
+    return services;
+  }
+  
+  /**
+   * Requests all classes from this CUPS server. Classes in cups are
+   * collections of printers. This means jobs directed to a class 
+   * are forwarded to the first available printer of the collection.
+   * 
+   * @return The list of available classes.
+   * @throws IppException if problems during request/response processing occur.
+   */
+  public List getAllClasses() throws IppException
+  {   
+    IppResponse response = null;
+   
+    try
+      {
+        IppRequest request = new IppRequest(uri, username, password);    
+        request.setOperationID((short)CupsIppOperation.CUPS_GET_CLASSES);        
+        request.setOperationAttributeDefaults();
+        
+        RequestedAttributes requestedAttrs 
+          = new RequestedAttributes("printer-uri-supported");
+        request.addOperationAttribute(requestedAttrs);
+        
+        response = request.send();
+      }   
+    catch (IOException e)
+      {
+        throw new IppException("IOException in IPP request/response.", e);
+      }    
+    
+    List prAttr = response.getPrinterAttributes();
+    List services = new ArrayList();   
+    
+    for (int i=0; i < prAttr.size(); i++)
+      {
+        Map printerAttributes = (Map) prAttr.get(i);
+        Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
+        PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
+        
+        try
+          {
+            CupsPrintService cups = new CupsPrintService(uri.getURI(),
+                                                         username, password);
+            services.add(cups);
+          }
+        catch (IppException e)
+          {
+            // do nothing, we only catch the IppException which could be
+            // thrown during instantiation as single printers may be discovered
+            // correctly but not usable due to other security restrictions
+          }        
+      }    
+                     
+    return services;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrintAttributeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrintAttributeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,148 @@
+/* PrintAttributeException.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 gnu.javax.print;
+
+import javax.print.AttributeException;
+import javax.print.PrintException;
+import javax.print.attribute.Attribute;
+
+/**
+ * A <code>PrintException</code> further refining the exception
+ * cause by providing an implementation of the print exception
+ * interface <code>AttributeException</code>.
+ * 
+ * @see javax.print.PrintException
+ * @see javax.print.AttributeException
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrintAttributeException extends PrintException 
+  implements AttributeException
+{
+  private Class[] categories;
+  private Attribute[] values;
+  
+  /**
+   * Constructs a <code>PrintAttributeException</code>
+   * with the given unsupported attributes and/or values.
+   * 
+   * @param unsupportedAttributes the unsupported categories, 
+   * may be <code>null</code>.
+   * @param unsupportedValues the unsupported attribute values, 
+   * may be <code>null</code>.
+   */
+  public PrintAttributeException(Class[] unsupportedAttributes,
+                                 Attribute[] unsupportedValues)
+  {
+    super();
+    categories = unsupportedAttributes;
+    values = unsupportedValues;
+  }
+
+  /**
+   * Constructs a <code>PrintAttributeException</code>
+   * with the given unsupported attributes and/or values.
+   * 
+   * @param e chained exception
+   * @param unsupportedAttributes the unsupported categories, 
+   * may be <code>null</code>.
+   * @param unsupportedValues the unsupported attribute values, 
+   * may be <code>null</code>.
+   */
+  public PrintAttributeException(Exception e,
+      Class[] unsupportedAttributes, Attribute[] unsupportedValues)
+  {
+    super(e);
+    categories = unsupportedAttributes;
+    values = unsupportedValues;
+  }
+
+  /**
+   * Constructs a <code>PrintAttributeException</code>
+   * with the given unsupported attributes and/or values.
+   * 
+   * @param s detailed message
+   * @param unsupportedAttributes the unsupported categories, 
+   * may be <code>null</code>.
+   * @param unsupportedValues the unsupported attribute values, 
+   * may be <code>null</code>.
+   */
+  public PrintAttributeException(String s,
+      Class[] unsupportedAttributes, Attribute[] unsupportedValues)
+  {
+    super(s);
+    categories = unsupportedAttributes;
+    values = unsupportedValues;
+  }
+
+  /**
+   * Constructs a <code>PrintAttributeException</code>
+   * with the given unsupported attributes and/or values.
+   * 
+   * @param s detailed message
+   * @param e chained exception
+   * @param unsupportedAttributes the unsupported categories, 
+   * may be <code>null</code>.
+   * @param unsupportedValues the unsupported attribute values, 
+   * may be <code>null</code>.
+   */
+  public PrintAttributeException(String s, Exception e,
+      Class[] unsupportedAttributes, Attribute[] unsupportedValues)
+  {
+    super(s, e);
+    categories = unsupportedAttributes;
+    values = unsupportedValues;
+  }
+
+  /**
+   * @see AttributeException#getUnsupportedAttributes()
+   */
+  public Class[] getUnsupportedAttributes()
+  {
+    return categories;
+  }
+
+  /**
+   * @see AttributeException#getUnsupportedValues()
+   */
+  public Attribute[] getUnsupportedValues()
+  {
+    return values;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrintFlavorException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrintFlavorException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,120 @@
+/* PrintFlavorException.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 gnu.javax.print;
+
+import javax.print.DocFlavor;
+import javax.print.FlavorException;
+import javax.print.PrintException;
+
+/**
+ * A <code>PrintException</code> further refining the exception
+ * cause by providing an implementation of the print exception
+ * interface <code>FlavorException</code>.
+ * 
+ * @see javax.print.PrintException
+ * @see javax.print.FlavorException
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class PrintFlavorException extends PrintException 
+  implements FlavorException
+{
+  private DocFlavor[] flavors;
+  
+  /**
+   * Constructs a <code>PrintFlavorException</code>
+   * with the given unsupported doc flavor array
+   * 
+   * @param unsupportedFlavors the unsupported document flavors.
+   */
+  public PrintFlavorException(DocFlavor[] unsupportedFlavors)
+  {
+    super();
+    flavors = unsupportedFlavors;
+  }
+
+  /**
+   * Constructs a <code>PrintFlavorException</code>
+   * with the given unsupported doc flavor array
+   * 
+   * @param e chained exception
+   * @param unsupportedFlavors the unsupported document flavors.
+   */
+  public PrintFlavorException(Exception e, DocFlavor[] unsupportedFlavors)
+  {
+    super(e);
+    flavors = unsupportedFlavors;
+  }
+
+  /**
+   * Constructs a <code>PrintFlavorException</code>
+   * with the given unsupported doc flavor array
+   * 
+   * @param s detailed message
+   * @param unsupportedFlavors the unsupported document flavors.
+   */
+  public PrintFlavorException(String s, DocFlavor[] unsupportedFlavors)
+  {
+    super(s);
+    flavors = unsupportedFlavors;
+  }
+
+  /**
+   * Constructs a <code>PrintFlavorException</code>
+   * with the given unsupported doc flavor array
+   * 
+   * @param s detailed message
+   * @param e chained exception
+   * @param unsupportedFlavors the unsupported document flavors.
+   */
+  public PrintFlavorException(String s, Exception e, 
+    DocFlavor[] unsupportedFlavors)
+  {
+    super(s, e);
+    flavors = unsupportedFlavors;
+  }
+
+  /**
+   * @see FlavorException#getUnsupportedFlavors()
+   */
+  public DocFlavor[] getUnsupportedFlavors()
+  {
+    return flavors;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrintUriException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrintUriException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,140 @@
+/* PrintUriException.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 gnu.javax.print;
+
+import java.net.URI;
+
+import javax.print.PrintException;
+import javax.print.URIException;
+
+/**
+ * A <code>PrintException</code> further refining the exception
+ * cause by providing an implementation of the print exception
+ * interface <code>URIException</code>.
+ * 
+ * @see javax.print.PrintException
+ * @see javax.print.URIException
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrintUriException extends PrintException 
+  implements URIException
+{
+  private int reason;
+  private URI uri;
+
+  /**
+   * Constructs a <code>PrintUriException</code> with the given reason
+   * and unsupported URI instance.
+   *
+   * @param reason the reason for the exception.
+   * @param unsupportedUri the URI which is unsupported.
+   * 
+   * @see URIException
+   */
+  public PrintUriException(int reason, URI unsupportedUri)
+  {
+    super();
+    this.reason = reason;
+    uri = unsupportedUri;     
+  }
+
+  /**
+   * Constructs a <code>PrintUriException</code> with the given reason
+   * and unsupported URI instance.
+   * 
+   * @param e chained exception
+   * @param reason the reason for the exception.
+   * @param unsupportedUri the URI which is unsupported.
+   */
+  public PrintUriException(Exception e, int reason, URI unsupportedUri)
+  {
+    super(e);
+    this.reason = reason;
+    uri = unsupportedUri;     
+  }
+
+  /**
+   * Constructs a <code>PrintUriException</code> with the given reason
+   * and unsupported URI instance.
+   * 
+   * @param s detailed message
+   * @param reason the reason for the exception.
+   * @param unsupportedUri the URI which is unsupported.
+   */
+  public PrintUriException(String s, int reason, URI unsupportedUri)
+  {
+    super(s);
+    this.reason = reason;
+    uri = unsupportedUri;     
+  }
+
+  /**
+   * Constructs a <code>PrintUriException</code> with the given reason
+   * and unsupported URI instance.
+   * 
+   * @param s detailed message
+   * @param e chained exception
+   * @param reason the reason for the exception.
+   * @param unsupportedUri the URI which is unsupported.
+   */
+  public PrintUriException(String s, Exception e, 
+    int reason, URI unsupportedUri)
+  {
+    super(s, e);
+    this.reason = reason;
+    uri = unsupportedUri;     
+  }
+
+  /**
+   * @see URIException#getReason()
+   */
+  public int getReason()
+  {
+    return reason;
+  }
+
+  /**
+   * @see URIException#getUnsupportedURI()
+   */
+  public URI getUnsupportedURI()
+  {
+    return uri;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrinterDialog.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/PrinterDialog.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1722 @@
+/* PrinterDialog.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 gnu.javax.print;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.HeadlessException;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.util.ArrayList;
+import java.util.ResourceBundle;
+
+import javax.print.DocFlavor;
+import javax.print.PrintService;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.Destination;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MediaPrintableArea;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterInfo;
+import javax.print.attribute.standard.PrinterIsAcceptingJobs;
+import javax.print.attribute.standard.PrinterMakeAndModel;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JSpinner;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+/**
+ * Implementation of the PrinterDialog used by
+ * {@link javax.print.ServiceUI} for visual selection
+ * of print services and its attributes.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterDialog extends JDialog implements ActionListener
+{
+  
+  /**
+   * The General Panel used in the printing dialog.
+   * @author Wolfgang Baer (WBaer at gmx.de)
+   */
+  final class GeneralPanel extends JPanel
+  {
+    /**
+     * Handles the copies attribute.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class CopiesAndSorted extends JPanel 
+      implements ChangeListener, ActionListener
+    {      
+      private JCheckBox sort;    
+      private JSpinner copies;
+      private JLabel copies_lb;
+      private SpinnerNumberModel copiesModel;
+    
+      CopiesAndSorted()
+      {
+        copies_lb = new JLabel(getLocalizedString("lb.copies"));        
+        sort = new JCheckBox(getLocalizedString("cb.sort"));
+        sort.addActionListener(this);
+    
+        copiesModel = new SpinnerNumberModel(1, 1, 9999, 1);
+        copies = new JSpinner(copiesModel);
+        copies.addChangeListener(this);
+        
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+        c.fill = GridBagConstraints.BOTH;
+        c.insets = new Insets(5, 5, 5, 5);
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.copies")));
+    
+        c.anchor = GridBagConstraints.WEST;
+    
+        c.gridx = 0;
+        c.gridy = 0;
+        add(copies_lb, c);
+    
+        c.gridx = 1;
+        c.gridy = 0;
+        add(copies, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(sort, c);
+      }
+      
+      // copies jspinner state
+      public void stateChanged(ChangeEvent event)
+      {
+        int value = ((Integer) copies.getValue()).intValue();
+        atts.add(new Copies(value));
+            
+        if (value > 1 && categorySupported(SheetCollate.class))
+          sort.setEnabled(true);
+        else
+          sort.setEnabled(false);                
+      }
+
+      // sorted checkbox state
+      public void actionPerformed(ActionEvent event)
+      {
+        if (sort.isSelected())
+          atts.add(SheetCollate.COLLATED);
+      }
+
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {        
+        if (categorySupported(Copies.class))
+          {
+            copies.setEnabled(true);
+            copies_lb.setEnabled(true);
+            
+            Copies copies = (Copies) attribute(Copies.class);
+            if (copies != null)
+              copiesModel.setValue(new Integer(copies.getValue()));
+            
+            if (((Integer)copiesModel.getValue()).intValue() > 1            
+                && categorySupported(SheetCollate.class))
+              {
+                sort.setEnabled(true);
+                Attribute collate = attribute(SheetCollate.class);
+                if (collate != null && collate.equals(SheetCollate.COLLATED))
+                  sort.setSelected(true); 
+              }
+            else
+              sort.setEnabled(false);
+          }
+        else
+          {
+            copies.setEnabled(false);            
+            copies_lb.setEnabled(false);
+          }
+      }
+    }
+
+    /**
+     * Handles the print ranges attribute.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class PrintRange extends JPanel 
+      implements ActionListener, FocusListener
+    {    
+      private JLabel to;    
+      private JRadioButton all_rb, pages_rb;   
+      private JTextField from_tf, to_tf;
+          
+      PrintRange()
+      {        
+        to = new JLabel(getLocalizedString("lb.to"));
+        to.setEnabled(false);
+    
+        all_rb = new JRadioButton(getLocalizedString("rbt.all"));
+        all_rb.setSelected(true);
+        all_rb.setActionCommand("ALL");
+        all_rb.addActionListener(this);
+        pages_rb = new JRadioButton(getLocalizedString("rbt.pages"));
+        pages_rb.setActionCommand("PAGES");
+        pages_rb.setEnabled(false);
+        pages_rb.addActionListener(this);
+    
+        ButtonGroup group = new ButtonGroup();
+        group.add(all_rb);
+        group.add(pages_rb);
+    
+        from_tf = new JTextField("1", 4);
+        from_tf.setEnabled(false);
+        from_tf.addFocusListener(this);
+        to_tf = new JTextField("1", 4);
+        to_tf.setEnabled(false);
+        to_tf.addFocusListener(this);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+        c.fill = GridBagConstraints.BOTH;
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.printrange")));
+    
+        c.insets = new Insets(15, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(all_rb, c);
+    
+        c.insets = new Insets(5, 5, 15, 5);
+        c.gridx = 0;
+        c.gridy = 1;
+        add(pages_rb, c);
+    
+        c.gridx = 1;
+        c.gridy = 1;
+        add(from_tf, c);
+    
+        c.gridx = 2;
+        c.gridy = 1;
+        add(to, c);
+    
+        c.insets = new Insets(5, 5, 15, 15);
+        c.gridx = 3;
+        c.gridy = 1;
+        add(to_tf, c);
+      }
+            
+      // focus pagerange
+      public void focusGained(FocusEvent event)
+      {
+        updatePageRanges();
+      }
+  
+      public void focusLost(FocusEvent event)
+      {
+        updatePageRanges();
+      }
+      
+      // updates the range after user changed it
+      private void updatePageRanges()
+      {
+        int lower = Integer.parseInt(from_tf.getText());
+        int upper = Integer.parseInt(to_tf.getText());
+        
+        if (lower > upper)
+          {
+            upper = lower;
+            to_tf.setText("" + lower);                
+          }
+        
+        PageRanges range = new PageRanges(lower, upper);
+        atts.add(range);
+      }
+
+      // page range change
+      public void actionPerformed(ActionEvent e)
+      { 
+        // if ALL is selected we must use a full-range object
+        if (e.getActionCommand().equals("ALL"))
+          {
+            from_tf.setEnabled(false);
+            to.setEnabled(false);
+            to_tf.setEnabled(false);
+            
+            atts.add(new PageRanges(1, Integer.MAX_VALUE));
+          }
+        else
+          {
+            from_tf.setEnabled(true);
+            to.setEnabled(true);
+            to_tf.setEnabled(true);
+            all_rb.setSelected(false);
+          }       
+      }
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        if (categorySupported(PageRanges.class))
+          {
+            pages_rb.setEnabled(true);
+            PageRanges range = (PageRanges) attribute(PageRanges.class);
+            if (range != null)
+              {
+                from_tf.setEnabled(true);
+                to.setEnabled(true);
+                to_tf.setEnabled(true);   
+                all_rb.setSelected(false);
+                pages_rb.setSelected(true);
+                
+                int[][] members = range.getMembers();
+                // Although passed in attributes may contain more than one 
+                // range we only take the first one
+                from_tf.setText("" + members[0][0]);
+                to_tf.setText("" + members[0][1]);
+              }
+          }
+        else
+          {
+            from_tf.setEnabled(false);
+            to.setEnabled(false);
+            to_tf.setEnabled(false);
+            all_rb.setSelected(true);
+          }
+       }
+    }
+
+    /**
+     * Handles the selection of the print services
+     * and its location and description attributes.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class PrintServices extends JPanel 
+      implements ActionListener
+    {    
+      private JLabel name, status, typ, info;
+      private JLabel statusValue, typValue, infoValue;   
+      private JButton attributes;    
+      private JComboBox services_cob;    
+      private JCheckBox fileRedirection_cb;
+    
+      PrintServices()
+      {
+        name = new JLabel(getLocalizedString("lb.name"));
+        status = new JLabel(getLocalizedString("lb.status"));
+        typ = new JLabel(getLocalizedString("lb.typ"));
+        info = new JLabel(getLocalizedString("lb.info"));
+        typValue = new JLabel();
+        infoValue = new JLabel();
+        statusValue = new JLabel();
+    
+        attributes = new JButton(getLocalizedString("bt.attributes"));
+        attributes.setEnabled(false);
+        attributes.setActionCommand("ATTRIBUTES");
+        attributes.addActionListener(this);
+    
+        services_cob = new JComboBox(getPrintServices());
+        services_cob.setActionCommand("SERVICE");
+        services_cob.addActionListener(this);
+    
+        fileRedirection_cb = new JCheckBox(getLocalizedString("cb.output"));
+        fileRedirection_cb.setEnabled(false);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.printservice")));
+    
+        c.insets = new Insets(5, 5, 5, 5);
+        c.anchor = GridBagConstraints.LINE_END;
+        c.gridx = 0;
+        c.gridy = 0;
+        add(name, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(status, c);
+    
+        c.gridx = 0;
+        c.gridy = 2;
+        add(typ, c);
+    
+        c.gridx = 0;
+        c.gridy = 3;
+        add(info, c);
+    
+        c.gridx = 2;
+        c.gridy = 3;
+        c.weightx = 1;
+        add(fileRedirection_cb, c);
+    
+        c.anchor = GridBagConstraints.LINE_START;
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 1;
+        c.gridy = 0;
+        c.weightx = 1.5;
+        add(services_cob, c);
+    
+        c.gridx = 1;
+        c.gridy = 1;
+        c.gridwidth = 2;
+        c.weightx = 1;
+        add(statusValue, c);
+        
+        c.gridx = 1;
+        c.gridy = 2;
+        c.gridwidth = 2;
+        c.weightx = 1;
+        add(typValue, c);
+    
+        c.gridx = 1;
+        c.gridy = 3;
+        c.gridwidth = 2;
+        c.weightx = 1;
+        add(infoValue, c);
+        
+        c.gridx = 2;
+        c.gridy = 0;
+        c.weightx = 1.5;
+        add(attributes, c);
+      }
+    
+      public void actionPerformed(ActionEvent e)
+      {
+        if (e.getActionCommand().equals("SERVICE"))
+          {
+            setSelectedPrintService((PrintService) services_cob.getSelectedItem());
+            updateAll();
+          }
+        else if (e.getActionCommand().equals("ATTRIBUTES"))
+          {
+            // TODO LowPriority-Enhancement: As tests have shown this button 
+            // is even gray and not enabled under Windows - Its a good place
+            // to provide a classpath specific browsing dialog for all 
+            // attributes not in the default printing dialog. 
+          }
+      }    
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        PrinterMakeAndModel att1 = (PrinterMakeAndModel)
+          getSelectedPrintService().getAttribute(PrinterMakeAndModel.class);
+        typValue.setText(att1 == null ? "" : att1.getValue());
+        
+        PrinterInfo att2 = (PrinterInfo) 
+          getSelectedPrintService().getAttribute(PrinterInfo.class);
+        infoValue.setText(att2 == null ? "" : att2.getValue());
+        
+        PrinterIsAcceptingJobs att3 = (PrinterIsAcceptingJobs)
+          getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class);
+        PrinterState att4 = (PrinterState)
+          getSelectedPrintService().getAttribute(PrinterState.class);
+        
+        String status = att4.toString();  
+        if (att3 == PrinterIsAcceptingJobs.ACCEPTING_JOBS)
+          status += " - " + getLocalizedString("lb.acceptingjobs");
+        else if (att3 == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS)
+          status += " - " + getLocalizedString("lb.notacceptingjobs");
+        
+        statusValue.setText(status);
+        
+        if (categorySupported(Destination.class))
+          {
+            fileRedirection_cb.setEnabled(false);
+          }
+      }
+      
+    }
+
+    private PrintServices printserv_panel;
+    private PrintRange printrange_panel;
+    private CopiesAndSorted copies;
+
+    /**
+     * Constructs the General Panel.
+     */
+    public GeneralPanel()
+    {     
+      setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+      printserv_panel = new PrintServices();
+      printrange_panel = new PrintRange();
+      copies = new CopiesAndSorted();
+
+      JPanel layout_panel = new JPanel();
+      layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS));
+      layout_panel.add(printrange_panel);
+      layout_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+      layout_panel.add(copies);
+
+      setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+      add(printserv_panel);
+      add(Box.createRigidArea(new Dimension(0, 12)));
+      add(layout_panel);
+    }
+    
+    /**
+     * Calls update on all internal panels to adjust
+     * for a new selected print service.
+     */
+    void update()
+    {
+      printserv_panel.updateForSelectedService();
+      printrange_panel.updateForSelectedService();
+      copies.updateForSelectedService();
+    }
+  }
+
+  /**
+   * The Page setup Panel.
+   * @author Wolfgang Baer (WBaer at gmx.de)
+   */
+  final class PageSetupPanel extends JPanel
+  {
+    /**
+     * Handles the orientation attribute.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class Orientation extends JPanel implements ActionListener
+    {
+      private JRadioButton portrait, landscape, rev_portrait, rev_landscape;
+      
+      Orientation()
+      {
+        portrait = new JRadioButton(getLocalizedString("rbt.portrait"));
+        portrait.addActionListener(this);
+        landscape = new JRadioButton(getLocalizedString("rbt.landscape"));
+        landscape.addActionListener(this);
+        rev_portrait = new JRadioButton(getLocalizedString("rbt.revportrait"));
+        rev_portrait.addActionListener(this);
+        rev_landscape = new JRadioButton(getLocalizedString("rbt.revlandscape"));
+        rev_landscape.addActionListener(this);
+    
+        ButtonGroup group = new ButtonGroup();
+        group.add(portrait);
+        group.add(landscape);
+        group.add(rev_portrait);
+        group.add(rev_landscape);
+          
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+        c.fill = GridBagConstraints.BOTH;
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.orientation")));
+    
+        c.insets = new Insets(5, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(portrait, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(landscape, c);
+    
+        c.gridx = 0;
+        c.gridy = 2;
+        add(rev_portrait, c);
+    
+        c.gridx = 0;
+        c.gridy = 3;
+        add(rev_landscape, c);
+      }
+    
+      // event handling orientation
+      public void actionPerformed(ActionEvent e)
+      {
+        if (e.getSource() == portrait)
+          atts.add(OrientationRequested.PORTRAIT);
+        else if (e.getSource() == landscape)
+          atts.add(OrientationRequested.LANDSCAPE);
+        else if (e.getSource() == rev_portrait)
+          atts.add(OrientationRequested.REVERSE_PORTRAIT);
+        else
+          atts.add(OrientationRequested.REVERSE_LANDSCAPE);      
+      }
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        if (categorySupported(OrientationRequested.class))
+          {
+            portrait.setEnabled(true);
+            landscape.setEnabled(true);
+            rev_landscape.setEnabled(true);
+            rev_portrait.setEnabled(true);
+            
+            Attribute orientation = attribute(OrientationRequested.class);
+            if (orientation != null)
+              {
+                if (orientation.equals(OrientationRequested.LANDSCAPE))
+                  landscape.setSelected(true);
+                else if (orientation.equals(OrientationRequested.PORTRAIT))
+                  portrait.setSelected(true);
+                else if (orientation.equals(OrientationRequested.REVERSE_PORTRAIT))
+                  rev_portrait.setSelected(true);
+                else 
+                  rev_landscape.setSelected(true);
+              }
+            else
+              {
+                Object defaultValue = defaultValue(OrientationRequested.class);
+                if (defaultValue.equals(OrientationRequested.LANDSCAPE))
+                  landscape.setSelected(true);
+                else if (defaultValue.equals(OrientationRequested.PORTRAIT))
+                  portrait.setSelected(true);
+                else if (defaultValue.equals(OrientationRequested.REVERSE_PORTRAIT))
+                  rev_portrait.setSelected(true);
+                else 
+                  rev_landscape.setSelected(true);
+              }
+          }
+        else
+          {
+            portrait.setEnabled(false);
+            landscape.setEnabled(false);
+            rev_landscape.setEnabled(false);
+            rev_portrait.setEnabled(false);
+          }       
+      }
+    }
+
+    /**
+     * Handles the media attribute.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class MediaTypes extends JPanel implements ActionListener
+    {
+      private JLabel size_lb, source_lb;
+      private JComboBox size, source;
+    
+      MediaTypes()
+      {
+        size_lb = new JLabel(getLocalizedString("lb.size"));
+        source_lb = new JLabel(getLocalizedString("lb.source"));
+    
+        size = new JComboBox();
+        size.setEditable(false);
+        size.addActionListener(this);
+        source = new JComboBox();
+        source.setEditable(false);
+        size.addActionListener(this);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.medias")));
+    
+        c.insets = new Insets(5, 5, 5, 5);
+        c.anchor = GridBagConstraints.LINE_END;
+        c.gridx = 0;
+        c.gridy = 0;
+        add(size_lb, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(source_lb, c);
+    
+        c.anchor = GridBagConstraints.LINE_START;
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 1;
+        c.gridy = 0;
+        c.weightx = 1.5;
+        add(size, c);
+    
+        c.gridx = 1;
+        c.gridy = 1;
+        c.weightx = 1.5;
+        add(source, c);
+      }
+    
+      public void actionPerformed(ActionEvent event)
+      {        
+        if (event.getSource() == size)
+          {
+            Object obj = size.getSelectedItem();
+            if (obj instanceof Media)
+              atts.add((Media) obj);    
+          }
+        
+        // we ignore source events currently
+        // as only the automatic selection is used.       
+      }
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      { 
+        if (categorySupported(Media.class))
+          {
+            Media[] medias = (Media[]) getSelectedPrintService()
+              .getSupportedAttributeValues(Media.class, flavor, null);
+            
+            size.removeAllItems();
+            if (medias.length == 0)
+              size.addItem(getLocalizedString("lb.automatically"));     
+            else
+              for (int i=0; i < medias.length; i++)
+                size.addItem(medias[i]);
+            
+            Media media = (Media) attribute(Media.class);
+            if (media != null)
+              size.setSelectedItem(media);
+            
+            // this is currently ignored
+            source.removeAllItems();
+            source.addItem(getLocalizedString("lb.automatically"));
+          }
+        else
+          {
+            size.removeAllItems();
+            source.removeAllItems();
+            
+            size.addItem(getLocalizedString("lb.automatically"));
+            source.addItem(getLocalizedString("lb.automatically"));
+          }
+       }
+    }
+
+    /**
+     * Handles the media printable area attribute.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class Margins extends JPanel implements FocusListener
+    {
+      private JLabel left, right, top, bottom;
+      private JTextField left_tf, right_tf, top_tf, bottom_tf;
+    
+      Margins()
+      {
+        left = new JLabel(getLocalizedString("lb.left"));
+        right = new JLabel(getLocalizedString("lb.right"));
+        top = new JLabel(getLocalizedString("lb.top"));
+        bottom = new JLabel(getLocalizedString("lb.bottom"));
+    
+        left_tf = new JTextField(7);
+        left_tf.addFocusListener(this);
+        right_tf = new JTextField(7);
+        right_tf.addFocusListener(this);
+        top_tf = new JTextField(7);
+        top_tf.addFocusListener(this);
+        bottom_tf = new JTextField(7);
+        bottom_tf.addFocusListener(this);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.margins")));
+    
+        c.insets = new Insets(5, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(left, c);
+    
+        c.gridx = 1;
+        c.gridy = 0;
+        add(right, c);
+    
+        c.insets = new Insets(5, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 1;
+        add(left_tf, c);
+    
+        c.gridx = 1;
+        c.gridy = 1;
+        add(right_tf, c);
+    
+        c.insets = new Insets(10, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 2;
+        add(top, c);
+    
+        c.gridx = 1;
+        c.gridy = 2;
+        add(bottom, c);
+    
+        c.insets = new Insets(0, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 3;
+        add(top_tf, c);
+    
+        c.gridx = 1;
+        c.gridy = 3;
+        add(bottom_tf, c);
+      }
+      
+      public void focusGained(FocusEvent event)
+      {
+        updateMargins();
+      }
+  
+      public void focusLost(FocusEvent event)
+      {
+        updateMargins();
+      }
+      
+      // updates the margins after user changed it
+      private void updateMargins()
+      {
+        // We currently do not support this attribute
+        // as it is not in the IPP spec and therefore not in CUPS
+      }
+      
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        if (categorySupported(MediaPrintableArea.class))
+          {
+            left.setEnabled(true);
+            right.setEnabled(true);
+            top.setEnabled(true);
+            bottom.setEnabled(true);
+            left_tf.setEnabled(true);
+            right_tf.setEnabled(true);
+            top_tf.setEnabled(true);
+            bottom_tf.setEnabled(true);           
+          }
+        else
+          {
+            left.setEnabled(false);
+            right.setEnabled(false);
+            top.setEnabled(false);
+            bottom.setEnabled(false);
+            left_tf.setEnabled(false);
+            right_tf.setEnabled(false);
+            top_tf.setEnabled(false);
+            bottom_tf.setEnabled(false); 
+          }     
+       }
+    }
+
+    private MediaTypes media_panel;
+    private Orientation orientation_panel;
+    private Margins margins_panel;
+
+    /** 
+     * Constructs the page setup user interface. 
+     */
+    public PageSetupPanel()
+    {
+      setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+      media_panel = new MediaTypes();
+      orientation_panel = new Orientation();
+      margins_panel = new Margins();
+
+      JPanel layout_panel = new JPanel();
+      layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS));
+      layout_panel.add(orientation_panel);
+      layout_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+      layout_panel.add(margins_panel);
+
+      setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+      add(media_panel);
+      add(Box.createRigidArea(new Dimension(0, 12)));
+      add(layout_panel);
+    }
+    
+    /**
+     * Calls update on all internal panels to adjust
+     * for a new selected print service.
+     */
+    void update()
+    {
+      media_panel.updateForSelectedService();
+      orientation_panel.updateForSelectedService();
+      margins_panel.updateForSelectedService();
+    }
+  }
+
+  /**
+   * The Appearance panel for quality, color etc.
+   * @author Wolfgang Baer (WBaer at gmx.de)
+   */
+  final class AppearancePanel extends JPanel
+  {
+    /**
+     * Handles the print quality attribute.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class Quality extends JPanel implements ActionListener
+    {
+      private JRadioButton low, normal, high;
+      private ButtonGroup group;
+    
+      Quality()
+      {
+        low = new JRadioButton(getLocalizedString("rbt.low"));
+        low.addActionListener(this);
+        normal = new JRadioButton(getLocalizedString("rbt.normal"));
+        normal.addActionListener(this);
+        high = new JRadioButton(getLocalizedString("rbt.high"));
+        high.addActionListener(this);
+    
+        group = new ButtonGroup();
+        group.add(low);
+        group.add(normal);
+        group.add(high);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.quality")));
+    
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.insets = new Insets(5, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(low, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(normal, c);
+    
+        c.gridx = 0;
+        c.gridy = 2;
+        add(high, c);
+      }
+    
+      public void actionPerformed(ActionEvent e)
+      {
+        if (e.getSource() == low)
+          atts.add(PrintQuality.DRAFT);
+        else if (e.getSource() == normal)
+          atts.add(PrintQuality.NORMAL);
+        else
+          atts.add(PrintQuality.HIGH);   
+      }
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        if (categorySupported(PrintQuality.class))
+          {
+            low.setEnabled(true);
+            normal.setEnabled(true);
+            high.setEnabled(true);
+            
+            Object defaultValue = defaultValue(PrintQuality.class);          
+            Attribute quality = attribute(PrintQuality.class);
+            
+            if (quality != null)
+              {
+                if (quality.equals(PrintQuality.DRAFT))
+                  low.setSelected(true);
+                else if (quality.equals(PrintQuality.NORMAL))
+                  normal.setSelected(true);
+                else 
+                  high.setSelected(true);
+              }
+            else
+              {
+                if (defaultValue.equals(PrintQuality.DRAFT))
+                  low.setSelected(true);
+                else if (defaultValue.equals(PrintQuality.NORMAL))
+                  normal.setSelected(true);
+                else 
+                  high.setSelected(true);
+              }              
+          }
+        else
+          {
+            low.setEnabled(false);
+            normal.setEnabled(false);
+            high.setEnabled(false);
+          }       
+      }
+    }
+  
+    /**
+     * Handles the job attributes as requesting username, jobname etc.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class JobAttributes extends JPanel
+      implements ActionListener, ChangeListener, FocusListener
+    {    
+      private JLabel jobname, username, priority_lb;    
+      private JTextField jobname_tf, username_tf;    
+      private JCheckBox cover;    
+      private JSpinner priority;
+      private SpinnerNumberModel model;
+    
+      JobAttributes()
+      {
+        jobname = new JLabel(getLocalizedString("lb.jobname"));
+        username = new JLabel(getLocalizedString("lb.username"));
+        priority_lb = new JLabel(getLocalizedString("lb.priority"));
+    
+        cover = new JCheckBox(getLocalizedString("cb.cover"));
+        cover.addActionListener(this);
+    
+        model = new SpinnerNumberModel(1, 1, 100, 1);
+        priority = new JSpinner(model);
+        priority.addChangeListener(this);
+    
+        jobname_tf = new JTextField();
+        jobname_tf.addFocusListener(this);
+        username_tf = new JTextField();
+        username_tf.addFocusListener(this);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.jobattributes")));
+    
+        c.insets = new Insets(10, 5, 10, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(cover, c);
+    
+        c.anchor = GridBagConstraints.LINE_END;
+        c.gridx = 1;
+        c.gridy = 0;
+        c.weightx = 2;
+        add(priority_lb, c);
+    
+        c.gridx = 2;
+        c.gridy = 0;
+        c.weightx = 0.5;
+        add(priority, c);
+    
+        c.anchor = GridBagConstraints.LINE_END;
+        c.gridx = 0;
+        c.gridy = 1;
+        add(jobname, c);
+    
+        c.gridx = 0;
+        c.gridy = 2;
+        add(username, c);
+    
+        c.anchor = GridBagConstraints.CENTER;
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 1;
+        c.gridy = 1;
+        c.gridwidth = 2;
+        c.weightx = 1.5;
+        add(jobname_tf, c);
+    
+        c.insets = new Insets(10, 5, 15, 5);
+        c.gridx = 1;
+        c.gridy = 2;
+        add(username_tf, c);
+      }
+      
+      public void actionPerformed(ActionEvent event)
+      {
+        if (cover.isSelected())
+          atts.add(JobSheets.STANDARD);
+        else
+          atts.add(JobSheets.NONE);
+      }
+      
+      public void stateChanged(ChangeEvent event)
+      {
+        int value = ((Integer) priority.getValue()).intValue();
+        atts.add(new JobPriority(value));  
+      }
+      
+      public void focusGained(FocusEvent event)
+      {        
+        updateTextfields(event);
+      }
+  
+      public void focusLost(FocusEvent event)
+      {
+        updateTextfields(event);
+      }
+      
+      private void updateTextfields(FocusEvent event)
+      {
+        if (event.getSource() == jobname_tf)
+            atts.add(new JobName(jobname_tf.getText(), null));
+        else
+            atts.add(new RequestingUserName(username_tf.getText(), null));
+      }
+
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        // JobPriority       
+        if (categorySupported(JobPriority.class))
+          {
+            JobPriority prio = (JobPriority) attribute(JobPriority.class);
+            JobPriority value = (JobPriority) defaultValue(JobPriority.class);         
+            priority.setEnabled(true);
+            if (prio != null)
+              model.setValue(new Integer(prio.getValue()));
+            else
+              model.setValue(new Integer(value.getValue()));
+          }         
+        else
+          priority.setEnabled(false);  
+        
+        // Requesting username
+        if (categorySupported(RequestingUserName.class))
+          {
+            Attribute user = attribute(RequestingUserName.class);
+            Object value = defaultValue(RequestingUserName.class);
+            username.setEnabled(true);            
+            if (user != null)
+              username_tf.setText(user.toString());
+            else
+              username_tf.setText(value.toString());
+          }
+        else
+          username.setEnabled(false);  
+        
+        // Job Name
+        if (categorySupported(JobName.class))
+          {
+            Attribute job = attribute(JobName.class);
+            Object value = defaultValue(JobName.class);
+            jobname.setEnabled(true);          
+            if (job != null)
+              jobname_tf.setText(job.toString());
+            else
+              jobname_tf.setText(value.toString());
+          }
+        else
+          jobname.setEnabled(false);  
+        
+        // Job sheets
+        if (categorySupported(JobSheets.class))
+          {
+            Attribute sheet = attribute(JobSheets.class);
+            Object value = defaultValue(JobSheets.class);
+            cover.setEnabled(true);       
+            if (sheet != null)
+              {
+                if (sheet.equals(JobSheets.NONE))
+                  cover.setSelected(false);
+                else 
+                  cover.setSelected(true);
+              }
+            else
+              {
+                if (value.equals(JobSheets.NONE))
+                  cover.setSelected(false);
+                else
+                  cover.setSelected(true);
+              }
+          }
+        else
+          cover.setEnabled(false);      
+      }
+    }
+  
+    /**
+     * Handles the sides attributes.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class SidesPanel extends JPanel implements ActionListener
+    {    
+      private JRadioButton oneside, calendar, duplex;
+    
+      SidesPanel()
+      { 
+        oneside = new JRadioButton(getLocalizedString("rbt.onesided"));
+        oneside.addActionListener(this);
+        calendar = new JRadioButton(getLocalizedString("rbt.calendar"));
+        calendar.addActionListener(this);
+        duplex = new JRadioButton(getLocalizedString("rbt.duplex"));
+        duplex.addActionListener(this);
+    
+        ButtonGroup group = new ButtonGroup();
+        group.add(oneside);
+        group.add(calendar);
+        group.add(duplex);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+        c.fill = GridBagConstraints.BOTH;
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.sides")));
+    
+        c.insets = new Insets(5, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(oneside, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(calendar, c);
+    
+        c.gridx = 0;
+        c.gridy = 2;
+        add(duplex, c);
+      }
+    
+      public void actionPerformed(ActionEvent e)
+      {
+        if (e.getSource() == calendar)
+          atts.add(Sides.TWO_SIDED_SHORT_EDGE);
+        else if (e.getSource() == oneside)
+          atts.add(Sides.ONE_SIDED);
+        else
+          atts.add(Sides.TWO_SIDED_LONG_EDGE);
+      }
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        if (categorySupported(Sides.class))
+          {
+            oneside.setEnabled(true);
+            calendar.setEnabled(true);
+            duplex.setEnabled(true);
+            
+            Object defaultValue = defaultValue(Sides.class);           
+            Attribute sides = attribute(Sides.class);
+            if (sides != null)
+              {
+                if (sides.equals(Sides.TWO_SIDED_SHORT_EDGE))
+                  calendar.setSelected(true);
+                else if (sides.equals(Sides.ONE_SIDED))
+                  oneside.setSelected(true);
+                else
+                  duplex.setSelected(true);
+              }
+            else
+              {
+                if (defaultValue.equals(Sides.TWO_SIDED_SHORT_EDGE))
+                  calendar.setSelected(true);
+                else if (defaultValue.equals(Sides.ONE_SIDED))
+                  oneside.setSelected(true);
+                else
+                  duplex.setSelected(true);
+              }
+          }
+        else
+          {           
+            oneside.setEnabled(false);
+            calendar.setEnabled(false);
+            duplex.setEnabled(false);
+          }       
+      }
+    }
+  
+    /**
+     * Handles the chromaticity attributes.
+     * @author Wolfgang Baer (WBaer at gmx.de)
+     */
+    final class Color extends JPanel implements ActionListener
+    {
+      private JRadioButton bw, color;
+    
+      Color()
+      {
+        bw = new JRadioButton(getLocalizedString("rbt.blackwhite"));
+        bw.addActionListener(this);
+        color = new JRadioButton(getLocalizedString("rbt.color"));
+        color.addActionListener(this);
+    
+        ButtonGroup group = new ButtonGroup();
+        group.add(bw);
+        group.add(color);
+    
+        GridBagLayout layout = new GridBagLayout();
+        GridBagConstraints c = new GridBagConstraints();
+    
+        setLayout(layout);
+        setBorder(new TitledBorder(getLocalizedString("title.color")));
+    
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.insets = new Insets(5, 5, 5, 5);
+        c.gridx = 0;
+        c.gridy = 0;
+        add(bw, c);
+    
+        c.gridx = 0;
+        c.gridy = 1;
+        add(color, c);
+      }
+    
+      public void actionPerformed(ActionEvent e)
+      {
+        if (e.getSource() == bw)
+          atts.add(Chromaticity.MONOCHROME);        
+        else
+          atts.add(Chromaticity.COLOR);
+      }
+    
+      /**
+       * Called to update for new selected
+       * print service. Tests if currently
+       * selected attributes are supported.
+       */
+      void updateForSelectedService()
+      {
+        if (categorySupported(Chromaticity.class))
+          {
+            bw.setEnabled(true);
+            color.setEnabled(true);           
+            
+            Object defaultValue = defaultValue(Chromaticity.class);           
+            Attribute chromaticity = attribute(Chromaticity.class);
+            if (chromaticity != null)
+              {
+                if (chromaticity.equals(Chromaticity.MONOCHROME))
+                  bw.setSelected(true);
+                else 
+                  color.setSelected(true);
+              }
+            else
+              {
+                if (defaultValue.equals(Chromaticity.MONOCHROME))
+                  bw.setSelected(true);
+                else               
+                  color.setSelected(true);
+              }
+          }
+        else
+          {           
+            bw.setEnabled(false);
+            color.setEnabled(false);
+          }
+      }
+    }
+  
+    private Quality quality_panel;
+    private JobAttributes jobAttr_panel;
+    private SidesPanel sides_panel;
+    private Color chromaticy_panel;
+  
+    /**
+     * Creates the panel for appearance attributes.
+     */
+    public AppearancePanel()
+    {
+      setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+  
+      quality_panel = new Quality();
+      jobAttr_panel = new JobAttributes();
+      sides_panel = new SidesPanel();
+      chromaticy_panel = new Color();
+  
+      JPanel layout_panel = new JPanel();
+      layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS));
+      layout_panel.add(chromaticy_panel);
+      layout_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+      layout_panel.add(quality_panel);
+  
+      JPanel layout2_panel = new JPanel();
+      layout2_panel.setLayout(new BoxLayout(layout2_panel, BoxLayout.LINE_AXIS));
+      layout2_panel.add(sides_panel);
+      layout2_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+      layout2_panel.add(jobAttr_panel);
+  
+      setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+      add(layout_panel);
+      add(Box.createRigidArea(new Dimension(0, 12)));
+      add(layout2_panel);
+    }
+    
+    /**
+     * Calls update on all internal panels to adjust
+     * for a new selected print service.
+     */
+    void update()
+    {
+      quality_panel.updateForSelectedService();
+      jobAttr_panel.updateForSelectedService();
+      sides_panel.updateForSelectedService();
+      chromaticy_panel.updateForSelectedService();
+    }
+  }
+
+  // on main contentpane
+  private JButton ok_bt;
+  private JButton cancel_bt;
+
+  // the tabs
+  private GeneralPanel general_panel;
+  private PageSetupPanel pagesetup_panel;
+  private AppearancePanel appearance_panel;
+  
+  private PrintService[] services;
+  private PrintService defaultService;
+  private PrintService selectedService;
+  private DocFlavor flavor;
+  private PrintRequestAttributeSet attributes;
+  
+  private boolean onlyPageDialog;  
+  private PrintRequestAttributeSet atts; 
+  
+  private final static ResourceBundle messages;
+
+  static
+  {    
+    messages = ResourceBundle.getBundle("gnu/javax/print/PrinterDialog");
+  }
+  
+  // TODO LowPriority: Include checks so that if a specific value formerly
+  // selected is no more supported by the new service changes to the default.
+  
+  /**
+   * Class private constructs a printer dialog.
+   * 
+   * @param gc the screen to use. <code>null</code> is default screen.
+   * @param services the print services to browse (not null).
+   * @param defaultService the default service. If <code>null</code>
+   * the first of the print services in the services array will be used.
+   * @param flavor the flavours to be printed.
+   * @param attributes the attributes requested. Will be updated 
+   * by selections done by the user in the dialog.
+   * @param onlyPageDialog if true a page settings only dialog is constructed.
+   * 
+   * @throws HeadlessException if GraphicsEnvironment is headless
+   */
+  private PrinterDialog(GraphicsConfiguration gc, PrintService[] services, 
+    PrintService defaultService, DocFlavor flavor, 
+    PrintRequestAttributeSet attributes, boolean onlyPageDialog, String title)
+    throws HeadlessException
+  {
+    super((Frame)null, title, true, gc);
+       
+    setResizable(false);
+    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+
+    // check and remove service not supporting the flavor
+    if (flavor != null)
+      {
+        ArrayList list = new ArrayList(services.length);
+        for(int i=0; i < services.length; i++)
+          if (services[i].isDocFlavorSupported(flavor))
+            list.add(services[i]);
+        
+        if (defaultService != null
+            && (! list.contains(defaultService)))
+          defaultService = (PrintService) list.get(0);
+        
+        PrintService[] newServices = new PrintService[list.size()];
+        this.services = (PrintService[]) list.toArray(newServices);
+      }
+    else
+      this.services = services;
+    
+    if (defaultService == null)
+      this.defaultService = services[0];
+    else
+      this.defaultService = defaultService;
+    
+    this.selectedService = this.defaultService;
+    this.flavor = flavor;
+    
+    // the attributes given by the user
+    this.attributes = attributes;
+    // the one to work with during browsing
+    this.atts = new HashPrintRequestAttributeSet(attributes);
+    
+    this.onlyPageDialog = onlyPageDialog;
+    
+    initUI(onlyPageDialog);    
+    pack();
+    updateAll();
+  }
+  
+  /**
+   * Constructs a page settings only dialog.
+   * 
+   * @param gc the screen to use. <code>null</code> is default screen.
+   * @param service the print service for the page dialog.
+   * the first of the print services in the services array will be used.
+   * @param flavor the flavours to be printed.
+   * @param attributes the attributes requested. Will be updated 
+   * by selections done by the user in the dialog. 
+   * 
+   * @throws HeadlessException if GraphicsEnvironment is headless
+   */
+  public PrinterDialog(GraphicsConfiguration gc, PrintService service, 
+    DocFlavor flavor, PrintRequestAttributeSet attributes)
+    throws HeadlessException
+  {
+    this(gc, new PrintService[] {service}, service, flavor, attributes, 
+         true, getLocalizedString("title.pagedialog"));  
+  }
+  
+  /**
+   * Constructs a printer dialog.
+   * 
+   * @param gc the screen to use. <code>null</code> is default screen.
+   * @param services the print services to browse (not null).
+   * @param defaultService the default service. If <code>null</code>
+   * the first of the print services in the services array will be used.
+   * @param flavor the flavours to be printed.
+   * @param attributes the attributes requested. Will be updated 
+   * by selections done by the user in the dialog. 
+   * 
+   * @throws HeadlessException if GraphicsEnvironment is headless
+   */
+  public PrinterDialog(GraphicsConfiguration gc, PrintService[] services, 
+    PrintService defaultService, DocFlavor flavor, 
+    PrintRequestAttributeSet attributes)
+    throws HeadlessException
+  {
+    this(gc, services, defaultService, flavor, attributes, 
+         false, getLocalizedString("title.printdialog"));
+  }
+
+  // initializes the gui parts
+  private void initUI(boolean onlyPageDialog)
+  { 
+    JPanel buttonPane = new JPanel();
+    
+    if (onlyPageDialog)
+      {
+        JPanel pane = new JPanel();
+        pane.setLayout(new BorderLayout());
+        pagesetup_panel = new PageSetupPanel();
+        pane.add(pagesetup_panel, BorderLayout.CENTER);
+            
+        ok_bt = new JButton(getLocalizedString("bt.OK"));
+        ok_bt.addActionListener(this);
+        cancel_bt = new JButton(getLocalizedString("bt.cancel"));
+        cancel_bt.addActionListener(this);     
+        
+        getContentPane().add(pane, BorderLayout.CENTER);        
+      }
+    else
+      {
+        general_panel = new GeneralPanel();
+        pagesetup_panel = new PageSetupPanel();
+        appearance_panel = new AppearancePanel();
+
+        JTabbedPane pane = new JTabbedPane();
+        pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+        ok_bt = new JButton(getLocalizedString("bt.print"));
+        ok_bt.addActionListener(this);
+        cancel_bt = new JButton(getLocalizedString("bt.cancel"));
+        cancel_bt.addActionListener(this);
+
+        // populate jtabbedpane
+        pane.addTab(getLocalizedString("tab.general"), general_panel);
+        pane.addTab(getLocalizedString("tab.pagesetup"), pagesetup_panel);
+        pane.addTab(getLocalizedString("tab.appearance"), appearance_panel);
+
+        // Put everything together
+        getContentPane().add(pane, BorderLayout.CENTER);
+      }
+    
+    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
+    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+    buttonPane.add(Box.createHorizontalGlue());
+    buttonPane.add(ok_bt);
+    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
+    buttonPane.add(cancel_bt);
+    
+    getContentPane().add(buttonPane, BorderLayout.PAGE_END);
+  }
+
+  /**
+   * Returns the modified attributes set.
+   * @return The attributes.
+   */
+  public PrintRequestAttributeSet getAttributes()
+  {
+    return attributes;
+  }
+
+  /**
+   * Returns the print service selected by the user.
+   * @return The selected print service.
+   */
+  public PrintService getSelectedPrintService()
+  {
+    return selectedService;
+  }
+  
+  /**
+   * Sets the currently selected print service.
+   * 
+   * @param service the service selected.
+   */
+  protected void setSelectedPrintService(PrintService service)
+  {
+    selectedService = service;
+  }
+  
+  /**
+   * Returns the print service array.
+   * @return The print services.
+   */
+  protected PrintService[] getPrintServices()
+  {
+    return services;
+  }
+  
+  /**
+   * Calls update on all panels to adjust
+   * for a new selected print service.
+   */
+  void updateAll()
+  {
+    pagesetup_panel.update();
+    
+    if (! onlyPageDialog)
+      {
+        general_panel.update();
+        appearance_panel.update();
+      }   
+  }
+  
+  boolean categorySupported(Class category)
+  {
+    return getSelectedPrintService().
+      isAttributeCategorySupported(category);
+  }
+  
+  Object defaultValue(Class category)
+  {
+    return getSelectedPrintService().
+      getDefaultAttributeValue(category);
+  }
+  
+  Attribute attribute(Class category)
+  {
+    return atts.get(category);
+  }
+  
+  /** 
+   *  Action handler for Print/Cancel buttons.
+   *  If cancel is pressed we reset the attributes
+   *  and the selected service.
+   *  
+   *  @param e the ActionEvent
+   */
+  public void actionPerformed(ActionEvent e)
+  {
+    if (e.getSource() == ok_bt)
+      {
+        setVisible(false);       
+        attributes.addAll(atts);
+        dispose();
+      }
+    else
+      {
+        setVisible(false);     
+        selectedService = null;
+        dispose();
+      }
+  }
+  
+  /**
+   * Retrieves localized messages from the resource bundle.
+   * 
+   * @param key the key
+   * @return The localized value for the key.
+   */
+  static final String getLocalizedString(String key) {
+    return messages.getString(key);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,471 @@
+/* DocPrintJobImpl.java -- Implementation of DocPrintJob.
+   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 gnu.javax.print.ipp;
+
+import gnu.javax.print.PrintFlavorException;
+import gnu.javax.print.ipp.attribute.job.JobId;
+import gnu.javax.print.ipp.attribute.job.JobUri;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+import gnu.javax.print.ipp.attribute.supported.OperationsSupported;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.print.CancelablePrintJob;
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.attribute.AttributeSetUtilities;
+import javax.print.attribute.DocAttributeSet;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.HashPrintJobAttributeSet;
+import javax.print.attribute.PrintJobAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.PrinterURI;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.event.PrintJobAttributeListener;
+import javax.print.event.PrintJobEvent;
+import javax.print.event.PrintJobListener;
+
+/**
+ * Implementation of the DocPrintJob interface. Implementation is 
+ * specific to the <code>IppPrintService</code> implementation.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class DocPrintJobImpl implements CancelablePrintJob
+{
+  /** The print service this job is bound to. */
+  private IppPrintService service;
+  
+  /** The set of print job listeners. */
+  private HashSet printJobListener = new HashSet();
+  
+  /** The print job attributes listeners. */
+  private ArrayList attributesListener = new ArrayList();
+  /** The print job attributes listeners associated attribute set. */
+  private ArrayList attributesListenerAttributes = new ArrayList();
+  
+  /** The username. */
+  private String username;
+  /** The password of the user. */
+  private String password;
+  
+  /** Returned job uri. */
+  private JobUri jobUri = null;
+  /** Returned job id. */
+  private JobId jobId = null;
+  
+  /** The requesting-username for later canceling */
+  private RequestingUserName requestingUser;
+  
+  /** The print job sets. */
+  private PrintJobAttributeSet oldSet = new HashPrintJobAttributeSet();
+  private PrintJobAttributeSet currentSet = new HashPrintJobAttributeSet();
+  
+  /** 
+   * State variable if we already started printing.
+   */
+  private boolean printing = false;
+ 
+  // TODO Implement complete PrintJobListener notification
+  // TODO Implement PrintJobAttributeListener notification
+
+  /**
+   * Constructs a DocPrintJobImpl instance bound to the given print service.
+   * 
+   * @param service the print service instance.
+   * @param user the user of this print service.
+   * @param passwd the password of the user.
+   */
+  public DocPrintJobImpl(IppPrintService service, String user, String passwd)
+  {
+    this.service = service;
+    username = user;
+    password = passwd;
+  }
+
+  /**
+   * @see DocPrintJob#addPrintJobAttributeListener(PrintJobAttributeListener, PrintJobAttributeSet)
+   */
+  public void addPrintJobAttributeListener(PrintJobAttributeListener listener,
+      PrintJobAttributeSet attributes)
+  {
+    if (listener == null)
+      return;
+    
+    attributesListener.add(listener);
+    attributesListenerAttributes.add(attributes);
+  }
+
+  /**
+   * @see DocPrintJob#addPrintJobListener(PrintJobListener)
+   */
+  public void addPrintJobListener(PrintJobListener listener)
+  {
+    if (listener == null)
+      return;
+    
+    printJobListener.add(listener);
+  }
+
+  /**
+   * @see javax.print.DocPrintJob#getAttributes()
+   */
+  public PrintJobAttributeSet getAttributes()
+  {
+    return AttributeSetUtilities.unmodifiableView(currentSet);
+  }
+
+  /**
+   * @see javax.print.DocPrintJob#getPrintService()
+   */
+  public PrintService getPrintService()
+  {
+    return service;
+  }
+
+  /**
+   * @see DocPrintJob#print(Doc, PrintRequestAttributeSet)
+   */
+  public void print(Doc doc, PrintRequestAttributeSet attributes)
+      throws PrintException
+  {
+    if (printing)
+      throw new PrintException("already printing");
+    
+    printing = true;
+    
+    DocAttributeSet docAtts = doc.getAttributes();
+    DocFlavor flavor = doc.getDocFlavor();
+    
+    if (flavor == null || (!service.isDocFlavorSupported(flavor)))
+      {
+        notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+        throw new PrintFlavorException("Invalid flavor", new DocFlavor[] {flavor});
+      }
+            
+    // merge attributes as doc attributes take precendence 
+    // over the print request attributes
+    HashAttributeSet mergedAtts = new HashAttributeSet();
+    
+    if (attributes != null)
+      mergedAtts.addAll(attributes);
+    if (docAtts != null)
+      mergedAtts.addAll(docAtts);
+    
+    // check for requesting-user-name -add the
+    // executing username if no other is specified
+    // save user name so we can make a cancel operation under same user    
+    if (! mergedAtts.containsKey(RequestingUserName.class))
+      {
+        mergedAtts.add(IppPrintService.REQUESTING_USER_NAME);
+        requestingUser = IppPrintService.REQUESTING_USER_NAME;
+      }
+    else
+      {
+        requestingUser = (RequestingUserName) 
+          mergedAtts.get(RequestingUserName.class);
+      }
+    
+    // same for job-name
+    if (! mergedAtts.containsKey(JobName.class))
+      mergedAtts.add(IppPrintService.JOB_NAME);
+          
+    IppResponse response = null;
+    
+    try
+      {
+        PrinterURI printerUri = service.getPrinterURI();
+        String printerUriStr = "http" + printerUri.toString().substring(3);
+     
+        URI uri = null;
+        try
+          {
+            uri = new URI(printerUriStr);
+          }
+        catch (URISyntaxException e) 
+          {
+            // does not happen 
+          }
+        
+        IppRequest request = 
+          new IppRequest(uri, username, password);   
+        
+        request.setOperationID( (short) OperationsSupported.PRINT_JOB.getValue());
+        request.setOperationAttributeDefaults();
+        request.addOperationAttribute(printerUri);
+        
+        if (mergedAtts != null)
+          {
+             request.addAndFilterJobOperationAttributes(mergedAtts);
+             request.addAndFilterJobTemplateAttributes(mergedAtts);
+          }        
+        
+        // DocFlavor getMimeType returns charset quoted
+        DocumentFormat format = DocumentFormat.createDocumentFormat(flavor);
+        request.addOperationAttribute(format);
+        
+        // Get and set the printdata based on the 
+        // representation classname
+        String className = flavor.getRepresentationClassName();    
+        
+        if (className.equals("[B")) 
+          {
+            request.setData((byte[]) doc.getPrintData());
+            response = request.send();
+          }
+        else if (className.equals("java.io.InputStream"))
+          {
+            InputStream stream = (InputStream) doc.getPrintData();
+            request.setData(stream);
+            response = request.send();
+            stream.close();
+          }
+        else if (className.equals("[C"))
+          {
+            try
+              {
+                // CUPS only supports UTF-8 currently so we convert
+                // We also assume that char[] is always utf-16 - correct ?                
+                String str = new String((char[]) doc.getPrintData());
+                request.setData(str.getBytes("utf-16"));
+                response = request.send();
+              }
+            catch (UnsupportedEncodingException e)
+              {
+                notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+                throw new PrintFlavorException("Invalid charset of flavor", e, new DocFlavor[] {flavor});
+              }
+          }          
+        else if (className.equals("java.io.Reader"))
+          {
+            try
+              {
+                // FIXME Implement
+                // Convert a Reader into a InputStream properly encoded
+                response = request.send();
+                throw new UnsupportedEncodingException("not supported yet");
+              }
+            catch (UnsupportedEncodingException e)
+              {
+                notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+                throw new PrintFlavorException("Invalid charset of flavor", e, new DocFlavor[] {flavor});
+              }
+          }  
+        else if (className.equals("java.lang.String"))
+          {
+            try
+              {
+                // CUPS only supports UTF-8 currently so we convert
+                // We also assume that String is always utf-16 - correct ?                
+                String str = (String) doc.getPrintData();
+                request.setData(str.getBytes("utf-16"));
+                response = request.send();
+              }
+            catch (UnsupportedEncodingException e)
+              {
+                notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+                throw new PrintFlavorException("Invalid charset of flavor", e, new DocFlavor[] {flavor});
+              }
+          }  
+        else if (className.equals("java.net.URL"))
+          {
+            URL url = (URL) doc.getPrintData();
+            InputStream stream = url.openStream();
+            request.setData(stream);
+            response = request.send();
+            stream.close();
+          }
+        else if (className.equals("java.awt.image.renderable.RenderableImage")
+                 || className.equals("java.awt.print.Printable")
+                 || className.equals("java.awt.print.Pageable"))
+          {
+            // For the future :-)
+            throw new PrintException("Not yet supported.");
+          }
+        else 
+          {
+            // should not happen - however
+            notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+            throw new PrintFlavorException("Invalid flavor", new DocFlavor[] {flavor});
+          }        
+        
+        // at this point the data is transfered
+        notifyPrintJobListeners(new PrintJobEvent(
+          this, PrintJobEvent.DATA_TRANSFER_COMPLETE));
+      }   
+    catch (IOException e)
+      {
+        throw new PrintException("IOException occured.", e);
+      } 
+      
+    int status = response.getStatusCode();
+    if (! (status == IppStatusCode.SUCCESSFUL_OK
+         || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+         || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+      {
+        notifyPrintJobListeners(new PrintJobEvent(
+          this, PrintJobEvent.JOB_FAILED));
+        throw new PrintException("Printing failed - received statuscode " + Integer.toHexString(status));
+        
+        // TODO maybe specific status codes may require to throw a specific
+        // detailed attribute exception
+      }
+    else
+      {
+        // start print job progress monitoring thread
+        // FIXME Implement
+        
+        // for now we just notify as finished
+        notifyPrintJobListeners(
+          new PrintJobEvent(this, PrintJobEvent.JOB_COMPLETE));
+      }
+            
+    List jobAtts = response.getJobAttributes();
+    
+    // extract the uri and id of job for canceling and further monitoring
+    Map jobAttributes = (Map) jobAtts.get(0);
+    jobUri = (JobUri) ((HashSet)jobAttributes.get(JobUri.class)).toArray()[0];
+    jobId = (JobId) ((HashSet)jobAttributes.get(JobId.class)).toArray()[0];   
+  }
+
+  /**
+   * @see DocPrintJob#removePrintJobAttributeListener(PrintJobAttributeListener)
+   */
+  public void removePrintJobAttributeListener(PrintJobAttributeListener listener)
+  {
+    if (listener == null)
+      return;
+    
+    int index = attributesListener.indexOf(listener);
+    if (index != -1)
+      {
+        attributesListener.remove(index);
+        attributesListenerAttributes.remove(index);
+      }
+  }
+
+  /**
+   * @see DocPrintJob#removePrintJobListener(PrintJobListener)
+   */
+  public void removePrintJobListener(PrintJobListener listener)
+  {
+    if (listener == null)
+      return;
+    
+    printJobListener.remove(listener);
+  }
+ 
+  /**
+   * @see CancelablePrintJob#cancel()
+   */
+  public void cancel() throws PrintException
+  {
+    if (jobUri == null)
+      {
+        throw new PrintException("print job is not yet send");
+      }
+    
+    IppResponse response = null;
+    
+    try
+      {
+        IppRequest request = new IppRequest(jobUri.getURI(), username, password);   
+        request.setOperationID( (short) OperationsSupported.CANCEL_JOB.getValue());
+        request.setOperationAttributeDefaults();
+        request.addOperationAttribute(jobUri);
+        request.addOperationAttribute(requestingUser);
+        response = request.send();        
+      }   
+    catch (IOException e)
+      { 
+        throw new IppException("IOException occured during cancel request.", e);
+      } 
+    
+    int status = response.getStatusCode();
+    if (! (status == IppStatusCode.SUCCESSFUL_OK
+         || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+         || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+      {
+        notifyPrintJobListeners(new PrintJobEvent(
+          this, PrintJobEvent.JOB_FAILED));
+        throw new PrintException("Canceling failed - received statuscode " + Integer.toHexString(status));        
+      }
+    else 
+      {
+        notifyPrintJobListeners(new PrintJobEvent(
+          this, PrintJobEvent.JOB_CANCELED));
+      }
+  }
+  
+  private void notifyPrintJobListeners(PrintJobEvent e)
+  {
+    Iterator it = printJobListener.iterator();
+    while (it.hasNext())
+      {
+        PrintJobListener l = (PrintJobListener) it.next();
+        if (e.getPrintEventType() == PrintJobEvent.DATA_TRANSFER_COMPLETE)
+          l.printDataTransferCompleted(e);
+        else if (e.getPrintEventType() == PrintJobEvent.JOB_CANCELED)
+          l.printJobCanceled(e);
+        else if (e.getPrintEventType() == PrintJobEvent.JOB_COMPLETE)
+          l.printJobCompleted(e);
+        else if (e.getPrintEventType() == PrintJobEvent.JOB_FAILED)
+          l.printJobFailed(e);
+        else if (e.getPrintEventType() == PrintJobEvent.NO_MORE_EVENTS)
+          l.printJobNoMoreEvents(e);
+        else 
+          l.printJobRequiresAttention(e);
+      }    
+  }
+  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* IppDelimiterTag.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 gnu.javax.print.ipp;
+
+
+/**
+ * IPP Delimiter Tags as described in RFC 2910 section 3.5.1.
+ * <p>
+ * Every delimiter tag value can occur in the protocol field 
+ * begin-attribute-group-tag and indicates that the following
+ * attributes will be part of the named group.<br>
+ * The end-of-attributes-tag signals the end of the attributes
+ * section in the IPP request/response and therefore the beginning
+ * of the data section (if any). 
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class IppDelimiterTag
+{
+  /** Start of the operation attributes group section. */
+  public static final byte OPERATION_ATTRIBUTES_TAG = 0x01;
+  
+  /** Start of the job attributes group section. */
+  public static final byte JOB_ATTRIBUTES_TAG = 0x02;
+  
+  /** End of the attributes section and begin of data section. */
+  public static final byte END_OF_ATTRIBUTES_TAG = 0x03;
+  
+  /** Start of the printer attributes group section. */
+  public static final byte PRINTER_ATTRIBUTES_TAG = 0x04;
+  
+  /** Start of the unsupported attributes group section. */
+  public static final byte UNSUPPORTED_ATTRIBUTES_TAG = 0x05;
+  
+    
+  // 0x00 reserved for definition in a future IETF
+  // standards track document
+  
+  // 0x06-0x0f reserved for future delimiters in IETF
+  // standards track documents
+    
+  private IppDelimiterTag()
+  {
+    // not to be instantiated
+  }
+    
+  /**
+   * Tests if given value corresponds to a 
+   * delimiter tag value.
+   * 
+   * @param value the value to test for
+   * @return <code>true</code> if, <code>false</code> otherwise.
+   */
+  public static boolean isDelimiterTag(byte value) 
+  {
+    if (value >= 0x01 && value <= 0x05)
+      return true;
+    
+    return false;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* IppException.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 gnu.javax.print.ipp;
+
+import javax.print.PrintException;
+
+/**
+ * <code>IppException</code> signals exception thrown by
+ * the IPP implementation for various things like a failed
+ * ipp request or a wrapped io exception.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class IppException extends PrintException
+{
+  /**
+   * Creates an <code>IppException</code>.
+   */
+  public IppException()
+  {
+    super();
+  }
+
+  /**
+   * Creates an <code>IppException</code>.
+   * @param s the message of the exception.
+   */
+  public IppException(String s)
+  {
+    super(s);
+  }
+  
+  /**
+   * Creates an <code>IppException</code>.
+   * @param e the exception cause this one.
+   */
+  public IppException(Exception e)
+  {
+    super(e);
+  }
+
+  /**
+   * Creates an <code>IppException</code>.
+   * @param s the message of the exception.
+   * @param e the exception cause this one.
+   */
+  public IppException(String s, Exception e)
+  {
+    super(s, e);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* IppMultiDocPrintService.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 gnu.javax.print.ipp;
+
+
+import java.net.URI;
+
+import javax.print.MultiDocPrintJob;
+import javax.print.MultiDocPrintService;
+
+/**
+ * Implementation of the MultiDocPrintService interface
+ * for IPP based printers.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class IppMultiDocPrintService extends IppPrintService 
+  implements MultiDocPrintService
+{
+  /** The username. */
+  private transient String user;
+  
+  /** The password of the user. */
+  private transient String passwd;
+
+  /**
+   * Creates a <code>IppMultiDocPrintService</code> object.
+   * 
+   * @param uri the URI of the IPP printer.
+   * @param username the user of this print service.
+   * @param password the password of the user.
+   * 
+   * @throws IppException if an error during connection occurs.
+   */
+  public IppMultiDocPrintService(URI uri, String username, String password)
+    throws IppException
+  {
+    super(uri, username, password);
+    user = username;
+    passwd = password;
+  }  
+
+  /**
+   * @see MultiDocPrintService#createMultiDocPrintJob()
+   */
+  public MultiDocPrintJob createMultiDocPrintJob() 
+  {
+    return new MultiDocPrintJobImpl(this, user, passwd);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,916 @@
+/* IppPrintService.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 gnu.javax.print.ipp;
+
+import gnu.classpath.SystemProperties;
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+import gnu.javax.print.ipp.attribute.RequestedAttributes;
+import gnu.javax.print.ipp.attribute.defaults.CopiesDefault;
+import gnu.javax.print.ipp.attribute.defaults.FinishingsDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobHoldUntilDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobPriorityDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+import gnu.javax.print.ipp.attribute.defaults.MediaDefault;
+import gnu.javax.print.ipp.attribute.defaults.MultipleDocumentHandlingDefault;
+import gnu.javax.print.ipp.attribute.defaults.NumberUpDefault;
+import gnu.javax.print.ipp.attribute.defaults.OrientationRequestedDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrintQualityDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrinterResolutionDefault;
+import gnu.javax.print.ipp.attribute.defaults.SidesDefault;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+import gnu.javax.print.ipp.attribute.supported.CompressionSupported;
+import gnu.javax.print.ipp.attribute.supported.DocumentFormatSupported;
+import gnu.javax.print.ipp.attribute.supported.FinishingsSupported;
+import gnu.javax.print.ipp.attribute.supported.JobHoldUntilSupported;
+import gnu.javax.print.ipp.attribute.supported.JobSheetsSupported;
+import gnu.javax.print.ipp.attribute.supported.MediaSupported;
+import gnu.javax.print.ipp.attribute.supported.MultipleDocumentHandlingSupported;
+import gnu.javax.print.ipp.attribute.supported.OperationsSupported;
+import gnu.javax.print.ipp.attribute.supported.OrientationRequestedSupported;
+import gnu.javax.print.ipp.attribute.supported.PageRangesSupported;
+import gnu.javax.print.ipp.attribute.supported.PrintQualitySupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterResolutionSupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterUriSupported;
+import gnu.javax.print.ipp.attribute.supported.SidesSupported;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintService;
+import javax.print.ServiceUIFactory;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.AttributeSetUtilities;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.Compression;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.Fidelity;
+import javax.print.attribute.standard.Finishings;
+import javax.print.attribute.standard.JobHoldUntil;
+import javax.print.attribute.standard.JobImpressions;
+import javax.print.attribute.standard.JobImpressionsSupported;
+import javax.print.attribute.standard.JobKOctets;
+import javax.print.attribute.standard.JobKOctetsSupported;
+import javax.print.attribute.standard.JobMediaSheets;
+import javax.print.attribute.standard.JobMediaSheetsSupported;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobPrioritySupported;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+import javax.print.attribute.standard.NumberUp;
+import javax.print.attribute.standard.NumberUpSupported;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterURI;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.Sides;
+import javax.print.event.PrintServiceAttributeListener;
+
+
+/**
+ * Implementation of the PrintService interface
+ * for IPP based printers.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class IppPrintService implements PrintService
+{
+  /** 
+   * A Map with sets of attributes.
+   * key: A attribute category
+   * value: A set with values
+   * 
+   * IPP may return sets of attributes e.g. for supported
+   * compression methods so we need to map to sets here.
+   */
+  private Map printerAttr;
+    
+  /** The set of listeners.*/
+  private HashSet printServiceAttributeListener;
+  
+  /** The username. */
+  private transient String user;
+  
+  /** The password of the user. */
+  private transient String passwd;
+  
+  /** The name of this print service. */
+  private String name;
+  
+  /** The list of supported document flavors. */
+  private List flavors;
+  
+  /** The standard printer URI. */
+  private PrinterURI printerUri;
+  
+  /** The list of all supported printer URIs. */
+  private ArrayList printerUris;
+    
+  /**
+   * Logger for tracing - enable by passing
+   * -Dgnu.classpath.debug.components=ipp to the vm.
+   */
+  static final Logger logger = SystemLogger.SYSTEM;
+  
+  /** 
+   * requesting-user-name defaults to the executing user.
+   */
+  public static final RequestingUserName REQUESTING_USER_NAME;
+  
+  /** 
+   * job-name defaults to "Java Printing".
+   */
+  public static final JobName JOB_NAME;
+  
+  static
+  {
+    JOB_NAME = new JobName("Java Printing", null);
+    REQUESTING_USER_NAME = new RequestingUserName(
+      SystemProperties.getProperty("user.name", ""), null);    
+  }
+  
+  // TODO Implement service listener notification and change detection.
+  
+  /**
+   * Creates a <code>IppPrintService</code> object.
+   * 
+   * @param uri the URI of the IPP printer.
+   * @param username the user of this print service.
+   * @param password the password of the user.
+   * 
+   * @throws IppException if an error during connection occurs.
+   */
+  public IppPrintService(URI uri, String username, String password) 
+    throws IppException
+  {
+    printerUri = new PrinterURI(uri);
+    user = username;
+    passwd = password;
+    
+    printServiceAttributeListener = new HashSet();
+        
+    printerAttr = getPrinterAttributes();
+    processResponse();
+  }
+  
+  /**
+   * Fetches all printer attributes from the IPP printer.
+   * 
+   * @return The Map with the printer attributes.
+   * @throws IppException if an error occurs.
+   */
+  private Map getPrinterAttributes() throws IppException
+  {
+    IppResponse response = null;
+    
+    try
+      {
+        IppRequest request = new IppRequest(printerUri.getURI(), user, passwd);    
+        
+        int operation = OperationsSupported.GET_PRINTER_ATTRIBUTES.getValue();
+        request.setOperationID((short) operation);        
+        request.setOperationAttributeDefaults();  
+        request.addOperationAttribute(printerUri);
+        
+        response = request.send();
+      }   
+    catch (IOException e)
+      {
+        throw new IppException("IOException in IPP request/response.", e);
+      }   
+     
+    return (Map) response.getPrinterAttributes().get(0);   
+  }
+  
+  /**
+   * Extracts the set of attribute values for a given 
+   * attribute category from the printer attributes map.
+   * 
+   * @param attributeClass the category
+   * @return The set of attributes of the category.
+   */
+  private Set getPrinterAttributeSet(Class attributeClass)
+  {
+    return (Set) printerAttr.get(attributeClass);
+  }
+  
+  /**
+   * Extracts the default attribute value for the given 
+   * default attribute category from the printer attributes map.
+   * 
+   * @param attributeClass the category
+   * @return The default attribute.
+   * 
+   * @throws ClassCastException if attributClass is not an
+   * instance of <code>DefaultValueAttribute</code>.
+   */
+  private Attribute getPrinterDefaultAttribute(Class attributeClass)
+  {
+    Set set = (Set) printerAttr.get(attributeClass);
+    return ((DefaultValueAttribute) set.toArray()[0]).getAssociatedAttribute();
+  }
+  
+  /**
+   * Processes the response, sorts and splits the attributes.
+   */
+  private void processResponse()
+  {
+    // printer name
+    PrinterName[] tmp = (PrinterName[]) getPrinterAttributeSet(
+                         PrinterName.class).toArray(new PrinterName[1]);
+    name = tmp[0].getValue();
+    
+    // supported flavors
+    // TODO Check if charsets-supported are charsets that are actually supported
+    // for text doc flavors as cups doesn't send charset parameters
+    
+    // utf-8 is supported at least - so we go with this only for now
+    flavors = new ArrayList();
+    Set flavorAttributes = getPrinterAttributeSet(DocumentFormatSupported.class);
+    if (flavorAttributes != null)
+      {
+        for (Iterator it = flavorAttributes.iterator(); it.hasNext();)
+          {
+            String mimeType = ((DocumentFormatSupported) it.next()).getValue();
+                        
+            if (mimeType.equals("text/plain"))
+              {
+                flavors.add(DocFlavor.CHAR_ARRAY.TEXT_PLAIN);
+                flavors.add(DocFlavor.READER.TEXT_PLAIN);
+                flavors.add(DocFlavor.STRING.TEXT_PLAIN);
+                
+                // add utf-8
+                mimeType = mimeType + "; charset=utf-8";
+              }
+            else if (mimeType.equals("text/html"))
+              {
+                flavors.add(DocFlavor.CHAR_ARRAY.TEXT_HTML);
+                flavors.add(DocFlavor.READER.TEXT_HTML);
+                flavors.add(DocFlavor.STRING.TEXT_HTML);
+                
+                // add utf-8
+                mimeType = mimeType + "; charset=utf-8";
+              }
+            
+            // Process the predefined DocFlavors and if mimetype is
+            // equal put them into the flavors array - otherwise
+            // just build them as binarie class representation.
+            boolean changed = false;
+            try
+              {
+                Class[] clazzes = new Class[] { DocFlavor.BYTE_ARRAY.class,
+                                                DocFlavor.INPUT_STREAM.class,
+                                                DocFlavor.URL.class };                
+                 
+                for (int j = 0; j < clazzes.length; j++)
+                  {
+                    Field[] fields = clazzes[j].getDeclaredFields();
+                    for (int i = 0; i < fields.length; i++)
+                      {
+                        if (fields[i].getType().equals(clazzes[j]))
+                          {
+                            DocFlavor flavor = (DocFlavor) fields[i].get(null);
+                            if (flavor.getMimeType().equals(mimeType))
+                              changed = flavors.add(flavor);
+                          }
+                      }
+                  }
+                if (!changed) // not in predefined constants of DocFlavor
+                  {                    
+                    // everything should be supported as binary stuff
+                    flavors.add(new DocFlavor(mimeType, "[B"));
+                    flavors.add(new DocFlavor(mimeType, "java.io.InputStream"));
+                    flavors.add(new DocFlavor(mimeType, "java.net.URL"));
+                  }
+              }
+            catch (SecurityException e)
+              {
+                // should not happen
+              }
+            catch (IllegalArgumentException e)
+              {
+                // should not happen
+              }
+            catch (IllegalAccessException e)
+              {
+                // should not happen, all fields are public
+              }
+          }
+      }
+    
+    // printer uris
+    Set uris = getPrinterAttributeSet(PrinterUriSupported.class);
+    printerUris = new ArrayList(uris.size());
+    Iterator it = uris.iterator();
+    while (it.hasNext())
+      {
+        PrinterUriSupported uri = (PrinterUriSupported) it.next();
+        printerUris.add( new PrinterURI(uri.getURI()));
+      }
+  }
+
+  /**
+   * We always return a implementation implementing CancelablePrintJob.
+   * 
+   * @see javax.print.PrintService#createPrintJob()
+   */
+  public DocPrintJob createPrintJob()
+  {
+    return new DocPrintJobImpl(this, user, passwd);
+  }
+  
+
+  /**
+   * @see javax.print.PrintService#getAttribute(java.lang.Class)
+   */
+  public PrintServiceAttribute getAttribute(Class category)
+  {
+    if (category == null)
+      throw new NullPointerException("category may not be null");
+    
+    if (! PrintServiceAttribute.class.isAssignableFrom(category))
+      throw new IllegalArgumentException(
+         "category must be of type PrintServiceAttribute");
+    
+    Set set = getPrinterAttributeSet(category);
+    if (set != null && set.size() > 0)     
+        return (PrintServiceAttribute) set.toArray()[0];
+        
+    return null;
+  }
+
+  /**
+   * @see javax.print.PrintService#getAttributes()
+   */
+  public PrintServiceAttributeSet getAttributes()
+  {
+    PrintServiceAttributeSet set = new HashPrintServiceAttributeSet();
+    
+    Iterator it = printerAttr.values().iterator();
+    while (it.hasNext())
+      {        
+        Iterator it2 = ((Set) it.next()).iterator();
+        while (it2.hasNext())
+          {
+            Attribute attr = (Attribute) it2.next();
+            if (attr instanceof PrintServiceAttribute)
+              set.add(attr);
+          }
+      }
+    
+    return AttributeSetUtilities.unmodifiableView(set);
+  }
+
+  /**
+   * @see javax.print.PrintService#getDefaultAttributeValue(java.lang.Class)
+   */
+  public Object getDefaultAttributeValue(Class category)
+  { 
+    // required attributes
+    if (category.equals(Fidelity.class))
+      return Fidelity.FIDELITY_FALSE;    
+    if (category.equals(JobName.class))
+      return JOB_NAME;
+    if (category.equals(RequestingUserName.class))
+      return REQUESTING_USER_NAME;
+    
+    // optional attributes
+    if (category.equals(JobPriority.class) 
+        && printerAttr.containsKey(JobPriorityDefault.class))
+      return getPrinterDefaultAttribute(JobPriorityDefault.class);
+    if (category.equals(JobHoldUntil.class) 
+        && printerAttr.containsKey(JobHoldUntilDefault.class))
+      return getPrinterDefaultAttribute(JobHoldUntilDefault.class);
+    if (category.equals(JobSheets.class) 
+        && printerAttr.containsKey(JobSheetsDefault.class))
+      return getPrinterDefaultAttribute(JobSheetsDefault .class);
+    if (category.equals(MultipleDocumentHandling.class) 
+        && printerAttr.containsKey(MultipleDocumentHandlingDefault.class))
+      return getPrinterDefaultAttribute(MultipleDocumentHandlingDefault.class);
+    if (category.equals(Copies.class) 
+        && printerAttr.containsKey(CopiesDefault.class))
+      return getPrinterDefaultAttribute(CopiesDefault.class);
+    if (category.equals(Finishings.class) 
+        && printerAttr.containsKey(FinishingsDefault.class))
+      return getPrinterDefaultAttribute(FinishingsDefault.class);
+    if (category.equals(Sides.class) 
+        && printerAttr.containsKey(SidesDefault.class))
+      return getPrinterDefaultAttribute(SidesDefault.class);
+    if (category.equals(NumberUp.class) 
+        && printerAttr.containsKey(NumberUpDefault.class))
+      return getPrinterDefaultAttribute(NumberUpDefault.class);
+    if (category.equals(OrientationRequested.class) 
+        && printerAttr.containsKey(OrientationRequestedDefault.class))
+      return getPrinterDefaultAttribute(OrientationRequestedDefault.class);
+    if (category.equals(Media.class) 
+        && printerAttr.containsKey(MediaDefault.class))
+      return getPrinterDefaultAttribute(MediaDefault.class);
+    if (category.equals(PrinterResolution.class) 
+        && printerAttr.containsKey(PrinterResolutionDefault.class))
+      return getPrinterDefaultAttribute(PrinterResolutionDefault.class);
+    if (category.equals(PrintQuality.class) 
+        && printerAttr.containsKey(PrintQualityDefault.class))
+      return getPrinterDefaultAttribute(PrintQualityDefault.class);
+    if (category.equals(Compression.class) 
+        && printerAttr.containsKey(CompressionSupported.class))
+      return Compression.NONE;
+    if (category.equals(PageRanges.class))
+      return new PageRanges(1, Integer.MAX_VALUE);
+
+    return null; 
+  }
+  
+  /**
+   * We return the value of <code>PrinterName</code> here.
+   * @see javax.print.PrintService#getName()
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * We currently provide no factories - just returns null.
+   * @see javax.print.PrintService#getServiceUIFactory()
+   */
+  public ServiceUIFactory getServiceUIFactory()
+  {
+    // SUN does not provide any service factory for
+    // print services (tested on linux/windows)
+    
+    // for the moment we do the same - just return null
+    // later on we could provide at least the about UI dialog
+    return null;
+  }
+
+  /**
+   * @see javax.print.PrintService#getSupportedAttributeCategories()
+   */
+  public Class[] getSupportedAttributeCategories()
+  {
+    Set categories = new HashSet();
+    
+    // Should only be job template attributes as of section 4.2    
+    if (printerAttr.containsKey(JobPrioritySupported.class))
+      categories.add(JobPriority.class);
+    if (printerAttr.containsKey(JobHoldUntilSupported.class))
+      categories.add(JobHoldUntil.class);
+    if (printerAttr.containsKey(JobSheetsSupported.class))
+      categories.add(JobSheets.class);
+    if (printerAttr.containsKey(MultipleDocumentHandlingSupported.class))
+      categories.add(MultipleDocumentHandling.class);    
+    if (printerAttr.containsKey(CopiesSupported.class))
+      categories.add(Copies.class);
+    if (printerAttr.containsKey(FinishingsSupported.class))
+      {
+        // if only none finishing is supported - it does not count as supported
+        Set set = getPrinterAttributeSet(FinishingsSupported.class);        
+        if (! (set.size() == 1 && set.contains(FinishingsSupported.NONE)))          
+          categories.add(Finishings.class);
+      }
+    if (printerAttr.containsKey(PageRangesSupported.class))
+      categories.add(PageRanges.class);
+    if (printerAttr.containsKey(SidesSupported.class))
+      categories.add(Sides.class);
+    if (printerAttr.containsKey(NumberUpSupported.class))
+      categories.add(NumberUp.class);
+    if (printerAttr.containsKey(OrientationRequestedSupported.class))
+      categories.add(OrientationRequested.class);
+    if (printerAttr.containsKey(MediaSupported.class))
+      categories.add(Media.class);
+    if (printerAttr.containsKey(PrinterResolutionSupported.class))
+      categories.add(PrinterResolution.class);
+    if (printerAttr.containsKey(PrintQualitySupported.class))
+      categories.add(PrintQuality.class);
+      
+    // Chromaticity, Destination, MediaPrintableArea, 
+    // SheetCollate, PresentationDirection - not IPP attributes
+    
+    // attributes outside section 4.2   
+    if (printerAttr.containsKey(CompressionSupported.class))
+      categories.add(Compression.class);
+    if (printerAttr.containsKey(JobImpressionsSupported.class))
+      categories.add(JobImpressions.class);
+    if (printerAttr.containsKey(JobKOctetsSupported.class))
+      categories.add(JobKOctets.class);
+    if (printerAttr.containsKey(JobMediaSheetsSupported.class))
+      categories.add(JobMediaSheets.class);
+    
+    // always supported as required by IPP specification
+    categories.add(Fidelity.class);
+    categories.add(JobName.class);
+    categories.add(RequestingUserName.class);
+
+    return (Class[]) categories.toArray(new Class[categories.size()]);
+  }
+
+  /**
+   * Implemented by a GetPrinterAttributes request. Subclasses providing supported
+   * attribute values totally different may override this methods. Subclass only in
+   * need of handling the response differently may override the method
+   * <code>handleSupportedAttributeValuesResponse(IppResponse, Class)</code> only.
+   * 
+   * @see PrintService#getSupportedAttributeValues(Class, DocFlavor, AttributeSet)
+   * @see #handleSupportedAttributeValuesResponse(IppResponse, Class)
+   */
+  public Object getSupportedAttributeValues(Class category, DocFlavor flavor,
+                                            AttributeSet attributes)
+  {
+    // We currently ignore the attribute set - there is nothing in the IPP
+    // specification which would come closer to what we do here.
+
+    if (category == null)
+      throw new NullPointerException("category may not be null");
+
+    if (!Attribute.class.isAssignableFrom(category))
+      throw new IllegalArgumentException("category must be of type Attribute");
+
+    if (flavor != null && !isDocFlavorSupported(flavor))
+      throw new IllegalArgumentException("flavor is not supported");
+
+    if (!isAttributeCategorySupported(category))
+      return null;
+
+    // always supported
+    if (category.equals(Fidelity.class))
+      return new Fidelity[] { Fidelity.FIDELITY_FALSE, Fidelity.FIDELITY_TRUE };
+    if (category.equals(JobName.class))
+      return JOB_NAME;
+    if (category.equals(RequestingUserName.class))
+      return REQUESTING_USER_NAME;
+
+    // map category to category-supported
+    String categoryName = IppUtilities.getSupportedAttrName(category);
+
+    IppResponse response = null;
+    try
+      {
+        IppRequest request = new IppRequest(printerUri.getURI(), user, passwd);
+        request.setOperationID(
+          (short) OperationsSupported.GET_PRINTER_ATTRIBUTES.getValue());
+        request.setOperationAttributeDefaults();
+        request.addOperationAttribute(new RequestedAttributes(categoryName));
+        request.addOperationAttribute(printerUri);
+        
+        if (flavor != null)
+          {
+            DocumentFormat f = DocumentFormat.createDocumentFormat(flavor);
+            request.addOperationAttribute(f);
+          }
+
+        response = request.send();
+        
+        int status = response.getStatusCode();
+        if (! (status == IppStatusCode.SUCCESSFUL_OK
+             || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+             || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+          {
+            logger.log(Component.IPP, "Statuscode not OK - got:" + status);
+          }
+      }
+    catch (IOException e)
+      {
+        // method cannot throw exception - just log
+        logger.log(Component.IPP, "IOException", e);
+      }
+    catch (IppException e)
+      {
+        // method cannot throw exception - just log
+        logger.log(Component.IPP, "IPPException", e);
+      }
+    
+    return handleSupportedAttributeValuesResponse(response, category);
+  }
+  
+  /**
+   * Called to handle the supported attribute values response for the given
+   * category. This might be overridden by subclasses with different requirements
+   * for parsing/handling the response from the GetPrinterAttributes.
+   * 
+   * @param response the response of the GetPrinterAttributes IPP request
+   * @param category the category for which the supported values are requested
+   * @return A object indicating the supported values for the given attribute 
+   * category, or <code>null</code> if this print service doesn't support the 
+   * given attribute category at all.
+   * 
+   * @see #getSupportedAttributeValues(Class, DocFlavor, AttributeSet)
+   */
+  protected Object handleSupportedAttributeValuesResponse(IppResponse response, 
+    Class category)
+  {
+    List printerAtts = response.getPrinterAttributes();
+   
+    // only one will be returned
+    Map printerAttribute = (Map) printerAtts.get(0);
+    Class suppCategory = IppUtilities.getSupportedCategory(category);
+    Set attr = (Set) printerAttribute.get(suppCategory);
+    
+    // We sometime assume its a single instance with arbritrary value just indicating 
+    // support or an array which is returned. This is because I sometimes just choosed
+    // what sounds right to me - as I have yet to find a printer which supports every 
+    // special category in the SUN implementation to see what they return :-)
+    
+    //  Map whats in the JSP API
+    if (suppCategory.equals(JobPrioritySupported.class))
+      return (JobPrioritySupported) attr.toArray(new JobPrioritySupported[1])[0];
+    if (suppCategory.equals(JobHoldUntilSupported.class))
+      return new JobHoldUntil(new Date());
+    if (suppCategory.equals(JobSheetsSupported.class))
+      return JobSheetsSupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(MultipleDocumentHandlingSupported.class))
+      return MultipleDocumentHandlingSupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(CopiesSupported.class))
+      return (CopiesSupported) attr.toArray(new CopiesSupported[1])[0];
+    if (suppCategory.equals(FinishingsSupported.class))
+      return FinishingsSupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(PageRangesSupported.class))
+      return new PageRanges[] { new PageRanges(1, Integer.MAX_VALUE) };    
+    if (suppCategory.equals(OrientationRequestedSupported.class))
+      return OrientationRequestedSupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(MediaSupported.class))
+      return MediaSupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(PrinterResolutionSupported.class))
+      return PrinterResolutionSupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(PrintQualitySupported.class))
+      return PrintQualitySupported.getAssociatedAttributeArray(attr);
+    if (suppCategory.equals(CompressionSupported.class))
+      return CompressionSupported.getAssociatedAttributeArray(attr);
+    // Special handling as it might also be in range of integers
+    if (suppCategory.equals(NumberUpSupported.class))
+      {
+        NumberUpSupported[] tmp = (NumberUpSupported[]) 
+          attr.toArray(new NumberUpSupported[attr.size()]);
+
+        if (attr.size() == 1) // number-up maybe in rangeofintegers
+          return tmp[0];
+
+        int[][] members = new int[attr.size()][2];
+        for (int j = 0; j < attr.size(); j++)
+          {
+            int value = tmp[j].getMembers()[0][0];
+            members[j] = new int[] { value, value };
+          }
+
+        NumberUpSupported supported = new NumberUpSupported(members);
+        return supported;
+      }
+        
+    return null;
+  }  
+  
+  /**
+   * @see javax.print.PrintService#getSupportedDocFlavors()
+   */
+  public DocFlavor[] getSupportedDocFlavors()
+  {
+    return (DocFlavor[]) flavors.toArray(new DocFlavor[flavors.size()]);
+  }
+
+  /**
+   * This is done by a validate-job operation and actually implemented in 
+   * this generic IPP reference implementation. Subclasses which does
+   * not correctly support Validate-Job operation might want to override this.
+   *
+   * @see PrintService#getUnsupportedAttributes(DocFlavor, AttributeSet)
+   */
+  public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
+                                               AttributeSet attributes)
+  {    
+    if (flavor != null && !isDocFlavorSupported(flavor))
+      throw new IllegalArgumentException("flavor is not supported");
+
+    IppResponse response = null;
+    try
+      {
+        IppRequest request = new IppRequest(printerUri.getURI(), user, passwd);
+        short operationId = (short) OperationsSupported.VALIDATE_JOB.getValue();
+        request.setOperationID(operationId);
+        request.setOperationAttributeDefaults();
+        request.addOperationAttribute(printerUri);
+        request.addOperationAttribute(Fidelity.FIDELITY_TRUE);
+        
+        if (attributes != null && attributes.size() > 0)
+          {
+            request.addAndFilterJobOperationAttributes(attributes);
+            request.addAndFilterJobTemplateAttributes(attributes);
+          }
+        
+        if (flavor != null)
+          {
+            DocumentFormat f = DocumentFormat.createDocumentFormat(flavor);
+            request.addOperationAttribute(f);
+          }
+        
+        response = request.send();
+        
+        int status = response.getStatusCode();
+        if (! (status == IppStatusCode.SUCCESSFUL_OK
+             || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+             || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+          {
+            logger.log(Component.IPP, "Statuscode not OK - got:" + status);
+          }
+      }
+    catch (IOException e)
+      {
+        // method cannot throw exception - just log
+        logger.log(Component.IPP, "IOException", e);
+      }
+    catch (IppException e)
+      {
+        // method cannot throw exception - just log
+        logger.log(Component.IPP, "IPPException", e);
+      }
+
+    // Validate Jobs returns only Unsupported and Operation  
+    List unsupportedMaps = response.getUnsupportedAttributes();    
+    if (unsupportedMaps.size() == 0)
+      return  null;
+    
+    Map unsupportedAttr = (Map) unsupportedMaps.get(0);
+    if (unsupportedAttr.size() == 0)
+      return null;
+    
+    // Convert the return map with unsupported attributes 
+    // into an AttribueSet instance
+    HashAttributeSet set = new HashAttributeSet();
+    Iterator it = unsupportedAttr.values().iterator();
+    while (it.hasNext())
+      {
+        Set unsupported = (Set) it.next();
+        Iterator it2 = unsupported.iterator();
+        while (it2.hasNext())
+          set.add((Attribute) it2.next());        
+      }
+    
+    return set;
+  }
+
+  /**
+   * @see PrintService#isAttributeCategorySupported(Class)
+   */
+  public boolean isAttributeCategorySupported(Class category)
+  {
+    if (category == null)
+      throw new NullPointerException("category may not be null");
+    
+    if (! Attribute.class.isAssignableFrom(category))
+      throw new IllegalArgumentException("category must be of type Attribute");
+    
+    return Arrays.asList(getSupportedAttributeCategories()).contains(category);
+  }
+
+  /**
+   * @see PrintService#isAttributeValueSupported(Attribute, DocFlavor, AttributeSet)
+   */
+  public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor,
+                                           AttributeSet attributes)
+  {
+    // just redirect to getSupportedAttributeValues    
+    Object values = getSupportedAttributeValues(attrval.getCategory(), 
+                                                flavor, attributes);    
+    // null means none supported
+    if (values == null)
+      return false;
+    
+    // object may be an array
+    if (values.getClass().isArray())
+      return Arrays.asList((Object[]) values).contains(attrval);
+    
+    // may be a single instance of the category (value is irrelevant)
+    if (values.getClass().equals(attrval.getCategory()))
+      return true;
+       
+    // a single instance of another class to give the bounds    
+    // copies
+    if (values.getClass().equals(CopiesSupported.class))
+      return ((CopiesSupported) values).contains((IntegerSyntax) attrval);    
+    // number up
+    if (values.getClass().equals(NumberUpSupported.class))
+      return ((NumberUpSupported) values).contains((IntegerSyntax) attrval);    
+    // job priority
+    if (values.getClass().equals(JobPrioritySupported.class))
+      {
+        JobPriority priority = (JobPriority) attrval;
+        JobPrioritySupported maxSupported = (JobPrioritySupported) values;
+        if (priority.getValue() < maxSupported.getValue())
+          return true;
+      }
+    
+    // I am unsure if these might also show up - not yet found a printer where 
+    // Suns implementation supports them: 
+    // JobImpressionsSupported, JobKOctetsSupported, JobMediaSheetsSupported
+    
+    return false;
+  }
+
+ 
+  /**
+   * @see javax.print.PrintService#isDocFlavorSupported(DocFlavor)
+   */
+  public boolean isDocFlavorSupported(DocFlavor flavor)
+  {
+    if (flavor == null)
+      throw new NullPointerException("DocFlavor may not be null.");
+    
+    return flavors.contains(flavor);
+  }
+
+  
+  /**
+   * @see PrintService#addPrintServiceAttributeListener(PrintServiceAttributeListener)
+   */
+  public void addPrintServiceAttributeListener(
+    PrintServiceAttributeListener listener)
+  {
+    printServiceAttributeListener.add(listener);
+  }
+  
+  /**
+   * @see PrintService#removePrintServiceAttributeListener(PrintServiceAttributeListener)
+   */
+  public void removePrintServiceAttributeListener(
+    PrintServiceAttributeListener listener)
+  {
+    printServiceAttributeListener.remove(listener);
+  }
+  
+  /**
+   * Returns "IppPrinter: " + <code>getName()</code>
+   * @return The string representation.
+   */
+  public String toString()
+  {
+    return "IppPrinter: " + getName();
+  } 
+  
+  /**
+   * Returns the printer-uri of this print service.
+   * 
+   * @return The printer-uri attribute.
+   */
+  public PrinterURI getPrinterURI()
+  {
+    return printerUri;
+  }  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppRequest.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppRequest.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,867 @@
+/* IppRequest.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 gnu.javax.print.ipp;
+
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+import gnu.javax.print.ipp.attribute.RequestedAttributes;
+import gnu.javax.print.ipp.attribute.job.AttributesCharset;
+import gnu.javax.print.ipp.attribute.job.AttributesNaturalLanguage;
+import gnu.javax.print.ipp.attribute.job.JobId;
+import gnu.javax.print.ipp.attribute.job.JobUri;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.DateTimeSyntax;
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.SetOfIntegerSyntax;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.URISyntax;
+import javax.print.attribute.standard.Compression;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.DocumentName;
+import javax.print.attribute.standard.Fidelity;
+import javax.print.attribute.standard.Finishings;
+import javax.print.attribute.standard.JobHoldUntil;
+import javax.print.attribute.standard.JobImpressions;
+import javax.print.attribute.standard.JobKOctets;
+import javax.print.attribute.standard.JobMediaSheets;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobOriginatingUserName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+import javax.print.attribute.standard.NumberUp;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterURI;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+
+/**
+ * <code>IppRequest</code> models a request to an IPP compatible
+ * server as described in RFC 2910 - IPP/1.1: Encoding and Transport.
+ * <p>
+ * The byte stream is structured as follows (for an official description
+ * please have a look at the RFC document mentioned above):
+ * <ul>
+ * <li>version-number          - 2 bytes - required</li>
+ * <li>operation-id            - 2 bytes - required</li>
+ * <li>request-id              - 4 bytes - required</li>
+ * <li>attribute-group         - n bytes - 0 or more</li>
+ * <li>end-of-attributes-tag   - 1 byte  - required</li>
+ * <li>data                    - q bytes - optional</li>
+ * </ul>
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class IppRequest
+{
+
+  /**
+   * The printer-poll timeout. 
+   */
+  private static final int timeout = 1000;
+
+  /**
+   * Helper class used to write the attributes of a request
+   * into the supplied data output stream in the correct way.
+   * 
+   * @author Wolfgang Baer (WBaer at gmx.de)
+   */
+  class RequestWriter
+  {    
+    private DataOutputStream out;
+    
+    /**
+     * Creates a RequestWriter.
+     * 
+     * @param stream the stream to write to.
+     */
+    RequestWriter(DataOutputStream stream)
+    {
+      out = stream;
+    }
+    
+    /**
+     * Writes an attribute in IntegerSyntax into the stream.
+     * @param attribute the attribute
+     * @throws IOException if thrown by the stream
+     */
+    private void write(IntegerSyntax attribute) throws IOException
+    {
+      String name = ((Attribute) attribute).getName();
+      out.writeByte(IppValueTag.INTEGER);
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(4); // length, integer is 4 bytes
+      out.writeInt(attribute.getValue());
+    }
+
+    /**
+     * Writes an attribute in EnumSyntax into the stream.
+     * @param attribute the attribute
+     * @throws IOException if thrown by the stream
+     */
+    private void write(EnumSyntax attribute) throws IOException
+    {
+      // in JPS API enum syntax is used for enums, keyword and boolean types
+      String name = ((Attribute) attribute).getName();
+
+      // the enum value types
+      if (attribute instanceof Finishings
+          || attribute instanceof OrientationRequested
+          || attribute instanceof PrintQuality)
+        {
+          out.writeByte(IppValueTag.ENUM);
+          out.writeShort(name.length());
+          out.write(name.getBytes());
+          out.writeShort(4); // length, enum is 4 bytes
+          out.writeInt(attribute.getValue());
+        }
+      // the boolean value type
+      else if (attribute instanceof Fidelity)
+        {
+          out.writeByte(IppValueTag.BOOLEAN);
+          out.writeShort(name.length());
+          out.write(name.getBytes());
+          out.writeShort(1); // length, boolean is 1 bytes
+          out.writeByte(attribute.getValue() == 0 ? 0x00 : 0x01);
+        }
+      // the keyword value types
+      else
+        {
+          String keyword = attribute.toString();
+          out.writeByte(IppValueTag.KEYWORD);
+          out.writeShort(name.length());
+          out.write(name.getBytes());
+          out.writeShort(keyword.length());
+          out.write(keyword.getBytes());
+        }
+    }
+
+    /**
+     * Writes an attribute in SetOfIntegerSyntax into the stream.
+     * @param attribute the attribute
+     * @throws IOException if thrown by the stream
+     */
+    private void write(SetOfIntegerSyntax attribute) throws IOException
+    {
+      String name = ((Attribute) attribute).getName();
+      int[][] ranges = attribute.getMembers();
+      for (int i = 0; i < ranges.length; i++)
+        {
+          out.writeByte(IppValueTag.RANGEOFINTEGER);
+          if (i == 0)
+            {
+              out.writeShort(name.length());
+              out.write(name.getBytes());
+            }
+          else
+            out.writeShort(0x0000); // only name-length 
+
+          out.writeShort(8); // range is 8 bytes
+          out.writeInt(ranges[i][0]);
+          out.writeInt(ranges[i][1]);
+        }
+    }
+
+    /**
+     * Writes an attribute in ResolutionSyntax into the stream.
+     * @param attribute the attribute
+     * @throws IOException if thrown by the stream
+     */
+    private void write(ResolutionSyntax attribute) throws IOException
+    {
+      String name = ((Attribute) attribute).getName();
+      out.writeByte(IppValueTag.RESOLUTION);
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(9); // length fixed to 9
+      out.writeInt(attribute.getCrossFeedResolution(ResolutionSyntax.DPI));
+      out.writeInt(attribute.getFeedResolution(ResolutionSyntax.DPI));
+      out.writeByte(ResolutionSyntax.DPI);
+    }
+
+    /**
+     * Writes an attribute in DateTimeSyntax into the stream.
+     * <p>
+     * The syntax value is defined as 11 octets follwing the
+     * DateAndTime format of RFC 1903. (see IppResponse)
+     * </p>
+     *
+     * @param attribute the attribute
+     * @throws IOException if thrown by the stream
+     */
+    private void write(DateTimeSyntax attribute) throws IOException
+    {
+      String name = ((Attribute) attribute).getName();
+      out.writeByte(IppValueTag.DATETIME);
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(11); // length fixed to 11
+
+      Date date = attribute.getValue();
+      Calendar cal = new GregorianCalendar();
+      cal.setTime(date);
+
+      out.writeShort(cal.get(Calendar.YEAR));
+      out.writeByte(cal.get(Calendar.MONTH));
+      out.writeByte(cal.get(Calendar.DAY_OF_MONTH));
+      out.writeByte(cal.get(Calendar.HOUR_OF_DAY));
+      out.writeByte(cal.get(Calendar.MINUTE));
+      int second = cal.get(Calendar.SECOND);
+      out.writeByte(second == 0 ? 60 : second);
+      out.writeByte(cal.get(Calendar.MILLISECOND) / 100);
+
+      int offsetInMillis = cal.get(Calendar.ZONE_OFFSET);
+      char directionFromUTC = '+';
+      if (offsetInMillis < 0)
+        {
+          directionFromUTC = '-';
+          offsetInMillis = offsetInMillis * (-1);
+        }
+
+      out.writeByte(directionFromUTC);
+      out.writeByte(offsetInMillis / 3600000); // hours    
+      out.writeByte((offsetInMillis % 3600000) / 60000); // minutes
+    }
+
+    /**
+     * Writes an attribute in TextSyntax into the stream.
+     * <p>
+     * By default attributes are qritten as TEXT_WITHOUT_LANGUAGE value-tag.
+     * As some attributes in the JPS are TextSyntax attributes but actually
+     * of NAME value-tag in IPP this method checks for these attributes and
+     * writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream.
+     * </p>
+     * 
+     * @param attribute the attribute
+     * @param out the stream to write to
+     * @throws IOException if thrown by the stream
+     */
+    private void write(TextSyntax attribute) throws IOException
+    {
+      // We only use *WithoutLanguage, correct according to spec.
+      String name = ((Attribute) attribute).getName();
+
+      if (attribute instanceof RequestingUserName
+          || attribute instanceof JobName
+          || attribute instanceof DocumentName
+          || attribute instanceof JobOriginatingUserName)
+        out.writeByte(IppValueTag.NAME_WITHOUT_LANGUAGE);
+      else if (attribute instanceof DocumentFormat)
+        out.writeByte(IppValueTag.MIME_MEDIA_TYPE);
+      else
+        out.writeByte(IppValueTag.TEXT_WITHOUT_LANGUAGE);
+      
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(attribute.getValue().length());
+      out.write(attribute.getValue().getBytes());     
+    }
+
+    /**
+     * Writes an attribute in URISyntax into the stream.
+     * @param attribute the attribute
+     * @param out the stream to write to
+     * @throws IOException if thrown by the stream
+     */
+    private void write(URISyntax attribute) throws IOException
+    {
+      // only uriScheme syntax type should not appear
+      // in a request (reference-uri-schemes-supported)
+      String name = ((Attribute) attribute).getName();
+      String uriAscii = attribute.getURI().toASCIIString();
+      out.writeByte(IppValueTag.URI);
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(uriAscii.length());
+      out.write(uriAscii.getBytes());
+    }
+
+    /**
+     * Writes an attribute in CharsetSyntax into the stream.
+     * @param attribute the attribute
+     * @param out the stream to write to
+     * @throws IOException if thrown by the stream
+     */
+    private void write(CharsetSyntax attribute) throws IOException
+    {      
+      String name = ((Attribute) attribute).getName();      
+      out.writeByte(IppValueTag.CHARSET);
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(attribute.getValue().length());
+      out.write(attribute.getValue().getBytes());
+    }
+
+    /**
+     * Writes an attribute in NaturalLanguageSyntax into the stream.
+     * @param attribute the attribute
+     * @param out the stream to write to
+     * @throws IOException if thrown by the stream
+     */
+    private void write(NaturalLanguageSyntax attribute) throws IOException
+    {
+      String name = ((Attribute) attribute).getName();
+      out.writeByte(IppValueTag.NATURAL_LANGUAGE);
+      out.writeShort(name.length());
+      out.write(name.getBytes());
+      out.writeShort(attribute.getValue().length());
+      out.write(attribute.getValue().getBytes());
+    }
+    
+    /**
+     * Writes an attribute in RequestedAttributes into the stream.
+     * @param attribute the attribute
+     * @param out the stream to write to
+     * @throws IOException if thrown by the stream
+     */
+    private void write(RequestedAttributes attribute) throws IOException
+    {
+      List values = attribute.getValues();
+      
+      String name = ((Attribute) attribute).getName();
+      out.writeByte(IppValueTag.KEYWORD);
+      out.writeShort(name.length());
+      out.write(name.getBytes()); 
+      out.writeShort(((String) values.get(0)).length());
+      out.write(((String) values.get(0)).getBytes());
+      
+      for (int i=1; i < values.size(); i++)
+        {
+          out.writeByte(IppValueTag.KEYWORD);
+          out.writeShort(0x0000); // length for additional value
+          out.writeShort(((String) values.get(i)).length());
+          out.write(((String) values.get(i)).getBytes());  
+        }
+    } 
+
+    
+    /**
+     * Writes the given operation attribute group of the given map instance
+     * (key=group, values=set of attributes) into the supplied data
+     * output stream.
+     * 
+     * @param attributes the set with the attributes.
+     * 
+     * @throws IOException if thrown by the used DataOutputStream.
+     * @throws IppException if unknown attributes occur.
+     */
+    public void writeOperationAttributes(AttributeSet attributes)
+        throws IOException, IppException
+    {
+      out.write(IppDelimiterTag.OPERATION_ATTRIBUTES_TAG);
+      
+      // its essential to write these two in this order and as first ones
+      Attribute att = attributes.get(AttributesCharset.class);
+      write((CharsetSyntax) att);
+      
+      logger.log(Component.IPP, "Attribute: Name: <" 
+        + att.getCategory().getName() + "> Value: <" + att.toString() + ">");  
+      
+      attributes.remove(AttributesCharset.class);
+      
+      att = attributes.get(AttributesNaturalLanguage.class);
+      write((NaturalLanguageSyntax) att);
+      attributes.remove(AttributesNaturalLanguage.class);
+      
+      logger.log(Component.IPP, "Attribute: Name: <" 
+        + att.getCategory().getName() + "> Value: <" + att.toString() + ">");
+      
+      // furthermore its essential to now write out the target attribute
+      PrinterURI printerUri = (PrinterURI) attributes.get(PrinterURI.class);
+      JobUri jobUri = (JobUri) attributes.get(JobUri.class);
+      JobId jobId = (JobId) attributes.get(JobId.class);
+      if (printerUri != null && jobId == null && jobUri == null)
+        {
+          write(printerUri);
+          attributes.remove(PrinterURI.class);
+          logger.log(Component.IPP, "Attribute: Name: <" + printerUri
+            .getCategory().getName() + "> Value: <" + printerUri.toString() + ">");
+        }
+      else if (jobUri != null && jobId == null && printerUri == null)
+        {
+          write(jobUri);
+          attributes.remove(JobUri.class);
+          logger.log(Component.IPP, "Attribute: Name: <" + jobUri
+            .getCategory().getName() + "> Value: <" + jobUri.toString() + ">");
+        }
+      else if (printerUri != null && jobId != null && jobUri == null)
+        {
+          write(printerUri); // must be third
+          write(jobId);
+          attributes.remove(PrinterURI.class);
+          attributes.remove(JobId.class);
+          logger.log(Component.IPP, "Attribute: Name: <" + printerUri
+            .getCategory().getName() + "> Value: <" + printerUri.toString() + ">");
+          logger.log(Component.IPP, "Attribute: Name: <" + jobId.getCategory()
+            .getName() + "> Value: <" + jobId.toString() + ">");
+        }
+      else if (jobUri != null && jobId != null)
+        {
+          write(jobUri);
+          attributes.remove(JobUri.class);
+          attributes.remove(JobId.class); // MUST NOT redundant
+          logger.log(Component.IPP, "Attribute: Name: <" + jobUri.getCategory()
+            .getName() + "> Value: <" + jobUri.toString() + ">");
+        }
+      else
+        {
+          new IppException("Unknown target operation attribute combination.");
+        }      
+      
+      writeAttributes(attributes);
+    }
+    
+    /**
+     * Writes the given attribute groups of the given map instance
+     * (key=group, values=set of attributes) into the supplied data
+     * output stream.
+     * 
+     * @param attributes the set with the attributes.
+     * 
+     * @throws IOException if thrown by the used DataOutputStream.
+     * @throws IppException if unknown attributes occur.
+     */
+    public void writeAttributes(AttributeSet attributes)
+        throws IOException, IppException
+    {
+      Attribute[] attributeArray = attributes.toArray();
+      for (int i = 0; i < attributeArray.length; i++)
+        {
+          logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i]
+            .getCategory().getName() + "> Value: <" 
+            + attributeArray[i].toString() + ">");          
+          
+          if (attributeArray[i] instanceof IntegerSyntax)
+            write((IntegerSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof TextSyntax)
+            write((TextSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof DateTimeSyntax)
+            write((DateTimeSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof ResolutionSyntax)
+            write((ResolutionSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof SetOfIntegerSyntax)
+            write((SetOfIntegerSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof EnumSyntax)
+            write((EnumSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof URISyntax)
+            write((URISyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof CharsetSyntax)
+            write((CharsetSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof NaturalLanguageSyntax)
+            write((NaturalLanguageSyntax) attributeArray[i]);
+          else if (attributeArray[i] instanceof RequestedAttributes)
+            write((RequestedAttributes) attributeArray[i]);
+          else
+            throw new IppException("Unknown syntax type");
+        }
+    }
+
+  }
+
+  /**
+   * Logger for tracing - enable by passing
+   * -Dgnu.classpath.debug.components=ipp to the vm.
+   */
+  static final Logger logger = SystemLogger.SYSTEM;
+
+  /**
+   * The request id counter simply counts up
+   * to give unique request ids per JVM instance.
+   */
+  private static int requestIdCounter = 1;
+
+  /** The IPP version defaults to 1.1 */
+  private static final short VERSION = 0x0101;
+
+  /** Signals if the request is already on its way */
+  private boolean alreadySent = false;
+
+  /** The operation type of this request. */
+  private short operation_id;
+
+  /** 
+   * The request id of this request. This is 
+   * assigned automatically by the constructor.
+   */
+  private final int request_id;
+
+  private AttributeSet operationAttributes;
+
+  private AttributeSet printerAttributes;
+
+  private AttributeSet jobAttributes;
+
+  private Object data;
+  
+  private URI requestUri;
+
+  /** The underlying connection - IPP is http based */
+  private HttpURLConnection  connection;
+  
+  /**
+   * Creates an IPPRequest instance.
+   * 
+   * @param uri the URI of the request
+   * @param user the user if any
+   * @param password the password of the supplied user
+   */
+  public IppRequest(URI uri, String user, String password)
+  {   
+    request_id = incrementRequestIdCounter();
+    requestUri = uri;
+    
+    try
+      {
+        URL url = new URL("http", 
+                      user == null 
+                      ? uri.getHost() : user + ":" 
+                      + password + "@" + uri.getHost(), 
+                      uri.getPort(), uri.getPath());
+       
+        connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("POST");
+        connection.setDoOutput(true);
+        
+        connection.setRequestProperty("Content-type", "application/ipp");
+        connection.setRequestProperty("Accept", "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");        
+      }   
+    catch (IOException e)
+      {
+        // MalformedURLException - uri is already checked
+        // ProtocolException - POST is correct method type
+        // IOException -HTTPURLConnection constructor actually 
+        // does never throw this exception.
+        logger.log(Component.IPP, "Unexpected IOException", e);
+      }
+    
+    logger.log(Component.IPP, "[IppConnection] Host: " + uri.getHost()
+                              + " Port: " + uri.getPort() + " Path: "
+                              + uri.getPath());
+  }
+
+  /**
+   * Synchronized method to be called by the constructor
+   * to assign a unique request id to this request.
+   * 
+   * @return The unique request id.
+   */
+  private synchronized int incrementRequestIdCounter()
+  {
+    return IppRequest.requestIdCounter++;
+  }
+
+  /**
+   * Returns the id of this request.
+   * 
+   * @return The request ID.
+   */
+  public int getRequestID()
+  {
+    return request_id;
+  }
+
+  /** 
+   * Sets the data of the request. The data used in this 
+   * request will be the one of the supplied inputstream
+   * instead of the alternative byte array possibility.
+   * 
+   * @param stream the input stream to use for the data.
+   */
+  public void setData(InputStream stream)
+  {
+    data = stream;
+  }
+
+  /** 
+   * Sets the data of the request. The data used in this 
+   * request will be the one of the supplied byte[]
+   * instead of the alternative input stream possibility.
+   * 
+   * @param bytes the byte[] to use for the data.
+   */
+  public void setData(byte[] bytes)
+  {
+    data = bytes;
+  }
+
+  /**
+   * Sets the operation id for this request.
+   * 
+   * @param id the operation id.
+   */
+  public void setOperationID(short id)
+  {
+    operation_id = id;
+  }
+
+  /**
+   * Adds the default values for the operation
+   * attributes "attributes-charset" and 
+   * "attributes-natural-language"
+   */
+  public void setOperationAttributeDefaults()
+  {
+    if (operationAttributes == null)
+      operationAttributes = new HashAttributeSet();
+
+    operationAttributes.add(AttributesCharset.UTF8);
+    operationAttributes.add(AttributesNaturalLanguage.EN);
+  }
+  
+  /**
+   * Add the job attribute of this request to the given
+   * attribute set.
+   * 
+   * @param attribute the job attribute.
+   */
+  public void addJobAttribute(Attribute attribute)
+  {
+    if (jobAttributes == null)
+      jobAttributes = new HashAttributeSet();
+    
+    jobAttributes.add(attribute);
+  }
+  
+  /**
+   * Sets the printer attribute of this request to the given
+   * attribute set.
+   * 
+   * @param attribute the printer attribute.
+   */
+  public void addPrinterAttributes(Attribute attribute)
+  {
+    if (printerAttributes == null)
+      printerAttributes = new HashAttributeSet();
+    
+    printerAttributes.add(attribute);
+  }
+
+  /**
+   * Adds the given attribute to the operation attributes set.
+   * 
+   * @param attribute the operation attribute to add.
+   */
+  public void addOperationAttribute(Attribute attribute)
+  {
+    if (operationAttributes == null)
+      operationAttributes = new HashAttributeSet();
+    
+    operationAttributes.add(attribute);
+  }
+  
+  /**
+   * Filters from the given attribute set the job operation out
+   * and adds them to the operation attributes set.
+   * 
+   * @param set the attributes to filter, may not be <code>null</code>.
+   */
+  public void addAndFilterJobOperationAttributes(AttributeSet set)
+  {
+    if (operationAttributes == null)
+      operationAttributes = new HashAttributeSet();
+    
+    // document-natural-language - not defined in JPS attributes
+    // document-format - specified outside, special treatment
+    Attribute[] tmp = set.toArray();
+    for (int i = 0; i < tmp.length; i++) 
+      {        
+        if (tmp[i].getCategory().equals(JobName.class)
+            || tmp[i].getCategory().equals(Fidelity.class)
+            || tmp[i].getCategory().equals(JobImpressions.class)
+            || tmp[i].getCategory().equals(JobKOctets.class)
+            || tmp[i].getCategory().equals(JobMediaSheets.class)
+            || tmp[i].getCategory().equals(Compression.class)
+            || tmp[i].getCategory().equals(DocumentName.class)
+            || tmp[i].getCategory().equals(RequestingUserName.class))
+                
+          operationAttributes.add(tmp[i]);            
+      }    
+  }
+  
+  /**
+   * Filters from the given attribute set the job template attributes
+   * out and adds them to the job attributes set.
+   * 
+   * @param set the attributes to filter, may not be <code>null</code>.
+   */
+  public void addAndFilterJobTemplateAttributes(AttributeSet set)
+  {
+    if (jobAttributes == null)
+      jobAttributes = new HashAttributeSet();
+    
+    // document-natural-language - not defined in JPS attributes
+    // document-format - specified outside, special treatment
+    Attribute[] tmp = set.toArray();
+    for (int i = 0; i < tmp.length; i++) 
+      {        
+        if (tmp[i].getCategory().equals(JobPriority.class)
+            || tmp[i].getCategory().equals(JobHoldUntil.class)
+            || tmp[i].getCategory().equals(JobSheets.class)
+            || tmp[i].getCategory().equals(MultipleDocumentHandling.class)
+            || tmp[i].getCategory().equals(Copies.class)
+            || tmp[i].getCategory().equals(Finishings.class)
+            || tmp[i].getCategory().equals(PageRanges.class)
+            || tmp[i].getCategory().equals(NumberUp.class)
+            || tmp[i].getCategory().equals(OrientationRequested.class)
+            || tmp[i].getCategory().equals(Media.class)
+            || tmp[i].getCategory().equals(PrinterResolution.class)
+            || tmp[i].getCategory().equals(PrintQuality.class)
+            || tmp[i].getCategory().equals(SheetCollate.class)
+            || tmp[i].getCategory().equals(Sides.class))
+                
+          jobAttributes.add(tmp[i]);            
+      }    
+  }
+
+  /**
+   * Does some validation of the supplied parameters and then
+   * sends the request to the ipp server or service.
+   * 
+   * @return The response if any.
+   * 
+   * @throws IllegalStateException if request is already sent
+   * @throws IppException if connection or request failed.
+   * @throws IOException if writing of the header, attributes or footer fails. 
+   */
+  public IppResponse send() throws IppException, IOException
+  {
+    if (alreadySent)
+      throw new IllegalStateException("Request is already sent");
+    
+    alreadySent = true;
+      
+    OutputStream stream = connection.getOutputStream();   
+    DataOutputStream out = new DataOutputStream(stream);
+        
+    //  the header 8 bytes long
+    out.writeShort(VERSION);
+    out.writeShort(operation_id);
+    out.writeInt(request_id);
+        
+    logger.log(Component.IPP, "OperationID: " + Integer.toHexString(operation_id) 
+      + " RequestID: " + request_id); 
+        
+    // Pass stuff the the attribute writer which knows how to
+    // write the attributes in correct order
+    logger.log(Component.IPP, "Operation Attributes");
+        
+    RequestWriter writer = new RequestWriter(out);
+    writer.writeOperationAttributes(operationAttributes);       
+        
+    if (jobAttributes != null)
+      {
+        logger.log(Component.IPP, "Job Attributes");
+        out.write(IppDelimiterTag.JOB_ATTRIBUTES_TAG);
+        writer.writeAttributes(jobAttributes);
+      }           
+    if (printerAttributes != null)
+      {
+        logger.log(Component.IPP, "Printer Attributes");
+        out.write(IppDelimiterTag.PRINTER_ATTRIBUTES_TAG);
+        writer.writeAttributes(printerAttributes);
+      }          
+
+    // write the delimiter to the data
+    out.write(IppDelimiterTag.END_OF_ATTRIBUTES_TAG);               
+
+    // check if data is byte[] or inputstream
+    if (data instanceof InputStream)
+      {
+        byte[] readbuf = new byte[2048];
+        int len = 0;            
+        while( (len = ((InputStream) data).read(readbuf)) > 0)
+          out.write(readbuf, 0, len);
+      }
+    else if (data != null)
+      {
+        out.write((byte[]) data);
+      }
+             
+    out.flush();
+    stream.flush();  
+  
+    // Set the connection timeout, for if the printer is offline.
+    // FIXME: The print services polling should probably be done in its
+    // own thread.
+    connection.setConnectTimeout( timeout );
+
+    int responseCode = connection.getResponseCode();
+    
+    if (responseCode == HttpURLConnection.HTTP_OK)
+      { 
+        IppResponse response = new IppResponse(requestUri, operation_id);        
+        response.setResponseData(connection.getInputStream());     
+        return response;
+      }
+
+    logger.log(Component.IPP, "HTTP-Statuscode: " + responseCode);
+
+    throw new IppException("Request failed got HTTP status code " 
+                           + responseCode);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppResponse.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppResponse.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,778 @@
+/* IppResponse.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 gnu.javax.print.ipp;
+
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+import gnu.javax.print.ipp.attribute.UnknownAttribute;
+import gnu.javax.print.ipp.attribute.defaults.DocumentFormatDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobHoldUntilDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+import gnu.javax.print.ipp.attribute.defaults.MediaDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrinterResolutionDefault;
+import gnu.javax.print.ipp.attribute.job.AttributesCharset;
+import gnu.javax.print.ipp.attribute.job.AttributesNaturalLanguage;
+import gnu.javax.print.ipp.attribute.job.JobMoreInfo;
+import gnu.javax.print.ipp.attribute.job.JobPrinterUri;
+import gnu.javax.print.ipp.attribute.job.JobUri;
+import gnu.javax.print.ipp.attribute.printer.CharsetConfigured;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+import gnu.javax.print.ipp.attribute.printer.NaturalLanguageConfigured;
+import gnu.javax.print.ipp.attribute.printer.PrinterCurrentTime;
+import gnu.javax.print.ipp.attribute.printer.PrinterDriverInstaller;
+import gnu.javax.print.ipp.attribute.supported.CharsetSupported;
+import gnu.javax.print.ipp.attribute.supported.DocumentFormatSupported;
+import gnu.javax.print.ipp.attribute.supported.GeneratedNaturalLanguageSupported;
+import gnu.javax.print.ipp.attribute.supported.JobHoldUntilSupported;
+import gnu.javax.print.ipp.attribute.supported.JobSheetsSupported;
+import gnu.javax.print.ipp.attribute.supported.MediaSupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterResolutionSupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterUriSupported;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.DateTimeAtCompleted;
+import javax.print.attribute.standard.DateTimeAtCreation;
+import javax.print.attribute.standard.DateTimeAtProcessing;
+import javax.print.attribute.standard.JobImpressionsSupported;
+import javax.print.attribute.standard.JobKOctetsSupported;
+import javax.print.attribute.standard.JobMediaSheetsSupported;
+import javax.print.attribute.standard.JobStateReason;
+import javax.print.attribute.standard.JobStateReasons;
+import javax.print.attribute.standard.NumberUpSupported;
+import javax.print.attribute.standard.PrinterMoreInfo;
+import javax.print.attribute.standard.PrinterMoreInfoManufacturer;
+import javax.print.attribute.standard.PrinterStateReason;
+import javax.print.attribute.standard.PrinterStateReasons;
+import javax.print.attribute.standard.Severity;
+
+/**
+ * <code>IppResponse</code> models a response received from an IPP 
+ * compatible server as described in RFC 2910 IPP 1.1 Encoding and Transport.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class IppResponse
+{
+
+  /**
+   * <code>ResponseReader</code> is responsible for parsing an IPP 1.1
+   * response stream. It provides access to the attribute groups after parsing
+   * via getter methods.
+   * <p>
+   * The enconding of a response is structured as follows (for an official 
+   * description please have a look at the RFC document mentioned above):
+   * <ul>
+   * <li>version-number            - 2 bytes - required</li>
+   * <li>status-code               - 2 bytes - required</li>
+   * <li>request-id                - 4 bytes - required</li>
+   * <li>attribute-group           - n bytes - 0 or more</li>
+   * <li>end-of-attributes-tag     - 1 byte  - required</li>
+   * <li>data                      - q bytes - optional</li>
+   * </ul>
+   * </p><p> 
+   * Where each attribute-group (if any) is encoded as follows:
+   * <ul>
+   * <li>begin-attribute-group-tag - 1 byte</li>
+   * <li>attribute                 - p bytes - 0 or more</li>
+   * </ul>
+   * </p><p> 
+   * Encoding of attributes:
+   * <ul>
+   * <li>attribute-with-one-value - q bytes</li>
+   * <li>additional-value         - r bytes  - 0 or more</li>
+   * </ul>
+   * </p><p>  
+   * Encoding of attribute-with-one-value:
+   * <ul>
+   * <li>value-tag                  - 1 byte</li>
+   * <li>name-length  (value is u)  - 2 bytes</li>
+   * <li>name                       - u bytes</li>
+   * <li>value-length  (value is v) - 2 bytes</li>
+   * <li>value                      - v bytes</li>
+   * </ul>
+   * </p><p> 
+   * Encoding of additional value:
+   * <ul>
+   * <li>value-tag                       - 1 byte</li>
+   * <li>name-length  (value is 0x0000)  - 2 bytes</li>
+   * <li>value-length (value is w)       - 2 bytes</li>
+   * <li>value                           - w bytes</li>
+   * </ul>
+   * </p>
+   * 
+   * @author Wolfgang Baer (WBaer at gmx.de)
+   */
+  class ResponseReader
+  {
+    /** The IPP version defaults to 1.1 */
+    private static final short VERSION = 0x0101;
+   
+    /**
+     * Parses the inputstream containing the response of the IPP request.
+     * @param input the inputstream
+     * @throws IppException if unexpected exceptions occur.
+     * @throws IOException if IO problems with the underlying inputstream occur.
+     */
+    public void parseResponse(InputStream input) 
+        throws IppException, IOException
+    {
+      DataInputStream stream = new DataInputStream(input);
+
+      short version = stream.readShort();
+      status_code = stream.readShort();
+      request_id = stream.readInt();
+
+      if (VERSION != version)
+        throw new IppException("Version mismatch - "
+          + "implementation does not support other versions than IPP 1.1");
+
+      logger.log(Component.IPP, "Statuscode: " 
+        + Integer.toHexString(status_code) + " Request-ID: " + request_id);
+
+      byte tag = 0;
+      boolean proceed = true;
+      HashMap tmp;
+      // iterate over attribute-groups until end-of-attributes-tag is found
+      while (proceed)
+        {
+          if (tag == 0) // only at start time
+            tag = stream.readByte();
+
+          logger.log(Component.IPP, "DelimiterTag: " + Integer.toHexString(tag));
+
+          // check if end of attributes
+          switch (tag)
+            {
+            case IppDelimiterTag.END_OF_ATTRIBUTES_TAG:
+              proceed = false;
+              break;
+            case IppDelimiterTag.OPERATION_ATTRIBUTES_TAG:
+              tmp = new HashMap();
+              tag = parseAttributes(tmp, stream);
+              operationAttributes.add(tmp);
+              break;
+            case IppDelimiterTag.JOB_ATTRIBUTES_TAG:
+              tmp = new HashMap();
+              tag = parseAttributes(tmp, stream);
+              jobAttributes.add(tmp);
+              break;
+            case IppDelimiterTag.PRINTER_ATTRIBUTES_TAG:
+              tmp = new HashMap();
+              tag = parseAttributes(tmp, stream);
+              printerAttributes.add(tmp);
+              break;
+            case IppDelimiterTag.UNSUPPORTED_ATTRIBUTES_TAG:
+              System.out.println("Called");
+              tmp = new HashMap();
+              tag = parseAttributes(tmp, stream);
+              unsupportedAttributes.add(tmp);
+              break;
+            default:
+              throw new IppException("Unknown tag with value "
+                                     + Integer.toHexString(tag) + " occured.");
+            }
+        }
+
+      // if there are more bytes that has to be data.
+      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+      byte[] readbuf = new byte[2048];
+      int len = 0;
+
+      while ((len = stream.read(readbuf)) > 0)
+        byteStream.write(readbuf, 0, len);
+
+      byteStream.flush();
+      data = byteStream.toByteArray();
+    }
+
+    /**
+     * The actual parsing of the attributes and further putting into the
+     * provided group maps.
+     * @param attributes the provided attribute group map.
+     * @param stream the provided stream to read from.
+     * @return The last read tag byte (normally a DelimiterTag)
+     * @throws IppException if unexpected exceptions occur.
+     * @throws IOException if IO problems with the underlying inputstream occur.
+     */
+    private byte parseAttributes(Map attributes, DataInputStream stream)
+        throws IppException, IOException
+    {
+      Attribute lastAttribute = null;
+      Attribute attribute = null;
+
+      // declaration of variables
+      short nameLength;
+      String name;
+      short valueLength;
+      byte[] value;
+
+      // tmp variables for parsing
+      // declared here so no name duplication occurs
+      URI uri;
+      String str;
+
+      while (true)
+        {
+          byte tag = stream.readByte();
+
+          if (IppDelimiterTag.isDelimiterTag(tag))
+            return tag;
+
+          // it must be a value tag now
+          // so we have either a attribute-with-one-value
+          // or (if setOf is possible) an additional-value
+
+          // (1) Length of the name
+          nameLength = stream.readShort();
+
+          // (2) The name itself
+          // may be an additional-value
+          if (nameLength == 0x0000)
+            name = lastAttribute.getName();
+          else
+            {
+              byte[] nameBytes = new byte[nameLength];
+              stream.read(nameBytes);
+              name = new String(nameBytes);
+            }
+
+          // (3) Length of the value
+          valueLength = stream.readShort();
+
+          // (4) The value itself
+          value = new byte[valueLength];
+          stream.read(value);       
+
+          // the value itself
+          switch (tag)
+            {
+            // out-of-band values
+            case IppValueTag.UNSUPPORTED:
+            case IppValueTag.UNKNOWN:
+            case IppValueTag.NO_VALUE:
+              // TODO implement out-of-band handling
+              // We currently throw an exception to see when it occurs - not yet :-)              
+              throw new IppException(
+                    "Unexpected name value for out-of-band value tag");
+            case IppValueTag.INTEGER:
+              int intValue = IppUtilities.convertToInt(value);
+              attribute = IppUtilities.getIntegerAttribute(name, intValue);
+
+              break;
+            case IppValueTag.BOOLEAN:
+              // JPS API models boolean syntax type as enums
+              // 0x01 = true, 0x00 = false - all are enums
+              attribute = IppUtilities.getEnumAttribute(name, new Integer(value[0]));
+              
+              break;
+            case IppValueTag.ENUM:
+              int intVal = IppUtilities.convertToInt(value);            
+              attribute = IppUtilities.getEnumAttribute(name, new Integer(intVal));    
+
+              break;
+            case IppValueTag.OCTECTSTRING_UNSPECIFIED:
+              // none exists according to spec
+              // so lets report as exception to see when it occurs
+              throw new IppException("Unspecified octet string occured.");
+
+            case IppValueTag.DATETIME:
+              Date date = parseDate(value);
+              if (name.equals("printer-current-time"))
+                attribute = new PrinterCurrentTime(date);
+              else if (name.equals("date-time-at-creation"))
+                attribute = new DateTimeAtCreation(date);
+              else if (name.equals("date-time-at-processing"))
+                attribute = new DateTimeAtProcessing(date);
+              else if (name.equals("date-time-at-completed"))
+                attribute = new DateTimeAtCompleted(date);
+
+              break;
+            case IppValueTag.RESOLUTION:
+              int crossFeed = IppUtilities.convertToInt(value[0], value[1], value[2], value[3]);
+              int feed = IppUtilities.convertToInt(value[4], value[5], value[6], value[7]);
+              int units = value[8];
+              
+              if (name.equals("printer-resolution-default"))
+                attribute = new PrinterResolutionDefault(crossFeed, feed, units);
+              else if (name.equals("printer-resolution-supported")) // may be here also
+                attribute = new PrinterResolutionSupported(crossFeed, feed, units);
+
+              break;
+            case IppValueTag.RANGEOFINTEGER:
+              int lower = IppUtilities.convertToInt(value[0], value[1], value[2], value[3]);
+              int upper = IppUtilities.convertToInt(value[4], value[5], value[6], value[7]);
+
+              if (name.equals("copies-supported"))
+                attribute = new CopiesSupported(lower, upper);
+              else if (name.equals("number-up-supported"))
+                attribute = new NumberUpSupported(lower, upper);
+              else if (name.equals("job-k-octets-supported")) 
+                attribute = new JobKOctetsSupported(lower, upper);
+              else if (name.equals("job-impressions-supported"))
+                attribute = new JobImpressionsSupported(lower, upper);
+              else if (name.equals("job-media-sheets-supported"))
+                attribute = new JobMediaSheetsSupported(lower, upper);
+
+              break;
+            case IppValueTag.TEXT_WITH_LANGUAGE:
+            case IppValueTag.TEXT_WITHOUT_LANGUAGE:
+            case IppValueTag.NAME_WITH_LANGUAGE:
+            case IppValueTag.NAME_WITHOUT_LANGUAGE:
+              attribute = IppUtilities.getTextAttribute(name, tag, value);
+             
+              break;
+            case IppValueTag.KEYWORD:
+              str = new String(value);
+              if (name.equals("job-hold-until-supported")) // may also be name type
+                attribute = new JobHoldUntilSupported(str, null);
+              else if (name.equals("job-hold-until-default"))
+                attribute = new JobHoldUntilDefault(str, null);             
+              else if (name.equals("media-supported"))
+                attribute = new MediaSupported(str, null);
+              else if (name.equals("media-default"))
+                  attribute = new MediaDefault(str, null);
+              else if (name.equals("job-sheets-default")) 
+                attribute = new JobSheetsDefault(str, null);
+              else if (name.equals("job-sheets-supported"))
+                attribute = new JobSheetsSupported(str, null);
+              else if (name.equals("job-state-reasons")) // setOf
+                attribute = parseJobStateReasons(value, lastAttribute);
+              else if (name.equals("printer-state-reasons")) // setOf
+                attribute = parsePrinterStateReasons(value, lastAttribute);
+              else
+                attribute = IppUtilities.getEnumAttribute(name, str);
+              
+              // all other stuff is either an enum or needs to be mapped to an 
+              // UnknownAttribute instance. Enums catched here are: 
+              // ipp-versions-supported, pdl-override-supported, compression-supported
+              // uri-authentication-supported, uri-security-supported, sides-supported
+              // sides-default, multiple-document-handling-supported, multiple-document-handling-default
+                            
+              break;
+            case IppValueTag.URI:
+              try
+                {
+                  uri = new URI(new String(value));
+                }
+              catch (URISyntaxException e)
+                {
+                  throw new IppException("Wrong URI syntax encountered.", e);
+                }
+
+              if (name.equals("job-uri"))
+                attribute = new JobUri(uri);
+              else if (name.equals("job-printer-uri"))
+                attribute = new JobPrinterUri(uri);
+              else if (name.equals("job-more-info"))
+                attribute = new JobMoreInfo(uri);
+              else if (name.equals("printer-uri-supported")) // setOf
+                attribute = new PrinterUriSupported(uri);
+              else if (name.equals("printer-more-info"))
+                attribute = new PrinterMoreInfo(uri);
+              else if (name.equals("printer-driver-installer"))
+                attribute = new PrinterDriverInstaller(uri);
+              else if (name.equals("printer-more-info-manufacturer"))
+                attribute = new PrinterMoreInfoManufacturer(uri);
+              
+              break;
+            case IppValueTag.URI_SCHEME:
+              // only one uri-scheme exists - and its an enum
+              if (name.equals("reference-uri-schemes-supported"))
+                attribute = IppUtilities.getEnumAttribute(name, new String(value));
+              
+              break;
+            case IppValueTag.CHARSET:
+              str = new String(value);
+              if (name.equals("attributes-charset"))
+                attribute = new AttributesCharset(str);
+              else if (name.equals("charset-configured"))
+                attribute = new CharsetConfigured(str);
+              else if (name.equals("charset-supported")) // setOf
+                attribute = new CharsetSupported(str);
+              
+              break;
+            case IppValueTag.NATURAL_LANGUAGE:
+              str = new String(value);
+              if (name.equals("attributes-natural-language"))
+                attribute = new AttributesNaturalLanguage(str);
+              else if (name.equals("natural-language-configured"))
+                attribute = new NaturalLanguageConfigured(str);
+              else if (name.equals("generated-natural-language-supported")) // setOf
+                attribute = new GeneratedNaturalLanguageSupported(str);
+              
+              break;
+            case IppValueTag.MIME_MEDIA_TYPE:
+              str = new String(value);
+              if (name.equals("document-format-default"))
+                attribute = new DocumentFormatDefault(str, null);
+              else if (name.equals("document-format-supported")) // setOf
+                attribute = new DocumentFormatSupported(str, null);
+              else if (name.equals("document-format")) // setOf
+                attribute = new DocumentFormat(str, null);
+              
+              break;
+            default:
+              throw new IppException("Unknown tag with value "
+                                     + Integer.toHexString(tag) + " found.");
+            }
+
+          if (attribute == null)
+            attribute =  new UnknownAttribute(tag, name, value);
+          
+          addAttribute(attributes, attribute);
+          lastAttribute = attribute;
+          
+          logger.log(Component.IPP, "Attribute: " + name
+                     + " Value: " + attribute.toString());
+        }
+    }
+
+    /**
+     * Adds a new attribute to the given attribute group. If this is the fist
+     * occurence of this attribute category a new set is created and associated
+     * with its category as key.
+     * @param attributeGroup
+     *          the attribute group
+     * @param attribute
+     *          the attribute to add
+     */
+    private void addAttribute(Map attributeGroup, Attribute attribute)
+    {
+      Class clazz = attribute.getCategory();
+      Set attributeValues = (Set) attributeGroup.get(clazz);
+
+      if (attributeValues == null) // first attribute of this category
+        {
+          attributeValues = new HashSet();
+          attributeGroup.put(clazz, attributeValues);
+        }
+
+      attributeValues.add(attribute);
+    }
+    
+    /**
+     * Parses a name with or without language attribute value from the byte[]
+     * and returns the result as an object[].
+     * @param value the byte[]
+     * @param lastAttr the last attribute
+     * @return The attribute.
+     */
+    private PrinterStateReasons parsePrinterStateReasons(byte[] value, Attribute lastAttr)
+    {
+      String str = new String(value);
+      PrinterStateReasons attribute; 
+      
+      if (lastAttr instanceof PrinterStateReasons)
+        attribute = (PrinterStateReasons) lastAttr;
+      else
+        attribute = new PrinterStateReasons();
+      
+      // special case indicating no reasons
+      if (str.equals("none")) 
+        return attribute;
+      
+      Severity severity = null;
+      PrinterStateReason reason = null;
+      
+      if (str.endsWith(Severity.WARNING.toString()))
+        severity = Severity.WARNING;
+      else if (str.endsWith(Severity.REPORT.toString()))
+        severity = Severity.REPORT;
+      else if (str.endsWith(Severity.ERROR.toString()))
+        severity = Severity.ERROR;
+      
+      if (severity != null)
+        str = str.substring(0, str.lastIndexOf('-'));    
+      else // we must associate a severity 
+        severity = Severity.REPORT;
+      
+      reason = (PrinterStateReason) 
+        IppUtilities.getEnumAttribute("printer-state-reason", str);
+      
+      attribute.put(reason , severity);
+      return attribute;
+    }
+    
+    /**
+     * Parses a name with or without language attribute value from the byte[]
+     * and returns the result as an object[].
+     * @param value the byte[]
+     * @param lastAttr the last attribute
+     * @return The attribute.
+     */
+    private JobStateReasons parseJobStateReasons(byte[] value, Attribute lastAttr)
+    {
+      String str = new String(value);
+      JobStateReasons attribute; 
+      
+      if (lastAttr instanceof JobStateReasons)
+        attribute = (JobStateReasons) lastAttr;
+      else
+        attribute = new JobStateReasons();
+      
+      // special case indicating no reasons
+      if (str.equals("none")) 
+        return attribute;
+      
+      JobStateReason reason = (JobStateReason) 
+        IppUtilities.getEnumAttribute("job-state-reason", str);
+      
+      attribute.add(reason);
+      return attribute;
+    }
+    
+    /**
+     * Parses a DateTime syntax attribute and returns the constructed Date
+     * object.
+     * <p>
+     * The syntax value is defined as 11 octets follwing the DateAndTime format
+     * of RFC 1903:
+     * <ul>
+     * <li>field | octets | contents | range</li>
+     * <li>1 | 1-2 | year | 0..65536</li>
+     * <li>2 | 3 | month | 1..12</li>
+     * <li>3 | 4 | day | 1..31</li>
+     * <li>4 | 5 | hour | 0..23</li>
+     * <li>5 | 6 | minutes | 0..59</li>
+     * <li>6 | 7 | seconds | 0..60 (use 60 for leap-second)</li>
+     * <li>7 | 8 | deci-seconds | 0..9</li>
+     * <li>8 | 9 | direction from UTC | '+' / '-'</li>
+     * <li>9 | 10 | hours from UTC | 0..11</li>
+     * <li>10 | 11 | minutes from UTC | 0..59</li>
+     * </ul>
+     * </p>
+     * 
+     * @param value the byte[]
+     * @return The date object.
+     */
+    private Date parseDate(byte[] value)
+    {
+      short year = IppUtilities.convertToShort(value[0], value[1]);
+
+      Calendar cal = Calendar.getInstance();
+      cal.set(Calendar.YEAR, year);
+      cal.set(Calendar.MONTH, value[2]);
+      cal.set(Calendar.DAY_OF_MONTH, value[3]);
+      cal.set(Calendar.HOUR_OF_DAY, value[4]);
+      cal.set(Calendar.MINUTE, value[5]);
+      cal.set(Calendar.SECOND, value[6]);
+      cal.set(Calendar.MILLISECOND, value[7] * 100); // deci-seconds
+
+      // offset from timezone
+      int offsetMilli = value[9] * 3600000; // hours to millis
+      offsetMilli = offsetMilli + value[10] * 60000; // minutes to millis
+
+      if (((char) value[8]) == '-')
+        offsetMilli = offsetMilli * (-1);
+
+      cal.set(Calendar.ZONE_OFFSET, offsetMilli);
+      return cal.getTime();
+    }
+  }
+  
+  /**
+   * Logger for tracing - enable by passing
+   * -Dgnu.classpath.debug.components=ipp to the vm.
+   */
+  static final Logger logger = SystemLogger.SYSTEM;
+  
+  URI uri;
+  short operation_id;
+  short status_code;
+  int request_id;
+
+  List operationAttributes;
+  List printerAttributes;
+  List jobAttributes;
+  List unsupportedAttributes;
+
+  byte[] data;
+
+  /**
+   * Creates an <code>IppResponse</code> instance.
+   * 
+   * @param uri the uri the request was directy to.
+   * @param operation_id the operation id of the request.
+   */
+  public IppResponse(URI uri, short operation_id)
+  {
+    this.uri = uri;
+    this.operation_id = operation_id;
+    operationAttributes = new ArrayList();
+    jobAttributes = new ArrayList();
+    printerAttributes = new ArrayList();
+    unsupportedAttributes = new ArrayList();
+  }
+
+  /**
+   * Sets the data received from the request sent.
+   * 
+   * @param input the input stream received.
+   * @throws IppException if parsing fails.
+   */
+  protected void setResponseData(InputStream input) throws IppException
+  {
+    ResponseReader reader = new ResponseReader();
+
+    try
+      {
+        reader.parseResponse(input);
+      }
+    catch (IOException e)
+      {
+        throw new IppException(
+            "Exception during response parsing caused by IOException", e);
+      }
+  }
+
+  /**
+   * Returns the uri of the original request.
+   * @return The URI of the request.
+   */
+  public URI getURI()
+  {
+    return uri;
+  }
+
+  /**
+   * Returns the operation id of the original request.
+   * @return The operation id of the request.
+   */
+  public int getOperationID()
+  {
+    return operation_id;
+  }
+
+  /**
+   * Returns the set of job attributes group maps.
+   * There may occur more than one group of type job attribute in a response
+   * because of e.g. multiple job or print service informations requested.
+   *  
+   * @return The list of job attribute grou maps.
+   */
+  public List getJobAttributes()
+  {
+    return jobAttributes;
+  }
+
+  /**
+   * Returns the set of operation attributes group maps.
+   * There may occur more than one group of type job attribute in a response
+   * because of e.g. multiple job or print service informations requested.
+   *  
+   * @return The list of operation attribute grou maps.
+   */
+  public List getOperationAttributes()
+  {
+    return operationAttributes;
+  }
+
+  /**
+   * Returns the set of printer attributes group maps.
+   * There may occur more than one group of type job attribute in a response
+   * because of e.g. multiple job or print service informations requested.
+   *  
+   * @return The list of printer attribute grou maps.
+   */
+  public List getPrinterAttributes()
+  {
+    return printerAttributes;
+  }
+
+  /**
+   * Returns the ID of the initial request.
+   * 
+   * @return The request ID.
+   */
+  public int getRequestID()
+  {
+    return request_id;
+  }
+
+  /**
+   * Returns the status code of the response.
+   * Defined in {@link IppStatusCode}.
+   * 
+   * @return The status code.
+   */
+  public short getStatusCode()
+  {
+    return status_code;
+  }
+
+  /**
+   * Returns the set of unsupported attributes group maps.
+   * There may occur more than one group of type job attribute in a response
+   * because of e.g. multiple job or print service informations requested.
+   *  
+   * @return The list of unsupported attribute grou maps.
+   */
+  public List getUnsupportedAttributes()
+  {
+    return unsupportedAttributes;
+  }
+
+  /**
+   * Returns the data of the response.
+   * 
+   * @return The data as byte[].
+   */
+  public byte[] getData()
+  {
+    return data;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,185 @@
+/* IppStatusCode.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 gnu.javax.print.ipp;
+
+/**
+ * IPP Status codes as described in RFC 2911 APPENDIX B 
+ * (Status Codes and Suggested Status Code Messages)
+ *
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class IppStatusCode
+{  
+  /** 
+   * Indicates a successful request with no attributes being 
+   * ignored or substituted. 
+   */
+  public static final int SUCCESSFUL_OK = 0x0000;
+
+  /** 
+   * Indicates a successful request, however some of the supplied
+   * attributes are ignored or substituted.
+   */
+  public static final int SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES = 0x0001;
+
+  /**
+   * Indicates a successful request, however some of the supplied
+   * attributes conflicted and therefore were ignored or substituted.
+   */
+  public static final int SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES = 0x0002;
+
+  // Client Error Status Codes
+  // Indicates that the client has done something wrong in its
+  // requests send to the IPP server object
+  
+  /** Indicates a bad request e.g. malformed syntax. */
+  public static final int CLIENT_ERROR_BAD_REQUEST = 0x0400;
+
+  /** Indicates that the client is forbidden to access the server. */
+  public static final int CLIENT_ERROR_FORBIDDEN = 0x0401;
+
+  /** Indicates that the client needs to authenticate. */
+  public static final int CLIENT_ERROR_NOT_AUTHENTICATED = 0x0402;
+
+  /** Indicates that the client is not authorized. */
+  public static final int CLIENT_ERROR_NOT_AUTHORIZED = 0x0403;
+
+  /** 
+   * Indicates a request which is not possible to process.
+   * For example if the request is directed at a job already finished. 
+   */
+  public static final int CLIENT_ERROR_NOT_POSSIBLE = 0x0404;
+
+  /** Indicates that the client got a timeout for additional action. */
+  public static final int CLIENT_ERROR_TIMEOUT = 0x0405;
+
+  /** Indicates that nothing was found for the request uri. */
+  public static final int CLIENT_ERROR_NOT_FOUND = 0x0406;
+
+  /** Indicates that the requested object is gone. */
+  public static final int CLIENT_ERROR_GONE = 0x0407;
+
+  /** Indicates that the request entities are too long. */
+  public static final int CLIENT_ERROR_REQUEST_ENTITY_TOO_LONG = 0x0408;
+
+  /** Indicates that a request value is too long. */
+  public static final int CLIENT_ERROR_REQUEST_VALUE_TOO_LONG = 0x0409;
+
+  /** Indicates that the supplied document format is not supported. */
+  public static final int CLIENT_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED = 0x040A;
+
+  /**
+   * Indicates that the supplied attributes or values of attributes are not
+   * supported by the printer object. Returning this code depends on the 
+   * given "ipp-attribute-fidelity" operation attribute value.
+   */
+  public static final int CLIENT_ERROR_ATTRIBUTES_OR_VALUES_NOT_SUPPORTED 
+    = 0x040B;
+
+  /** 
+   * Indicates the the URI scheme in a supplied print-uri or send-uri attribute
+   * is not supported.
+   */ 
+  public static final int CLIENT_ERROR_URI_SCHEME_NOT_SUPPORTED = 0x040C;
+
+  /** Indicates that a supplied attributes-charset is not supported. */
+  public static final int CLIENT_ERROR_CHARSET_NOT_SUPPORTED = 0x040D;
+
+  /** Indicates that conflicting attributes are in the request. */
+  public static final int CLIENT_ERROR_CONFLICTING_ATTRIBUTES =  0x040E;
+
+  /** Indicates that the specified algorithm is not supported. */
+  public static final int CLIENT_ERROR_COMPRESSION_NOT_SUPPORTED =  0x040F;
+
+  /** 
+   * Indicates that the document cannot be decompressed with the client 
+   * compression algorithm specified by the client.
+   */
+  public static final int CLIENT_ERROR_COMPRESSION_ERROR =  0x0410;
+
+  /** Indicates an error in the document format of the document. */
+  public static final int CLIENT_ERROR_DOCUMENT_FORMAT_ERROR =  0x0411;
+
+  /** 
+   * Indicates that the document supplied via print-uri or send-uri cannot be 
+   * accessed by the printer object.
+   */
+  public static final int CLIENT_ERROR_DOCUMENT_ACCESS_ERROR =  0x0412;
+
+  
+  /** Indicates an internal server error. */
+  public static final int SERVER_ERROR_INTERNAL_ERROR = 0x0500;
+
+  /** Indicates that the server does not support the operation. */
+  public static final int SERVER_ERROR_OPERATION_NOT_SUPPORTED =  0x0501;
+
+  /** Indicates that the server' service is not available. */
+  public static final int SERVER_ERROR_SERVICE_UNAVAILABLE =  0x0502;
+
+  /** Indicates that the server does not support the IPP version. */
+  public static final int SERVER_ERROR_VERSION_NOT_SUPPORTED =  0x0503;
+
+  /** Indicates that the server has a device error e.g. paper jam. */
+  public static final int SERVER_ERROR_DEVICE_ERROR = 0x0504;
+
+  /** Indicates that the server has a temporary error. */
+  public static final int SERVER_ERROR_TEMPORARY_ERROR = 0x0505;
+
+  /** Indicates that the server is currently not accepting jobs. */
+  public static final int SERVER_ERROR_NOT_ACCEPTING_JOBS = 0x0506;
+
+  /** 
+   * Indicates that the server is currently busy with processing.
+   * Requests may be tried later again.
+   */
+  public static final int SERVER_ERROR_BUSY = 0x0507;
+
+  /** Indicates that the server has canceled the job for various reasons. */
+  public static final int SERVER_ERROR_JOB_CANCELED = 0x0508;
+
+  /** Indicates that the server does not support multidocument jobs. */
+  public static final int SERVER_ERROR_MULTIPLE_DOCUMENT_JOBS_NOT_SUPPORTED 
+    = 0x0509;
+
+  private IppStatusCode()
+  {    
+    // not to be instantiated
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,551 @@
+/* IppUtilities.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 gnu.javax.print.ipp;
+
+import gnu.javax.print.ipp.attribute.DetailedStatusMessage;
+import gnu.javax.print.ipp.attribute.DocumentAccessError;
+import gnu.javax.print.ipp.attribute.StatusMessage;
+import gnu.javax.print.ipp.attribute.defaults.CopiesDefault;
+import gnu.javax.print.ipp.attribute.defaults.FinishingsDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobHoldUntilDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobPriorityDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+import gnu.javax.print.ipp.attribute.defaults.MediaDefault;
+import gnu.javax.print.ipp.attribute.defaults.MultipleDocumentHandlingDefault;
+import gnu.javax.print.ipp.attribute.defaults.NumberUpDefault;
+import gnu.javax.print.ipp.attribute.defaults.OrientationRequestedDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrintQualityDefault;
+import gnu.javax.print.ipp.attribute.defaults.SidesDefault;
+import gnu.javax.print.ipp.attribute.job.JobDetailedStatusMessages;
+import gnu.javax.print.ipp.attribute.job.JobDocumentAccessErrors;
+import gnu.javax.print.ipp.attribute.job.JobId;
+import gnu.javax.print.ipp.attribute.job.JobStateMessage;
+import gnu.javax.print.ipp.attribute.printer.MultipleOperationTimeOut;
+import gnu.javax.print.ipp.attribute.printer.PrinterStateMessage;
+import gnu.javax.print.ipp.attribute.printer.PrinterUpTime;
+import gnu.javax.print.ipp.attribute.supported.CompressionSupported;
+import gnu.javax.print.ipp.attribute.supported.FinishingsSupported;
+import gnu.javax.print.ipp.attribute.supported.IppVersionsSupported;
+import gnu.javax.print.ipp.attribute.supported.JobHoldUntilSupported;
+import gnu.javax.print.ipp.attribute.supported.JobSheetsSupported;
+import gnu.javax.print.ipp.attribute.supported.MediaSupported;
+import gnu.javax.print.ipp.attribute.supported.MultipleDocumentHandlingSupported;
+import gnu.javax.print.ipp.attribute.supported.MultipleDocumentJobsSupported;
+import gnu.javax.print.ipp.attribute.supported.OperationsSupported;
+import gnu.javax.print.ipp.attribute.supported.OrientationRequestedSupported;
+import gnu.javax.print.ipp.attribute.supported.PageRangesSupported;
+import gnu.javax.print.ipp.attribute.supported.PrintQualitySupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterResolutionSupported;
+import gnu.javax.print.ipp.attribute.supported.SidesSupported;
+import gnu.javax.print.ipp.attribute.supported.UriAuthenticationSupported;
+import gnu.javax.print.ipp.attribute.supported.UriSecuritySupported;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.ColorSupported;
+import javax.print.attribute.standard.Compression;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.Fidelity;
+import javax.print.attribute.standard.Finishings;
+import javax.print.attribute.standard.JobHoldUntil;
+import javax.print.attribute.standard.JobImpressionsCompleted;
+import javax.print.attribute.standard.JobKOctetsProcessed;
+import javax.print.attribute.standard.JobMediaSheetsCompleted;
+import javax.print.attribute.standard.JobMessageFromOperator;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobOriginatingUserName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobPrioritySupported;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.JobState;
+import javax.print.attribute.standard.JobStateReason;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+import javax.print.attribute.standard.NumberOfInterveningJobs;
+import javax.print.attribute.standard.NumberUp;
+import javax.print.attribute.standard.NumberUpSupported;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.OutputDeviceAssigned;
+import javax.print.attribute.standard.PDLOverrideSupported;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PagesPerMinute;
+import javax.print.attribute.standard.PagesPerMinuteColor;
+import javax.print.attribute.standard.PresentationDirection;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterInfo;
+import javax.print.attribute.standard.PrinterIsAcceptingJobs;
+import javax.print.attribute.standard.PrinterLocation;
+import javax.print.attribute.standard.PrinterMakeAndModel;
+import javax.print.attribute.standard.PrinterMessageFromOperator;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.attribute.standard.PrinterStateReason;
+import javax.print.attribute.standard.QueuedJobCount;
+import javax.print.attribute.standard.ReferenceUriSchemesSupported;
+import javax.print.attribute.standard.Severity;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+
+/**
+ * Collection of static utilities methods used in
+ * IPP response parsing and all over the place.
+ * <p>
+ * Also provides mapping from the attribute name values to
+ * the actual class object. Used to construct objects via reflection.
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class IppUtilities
+{
+  // These are reused in the reflection code to not instantiate an array everytime
+  private static Object[] INTEGER_ATT_VALUE = new Object[1];
+  private static Class[] INTEGER_CLASS_ARRAY = new Class[] {int.class};
+  private static Object[] TEXT_ATT_VALUE = new Object[2];
+  private static Class[] TEXT_CLASS_ARRAY = new Class[] {String.class, Locale.class};
+  
+  // The map -> Attribute name to Attribute class
+  private static HashMap classesByName = new HashMap();
+  // The map -> StandardAttribute class to SupportedAttribute category name
+  private static HashMap instanceByClass = new HashMap();
+
+  /**
+   * All the currently needed attributes
+   */
+  static
+    {
+      // enums      
+      classesByName.put(JobState.ABORTED.getName(), JobState.class);
+      classesByName.put(Sides.DUPLEX.getName(), Sides.class);
+      classesByName.put(SheetCollate.COLLATED.getName(), SheetCollate.class);
+      classesByName.put(Severity.ERROR.getName(), Severity.class);
+      classesByName.put(JobSheets.NONE.getName(), JobSheets.class);
+      classesByName.put(Finishings.BIND.getName(), Finishings.class);
+      classesByName.put(Fidelity.FIDELITY_FALSE.getName(), Fidelity.class);
+      classesByName.put(Compression.GZIP.getName(), Compression.class);
+      classesByName.put(Chromaticity.COLOR.getName(), Chromaticity.class);
+      classesByName.put(PrintQuality.DRAFT.getName(), PrintQuality.class);
+      classesByName.put(PrinterState.IDLE.getName(), PrinterState.class);
+      classesByName.put(SidesDefault.ONE_SIDED.getName(), SidesDefault.class);
+      classesByName.put(ReferenceUriSchemesSupported.FILE.getName(), 
+                        ReferenceUriSchemesSupported.class);           
+      classesByName.put(PrinterStateReason.DOOR_OPEN.getName(),
+                        PrinterStateReason.class);            
+      classesByName.put(PresentationDirection.TOLEFT_TOTOP.getName(), 
+                        PresentationDirection.class);
+      classesByName.put(PDLOverrideSupported.ATTEMPTED.getName(), 
+                        PDLOverrideSupported.class);
+      classesByName.put(OrientationRequested.PORTRAIT.getName(), 
+                        OrientationRequested.class);
+      classesByName.put(MultipleDocumentHandling.SINGLE_DOCUMENT.getName(), 
+                        MultipleDocumentHandling.class);
+      classesByName.put(JobStateReason.JOB_QUEUED.getName(), 
+                        JobStateReason.class);
+      classesByName.put(UriAuthenticationSupported.NONE.getName(), 
+                        UriAuthenticationSupported.class);      
+      classesByName.put(OperationsSupported.GET_JOBS.getName(), 
+                        OperationsSupported.class);      
+      classesByName.put(UriSecuritySupported.NONE.getName(), 
+                        UriSecuritySupported.class);          
+      classesByName.put(FinishingsSupported.NONE.getName(), 
+                        FinishingsSupported.class);      
+      classesByName.put(FinishingsDefault.NONE.getName(), 
+                        FinishingsDefault.class);      
+      classesByName.put(IppVersionsSupported.V_1_0.getName(), 
+                        IppVersionsSupported.class);      
+      classesByName.put(MultipleDocumentHandlingSupported.SINGLE_DOCUMENT.getName(), 
+                        MultipleDocumentHandlingSupported.class);      
+      classesByName.put(MultipleDocumentHandlingDefault.SINGLE_DOCUMENT.getName(), 
+                        MultipleDocumentHandlingDefault.class);      
+      classesByName.put(CompressionSupported.NONE.getName(), 
+                        CompressionSupported.class);      
+      classesByName.put(OrientationRequestedSupported.PORTRAIT.getName(), 
+                        OrientationRequestedSupported.class);      
+      classesByName.put(OrientationRequestedDefault.PORTRAIT.getName(), 
+                        OrientationRequestedDefault.class);        
+      classesByName.put(SidesSupported.ONE_SIDED.getName(), 
+                        SidesSupported.class);     
+      classesByName.put(PrintQualityDefault.DRAFT.getName(), 
+                        PrintQualityDefault.class);      
+      classesByName.put(PrintQualitySupported.DRAFT.getName(), 
+                        PrintQualitySupported.class);      
+      classesByName.put(ReferenceUriSchemesSupported.FTP.getName(), 
+                        ReferenceUriSchemesSupported.class);
+      
+      // the boolean types 
+      classesByName.put(ColorSupported.SUPPORTED.getName(), ColorSupported.class);      
+      classesByName.put(PrinterIsAcceptingJobs.ACCEPTING_JOBS.getName(), 
+                        PrinterIsAcceptingJobs.class);
+      classesByName.put(MultipleDocumentJobsSupported.SUPPORTED.getName(), 
+                        MultipleDocumentJobsSupported.class);
+      classesByName.put(PageRangesSupported.SUPPORTED.getName(), 
+                        PageRangesSupported.class);
+                 
+      // TextSyntax derived attributes
+      classesByName.put("media-default", MediaDefault.class); 
+      classesByName.put("media-supported", MediaSupported.class);
+      classesByName.put("media", MediaSizeName.class); 
+      classesByName.put("printer-location", PrinterLocation.class); 
+      classesByName.put("printer-info", PrinterInfo.class); 
+      classesByName.put("printer-make-and-model", PrinterMakeAndModel.class); 
+      classesByName.put("printer-state-message", PrinterStateMessage.class);
+      classesByName.put("job-state-message", JobStateMessage.class);         
+      classesByName.put("job-sheets-default", JobSheetsDefault.class); 
+      classesByName.put("job-sheets-supported", JobSheetsSupported.class); 
+      classesByName.put("job-name", JobName.class); 
+      classesByName.put("printer-name", PrinterName.class); 
+      classesByName.put("status-message", StatusMessage.class); 
+      classesByName.put("detailed-status-message", DetailedStatusMessage.class); 
+      classesByName.put("document-access-error", DocumentAccessError.class); 
+      classesByName.put("output-device-assigned", OutputDeviceAssigned.class); 
+      classesByName.put("job-hold-until-default", JobHoldUntilDefault.class);       
+      classesByName.put("job-originating-user-name", 
+                        JobOriginatingUserName.class); 
+      classesByName.put("job-hold-until-supported", 
+                        JobHoldUntilSupported.class);
+      classesByName.put("job-message-from-operator", 
+                        JobMessageFromOperator.class); 
+      classesByName.put("printer-message-from-operator", 
+                        PrinterMessageFromOperator.class); 
+      classesByName.put("job-detailed-status-messages", 
+                        JobDetailedStatusMessages.class);
+      classesByName.put("job-document-access-errors", 
+                        JobDocumentAccessErrors.class);    
+      
+      // IntegerSyntax derived Attributes
+      classesByName.put("copies-default", CopiesDefault.class); 
+      classesByName.put("job-id", JobId.class); 
+      classesByName.put("job-priority-supported", JobPrioritySupported.class);
+      classesByName.put("job-priority-default", JobPriorityDefault.class);
+      classesByName.put("number-up-supported", NumberUpSupported.class);
+      classesByName.put("number-up-default", NumberUpDefault.class);
+      classesByName.put("queued-job-count", QueuedJobCount.class);
+      classesByName.put("printer-up-time", PrinterUpTime.class);      
+      classesByName.put("pages-per-minute", PagesPerMinute.class);
+      classesByName.put("pages-per-minute-color", PagesPerMinuteColor.class);       
+      classesByName.put("job-k-octets-processed", JobKOctetsProcessed.class);
+      classesByName.put("number-of-intervening-jobs", 
+                        NumberOfInterveningJobs.class);
+      classesByName.put("job-impressions-completed", 
+                        JobImpressionsCompleted.class); 
+      classesByName.put("job-media-sheets-completed", 
+                        JobMediaSheetsCompleted.class);
+      classesByName.put("multiple-operation-time-out", 
+                        MultipleOperationTimeOut.class);
+      
+      
+      // 4.2 job template attributes
+      instanceByClass.put(JobPriority.class, new JobPrioritySupported(1));
+      instanceByClass.put(JobHoldUntil.class, new JobHoldUntilSupported("", null));
+      instanceByClass.put(JobSheets.class, new JobSheetsSupported("", null));
+      instanceByClass.put(MultipleDocumentHandling.class, MultipleDocumentHandlingSupported.SINGLE_DOCUMENT);
+      instanceByClass.put(Copies.class, new CopiesSupported(1));
+      instanceByClass.put(Finishings.class, FinishingsSupported.BIND);
+      instanceByClass.put(PageRanges.class, PageRangesSupported.SUPPORTED);
+      instanceByClass.put(Sides.class, SidesSupported.DUPLEX);
+      instanceByClass.put(NumberUp.class, new NumberUpSupported(1));
+      instanceByClass.put(OrientationRequested.class, OrientationRequestedSupported.LANDSCAPE);
+      instanceByClass.put(Media.class, new MediaSupported("", null));
+      instanceByClass.put(PrinterResolution.class, new PrinterResolutionSupported(1,1,1));
+      instanceByClass.put(PrintQuality.class, PrintQualitySupported.DRAFT);
+
+      // 4.4 printer attributes
+      instanceByClass.put(Compression.class, CompressionSupported.COMPRESS);
+    }
+  
+  private IppUtilities()
+  {
+    // not to be instantiated
+  }
+
+  /**
+   * Returns the implementing class object for given
+   * attribute name objects.
+   * 
+   * @param name the attribute name
+   * @return The <code>Class</code> object.
+   */
+  public static Class getClass(String name)
+  {
+    return (Class) classesByName.get(name);
+  }
+  
+  /**
+   * Returns the name of the supported attribute 
+   * based on the given standard attribute category.
+   * 
+   * @param clazz the standard attribute category
+   * @return The name of the supported attribute category.
+   */
+  public static String getSupportedAttrName(Class clazz)
+  {
+    return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getName();
+  }
+  
+  /**
+   * Returns the category of the supported attribute 
+   * based on the given standard attribute category.
+   * 
+   * @param clazz the standard attribute category
+   * @return The supported attribute category.
+   */
+  public static Class getSupportedCategory(Class clazz)
+  {
+    return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getCategory();
+  }  
+
+  /**
+   * Helper method to convert to an int.
+   * @param b the byte array
+   * @return The converted int.
+   */
+  public static int convertToInt(byte[] b)
+  {
+    return (((b[0] & 0xff) << 24) | ((b[1] & 0xff) << 16)
+            | ((b[2] & 0xff) << 8) | (b[3] & 0xff));
+  }
+  
+  /**
+   * Helper method to convert to an int.
+   * @param b1 the 1th byte
+   * @param b2 the 2th byte
+   * @param b3 the 3th byte
+   * @param b4 the 4th byte
+   * @return The converted int.
+   */
+  public static int convertToInt(byte b1, byte b2, byte b3, byte b4)
+  {
+    return (((b1 & 0xff) << 24) | ((b2 & 0xff) << 16)
+            | ((b3 & 0xff) << 8) | (b4 & 0xff));
+  }
+
+  /**
+   * Helper method to convert to a short.
+   * @param b1 the 1th byte
+   * @param b2 the 2th byte
+   * @return The converted short.
+   */
+  public static short convertToShort(byte b1, byte b2)
+  {
+    return (short) ((b1 << 8) | (b2 & 0xff));
+  }
+  
+  /**
+   * Instantiates an <code>EnumSyntax</code> based attribute with the given IPP
+   * name and the given value (Enums maybe int or String based).
+   * 
+   * @param name the attribute name of the subclass.
+   * @param value the integer value of the specific enum.
+   * @return The Attribute (a subclass of EnumSyntax)
+   */
+  public static Attribute getEnumAttribute(String name, Object value)
+  {
+    Class attrClass = getClass(name);
+    
+    // There might be unknown enums we have no mapped class for
+    if (attrClass ==  null)
+      return null;    
+
+    try
+      {
+        Field[] fields = attrClass.getDeclaredFields();
+        for (int i = 0; i < fields.length; i++)
+          {
+            Field field = fields[i];
+            if (field.getType().equals(attrClass))
+              {
+                EnumSyntax attr = (EnumSyntax) field.get(null);
+                if (value instanceof Integer
+                    && attr.getValue() == ((Integer) value).intValue())
+                  return (Attribute) attr;
+                else if (value instanceof String
+                         && attr.toString().equals(value))
+                  return (Attribute) attr;
+              }
+          }
+      }
+    catch (SecurityException e)
+      {
+        // should not happen
+      }
+    catch (IllegalArgumentException e)
+      {
+        // should not happen
+      }
+    catch (IllegalAccessException e)
+      {
+        // should not happen, all fields are public
+      }
+    
+    return null;
+  }
+  
+  
+  
+  /**
+   * Instantiates an <code>IntegerSyntax</code> based attribute with the 
+   * given IPP name for the given int value.
+   * 
+   * @param name the attribute name of the subclass.
+   * @param value the integer value
+   * @return The Attribute (a subclass of IntegerSyntax)
+   */
+  public static Attribute getIntegerAttribute(String name, int value)
+  {    
+    Class attrClass = getClass(name);
+    
+    // There might be unknown attributes we have no mapped class for
+    if (attrClass ==  null)
+      return null;
+
+    try
+      {
+        INTEGER_ATT_VALUE[0] = new Integer(value);
+        Constructor c = attrClass.getDeclaredConstructor(INTEGER_CLASS_ARRAY);       
+        return (Attribute) c.newInstance(INTEGER_ATT_VALUE);         
+      }
+    catch (SecurityException e)
+      {
+        // should not happen
+      }
+    catch (NoSuchMethodException e)
+      {
+        // should not happen
+      }
+    catch (IllegalAccessException e)
+      {
+        // should not happen, all fields are public
+      }
+    catch (InstantiationException e)
+    {
+      // should not happen, all fields are public
+    }
+    catch (InvocationTargetException e)
+    {
+      // should not happen, all fields are public
+    }
+    
+    return null;
+  }  
+  
+  /**
+   * Instantiates an <code>TextSyntax</code> based attribute with the given
+   * IPP name for the given text value (will be decoded).
+   * 
+   * @param name the attribute name of the subclass.
+   * @param tag the tag defined in {@link IppValueTag}
+   * @param value the byte[] value to be decoded based on the tag value.
+   * @return The Attribute (a subclass of TextSyntax)
+   */
+  public static Attribute getTextAttribute(String name, byte tag, byte[] value)
+  { 
+    // without language tag is rather easy - default locale
+    if (tag == IppValueTag.NAME_WITHOUT_LANGUAGE
+        || tag == IppValueTag.TEXT_WITHOUT_LANGUAGE)
+      {
+        TEXT_ATT_VALUE[0] = new String(value);
+        TEXT_ATT_VALUE[1] = Locale.getDefault();
+      }
+    else
+      {
+        short langLength = convertToShort(value[0], value[1]);
+        byte[] tmp = new byte[langLength];
+        byte[] tmp2 = new byte[value.length - 4 - langLength];
+        System.arraycopy(value, 2, tmp, 0, langLength);
+
+        // parse into language/region
+        String language = new String(tmp);
+        String text = new String(tmp2);
+        Locale locale = null;
+        
+        if (language.length() > 2)
+          locale = new Locale(language.substring(0, 2), language.substring(3));
+        else
+          locale = new Locale(language);
+
+        TEXT_ATT_VALUE[0] = text;
+        TEXT_ATT_VALUE[1] = locale;
+      }    
+    
+    Class attrClass = getClass(name);
+    
+    // There might be unknown attributes we have no mapped class for
+    if (attrClass ==  null)
+      return null;
+
+    try
+      {
+        Constructor c = attrClass.getDeclaredConstructor(TEXT_CLASS_ARRAY);       
+        return (Attribute) c.newInstance(TEXT_ATT_VALUE);         
+      }
+    catch (SecurityException e)
+      {
+        // should not happen
+      }
+    catch (NoSuchMethodException e)
+      {
+        // should not happen
+      }
+    catch (IllegalAccessException e)
+      {
+        // should not happen, all fields are public
+      }
+    catch (InstantiationException e)
+      {
+        // should not happen, all fields are public
+      }
+    catch (InvocationTargetException e)
+      {
+        // should not happen, all fields are public
+      }
+    
+    return null;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,170 @@
+/* IppValueTag.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 gnu.javax.print.ipp;
+
+/**
+ * IPP Value Tags as described in RFC 2910 section 3.5.2.
+ * <p>
+ * Attributes are always of a special type syntax (e.g. boolean or
+ * interger attribute). These value types are specified by the tag
+ * constants provided in this class. Beside the syntax types some
+ * out of band values for reporting requested attributes as 
+ * unsupported, unknown etc. back to the client.
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class IppValueTag
+{ 
+  
+  /** Out of band value for unsupported attributes. */
+  public static final byte UNSUPPORTED = 0x10;
+  
+  // 0x11 reserved for 'default' for definition in a future
+  //      IETF standards track document 
+  
+  /** Out of band value for unknown attributes. */
+  public static final byte UNKNOWN = 0x12;
+  
+  /** Out of band value for attribute without a value. */
+  public static final byte NO_VALUE = 0x13;
+  
+  // 0x14-0x1F reserved for "out-of-band" values in future IETF
+  //           standards track documents.
+  
+  // 0x20 reserved for definition in a future IETF
+  //      standards track document
+  
+  /** Indicates a value of syntax type integer. */
+  public static final byte INTEGER = 0x21;
+  
+  /** Indicates a value of syntax type boolean. */
+  public static final byte BOOLEAN = 0x22;
+  
+  /** Indicates a value of syntax type enum (enumeration). */
+  public static final byte ENUM = 0x23;
+  
+  // 0x24-0x2F reserved for integer types for definition in
+  //           future IETF standards track documents
+
+  /** Indicates a value of syntax type octect string. */
+  public static final byte OCTECTSTRING_UNSPECIFIED = 0x30;
+  
+  /** Indicates a value of syntax type datetime. */
+  public static final byte DATETIME = 0x31;
+  
+  /** Indicates a value of syntax type resolution. */
+  public static final byte RESOLUTION = 0x32;
+  
+  /** Indicates a value of syntax type range of integers. */
+  public static final byte RANGEOFINTEGER = 0x33;
+ 
+  // 0x34 reserved for definition in a future IETF
+  //      standards track document
+  
+  /** Indicates a value of syntax type text with language. */
+  public static final byte TEXT_WITH_LANGUAGE = 0x35;
+  
+  /** Indicates a value of syntax type name with language. */
+  public static final byte NAME_WITH_LANGUAGE = 0x36;
+  
+  // 0x37-0x3F reserved for octetString type definitions in
+  //            future IETF standards track documents
+
+  // 0x40 reserved for definition in a future IETF
+  //      standards track document
+  
+  /** Indicates a value of syntax type text without language. */
+  public static final byte TEXT_WITHOUT_LANGUAGE = 0x41;
+  
+  /** Indicates a value of syntax type name without language. */
+  public static final byte NAME_WITHOUT_LANGUAGE = 0x42;
+ 
+  // 0x43 reserved for definition in a future IETF
+  //      standards track document
+  
+  /** Indicates a value of syntax type keyword. */
+  public static final byte KEYWORD = 0x44;  
+  
+  /** Indicates a value of syntax type URI. */
+  public static final byte URI = 0x45;  
+  
+  /** Indicates a value of syntax type URI scheme. */
+  public static final byte URI_SCHEME = 0x46;
+  
+  /** Indicates a value of syntax type charset. */
+  public static final byte CHARSET = 0x47;  
+  
+  /** Indicates a value of syntax type language. */
+  public static final byte NATURAL_LANGUAGE =0x48;   
+  
+  /** Indicates a value of syntax type mime media. */
+  public static final byte MIME_MEDIA_TYPE = 0x49;
+
+  // 0x4A-0x5F reserved for character string type definitions
+  //           in future IETF standards track documents
+
+
+  private IppValueTag()
+  {
+    // not to be instantiated;
+  }
+  
+  /**
+   * Tests if given value corresponds to a 
+   * value tag value.
+   * 
+   * @param value the value to test for
+   * @return <code>true</code> if, <code>false</code> otherwise.
+   */
+  public static boolean isValueTag(byte value) 
+  {
+    if(value == 0x10 || value == 0x12 || value == 0x13
+        || value == 0x21 || value == 0x22 || value == 0x23
+        || value == 0x30 || value == 0x31 || value == 0x32
+        || value == 0x33 || value == 0x35 || value == 0x36
+        || value == 0x41 || value == 0x42 || value == 0x44
+        || value == 0x45 || value == 0x46 || value == 0x47
+        || value == 0x48 || value == 0x49 )
+      return true;
+    
+    return false;
+  }
+  
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* MultiDocPrintJobImpl.java -- GNU implementation of MultiDocPrintJob
+   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 gnu.javax.print.ipp;
+
+
+import javax.print.MultiDoc;
+import javax.print.MultiDocPrintJob;
+import javax.print.PrintException;
+import javax.print.attribute.PrintRequestAttributeSet;
+
+/**
+ * Implementation of the MultiDocPrintJob interface. Implementation 
+ * is specific to the <code>IppPrintService</code> implementation.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class MultiDocPrintJobImpl extends DocPrintJobImpl 
+  implements MultiDocPrintJob
+{
+
+  /**
+   * Constructor forwarding arguments to the super constructor.
+   * 
+   * @param service the print service instance.
+   * @param user the user of this print service.
+   * @param passwd the password of the user.
+   */
+  public MultiDocPrintJobImpl(IppPrintService service, String user,
+                              String passwd)
+  {
+    super(service, user, passwd);
+  }
+
+  /**
+   * @see MultiDocPrintJob#print(MultiDoc, PrintRequestAttributeSet)
+   */
+  public void print(MultiDoc multiDoc, PrintRequestAttributeSet attributes)
+      throws PrintException
+  {
+    // FIXME Implement
+    throw new PrintException("Multidoc not yet supported by implementation.");
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* CharsetSyntax.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 gnu.javax.print.ipp.attribute;
+
+import java.io.Serializable;
+
+/**
+ * <code>CharsetSyntax</code> is the abstract base class of all attribute 
+ * classes which provide a charset (US-ASCII) string as value.
+ *
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public abstract class CharsetSyntax implements Cloneable, Serializable
+{
+  private final String value;
+
+  /**
+   * Creates a <code>CharsetSyntax</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   *
+   * @exception NullPointerException if value is null
+   */
+  protected CharsetSyntax(String value)
+  {
+    if (value == null)
+      throw new NullPointerException("value may not be null");
+    
+    this.value = value;
+  }
+
+  /**
+   * Returns the value of this syntax object.
+   *
+   * @return The value.
+   */
+  public String getValue()
+  {
+    return value;
+  }
+
+  /**
+   * Returns the hashcode for this object.
+   *
+   * @return The hashcode.
+   */
+  public int hashCode()
+  {
+    return value.hashCode();
+  }
+
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return true if both objects are equal, false otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof CharsetSyntax))
+      return false;
+
+    CharsetSyntax tmp = (CharsetSyntax) obj;    
+    return value.equals(tmp.getValue());
+  }
+
+  /**
+   * Returns a string representing the object. The returned
+   * string is the underlying text value of this object.
+   * 
+   * @return The string representation.
+   */
+  public String toString()
+  {
+    return getValue();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* DefaultValueAttribute.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 gnu.javax.print.ipp.attribute;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * Marker interface for all attribute classes describing attributes 
+ * providing default values. Often there exist a sequence of an
+ * attribute name like: Name - > Name-default -> Name-supported.
+ *
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public interface DefaultValueAttribute extends Attribute
+{  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* DetailedStatusMessage.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 gnu.javax.print.ipp.attribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * DetailedStatusMessage attribute as described in RFC 2911 section
+ * 3.1.6  Operation Response Status Codes and Status Message 
+ * provides a short description of the status of the operation.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class DetailedStatusMessage extends TextSyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>DetailedStatusMessage</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public DetailedStatusMessage(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>DetailedStatusMessage</code> itself.
+   */
+  public Class getCategory()
+  {
+    return DetailedStatusMessage.class;
+  }
+
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "detailed-status-message".
+   */
+  public String getName()
+  {
+    return "detailed-status-message";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* DocumentAccessError.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 gnu.javax.print.ipp.attribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * DocumentAccessError attribute as described in RFC 2911 section
+ * 3.1.6  Operation Response Status Codes and Status Message 
+ * provides additional information for document access errors.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class DocumentAccessError extends TextSyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>DocumentAccessError</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public DocumentAccessError(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>DocumentAccessError</code> itself.
+   */
+  public Class getCategory()
+  {
+    return DocumentAccessError.class;
+  }
+
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "document-access-error".
+   */
+  public String getName()
+  {
+    return "document-access-error";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* NaturalLanguageSyntax.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 gnu.javax.print.ipp.attribute;
+
+import java.io.Serializable;
+
+/**
+ * <code>NaturalLanguageSyntax</code> is the abstract base class of all 
+ * attribute classes which provide a natural language (US-ASCII) 
+ * string as value.
+ *
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public abstract class NaturalLanguageSyntax 
+  implements Cloneable, Serializable
+{
+  private final String value;
+
+  /**
+   * Creates a <code>NaturalLanguageSyntax</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   *
+   * @exception NullPointerException if value is null
+   */
+  protected NaturalLanguageSyntax(String value)
+  {
+    if (value == null)
+      throw new NullPointerException("value may not be null");
+    
+    this.value = value;
+  }
+
+  /**
+   * Returns the value of this syntax object.
+   *
+   * @return The value.
+   */
+  public String getValue()
+  {
+    return value;
+  }
+
+  /**
+   * Returns the hashcode for this object.
+   *
+   * @return The hashcode.
+   */
+  public int hashCode()
+  {
+    return value.hashCode();
+  }
+
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return true if both objects are equal, false otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof NaturalLanguageSyntax))
+      return false;
+
+    NaturalLanguageSyntax tmp = (NaturalLanguageSyntax) obj;    
+    return value.equals(tmp.getValue());
+  }
+
+  /**
+   * Returns a string representing the object. The returned
+   * string is the underlying text value of this object.
+   * 
+   * @return The string representation.
+   */
+  public String toString()
+  {
+    return getValue();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,130 @@
+/* RequestedAttributes.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 gnu.javax.print.ipp.attribute;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * <code>RequestedAttributes</code> specifies the requested
+ * attributes in an IPP request operation.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class RequestedAttributes implements Attribute
+{
+  private ArrayList attributes;
+
+  /**
+   * Creates a <code>RequestedAttributes</code> object with 
+   * the initial value.
+   *
+   * @param value the string for the ipp name
+   *
+   * @exception NullPointerException if value is null
+   */
+  public RequestedAttributes(String value)
+  {
+    if (value == null)
+      throw new NullPointerException();
+    
+    attributes = new ArrayList();      
+    attributes.add(value);
+  }
+  
+  /**
+   * Adds the IPP name value to the set.
+   * 
+   * @param value the string for the ipp name
+   */
+  public void addValue(String value)
+  {
+    attributes.add(value);
+  }
+  
+  /**
+   * Returns the values.
+   * 
+   * @return The values as list.
+   */
+  public List getValues() 
+  {
+    return attributes;    
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>DocumentFormat</code> itself.
+   */
+  public Class getCategory()
+  {
+    return RequestedAttributes.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "requested-attributes".
+   */
+  public String getName()
+  {
+    return "requested-attributes";
+  }
+
+  /**
+   * Returns the string representation for this object.
+   *
+   * @return The string representation.
+   */
+  public String toString()
+  {
+    StringBuffer b = new StringBuffer();
+    
+    if (attributes.size() > 0)
+      b.append(attributes.get(0));
+    
+    for (int i=1; i < attributes.size(); i++)
+      b.append(", " + attributes.get(i));
+    
+    return b.toString();
+  }  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* StatusMessage.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 gnu.javax.print.ipp.attribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * StatusMessage attribute as described in RFC 2911 section
+ * 3.1.6  Operation Response Status Codes and Status Message 
+ * provides a short description of the status of the operation.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class StatusMessage extends TextSyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>StatusMessage</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public StatusMessage(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>StatusMessage</code> itself.
+   */
+  public Class getCategory()
+  {
+    return StatusMessage.class;
+  }
+
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "status-message".
+   */
+  public String getName()
+  {
+    return "status-message";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,190 @@
+/* UnknownAttribute.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 gnu.javax.print.ipp.attribute;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.IppValueTag;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * UnknownAttribute holds all the parsed Attribute information.
+ * It provides methods to get the value-tag, name and value.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class UnknownAttribute implements Attribute
+{
+  private byte tag;
+  private String name;
+  private byte[] value;
+
+  /**
+   * Creates a <code>UnknownAttribute</code> object with the given values.
+   *
+   * @param tag the value tag 
+   * @param name the attribute name
+   * @param value the byte[] with the value
+   */
+  public UnknownAttribute(byte tag, String name, byte[] value)
+  {
+    this.tag = tag;
+    this.name = name;
+    this.value = value;
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>UnknownAttribute</code> itself.
+   */
+  public Class getCategory()
+  {
+    return UnknownAttribute.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name attributes IPP name.
+   */
+  public String getName()
+  {
+    return name;
+  }
+  
+  /**
+   * Returns the value tag
+   * @return The tag.
+   * 
+   * @see gnu.javax.print.ipp.IppValueTag
+   */
+  public byte getValueTag()
+  {
+    return tag;
+  }
+  
+  /**
+   * Returns the name of the attribute.
+   * @return The name.
+   */
+  public String getAttributeName()
+  {
+    return name;
+  }
+  
+  /**
+   * Returns the attribute value origin byte array.
+   * @return The value.
+   */
+  public byte[] getAttributeValue()
+  {
+    return value;
+  }
+  
+  /**
+   * Returns the attribute value decoded as String.
+   * @return The value as String.
+   */
+  public String getAttributeValueAsString()
+  {
+    return new String(value);
+  }
+  
+  /**
+   * Returns the attribute value decoded as int.
+   * @return The value as int.
+   */
+  public int getAttributeValueAsInt()
+  {
+    return IppUtilities.convertToInt(value);
+  }
+    
+  /**
+   * Returns the attribute value decoded as an URI.
+   * @return The value as URI.
+   */
+  public URI getAttributeValueAsUri()
+  {
+    try
+      {
+        return new URI(new String(value));
+      }
+    catch (URISyntaxException e)
+      {
+        return null;
+      }
+  }
+
+  /**
+   * Provides a string representation for some default
+   * tag types (e.g. int, rangeofinteger, string, uri).
+   * For other more complex types "No conversion found."
+   * is returned. 
+   */
+  public String toString()
+  {
+    switch (tag)
+      {
+      case IppValueTag.INTEGER:
+        return "" + getAttributeValueAsInt();
+      case IppValueTag.RANGEOFINTEGER:
+        int lower = IppUtilities.convertToInt(value[0], value[1], 
+                                              value[2], value[3]);
+        int upper = IppUtilities.convertToInt(value[4], value[5], 
+                                              value[6], value[7]);
+        return lower + "-" + upper;
+      case IppValueTag.URI:
+        return getAttributeValueAsUri().toString();
+      case IppValueTag.KEYWORD:
+      case IppValueTag.URI_SCHEME:
+      case IppValueTag.CHARSET:
+      case IppValueTag.NATURAL_LANGUAGE:
+      case IppValueTag.MIME_MEDIA_TYPE:
+      case IppValueTag.NAME_WITHOUT_LANGUAGE:
+      case IppValueTag.TEXT_WITHOUT_LANGUAGE:
+        return getAttributeValueAsString();
+      default:
+        return "No conversion found.";
+      }
+  }  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* CopiesDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.standard.Copies;
+
+/**
+ * <code>CopiesDefault</code> provides the default value
+ * for the copies attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class CopiesDefault extends IntegerSyntax
+  implements DefaultValueAttribute
+{
+    
+  /**
+   * Creates a <code>CopiesDefault</code> object.
+   *
+   * @param value the number of copies
+   *
+   * @exception IllegalArgumentException if value < 1
+   */
+  public CopiesDefault(int value)
+  {
+    super(value);
+
+    if (value < 1)
+      throw new IllegalArgumentException("value may not be less than 1");
+  }
+  
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return <code>true</code> if both objects are equal, 
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if(! (obj instanceof CopiesDefault))
+      return false;
+
+    return super.equals(obj);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>CopiesDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return CopiesDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "copies-default".
+   */
+  public String getName()
+  {
+    return "copies-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * <p>May return null if no value exists in JPS API.</p>
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return new Copies(getValue());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* DocumentFormatDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * <code>DocumentFormatDefault</code> specifies the default document
+ * format of a printer.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ *
+ */
+public final class DocumentFormatDefault extends TextSyntax 
+  implements DefaultValueAttribute
+{
+
+  /**
+   * Creates a <code>DocumentFormatDefault</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public DocumentFormatDefault(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>DocumentFormatDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return DocumentFormatDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "document-format-default".
+   */
+  public String getName()
+  {
+    return "document-format-default";
+  }
+
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return new DocumentFormat(getValue(), getLocale());
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,263 @@
+/* FinishingsDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * The <code>FinishingsDefault</code> attribute provides the supported
+ * values for finishings of a job.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class FinishingsDefault extends EnumSyntax
+  implements DefaultValueAttribute
+{
+
+  /** No finishing. */
+  public static final FinishingsDefault NONE = new FinishingsDefault(3);
+  
+  /** Staple the document(s) */
+  public static final FinishingsDefault STAPLE = new FinishingsDefault(4);
+  
+  /** Cover a document */
+  public static final FinishingsDefault COVER = new FinishingsDefault(6);
+  
+  /**
+   * This value indicates that a binding is to be applied to the document.
+   * The type and placement of the binding is site-defined.
+   */
+  public static final FinishingsDefault BIND = new FinishingsDefault(7);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) 
+   * along the middle fold.  
+   */
+  public static final FinishingsDefault SADDLE_STITCH = new FinishingsDefault(8);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) 
+   * along one edge. 
+   */
+  public static final FinishingsDefault EDGE_STITCH = new FinishingsDefault(9);
+  
+  /** 
+   * Bind the document(s) with one or more staples in the top left 
+   * corner. 
+   */
+  public static final FinishingsDefault STAPLE_TOP_LEFT = new FinishingsDefault(20);
+  
+  /** 
+   * Bind the document(s) with one or more staples in the bottom 
+   * left corner. 
+   */
+  public static final FinishingsDefault STAPLE_BOTTOM_LEFT = new FinishingsDefault(21);
+  
+  /**
+   * Bind the document(s) with one or more staples in the top right corner.
+   */
+  public static final FinishingsDefault STAPLE_TOP_RIGHT = new FinishingsDefault(22);
+  
+  /**
+   * Bind the document(s) with one or more staples in the bottom right corner.
+   */
+  public static final FinishingsDefault STAPLE_BOTTOM_RIGHT = new FinishingsDefault(23);
+  
+  /**
+   * Bind the document(s) with one or more  staples (wire stitches) 
+   * along the left edge.
+   */
+  public static final FinishingsDefault EDGE_STITCH_LEFT = new FinishingsDefault(24);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) along 
+   * the top edge.
+   */
+  public static final FinishingsDefault EDGE_STITCH_TOP = new FinishingsDefault(25);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) along 
+   * the right edge.
+   */
+  public static final FinishingsDefault EDGE_STITCH_RIGHT = new FinishingsDefault(26);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) along
+   * the bottom edge. 
+   */
+  public static final FinishingsDefault EDGE_STITCH_BOTTOM = new FinishingsDefault(27);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * left edge assuming a portrait document.
+   */
+  public static final FinishingsDefault STAPLE_DUAL_LEFT = new FinishingsDefault(28);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * top edge assuming a portrait document.
+   */
+  public static final FinishingsDefault STAPLE_DUAL_TOP = new FinishingsDefault(29);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * right edge assuming a portrait document.
+   */
+  public static final FinishingsDefault STAPLE_DUAL_RIGHT = new FinishingsDefault(30);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * bottom edge assuming a portrait document.
+   */
+  public static final FinishingsDefault STAPLE_DUAL_BOTTOM = new FinishingsDefault(31);
+
+  private static final String[] stringTable = { "none", "staple", null, 
+                                                "cover", "bind", "saddle-stitch",
+                                                "edge-stitch", null, null, null,
+                                                null, null, null, null, null,
+                                                null, null, "staple-top-left",
+                                                "staple-bottom-left", 
+                                                "staple-top-right", 
+                                                "staple-bottom-right",
+                                                "edge-stitch-left",
+                                                "edge-stitch-top",
+                                                "edge-stitch-right",
+                                                "edge-stitch-bottom",
+                                                "staple-dual-left",
+                                                "staple-dual-top",
+                                                "staple-dual-right",
+                                                "staple-dual-bottom" };
+  
+  private static final FinishingsDefault[] enumValueTable = { NONE, STAPLE, null, 
+                                                       COVER, BIND, 
+                                                       SADDLE_STITCH,
+                                                       EDGE_STITCH, null, 
+                                                       null, null, null, 
+                                                       null, null, null, 
+                                                       null, null, null, 
+                                                       STAPLE_TOP_LEFT,
+                                                       STAPLE_BOTTOM_LEFT,
+                                                       STAPLE_TOP_RIGHT,
+                                                       STAPLE_BOTTOM_RIGHT,
+                                                       EDGE_STITCH_LEFT,
+                                                       EDGE_STITCH_TOP,
+                                                       EDGE_STITCH_RIGHT,
+                                                       EDGE_STITCH_BOTTOM,
+                                                       STAPLE_DUAL_LEFT,
+                                                       STAPLE_DUAL_TOP,
+                                                       STAPLE_DUAL_RIGHT,
+                                                       STAPLE_DUAL_BOTTOM };
+  
+  /**
+   * Constructs a <code>FinishingsDefault</code> object.
+   * 
+   * @param value the value
+   */
+  protected FinishingsDefault(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return the class <code>FinishingsDefault</code> itself
+   */
+  public Class getCategory()
+  {
+    return FinishingsDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "finishings-default".
+   */
+  public String getName()
+  {
+    return "finishings-default";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+  /**
+   * Returns the lowest used value by the enumerations of this class.
+   * .
+   * @return The lowest value used.
+   */
+  protected int getOffset()
+  {
+    return 3;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return IppUtilities.getEnumAttribute("finishings", new Integer(getValue()));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,149 @@
+/* JobHoldUntilDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import java.util.Date;
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.JobHoldUntil;
+
+/**
+ * JobHoldUntilDefault attribute provides the default value
+ * for the attribute type job-hold-until.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobHoldUntilDefault extends TextSyntax 
+  implements DefaultValueAttribute
+{
+  
+  // a keyword/name based attribute in IPP 
+  // can be extended by administrators
+  // standard values are predefined
+  
+  /** Job should be printed immediately. */
+  public static final JobHoldUntilDefault NO_HOLD = 
+    new JobHoldUntilDefault("no-hold", null);
+  
+  /** Job should be hold indefinitely. */
+  public static final JobHoldUntilDefault INDEFINITE = 
+    new JobHoldUntilDefault("indefinite", null);
+  
+  /**  Job should be processed during the day. */
+  public static final JobHoldUntilDefault DAY_TIME = 
+    new JobHoldUntilDefault("day-time", null);
+  
+  /**  Job should be processed in the evening. */
+  public static final JobHoldUntilDefault EVENING = 
+    new JobHoldUntilDefault("evening", null);
+  
+  /**  Job should be processed during night. */
+  public static final JobHoldUntilDefault NIGHT = 
+    new JobHoldUntilDefault("night", null);
+  
+  /**  Job should be processed during the weekend. */
+  public static final JobHoldUntilDefault WEEKEND = 
+    new JobHoldUntilDefault("weekend", null);
+  
+  /**  
+   * Job should be processed as second-shift 
+   * (after close of business). 
+   */
+  public static final JobHoldUntilDefault SECOND_SHIFT = 
+    new JobHoldUntilDefault("second-shift", null);
+  
+  /**  
+   * Job should be processed as third-shift 
+   * (after midnight). 
+   */
+  public static final JobHoldUntilDefault THIRD_SHIFT = 
+    new JobHoldUntilDefault("third-shift", null); 
+
+  /**
+   * Creates a <code>JobHoldUntilDefault</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @throws NullPointerException if value is null
+   */
+  public JobHoldUntilDefault(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobHoldUntilDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobHoldUntilDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-hold-until-default".
+   */
+  public String getName()
+  {
+    return "job-hold-until-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    // FIXME Same Mapping problem as in IppPrintService
+    return new JobHoldUntil(new Date());
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* JobPriorityDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.standard.JobPriority;
+
+
+/**
+ * JobPriorityDefault attribute provides the default value of
+ * the printer object for the job-priority attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobPriorityDefault extends IntegerSyntax
+  implements DefaultValueAttribute
+{
+  
+  /**
+   * Creates a <code>JobPriorityDefault</code> object.
+   *
+   * @param value the priority
+   *
+   * @exception IllegalArgumentException if value < 1 or value > 100
+   */
+  public JobPriorityDefault(int value)
+  {
+    super(value);
+
+    if (value < 1 || value > 100)
+      throw new IllegalArgumentException("value out of range");
+  }
+
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return <code>true</code> if both objects are equal, 
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if(! (obj instanceof JobPriorityDefault))
+      return false;
+
+    return super.equals(obj);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobPriorityDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobPriorityDefault.class;
+  }
+
+  /**
+   * Returns name of this class.
+   *
+   * @return The anme "job-priority-default".
+   */
+  public String getName()
+  {
+    return "job-priority-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return new JobPriority(getValue());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,122 @@
+/* JobSheetsDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.JobSheets;
+
+/**
+ * JobSheetsDefault attribute provides the default value of
+ * the printer object for the job-sheets attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobSheetsDefault extends TextSyntax 
+  implements DefaultValueAttribute
+{
+  //a keyword/name based attribute in IPP 
+  // can be extended by administrators
+  // standard values are predefined
+  
+  /** No job sheet is the default */
+  public static final JobSheetsDefault NONE = 
+    new JobSheetsDefault("none", Locale.getDefault());
+  
+  /** A job sheet is the default */
+  public static final JobSheetsDefault STANDARD = 
+    new JobSheetsDefault("standard", Locale.getDefault());
+  
+  /**
+   * Creates a <code>JobSheetsDefault</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @throws NullPointerException if value is null
+   */
+  public JobSheetsDefault(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+ 
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobSheetsDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobSheetsDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-sheets-default".
+   */
+  public String getName()
+  {
+    return "job-sheets-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * <p>May return null if no value exists in JPS API.</p>
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    if (this.equals(JobSheetsDefault.NONE))
+      return JobSheets.NONE;
+    if (this.equals(JobSheetsDefault.STANDARD))
+      return JobSheets.STANDARD;
+    
+    return null;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* MediaDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * MediaDefault attribute provides the default value of
+ * the printer object for the media attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class MediaDefault extends TextSyntax 
+  implements DefaultValueAttribute
+{
+  
+  /**
+   * Creates a <code>MediaDefault</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @throws NullPointerException if value is null
+   */
+  public MediaDefault(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+ 
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>MediaDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return MediaDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "media-default".
+   */
+  public String getName()
+  {
+    return "media-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return IppUtilities.getEnumAttribute("media" , getValue());
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+/* MultipleDocumentHandlingDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * <code>MultipleDocumentHandlingDefault</code> provides the
+ * default value for the MultipleDocumentHandling attribute.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class MultipleDocumentHandlingDefault extends EnumSyntax
+  implements DefaultValueAttribute
+{
+  
+  //a keyword based attribute in IPP - int values just starting at 0
+  
+  /** 
+   * Supports only multiple documents treated as a single document. This 
+   * applies to attributes which specify treatment of multiple document jobs.
+   */
+  public static final MultipleDocumentHandlingDefault SINGLE_DOCUMENT =
+    new MultipleDocumentHandlingDefault(0);
+  
+  /** Supports multiple documents as uncollated copies */
+  public static final MultipleDocumentHandlingDefault SEPARATE_DOCUMENTS_UNCOLLATED_COPIES =
+    new MultipleDocumentHandlingDefault(1);
+  
+  /** Supports multiple documents as collated copies */
+  public static final MultipleDocumentHandlingDefault SEPARATE_DOCUMENTS_COLLATED_COPIES =
+    new MultipleDocumentHandlingDefault(2);
+  
+  /** 
+   * Supports multiple documents where every single document starts
+   * with a new sheet. 
+   */
+  public static final MultipleDocumentHandlingDefault SINGLE_DOCUMENT_NEW_SHEET =
+    new MultipleDocumentHandlingDefault(3);
+
+  private static final String[] stringTable = { "single-document", 
+                                                "separate-documents-uncollated-copies",
+                                                "separate-documents-collated-copies",
+                                                "single-document-new-sheet" };
+  
+  private static final MultipleDocumentHandlingDefault[] enumValueTable = 
+    { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
+      SEPARATE_DOCUMENTS_COLLATED_COPIES, SINGLE_DOCUMENT_NEW_SHEET};
+  
+  /**
+   * Constructs a <code>MultipleDocumentHandlingDefault</code> object.
+   * 
+   * @param value the enum value
+   */
+  protected MultipleDocumentHandlingDefault(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>MultipleDocumentHandlingDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return MultipleDocumentHandlingDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "multiple-document-handling-default".
+   */
+  public String getName()
+  {
+    return "multiple-document-handling-default";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return IppUtilities.getEnumAttribute("multiple-document-handling", 
+                                         new Integer(getValue()));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,114 @@
+/* NumberUpDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.standard.NumberUp;
+
+/**
+ * NumberUpDefault attribute provides the default value of
+ * the numper up attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class NumberUpDefault extends IntegerSyntax
+  implements DefaultValueAttribute
+{
+    
+  /**
+   * Creates a <code>NumberUpDefault</code> object.
+   *
+   * @param value the value
+   * @throws IllegalArgumentException if value < 1
+   */
+  public NumberUpDefault(int value)
+  {
+    super(value);
+  }
+  
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return <code>true</code> if both objects are equal, 
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if(! (obj instanceof NumberUpDefault))
+      return false;
+
+    return super.equals(obj);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>NumberUpDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return NumberUpDefault.class;
+  }
+
+  /**
+   * Returns name of this class.
+   *
+   * @return The name "number-up-default".
+   */
+  public String getName()
+  {
+    return "number-up-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * <p>May return null if no value exists in JPS API.</p>
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return new NumberUp(getValue());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,154 @@
+/* OrientationRequestedDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * The <code>OrientationRequestedDefault</code> attribute provides 
+ * the default value for the job attribute orientation-requested.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class OrientationRequestedDefault extends EnumSyntax
+  implements DefaultValueAttribute
+{
+  
+  /** Orientation as portrait. */
+  public static final OrientationRequestedDefault PORTRAIT =
+    new OrientationRequestedDefault(3);
+  
+  /** Orientation as landscape. */
+  public static final OrientationRequestedDefault LANDSCAPE =
+    new OrientationRequestedDefault(4);
+  
+  /** Orientation as reversed landscape. */
+  public static final OrientationRequestedDefault REVERSE_LANDSCAPE =
+    new OrientationRequestedDefault(5);
+  
+  /** Orientation as reversed portrait. */
+  public static final OrientationRequestedDefault REVERSE_PORTRAIT =
+    new OrientationRequestedDefault(6);
+
+
+  private static final String[] stringTable = { "portrait", "landscape",
+                                                "reverse-landscape",
+                                                "reverse-portrait" };
+  
+  private static final OrientationRequestedDefault[] 
+      enumValueTable = { PORTRAIT, LANDSCAPE, 
+                         REVERSE_LANDSCAPE, REVERSE_PORTRAIT };
+  
+  /**
+   * Constructs a <code>OrientationRequestedDefault</code> object.
+   * 
+   * @param value the value
+   */
+  protected OrientationRequestedDefault(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>OrientationRequestedDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return OrientationRequestedDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "orientation-requested-default".
+   */
+  public String getName()
+  {
+    return "orientation-requested-default";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the lowest used value by the enumerations of this class.
+   * .
+   * @return The lowest value used.
+   */
+  protected int getOffset()
+  {
+    return 3;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return IppUtilities.getEnumAttribute("orientation-requested", 
+                                         new Integer(getValue()));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,141 @@
+/* PrintQualityDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * <code>PrintQualityDefault</code> provides the
+ * default value for the print-quality attribute.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrintQualityDefault extends EnumSyntax
+  implements DefaultValueAttribute
+{
+  /** Draft quality of the printer. */
+  public static final PrintQualityDefault DRAFT = new PrintQualityDefault(3);
+  
+  /** Normal quality of the printer. */
+  public static final PrintQualityDefault NORMAL = new PrintQualityDefault(4);
+  
+  /** High quality of the printer. */
+  public static final PrintQualityDefault HIGH = new PrintQualityDefault(5);
+
+  private static final String[] stringTable = { "draft", "normal", "high" };
+  
+  private static final PrintQualityDefault[] enumValueTable = { DRAFT, NORMAL, HIGH };
+  
+  /**
+   * Constructs a <code>PrintQualityDefault</code> object.
+   * 
+   * @param value the value of the enum
+   */
+  protected PrintQualityDefault(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrintQualityDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrintQualityDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "print-quality-default".
+   */
+  public String getName()
+  {
+    return "print-quality-default";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the lowest used value by the enumerations of this class.
+   * .
+   * @return The lowest value used.
+   */
+  protected int getOffset()
+  {
+    return 3;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return IppUtilities.getEnumAttribute(
+      "print-quality", new Integer(getValue()));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,119 @@
+/* PrinterResolutionDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.standard.PrinterResolution;
+
+
+/**
+ * The <code>PrinterResolutionDefault</code> attribute provides 
+ * the default value for the job attribute printer-resolution.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterResolutionDefault extends ResolutionSyntax
+  implements DefaultValueAttribute
+{
+  
+  /**
+   * Creates a <code>ResolutionSyntax</code> object with the given arguments.
+   *
+   * @param crossFeedResolution the cross feed resolution
+   * @param feedResolution the feed resolution
+   * @param units the unit to use (e.g. {@link #DPCM} or {@link #DPI})
+   *
+   * @exception IllegalArgumentException if preconditions fail
+   */
+  public PrinterResolutionDefault(int crossFeedResolution, int feedResolution,
+                           int units)
+  {
+    super(crossFeedResolution, feedResolution, units);
+  }
+  
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return <code>true</code> if both objects are equal, 
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if(! (obj instanceof PrinterResolutionDefault))
+      return false;
+    
+    return super.equals(obj);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterResolutionDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterResolutionDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-resolution-default".
+   */
+  public String getName()
+  {
+    return "printer-resolution-default";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return new PrinterResolution(getCrossFeedResolutionDphi(), 
+                                 getFeedResolutionDphi(), 1);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,150 @@
+/* SidesDefault.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 gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * <code>SidesDefault</code> provides the
+ * default for the sides attribute.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class SidesDefault extends EnumSyntax
+  implements DefaultValueAttribute
+{
+  
+  /** Specifies that each page should be printed on one sheet. */
+  public static final SidesDefault ONE_SIDED = new SidesDefault(0);
+  
+  /** 
+   * Specifies that two following pages should be printed on the 
+   * front and back of one sheet for binding on the long edge.
+   */
+  public static final SidesDefault TWO_SIDED_LONG_EDGE = 
+    new SidesDefault(1);
+  
+  /** 
+   * Specifies that two following pages should be printed on the 
+   * front and back of one sheet for binding on the short edge.
+   */
+  public static final SidesDefault TWO_SIDED_SHORT_EDGE = 
+    new SidesDefault(2);
+  
+  /** An alias constant for "two sided long edge". */
+  public static final SidesDefault DUPLEX = new SidesDefault(1);
+  
+  /** An alias constant for "two sided short edge". */
+  public static final SidesDefault TUMBLE = new SidesDefault(2);
+
+  private static final String[] stringTable = { "one-sided", 
+                                                "two-sided-long-edge",
+                                                "two-sided-short-edge" };
+  
+  private static final SidesDefault[] enumValueTable = { ONE_SIDED, 
+                                                         TWO_SIDED_LONG_EDGE, 
+                                                         TWO_SIDED_SHORT_EDGE };
+  
+  
+  /**
+   * Creates a <code>SidesDefault</code> object.
+   *
+   * @param value the value of the enum
+   */
+  protected SidesDefault(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>SidesDefault</code> itself.
+   */
+  public Class getCategory()
+  {
+    return SidesDefault.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "sides-default".
+   */
+  public String getName()
+  {
+    return "sides-default";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this DefaultValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Attribute getAssociatedAttribute() 
+  {
+    return IppUtilities.getEnumAttribute("sides", new Integer(getValue()));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* AttributesCharset.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 gnu.javax.print.ipp.attribute.job;
+
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * AttributesCharset attribute as described in RFC 2911 chapter
+ * 3.1.4 Character Set and Natural Language Operation Attributes.
+ * <p>
+ * This operation attribute identifies the charset used by any text 
+ * and name attribute supplied by the client in the request. This
+ * charset must be used by the printer object in the response.<br>
+ * All clients and IPP objects must support the 'utf-8' charset.
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class AttributesCharset extends CharsetSyntax 
+  implements Attribute
+{
+  
+  /** Defines a default UTF-8 charset instance */
+  public static final AttributesCharset UTF8 = new AttributesCharset("utf-8");
+
+  /**
+   * Creates a <code>AttributesCharset</code> object.
+   * 
+   * @param value the charset string value.
+   */
+  public AttributesCharset(String value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>AttributesCharset</code> itself.
+   */
+  public Class getCategory()
+  {
+    return AttributesCharset.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "attributes-charset".
+   */
+  public String getName()
+  {
+    return "attributes-charset";
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* AttributesNaturalLanguage.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 gnu.javax.print.ipp.attribute.job;
+
+
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * AttributesNaturalLanguage attribute as described in RFC 2911 chapter
+ * 3.1.4 Character Set and Natural Language Operation Attributes.
+ * <p>
+ * This operation attribute identifies the natural language used
+ * by any text and name attribute supplied by the client in the request.
+ * The printer object should use this natural language for the response 
+ * to this request.
+ * </p>
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class AttributesNaturalLanguage extends NaturalLanguageSyntax 
+  implements Attribute
+{
+  
+  /** Defines the default language EN */
+  public static final AttributesNaturalLanguage EN = 
+    new AttributesNaturalLanguage("en");
+
+  /**
+   * Creates a <code>AttributesNaturalLanguage</code> object.
+   * 
+   * @param value the language string value.
+   */
+  public AttributesNaturalLanguage(String value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>AttributesNaturalLanguage</code> itself.
+   */
+  public Class getCategory()
+  {
+    return AttributesNaturalLanguage.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "attributes-natural-language".
+   */
+  public String getName()
+  {
+    return "attributes-natural-language";
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* JobDetailedStatusMessages.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 gnu.javax.print.ipp.attribute.job;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobDetailedStatusMessages provides additional detailed and
+ * technical job informations.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobDetailedStatusMessages 
+  extends TextSyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>JobDetailedStatusMessages</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public JobDetailedStatusMessages(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobDetailedStatusMessages</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobDetailedStatusMessages.class;
+  }
+
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-detailed-status-messages".
+   */
+  public String getName()
+  {
+    return "job-detailed-status-messages";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* JobDocumentAccessErrors.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 gnu.javax.print.ipp.attribute.job;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobDocumentAccessErrors provides additional information
+ * for each access error for print-uri or document-uri jobs.
+ * technical job informations.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobDocumentAccessErrors 
+  extends TextSyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>JobDocumentAccessErrors</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public JobDocumentAccessErrors(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobDocumentAccessErrors</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobDocumentAccessErrors.class;
+  }
+
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-document-access-errors".
+   */
+  public String getName()
+  {
+    return "job-document-access-errors";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* JobId.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 gnu.javax.print.ipp.attribute.job;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+
+/**
+ * The <code>JobId</code> attribute contains the ID of a
+ * print job created or currently being processed.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobId extends IntegerSyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>IntegerSyntax</code> with the given value.
+   *
+   * @param value the integer to set
+   * @throws IllegalArgumentException if value is < 1
+   */
+  public JobId(int value)
+  {
+    super(value);
+    
+    if (value < 1)
+      throw new IllegalArgumentException("job-id may not be less than 1");
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobId</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobId.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-id".
+   */
+  public String getName()
+  {
+    return "job-id";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* JobMoreInfo.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 gnu.javax.print.ipp.attribute.job;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * JobMoreInfo attribute as described in RFC 2911 section
+ * 4.3.4 contains the URI where more information about a job
+ * (e.g. through a HTML page) can be found.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobMoreInfo extends URISyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>JobMoreInfo</code> object.
+   *
+   * @param uri the URI value for the syntax
+   * @throws NullPointerException if uri is null
+   */
+  public JobMoreInfo(URI uri)
+  {
+    super(uri);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobMoreInfo</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobMoreInfo.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-more-info".
+   */
+  public String getName()
+  {
+    return "job-more-info";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* JobPrinterUri.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 gnu.javax.print.ipp.attribute.job;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * JobPrinterUri attribute as described in RFC 2911 section
+ * 4.3.3 contains the URI of the printer which created and
+ * processes a job.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobPrinterUri extends URISyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>JobPrinterUri</code> object.
+   *
+   * @param uri the URI value for the syntax
+   * @throws NullPointerException if uri is null
+   */
+  public JobPrinterUri(URI uri)
+  {
+    super(uri);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobPrinterUri</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobPrinterUri.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-printer-uri".
+   */
+  public String getName()
+  {
+    return "job-printer-uri";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* JobStateMessage.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 gnu.javax.print.ipp.attribute.job;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobStateMessage attribute describes information about the
+ * job-state and job-state-reasons in human readable form.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobStateMessage 
+  extends TextSyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>JobStateMessage</code> object with the given value
+   * and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public JobStateMessage(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobStateMessage</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobStateMessage.class;
+  }
+
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-state-message".
+   */
+  public String getName()
+  {
+    return "job-state-message";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* JobUri.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 gnu.javax.print.ipp.attribute.job;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * JobUri attribute as described in RFC 2911 section
+ * 4.3.1 contains the URI for a job generated by the printer
+ * after a create request.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobUri extends URISyntax implements Attribute
+{
+
+  /**
+   * Creates a <code>JobUri</code> object.
+   *
+   * @param uri the URI value for the syntax
+   * @throws NullPointerException if uri is null
+   */
+  public JobUri(URI uri)
+  {
+    super(uri);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobUri</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobUri.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-uri".
+   */
+  public String getName()
+  {
+    return "job-uri";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* CharsetConfigured.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 gnu.javax.print.ipp.attribute.printer;
+
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * CharsetConfigured attribute as described in RFC 2911 section
+ * 4.4.17 provides the charset which is configured by the
+ * server to be used in the name and text syntax attribute types.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class CharsetConfigured extends CharsetSyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>CharsetConfigured</code> object.
+   * 
+   * @param value the charset string value.
+   */
+  public CharsetConfigured(String value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>CharsetConfigured</code> itself.
+   */
+  public Class getCategory()
+  {
+    return CharsetConfigured.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "charset-configured".
+   */
+  public String getName()
+  {
+    return "charset-configured";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* DocumentFormat.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 gnu.javax.print.ipp.attribute.printer;
+
+import java.util.Locale;
+
+import javax.print.DocFlavor;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * <code>DocumentFormatSupported</code> specifies the supported document
+ * formats of a printer. Printer are supplying a set of this attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class DocumentFormat extends TextSyntax 
+  implements SupportedValuesAttribute
+{
+
+  /**
+   * Creates a <code>DocumentFormat</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public DocumentFormat(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+  
+  /**
+   * Constructs a document format object for the given flavor.
+   * The constructor reworkes the mimetype of the given flavor
+   * to remove the quoted charset parameter if present.
+   * 
+   * @param flavor the flavor with the mimetype
+   * @return The created document format.
+   */
+  public static DocumentFormat createDocumentFormat(DocFlavor flavor)
+  {
+    String charset = flavor.getParameter("charset");
+    String mimetype = flavor.getMediaType() + "/" + flavor.getMediaSubtype();
+    if (charset != null)
+      mimetype += "; charset=" + charset;
+    
+    return new DocumentFormat(mimetype, null);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>DocumentFormat</code> itself.
+   */
+  public Class getCategory()
+  {
+    return DocumentFormat.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "document-format".
+   */
+  public String getName()
+  {
+    return "document-format";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* MultipleOperationTimeOut.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 gnu.javax.print.ipp.attribute.printer;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+
+/**
+ * MultipleOperationTimeOut attribute as described in RFC 2911 section
+ * 4.4.31 provides the minimum time ins second a printer object waits
+ * before time out and recovery. The printer object waits e.g. for
+ * additional SendDocument or SendUri operations.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class MultipleOperationTimeOut extends IntegerSyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>MultipleOperationTimeOut</code> with the given value.
+   *
+   * @param value the integer to set
+   */
+  public MultipleOperationTimeOut(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>MultipleOperationTimeOut</code> itself.
+   */
+  public Class getCategory()
+  {
+    return MultipleOperationTimeOut.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "multiple-operation-time-out".
+   */
+  public String getName()
+  {
+    return "multiple-operation-time-out";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* NaturalLanguageConfigured.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 gnu.javax.print.ipp.attribute.printer;
+
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * NaturalLanguageConfigured attribute as described in RFC 2911 
+ * section 4.4.19 provides the natural language which is configured
+ * by the server to be used in the name and text syntax attribute types.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class NaturalLanguageConfigured extends NaturalLanguageSyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>NaturalLanguageConfigured</code> object.
+   * 
+   * @param value the charset string value.
+   */
+  public NaturalLanguageConfigured(String value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>NaturalLanguageConfigured</code> itself.
+   */
+  public Class getCategory()
+  {
+    return NaturalLanguageConfigured.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "natural-language-configured".
+   */
+  public String getName()
+  {
+    return "natural-language-configured";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* PrinterCurrentTime.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 gnu.javax.print.ipp.attribute.printer;
+
+import java.util.Date;
+
+import javax.print.attribute.DateTimeSyntax;
+import javax.print.attribute.PrintServiceAttribute;
+
+/**
+ * PrinterCurrentTime attribute as described in RFC 2911 section
+ * 4.4.30 provides the current time of the print service.
+ * Its to be used by other attributes like the date-time-at-xxx
+ * attributes in the creation process.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterCurrentTime extends DateTimeSyntax 
+  implements PrintServiceAttribute
+{
+
+  /**
+   * Creates a <code>PrinterCurrentTime</code> object.
+   *
+   * @param value the date at creation time
+   *
+   * @exception NullPointerException if value is null
+   */
+  public PrinterCurrentTime(Date value)
+  {
+    super(value);
+  }
+
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return <code>true</code> if both objects are equal, 
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if(! (obj instanceof PrinterCurrentTime))
+      return false;
+
+    return super.equals(obj);
+  }
+  
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterCurrentTime</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterCurrentTime.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-current-time".
+   */
+  public String getName()
+  {
+    return "printer-current-time";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* PrinterDriverInstaller.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 gnu.javax.print.ipp.attribute.printer;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * PrinterDriverInstaller attribute as described in RFC 2911 section
+ * 4.4.81 provides the URI where a printer driver installer
+ * can be found.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterDriverInstaller extends URISyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>PrinterDriverInstaller</code> object.
+   *
+   * @param uri the URI value for the syntax
+   * @throws NullPointerException if uri is null
+   */
+  public PrinterDriverInstaller(URI uri)
+  {
+    super(uri);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterDriverInstaller</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterDriverInstaller.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-driver-installer".
+   */
+  public String getName()
+  {
+    return "printer-driver-installer";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* PrinterStateMessage.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 gnu.javax.print.ipp.attribute.printer;
+
+import java.util.Locale;
+
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * PrinterStateMessage attribute as described in RFC 2911 section
+ * 4.4.13 provides a textual representation of the attributes
+ * printer-state and printer-state-reasons for consumption by
+ * humans.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterStateMessage extends TextSyntax 
+  implements PrintServiceAttribute
+{
+
+  /**
+   * Creates a <code>PrinterStateMessage</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public PrinterStateMessage(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterStateMessage</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterStateMessage.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-state-message".
+   */
+  public String getName()
+  {
+    return "printer-state-message";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* PrinterUpTime.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 gnu.javax.print.ipp.attribute.printer;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+
+/**
+ * PrinterUpTime attribute as described in RFC 2911 section
+ * 4.4.29 provides the uptime of the printer object. This
+ * is a value in second starting at 1 after a initialization 
+ * or reboot of the printer object.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterUpTime extends IntegerSyntax 
+  implements Attribute
+{
+
+  /**
+   * Creates a <code>PrinterUpTime</code> with the given value.
+   *
+   * @param value the integer to set
+   */
+  public PrinterUpTime(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterUpTime</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterUpTime.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-up-time".
+   */
+  public String getName()
+  {
+    return "printer-up-time";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* CharsetSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * CharsetSupported attribute as described in RFC 2911 section
+ * 4.4.18 provides the charset which are supported by the
+ * IPP implementation to be used in the name and text syntax 
+ * attribute types.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class CharsetSupported extends CharsetSyntax 
+  implements SupportedValuesAttribute
+{
+
+  /**
+   * Creates a <code>CharsetSupported</code> object.
+   * 
+   * @param value the charset string value.
+   */
+  public CharsetSupported(String value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>CharsetSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return CharsetSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "charset-supported".
+   */
+  public String getName()
+  {
+    return "charset-supported";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,162 @@
+/* CompressionSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.Compression;
+
+
+/**
+ * <code>CompressionSupported</code> provides the values which are
+ * supported for the compression attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class CompressionSupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+  
+  /** The print data is not compressed. */
+  public static final CompressionSupported NONE = new CompressionSupported(0);
+  
+  /** The print data is ZIP compressed. */
+  public static final CompressionSupported DEFLATE = new CompressionSupported(1);
+  
+  /** The print data is GNU Zip compressed. */
+  public static final CompressionSupported GZIP = new CompressionSupported(2);
+  
+  /** The print data is UNIX compressed. */
+  public static final CompressionSupported COMPRESS = new CompressionSupported(3);
+  
+  private static final String[] stringTable = { "none", "deflate", 
+                                                "gzip", "compress" };
+  
+  private static final CompressionSupported[] enumValueTable = { NONE, DEFLATE, 
+                                                        GZIP, COMPRESS };
+
+  /**
+   * Constructs a <code>CompressionSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  protected CompressionSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>CompressionSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return CompressionSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "compression-supported".
+   */
+  public String getName()
+  {
+    return "compression-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Compression getAssociatedAttribute() 
+  {
+    return (Compression) IppUtilities.getEnumAttribute(
+            "compression", new Integer(getValue()));
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static Compression[] getAssociatedAttributeArray(Set set) 
+  {
+    CompressionSupported tmp;
+    Compression[] result = new Compression[set.size()];      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (CompressionSupported) it.next();
+        result[j] = tmp.getAssociatedAttribute();
+        j++;
+      }            
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* DocumentFormatSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import java.util.Locale;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * <code>DocumentFormatSupported</code> specifies the supported document
+ * formats of a printer. Printer are supplying a set of this attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class DocumentFormatSupported extends TextSyntax 
+  implements SupportedValuesAttribute
+{
+
+  /**
+   * Creates a <code>DocumentFormatSupported</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @exception NullPointerException if value is null
+   */
+  public DocumentFormatSupported(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>DocumentFormatSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return DocumentFormatSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "document-format-supported".
+   */
+  public String getName()
+  {
+    return "document-format-supported";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,303 @@
+/* FinishingsSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.Finishings;
+
+
+/**
+ * The <code>FinishingsSupported</code> attribute provides the supported
+ * values for finishings of a job.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class FinishingsSupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+
+  /** No finishing. */
+  public static final FinishingsSupported NONE = new FinishingsSupported(3);
+  
+  /** Staple the document(s) */
+  public static final FinishingsSupported STAPLE = new FinishingsSupported(4);
+  
+  /** Cover a document */
+  public static final FinishingsSupported COVER = new FinishingsSupported(6);
+  
+  /**
+   * This value indicates that a binding is to be applied to the document.
+   * The type and placement of the binding is site-defined.
+   */
+  public static final FinishingsSupported BIND = new FinishingsSupported(7);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) 
+   * along the middle fold.  
+   */
+  public static final FinishingsSupported SADDLE_STITCH = 
+    new FinishingsSupported(8);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) 
+   * along one edge. 
+   */
+  public static final FinishingsSupported EDGE_STITCH = 
+    new FinishingsSupported(9);
+  
+  /** 
+   * Bind the document(s) with one or more staples in the top left 
+   * corner. 
+   */
+  public static final FinishingsSupported STAPLE_TOP_LEFT = 
+    new FinishingsSupported(20);
+  
+  /** 
+   * Bind the document(s) with one or more staples in the bottom 
+   * left corner. 
+   */
+  public static final FinishingsSupported STAPLE_BOTTOM_LEFT = 
+    new FinishingsSupported(21);
+  
+  /**
+   * Bind the document(s) with one or more staples in the top right corner.
+   */
+  public static final FinishingsSupported STAPLE_TOP_RIGHT = 
+    new FinishingsSupported(22);
+  
+  /**
+   * Bind the document(s) with one or more staples in the bottom right corner.
+   */
+  public static final FinishingsSupported STAPLE_BOTTOM_RIGHT = 
+    new FinishingsSupported(23);
+  
+  /**
+   * Bind the document(s) with one or more  staples (wire stitches) 
+   * along the left edge.
+   */
+  public static final FinishingsSupported EDGE_STITCH_LEFT = 
+    new FinishingsSupported(24);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) along 
+   * the top edge.
+   */
+  public static final FinishingsSupported EDGE_STITCH_TOP = 
+    new FinishingsSupported(25);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) along 
+   * the right edge.
+   */
+  public static final FinishingsSupported EDGE_STITCH_RIGHT = 
+    new FinishingsSupported(26);
+  
+  /**
+   * Bind the document(s) with one or more staples (wire stitches) along
+   * the bottom edge. 
+   */
+  public static final FinishingsSupported EDGE_STITCH_BOTTOM = 
+    new FinishingsSupported(27);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * left edge assuming a portrait document.
+   */
+  public static final FinishingsSupported STAPLE_DUAL_LEFT = 
+    new FinishingsSupported(28);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * top edge assuming a portrait document.
+   */
+  public static final FinishingsSupported STAPLE_DUAL_TOP = 
+    new FinishingsSupported(29);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * right edge assuming a portrait document.
+   */
+  public static final FinishingsSupported STAPLE_DUAL_RIGHT = 
+    new FinishingsSupported(30);
+  
+  /**
+   * Bind the document(s) with two staples (wire stitches) along the 
+   * bottom edge assuming a portrait document.
+   */
+  public static final FinishingsSupported STAPLE_DUAL_BOTTOM = 
+    new FinishingsSupported(31);
+
+  private static final String[] stringTable = { "none", "staple", null, 
+                                                "cover", "bind", "saddle-stitch",
+                                                "edge-stitch", null, null, null,
+                                                null, null, null, null, null,
+                                                null, null, "staple-top-left",
+                                                "staple-bottom-left", 
+                                                "staple-top-right", 
+                                                "staple-bottom-right",
+                                                "edge-stitch-left",
+                                                "edge-stitch-top",
+                                                "edge-stitch-right",
+                                                "edge-stitch-bottom",
+                                                "staple-dual-left",
+                                                "staple-dual-top",
+                                                "staple-dual-right",
+                                                "staple-dual-bottom" };
+  
+  private static final FinishingsSupported[] enumValueTable = { NONE, STAPLE, 
+                                                       null, COVER, BIND, 
+                                                       SADDLE_STITCH,
+                                                       EDGE_STITCH, null, 
+                                                       null, null, null, 
+                                                       null, null, null, 
+                                                       null, null, null, 
+                                                       STAPLE_TOP_LEFT,
+                                                       STAPLE_BOTTOM_LEFT,
+                                                       STAPLE_TOP_RIGHT,
+                                                       STAPLE_BOTTOM_RIGHT,
+                                                       EDGE_STITCH_LEFT,
+                                                       EDGE_STITCH_TOP,
+                                                       EDGE_STITCH_RIGHT,
+                                                       EDGE_STITCH_BOTTOM,
+                                                       STAPLE_DUAL_LEFT,
+                                                       STAPLE_DUAL_TOP,
+                                                       STAPLE_DUAL_RIGHT,
+                                                       STAPLE_DUAL_BOTTOM };
+  
+  /**
+   * Constructs a <code>FinishingsSupported</code> object.
+   * 
+   * @param value the value
+   */
+  protected FinishingsSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return the class <code>FinishingsSupported</code> itself
+   */
+  public Class getCategory()
+  {
+    return FinishingsSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "finishings-supported".
+   */
+  public String getName()
+  {
+    return "finishings-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+  /**
+   * Returns the lowest used value by the enumerations of this class.
+   * .
+   * @return The lowest value used.
+   */
+  protected int getOffset()
+  {
+    return 3;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public Finishings getAssociatedAttribute() 
+  {
+    return (Finishings) IppUtilities.getEnumAttribute(
+           "finishings", new Integer(getValue()));
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static Finishings[] getAssociatedAttributeArray(Set set) 
+  {
+    FinishingsSupported tmp;
+    Finishings[] result = new Finishings[set.size()];      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (FinishingsSupported) it.next();
+        result[j] = tmp.getAssociatedAttribute();
+        j++;
+      }            
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* GeneratedNaturalLanguageSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * GeneratedNaturalLanguageSupported attribute as described 
+ * in RFC 2911 section 4.4.20 provides the natural languages
+ * which are supported by the IPP implementation to be used 
+ * in the name and text syntax attribute types.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class GeneratedNaturalLanguageSupported 
+  extends NaturalLanguageSyntax 
+  implements SupportedValuesAttribute
+{
+
+  /**
+   * Creates a <code>GeneratedNaturalLanguageSupported</code> object.
+   * 
+   * @param value the charset string value.
+   */
+  public GeneratedNaturalLanguageSupported(String value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>GeneratedNaturalLanguageSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return GeneratedNaturalLanguageSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "generated-natural-language-supported".
+   */
+  public String getName()
+  {
+    return "generated-natural-language-supported";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* IppVersionsSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * IppVersionsSupported attribute as described in RFC 2911 section
+ * 4.4.14 provides the value(s) (implemented as EnumSyntax)
+ * of the supported IPP versions.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class IppVersionsSupported extends EnumSyntax 
+  implements SupportedValuesAttribute
+{
+  
+  // a keyword based attribute in IPP - int values just starting at 0
+  
+  /** IPP version 1.0 */
+  public static final IppVersionsSupported V_1_0 = 
+    new IppVersionsSupported(0);
+  
+  /** IPP version 1.1 */
+  public static final IppVersionsSupported V_1_1 = 
+    new IppVersionsSupported(1);
+  
+  private static final String[] stringTable = { "1.0", "1.1" };
+  
+  private static final IppVersionsSupported[] enumValueTable = { V_1_0, 
+                                                                 V_1_1 };
+
+  /**
+   * Constructs a <code>IppVersionsSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  public IppVersionsSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>IppVersionsSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return IppVersionsSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "ipp-versions-supported".
+   */
+  public String getName()
+  {
+    return "ipp-versions-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,133 @@
+/* JobHoldUntilSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import java.util.Locale;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobHoldUntilSupported attribute provides the supported
+ * values for the attribute type job-hold-until.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobHoldUntilSupported extends TextSyntax 
+  implements SupportedValuesAttribute
+{
+  
+  // a keyword/name based attribute in IPP 
+  // can be extended by administrators
+  // standard values are predefined
+  
+  /** Job should be printed immediately. */
+  public static final JobHoldUntilSupported NO_HOLD = 
+    new JobHoldUntilSupported("no-hold", null);
+  
+  /** Job should be hold indefinitely. */
+  public static final JobHoldUntilSupported INDEFINITE = 
+    new JobHoldUntilSupported("indefinite", null);
+  
+  /**  Job should be processed during the day. */
+  public static final JobHoldUntilSupported DAY_TIME = 
+    new JobHoldUntilSupported("day-time", null);
+  
+  /**  Job should be processed in the evening. */
+  public static final JobHoldUntilSupported EVENING = 
+    new JobHoldUntilSupported("evening", null);
+  
+  /**  Job should be processed during night. */
+  public static final JobHoldUntilSupported NIGHT = 
+    new JobHoldUntilSupported("night", null);
+  
+  /**  Job should be processed during the weekend. */
+  public static final JobHoldUntilSupported WEEKEND = 
+    new JobHoldUntilSupported("weekend", null);
+  
+  /**  
+   * Job should be processed as second-shift 
+   * (after close of business). 
+   */
+  public static final JobHoldUntilSupported SECOND_SHIFT = 
+    new JobHoldUntilSupported("second-shift", null);
+  
+  /**  
+   * Job should be processed as third-shift 
+   * (after midnight). 
+   */
+  public static final JobHoldUntilSupported THIRD_SHIFT = 
+    new JobHoldUntilSupported("third-shift", null); 
+
+  /**
+   * Creates a <code>JobHoldUntilSupported</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @throws NullPointerException if value is null
+   */
+  public JobHoldUntilSupported(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobHoldUntilSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobHoldUntilSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-hold-until-supported".
+   */
+  public String getName()
+  {
+    return "job-hold-until-supported";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,150 @@
+/* JobSheetsSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.JobSheets;
+
+/**
+ * JobSheetsSupported attribute provides the supported values
+ * of the job-sheets attribute.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class JobSheetsSupported extends TextSyntax 
+    implements SupportedValuesAttribute
+{
+  //a keyword/name based attribute in IPP 
+  // can be extended by administrators
+  // standard values are predefined
+  
+  /** No job sheet is the default */
+  public static final JobSheetsDefault NONE = 
+    new JobSheetsDefault("none", Locale.getDefault());
+  
+  /** A job sheet is the default */
+  public static final JobSheetsDefault STANDARD = 
+    new JobSheetsDefault("standard", Locale.getDefault());
+  
+  /**
+   * Creates a <code>JobSheetsSupported</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @throws NullPointerException if value is null
+   */
+  public JobSheetsSupported(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+ 
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>JobSheetsSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return JobSheetsSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "job-sheets-supported".
+   */
+  public String getName()
+  {
+    return "job-sheets-supported";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * <p>May return null if no value exists in JPS API.</p>
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public JobSheets getAssociatedAttribute() 
+  {
+    if (this.equals(JobSheetsDefault.NONE))
+      return JobSheets.NONE;
+    if (this.equals(JobSheetsDefault.STANDARD))
+      return JobSheets.STANDARD;
+    
+    return null;
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static JobSheets[] getAssociatedAttributeArray(Set set) 
+  {
+    JobSheetsSupported tmp;
+    ArrayList result = new ArrayList();      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (JobSheetsSupported) it.next();
+        Attribute att = tmp.getAssociatedAttribute();
+        if (att != null)
+          result.add(att);
+        j++;
+      }            
+    return (JobSheets[]) result.toArray(new JobSheets[result.size()]);
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* MediaSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.Media;
+
+/**
+ * MediaSupported attribute provides the keyword values
+ * of the media types supported by the printer object.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class MediaSupported extends TextSyntax 
+    implements SupportedValuesAttribute
+{
+
+  /**
+   * Creates a <code>MediaSupported</code> object with the 
+   * given value and locale.
+   *
+   * @param value the value for this syntax
+   * @param locale the locale to use, if <code>null</code> the default
+   * locale is used.
+   *
+   * @throws NullPointerException if value is null
+   */
+  public MediaSupported(String value, Locale locale)
+  {
+    super(value, locale);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>MediaSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return MediaSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "media-supported".
+   */
+  public String getName()
+  {
+    return "media-supported";
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   */
+  public static Media[] getAssociatedAttributeArray(Set set) 
+  {
+    MediaSupported tmp;
+    Media tmp2;
+    ArrayList result = new ArrayList();          
+    Iterator it = set.iterator();
+    while (it.hasNext())
+      {
+        tmp = (MediaSupported) it.next();
+        tmp2 = (Media) IppUtilities.getEnumAttribute("media", tmp.toString());
+        if (tmp2 != null)
+          result.add(tmp2);
+      }            
+    return (Media[]) result.toArray(new Media[result.size()]);
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,177 @@
+/* MultipleDocumentHandlingSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+
+
+/**
+ * <code>MultipleDocumentHandlingSupported</code> provides the
+ * supported values for the MultipleDocumentHandling attribute.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class MultipleDocumentHandlingSupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+  
+  //a keyword based attribute in IPP - int values just starting at 0
+  
+  /** 
+   * Supports only multiple documents treated as a single document. This 
+   * applies to attributes which specify treatment of multiple document jobs.
+   */
+  public static final MultipleDocumentHandlingSupported SINGLE_DOCUMENT =
+    new MultipleDocumentHandlingSupported(0);
+  
+  /** Supports multiple documents as uncollated copies */
+  public static final MultipleDocumentHandlingSupported SEPARATE_DOCUMENTS_UNCOLLATED_COPIES =
+    new MultipleDocumentHandlingSupported(1);
+  
+  /** Supports multiple documents as collated copies */
+  public static final MultipleDocumentHandlingSupported SEPARATE_DOCUMENTS_COLLATED_COPIES =
+    new MultipleDocumentHandlingSupported(2);
+  
+  /** 
+   * Supports multiple documents where every single document starts
+   * with a new sheet. 
+   */
+  public static final MultipleDocumentHandlingSupported SINGLE_DOCUMENT_NEW_SHEET =
+    new MultipleDocumentHandlingSupported(3);
+
+  private static final String[] stringTable = { "single-document", 
+                                                "separate-documents-uncollated-copies",
+                                                "separate-documents-collated-copies",
+                                                "single-document-new-sheet" };
+  
+  private static final MultipleDocumentHandlingSupported[] enumValueTable = 
+    { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
+      SEPARATE_DOCUMENTS_COLLATED_COPIES, SINGLE_DOCUMENT_NEW_SHEET};
+  
+  /**
+   * Constructs a <code>MultipleDocumentHandlingSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  protected MultipleDocumentHandlingSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>MultipleDocumentHandlingSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return MultipleDocumentHandlingSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "multiple-document-handling-supported".
+   */
+  public String getName()
+  {
+    return "multiple-document-handling-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public MultipleDocumentHandling getAssociatedAttribute() 
+  {
+    return (MultipleDocumentHandling) IppUtilities.getEnumAttribute(
+            "multiple-document-handling", new Integer(getValue()));
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static MultipleDocumentHandling[] getAssociatedAttributeArray(Set set)
+  {
+    MultipleDocumentHandlingSupported tmp;
+    MultipleDocumentHandling[] result = new MultipleDocumentHandling[set.size()];      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (MultipleDocumentHandlingSupported) it.next();
+        result[j] = tmp.getAssociatedAttribute();
+        j++;
+      }            
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* MultipleDocumentJobsSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * <code>MultipleDocumentJobsSupported</code> specifies if a printer
+ * supported multiple documents in one job.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public class MultipleDocumentJobsSupported extends EnumSyntax 
+  implements SupportedValuesAttribute
+{
+  
+  /** Multiple documents per job are not supported. */
+  public static final MultipleDocumentJobsSupported NOT_SUPPORTED = 
+    new MultipleDocumentJobsSupported(0);
+  
+  /** Multiple documents per job are supported. */
+  public static final MultipleDocumentJobsSupported SUPPORTED = 
+    new MultipleDocumentJobsSupported(1);
+
+  private static final String[] stringTable = { "not-supported", "supported" };
+  
+  private static final MultipleDocumentJobsSupported[] enumValueTable = 
+    { NOT_SUPPORTED, SUPPORTED };
+  
+  /**
+   * Constructs a <code>MultipleDocumentJobsSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  protected MultipleDocumentJobsSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>MultipleDocumentJobsSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return MultipleDocumentJobsSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "multiple-document-jobs-supported".
+   */
+  public String getName()
+  {
+    return "multiple-document-jobs-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,230 @@
+/* OperationsSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * <code>OperationsSupported</code> specifies the enums of the operations
+ * supported by a given printer or job object. The attribute is further
+ * specified in RFC 2911 section 4.4.15.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class OperationsSupported extends EnumSyntax 
+  implements SupportedValuesAttribute
+{  
+  /*
+   * Value               Operation Name
+     -----------------   -------------------------------------
+     0x0000              reserved, not used
+     0x0001              reserved, not used
+     0x0002              Print-Job
+     0x0003              Print-URI
+     0x0004              Validate-Job
+     0x0005              Create-Job
+     0x0006              Send-Document
+     0x0007              Send-URI
+     0x0008              Cancel-Job
+     0x0009              Get-Job-Attributes
+     0x000A              Get-Jobs
+     0x000B              Get-Printer-Attributes
+     0x000C              Hold-Job
+     0x000D              Release-Job
+     0x000E              Restart-Job
+     0x000F              reserved for a future operation
+     0x0010              Pause-Printer
+     0x0011              Resume-Printer
+     0x0012              Purge-Jobs
+     0x0013-0x3FFF       reserved for future IETF standards track operations
+     0x4000-0x8FFF       reserved for vendor extensions
+   */
+  
+  // standard ipp 1.1 operations
+
+  /** 
+   * Operation to print a job in one request/response. */
+  public static final OperationsSupported PRINT_JOB = 
+    new OperationsSupported(0x02);
+  
+  /** Operation to print a document from an URI */
+  public static final OperationsSupported PRINT_URI = 
+    new OperationsSupported(0x03);
+  
+  /** Operation to validate a job before submission. */
+  public static final OperationsSupported VALIDATE_JOB = 
+    new OperationsSupported(0x04);
+  
+  /** 
+   * Operation to create an initial job for use with multiple document per job. 
+   */
+  public static final OperationsSupported CREATE_JOB = 
+    new OperationsSupported(0x05);
+  
+  /** 
+   * Operation to send a document to a multidoc job created via CREATE_JOB 
+   */
+  public static final OperationsSupported SEND_DOCUMENT = 
+    new OperationsSupported(0x06);
+  
+  /** 
+   * Operation to send a document uri to a multidoc job created 
+   * via CREATE_JOB. The document accessible from this URI will be printed. 
+   */
+  public static final OperationsSupported SEND_URI = 
+    new OperationsSupported(0x07);
+  
+  /** Operation to cancel a job by its ID or name.  */
+  public static final OperationsSupported CANCEL_JOB = 
+    new OperationsSupported(0x08);
+  
+  /** Operation to get job attributes of a current job. */
+  public static final OperationsSupported GET_JOB_ATTRIBUTES = 
+    new OperationsSupported(0x09);
+  
+  /** Operation to pause a printer. */
+  public static final OperationsSupported PAUSE_PRINTER = 
+    new OperationsSupported(0x10);
+  
+  /** Operation to get all currently queued or processed jobs. */
+  public static final OperationsSupported GET_JOBS = 
+    new OperationsSupported(0x0A);
+  
+  /** Operation to get the attributes of a printer. */
+  public static final OperationsSupported GET_PRINTER_ATTRIBUTES = 
+    new OperationsSupported(0x0B);
+  
+  /** Operation to put a job on hold by its ID or name. */
+  public static final OperationsSupported HOLD_JOB = 
+    new OperationsSupported(0x0C);
+  
+  /** Operation to release a job by its ID or name. */
+  public static final OperationsSupported RELEASE_JOB = 
+    new OperationsSupported(0x0D);
+  
+  /** Operation to restart a job by its ID or name. */
+  public static final OperationsSupported RESTART_JOB = 
+    new OperationsSupported(0x0E);
+  
+  /** Not yet an operation - reserved for futher use. */
+  public static final OperationsSupported RESERVED = 
+    new OperationsSupported(0x0F);
+  
+  /** Operation to resume a printer. */
+  public static final OperationsSupported RESUME_PRINTER = 
+    new OperationsSupported(0x11);
+  
+  /** Operation to remove all jobs from a printer regardless of state. */
+  public static final OperationsSupported PURGE_JOBS = 
+    new OperationsSupported(0x12);
+
+
+  private static final String[] stringTable = { "print-job", "print-uri", 
+                                                "validate-job", "create-job",
+                                                "send-document", "send-uri", 
+                                                "cancel-job", "get-job-attributes",
+                                                "pause-printer", "get-jobs", 
+                                                "get-printer-attributes", "hold-job",
+                                                "release-job", "restart-job", "reserved",
+                                                "resume-printer", "purge-job"};
+  
+  private static final OperationsSupported[] enumValueTable = 
+    { PRINT_JOB, PRINT_URI, VALIDATE_JOB, CREATE_JOB, SEND_DOCUMENT, SEND_URI,
+      CANCEL_JOB, GET_JOB_ATTRIBUTES, PAUSE_PRINTER, GET_JOBS, GET_PRINTER_ATTRIBUTES,
+      HOLD_JOB, RELEASE_JOB, RESTART_JOB, RESERVED, RESUME_PRINTER, PURGE_JOBS};
+  
+  
+  /**
+   * Constructs a <code>OperationsSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  protected OperationsSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>OperationsSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return OperationsSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "operations-supported".
+   */
+  public String getName()
+  {
+    return "operations-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+  // we start with 2
+  protected int getOffset()
+  {
+    return 2;
+  } 
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,179 @@
+/* OrientationRequestedSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.OrientationRequested;
+
+
+/**
+ * The <code>OrientationRequestedSupported</code> attribute provides 
+ * the supported values for the job attribute orientation-requested.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class OrientationRequestedSupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+  
+  /** Orientation as portrait. */
+  public static final OrientationRequestedSupported PORTRAIT =
+    new OrientationRequestedSupported(3);
+  
+  /** Orientation as landscape. */
+  public static final OrientationRequestedSupported LANDSCAPE =
+    new OrientationRequestedSupported(4);
+  
+  /** Orientation as reversed landscape. */
+  public static final OrientationRequestedSupported REVERSE_LANDSCAPE =
+    new OrientationRequestedSupported(5);
+  
+  /** Orientation as reversed portrait. */
+  public static final OrientationRequestedSupported REVERSE_PORTRAIT =
+    new OrientationRequestedSupported(6);
+
+
+  private static final String[] stringTable = { "portrait", "landscape",
+                                                "reverse-landscape",
+                                                "reverse-portrait" };
+  
+  private static final OrientationRequestedSupported[] 
+      enumValueTable = { PORTRAIT, LANDSCAPE, 
+                         REVERSE_LANDSCAPE, REVERSE_PORTRAIT };
+  
+  /**
+   * Constructs a <code>OrientationRequestedSupported</code> object.
+   * 
+   * @param value the value
+   */
+  protected OrientationRequestedSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>OrientationRequestedSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return OrientationRequestedSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "orientation-requested-supported".
+   */
+  public String getName()
+  {
+    return "orientation-requested-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the lowest used value by the enumerations of this class.
+   * .
+   * @return The lowest value used.
+   */
+  protected int getOffset()
+  {
+    return 3;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public OrientationRequested getAssociatedAttribute() 
+  {
+    return (OrientationRequested) IppUtilities.getEnumAttribute(
+            "orientation-requested", new Integer(getValue()));
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static OrientationRequested[] getAssociatedAttributeArray(Set set) 
+  {
+    OrientationRequestedSupported tmp;
+    OrientationRequested[] result = new OrientationRequested[set.size()];      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (OrientationRequestedSupported) it.next();
+        result[j] = tmp.getAssociatedAttribute();
+        j++;
+      }            
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* PageRangesSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+
+/**
+ * <code>PageRangesSupported</code> is a boolean typed
+ * attribute indicating (as EnumSyntax) if page ranges
+ * are supported.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PageRangesSupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+  /** Page ranges are not supported. */
+  public static final PageRangesSupported NOT_SUPPORTED = 
+    new PageRangesSupported(0);
+  
+  /** Page ranges are supported. */
+  public static final PageRangesSupported SUPPORTED = 
+    new PageRangesSupported(1);
+
+  private static final String[] stringTable = { "not-supported", "supported" };
+  
+  private static final PageRangesSupported[] enumValueTable = { NOT_SUPPORTED,
+                                                                SUPPORTED };
+  
+  /**
+   * Constructs a <code>PageRangesSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  protected PageRangesSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PageRangesSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PageRangesSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "page-ranges-supported".
+   */
+  public String getName()
+  {
+    return "page-ranges-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* PrintQualitySupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.PrintQuality;
+
+
+/**
+ * <code>PrintQualitySupported</code> provides the
+ * supported values for the print-quality attribute.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrintQualitySupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+  /** Draft quality of the printer. */
+  public static final PrintQualitySupported DRAFT = 
+    new PrintQualitySupported(3);
+  
+  /** Normal quality of the printer. */
+  public static final PrintQualitySupported NORMAL = 
+    new PrintQualitySupported(4);
+  
+  /** High quality of the printer. */
+  public static final PrintQualitySupported HIGH = 
+    new PrintQualitySupported(5);
+
+  private static final String[] stringTable = { "draft", "normal", "high" };
+  
+  private static final PrintQualitySupported[] enumValueTable = { DRAFT, 
+                                                                  NORMAL, 
+                                                                  HIGH };
+  
+  /**
+   * Constructs a <code>PrintQualitySupported</code> object.
+   * 
+   * @param value the value of the enum
+   */
+  protected PrintQualitySupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrintQualitySupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrintQualitySupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "print-quality-supported".
+   */
+  public String getName()
+  {
+    return "print-quality-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+  
+  /**
+   * Returns the lowest used value by the enumerations of this class.
+   * .
+   * @return The lowest value used.
+   */
+  protected int getOffset()
+  {
+    return 3;
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public PrintQuality getAssociatedAttribute() 
+  {
+    return (PrintQuality) IppUtilities.getEnumAttribute(
+                          "print-quality", new Integer(getValue()));
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static PrintQuality[] getAssociatedAttributeArray(Set set) 
+  {
+    PrintQualitySupported tmp;
+    PrintQuality[] result = new PrintQuality[set.size()];      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (PrintQualitySupported) it.next();
+        result[j] = tmp.getAssociatedAttribute();
+        j++;
+      }            
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,143 @@
+/* PrinterResolutionSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.PrinterResolution;
+
+
+/**
+ * The <code>PrinterResolutionSupported</code> attribute provides 
+ * the supported values for the job attribute printer-resolution.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterResolutionSupported extends ResolutionSyntax
+  implements SupportedValuesAttribute
+{
+  
+  /**
+   * Creates a <code>PrinterResolutionSupported</code> object with the 
+   * given arguments.
+   *
+   * @param crossFeedResolution the cross feed resolution
+   * @param feedResolution the feed resolution
+   * @param units the unit to use (e.g. {@link #DPCM} or {@link #DPI})
+   *
+   * @exception IllegalArgumentException if preconditions fail
+   */
+  public PrinterResolutionSupported(int crossFeedResolution, 
+      int feedResolution, int units)
+  {
+    super(crossFeedResolution, feedResolution, units);
+  }
+  
+  /**
+   * Tests if the given object is equal to this object.
+   *
+   * @param obj the object to test
+   *
+   * @return <code>true</code> if both objects are equal, 
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if(! (obj instanceof PrinterResolutionSupported))
+      return false;
+    
+    return super.equals(obj);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterResolutionSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterResolutionSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-resolution-supported".
+   */
+  public String getName()
+  {
+    return "printer-resolution-supported";
+  }
+  
+  /**
+   * Returns the equally enum of the standard attribute class
+   * of this SupportedValuesAttribute enum.
+   * 
+   * @return The enum of the standard attribute class.
+   */
+  public PrinterResolution getAssociatedAttribute() 
+  {
+    return new PrinterResolution(getCrossFeedResolutionDphi(), 
+                                 getFeedResolutionDphi(), 1);
+  }
+  
+  /**
+   * Constructs an array from a set of -supported attributes.
+   * @param set set to process
+   * @return The constructed array.
+   * 
+   * @see #getAssociatedAttribute()
+   */
+  public static PrinterResolution[] getAssociatedAttributeArray(Set set) 
+  {
+    PrinterResolutionSupported tmp;
+    PrinterResolution[] result = new PrinterResolution[set.size()];      
+    Iterator it = set.iterator();
+    int j = 0;
+    while (it.hasNext())
+      {
+        tmp = (PrinterResolutionSupported) it.next();
+        result[j] = tmp.getAssociatedAttribute();
+        j++;
+      }            
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* PrinterUriSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import java.net.URI;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * PrinterUriSupported attribute as described in RFC 2911 section
+ * 4.4.1 contains one of the URIs the printer supported for
+ * job processing (e.g. one with authentication).
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class PrinterUriSupported extends URISyntax 
+  implements SupportedValuesAttribute
+{
+
+  /**
+   * Creates a <code>PrinterUriSupported</code> object.
+   *
+   * @param uri the URI value for the syntax
+   * @throws NullPointerException if uri is null
+   */
+  public PrinterUriSupported(URI uri)
+  {
+    super(uri);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>PrinterUriSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return PrinterUriSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "printer-uri-supported".
+   */
+  public String getName()
+  {
+    return "printer-uri-supported";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,136 @@
+/* SidesSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+
+/**
+ * <code>SidesSupported</code> provides the
+ * supported values for the sides attribute.
+ *  
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class SidesSupported extends EnumSyntax
+  implements SupportedValuesAttribute
+{
+  
+  /** Specifies that each page should be printed on one sheet. */
+  public static final SidesSupported ONE_SIDED = new SidesSupported(0);
+  
+  /** 
+   * Specifies that two following pages should be printed on the 
+   * front and back of one sheet for binding on the long edge.
+   */
+  public static final SidesSupported TWO_SIDED_LONG_EDGE = 
+    new SidesSupported(1);
+  
+  /** 
+   * Specifies that two following pages should be printed on the 
+   * front and back of one sheet for binding on the short edge.
+   */
+  public static final SidesSupported TWO_SIDED_SHORT_EDGE = 
+    new SidesSupported(2);
+  
+  /** An alias constant for "two sided long edge". */
+  public static final SidesSupported DUPLEX = new SidesSupported(1);
+  
+  /** An alias constant for "two sided short edge". */
+  public static final SidesSupported TUMBLE = new SidesSupported(2);
+
+  private static final String[] stringTable = { "one-sided", 
+                                                "two-sided-long-edge",
+                                                "two-sided-short-edge" };
+  
+  private static final SidesSupported[] 
+      enumValueTable = { ONE_SIDED, TWO_SIDED_LONG_EDGE, 
+                         TWO_SIDED_SHORT_EDGE };
+  
+  
+  /**
+   * Creates a <code>SidesSupported</code> object.
+   *
+   * @param value the value of the enum
+   */
+  protected SidesSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>SidesSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return SidesSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "sides-supported".
+   */
+  public String getName()
+  {
+    return "sides-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,141 @@
+/* UriAuthenticationSupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * UriAuthenticationSupported attribute as described in RFC 2911 section
+ * 4.4.2 provides the keywords (implemented as EnumSyntax) which 
+ * authentication methods are supported by the printer object. This
+ * includes a value of none.
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class UriAuthenticationSupported extends EnumSyntax 
+  implements SupportedValuesAttribute
+{
+  
+  // a keyword based attribute in IPP - int values just starting at 0
+  
+  /** Supports no authentication - assumes anonymous process */
+  public static final UriAuthenticationSupported NONE = 
+    new UriAuthenticationSupported(0);
+  
+  /** 
+   * The authenticated user assumed is the value of the
+   * "requesting-user-name" operation attribute supplied
+   * with the operation.
+   */
+  public static final UriAuthenticationSupported REQUESTING_USER_NAME = 
+    new UriAuthenticationSupported(1);
+  
+  /** Supports HTTP basic authentication (RFC 2617) */
+  public static final UriAuthenticationSupported BASIC = 
+    new UriAuthenticationSupported(2);
+  
+  /** Supports HTTP digest authentication (RFC 2617) */
+  public static final UriAuthenticationSupported DIGEST = 
+    new UriAuthenticationSupported(3);
+  
+  /** Supports authentication through a client provided certificate */
+  public static final UriAuthenticationSupported CERTIFICATE = 
+    new UriAuthenticationSupported(4);
+  
+  private static final String[] stringTable = { "none", 
+                                                "requesting-user-name",                                              
+                                                "basic", "digest", 
+                                                "certificate" };
+  
+  private static final UriAuthenticationSupported[] enumValueTable = 
+    { NONE, REQUESTING_USER_NAME, BASIC, DIGEST, CERTIFICATE };
+
+  /**
+   * Constructs a <code>UriAuthenticationSupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  public UriAuthenticationSupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>UriAuthenticationSupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return UriAuthenticationSupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "uri-authentication-supported".
+   */
+  public String getName()
+  {
+    return "uri-authentication-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,126 @@
+/* UriSecuritySupported.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 gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * UriSecuritySupported attribute as described in RFC 2911 section
+ * 4.4.3 provides the keywords (implemented as EnumSyntax) for
+ * the security mechanisms supported by the corresponding uri's
+ * supported (same place in setOf).
+ * 
+ * @author Wolfgang Baer (WBaer at gmx.de)
+ */
+public final class UriSecuritySupported extends EnumSyntax 
+  implements SupportedValuesAttribute
+{
+  
+  // a keyword based attribute in IPP - int values just starting at 0
+  
+  /** The URI has no secure communication */
+  public static final UriSecuritySupported NONE = 
+    new UriSecuritySupported(0);
+  
+  /** The URI has SSL3 communication */
+  public static final UriSecuritySupported SSL3 = 
+    new UriSecuritySupported(1);
+  
+  /**  The URI has TLS (RFC 2246) communication */
+  public static final UriSecuritySupported TLS = 
+    new UriSecuritySupported(2);
+  
+  private static final String[] stringTable = { "none", "ssl3", "tls" };
+  
+  private static final UriSecuritySupported[] enumValueTable = { NONE, 
+                                                                 SSL3, TLS };
+
+  /**
+   * Constructs a <code>UriSecuritySupported</code> object.
+   * 
+   * @param value the enum value
+   */
+  public UriSecuritySupported(int value)
+  {
+    super(value);
+  }
+
+  /**
+   * Returns category of this class.
+   *
+   * @return The class <code>UriSecuritySupported</code> itself.
+   */
+  public Class getCategory()
+  {
+    return UriSecuritySupported.class;
+  }
+
+  /**
+   * Returns the name of this attribute.
+   *
+   * @return The name "uri-security-supported".
+   */
+  public String getName()
+  {
+    return "uri-security-supported";
+  }
+  
+  /**
+   * Returns a table with the enumeration values represented as strings
+   * for this object.
+   *
+   * @return The enumeration values as strings.
+   */
+  protected String[] getStringTable()
+  {
+    return stringTable;
+  }
+
+  /**
+   * Returns a table with the enumeration values for this object.
+   *
+   * @return The enumeration values.
+   */
+  protected EnumSyntax[] getEnumValueTable()
+  {
+    return enumValueTable;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/CorbaInput.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/CorbaInput.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,297 @@
+/* CorbaInput.java --
+   Copyright (C) 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 gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.CDR.gnuRuntime;
+
+import org.omg.CORBA_2_3.portable.InputStream;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Converts calls on java ObjectOutputStream to calls on CORBA OutputStream. A
+ * class to substitute for objects using readObject method.
+ * 
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class CorbaInput
+  extends ObjectInputStream
+  implements ObjectInput
+{
+
+  /**
+   * The underlying CORBA stream from where the actual input is taken.
+   */
+  public InputStream stream;
+
+  /**
+   * The utility class to write the object fields in default way.
+   */
+  final RmiUtilities util;
+
+  /**
+   * The object currently being read.
+   */
+  Object current;
+
+  /**
+   * The offset of the object currently being read.
+   */
+  int offset;
+
+  /**
+   * The repository id of the object currently being read.
+   */
+  String rid;
+
+  /**
+   * The runtime, related to the object currently being read.
+   */
+  gnuRuntime runtime;
+
+  /**
+   * Create an instance, delegating calls to the given CORBA stream.
+   */
+  public CorbaInput(InputStream an_input, Object firstObject,
+                          RmiUtilities an_util, int an_offset, String a_rid,
+                          gnuRuntime a_runtime)
+    throws Exception
+  {
+    stream = an_input;
+    current = firstObject;
+    util = an_util;
+
+    offset = an_offset;
+    rid = a_rid;
+    runtime = a_runtime;
+  }
+
+  /** @inheritDoc */
+  public int available()
+    throws IOException
+  {
+    return stream.available();
+  }
+
+  /**
+   * No action.
+   */
+  public void close()
+    throws IOException
+  {
+  }
+
+  /** @inheritDoc */
+  public void defaultReadObject()
+    throws IOException, ClassNotFoundException
+  {
+    util.readFields(offset, rid, (Serializable) current, stream, runtime);
+  }
+
+  /** @inheritDoc */
+  public void mark(int readlimit)
+  {
+    stream.mark(readlimit);
+  }
+
+  /** @inheritDoc */
+  public boolean markSupported()
+  {
+    return stream.markSupported();
+  }
+
+  /** @inheritDoc */
+  public int read()
+    throws IOException
+  {
+    return stream.read();
+  }
+
+  /** @inheritDoc */
+  public int read(byte[] buf, int off, int len)
+    throws IOException
+  {
+    return stream.read(buf, off, len);
+  }
+
+  /** @inheritDoc */
+  public int read(byte[] b)
+    throws IOException
+  {
+    return stream.read(b);
+  }
+
+  /** @inheritDoc */
+  public boolean readBoolean()
+    throws IOException
+  {
+    return stream.read_boolean();
+  }
+
+  /** @inheritDoc */
+  public byte readByte()
+    throws IOException
+  {
+    return (byte) stream.read();
+  }
+
+  /** @inheritDoc */
+  public char readChar()
+    throws IOException
+  {
+    return stream.read_char();
+  }
+
+  /** @inheritDoc */
+  public double readDouble()
+    throws IOException
+  {
+    return stream.read_double();
+  }
+
+  /** @inheritDoc */
+  public float readFloat()
+    throws IOException
+  {
+    return stream.read_float();
+  }
+
+  /** @inheritDoc */
+  public void readFully(byte[] buf, int off, int len)
+    throws IOException
+  {
+    // This class only reads from the buffered streams.
+    stream.read(buf, off, len);
+  }
+
+  /** @inheritDoc */
+  public void readFully(byte[] buf)
+    throws IOException
+  {
+    // This class only reads from the buffered streams.
+    stream.read(buf);
+  }
+
+  /** @inheritDoc */
+  public int readInt()
+    throws IOException
+  {
+    return stream.read_long();
+  }
+
+  /** @inheritDoc */
+  public String readLine()
+    throws IOException
+  {
+    return new DataInputStream(this).readLine();
+  }
+
+  /** @inheritDoc */
+  public long readLong()
+    throws IOException
+  {
+    return stream.read_longlong();
+  }
+
+  /** @inheritDoc */
+  public short read_short()
+    throws IOException
+  {
+    return stream.read_short();
+  }
+
+  /** @inheritDoc */
+  public int readUnsignedByte()
+    throws IOException
+  {
+    return (stream.read() & 0xFF);
+  }
+
+  /** @inheritDoc */
+  public int readUnsignedShort()
+    throws IOException
+  {
+    return (stream.read_short() & 0xFFFF);
+  }
+
+  /**
+   * Read as wide string (not as UTF).
+   */
+  public String readUTF()
+    throws IOException
+  {
+    return stream.read_wstring();
+  }
+
+  /** @inheritDoc */
+  public void reset()
+    throws IOException
+  {
+    stream.reset();
+  }
+
+  /** @inheritDoc */
+  public long skip(long n)
+    throws IOException
+  {
+    return stream.skip(n);
+  }
+
+  /** @inheritDoc */
+  public int skipBytes(int len)
+    throws IOException
+  {
+    return (int) stream.skip(len);
+  }
+
+  /**
+   * Objects are read as abstract interfaces.
+   */
+  protected Object readObjectOverride()
+    throws IOException, ClassNotFoundException
+  {
+    current = stream.read_abstract_interface();
+    return current;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/CorbaOutput.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/CorbaOutput.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,219 @@
+/* CorbaOutput.java --
+   Copyright (C) 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 gnu.javax.rmi.CORBA;
+
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * A class to substitute as an ObjectOutputStream for objects using writeObject
+ * method.
+ * 
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class CorbaOutput
+  extends ObjectOutputStream
+  implements ObjectOutput
+{
+  /**
+   * A CORBA stream where the output is forwarded.
+   */
+  final OutputStream stream;
+
+  /**
+   * The utility class to write the object fields in default way.
+   */
+  final RmiUtilities util;
+
+  /**
+   * The object currently being written.
+   */
+  Object current;
+
+  /**
+   * Create an instance, delegating calls to the given CORBA stream.
+   */
+  public CorbaOutput(OutputStream an_output, Object firstObject,
+                           RmiUtilities an_util)
+    throws Exception
+  {
+    stream = an_output;
+    current = firstObject;
+    util = an_util;
+  }
+
+  /**
+   * No action.
+   */
+  public void close()
+    throws IOException
+  {
+  }
+
+  /** @inheritDoc */
+  public void flush()
+    throws IOException
+  {
+    stream.flush();
+  }
+
+  /** @inheritDoc */
+  public void write(byte[] buf, int off, int len)
+    throws IOException
+  {
+    stream.write(buf, off, len);
+  }
+
+  /** @inheritDoc */
+  public void write(byte[] buf)
+    throws IOException
+  {
+    stream.write(buf);
+  }
+
+  /** @inheritDoc */
+  public void write(int val)
+    throws IOException
+  {
+    stream.write(val);
+  }
+
+  /** @inheritDoc */
+  public void writeBoolean(boolean val)
+    throws IOException
+  {
+    stream.write_boolean(val);
+  }
+
+  /** @inheritDoc */
+  public void writeByte(int val)
+    throws IOException
+  {
+    stream.write(val);
+  }
+
+  /** @inheritDoc */
+  public void writeBytes(String str)
+    throws IOException
+  {
+    stream.write_string(str);
+  }
+
+  /** @inheritDoc */
+  public void writeChar(int val)
+    throws IOException
+  {
+    stream.write_wchar((char) val);
+  }
+
+  /** @inheritDoc */
+  public void writeChars(String str)
+    throws IOException
+  {
+    stream.write_char_array(str.toCharArray(), 0, str.length());
+  }
+
+  /** @inheritDoc */
+  public void writeDouble(double val)
+    throws IOException
+  {
+    stream.write_double(val);
+  }
+
+  /** @inheritDoc */
+  public void writeFloat(float val)
+    throws IOException
+  {
+    stream.write_float(val);
+  }
+
+  /** @inheritDoc */
+  public void writeInt(int val)
+    throws IOException
+  {
+    stream.write_long(val);
+  }
+
+  /** @inheritDoc */
+  public void writeLong(long val)
+    throws IOException
+  {
+    stream.write_longlong(val);
+  }
+
+  /**
+   * Objects are written as abstract interfaces.
+   */
+  protected void writeObjectOverride(Object obj)
+    throws IOException
+  {
+    current = obj;
+    stream.write_abstract_interface(obj);
+  }
+
+  /** @inheritDoc */
+  public void writeShort(int val)
+    throws IOException
+  {
+    stream.write_short((short) val);
+  }
+
+  /**
+   * Such strings are written as wide strings, not as UTF.
+   */
+  public void writeUTF(String str)
+    throws IOException
+  {
+    stream.write_wstring(str);
+  }
+
+  /**
+   * @inheritDoc
+   */
+  public void defaultWriteObject()
+    throws IOException
+  {
+    util.writeFields(stream, (Serializable) current);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* DefaultWriteObjectTester.java --
+   Copyright (C) 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 gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.CDR.BufferedCdrOutput;
+
+import java.io.IOException;
+
+/**
+ * Tests if the defaultWriteObject method has been called. 
+ * This information is required by RMI-IIOP header.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class DefaultWriteObjectTester
+  extends CorbaOutput
+{
+  /**
+   * The flag, indicating, that the defaultWriteObject method was called.
+   */
+  public boolean dwo_called;
+  
+  /**
+   * Create an instance, delegating calls to the given CORBA stream.
+   */
+  public DefaultWriteObjectTester(Object firstObject)
+    throws Exception
+  {
+    super(new BufferedCdrOutput(), firstObject, null);
+  }
+
+  /**
+   * Set the flag that defaultWriteObject was called.
+   */
+  public void defaultWriteObject()
+    throws IOException
+  {
+    dwo_called = true;
+  }
+
+  /**
+   * Do not write other objects.
+   */
+  protected void writeObjectOverride(Object obj)
+    throws IOException
+  {
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/DelegateFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/DelegateFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,107 @@
+/* DelegateFactory.java -- 
+   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.ObjectCreator;
+
+
+/**
+ * This class produces delegates, using the system properties. If not
+ * corresponding property is specified, returns default implementations.
+ * 
+ * @author Wu Gansha (gansha.wu at intel.com)
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class DelegateFactory
+{
+  /**
+   * The name to get a stub delegate.
+   */
+  public static final String STUB = "Stub";
+
+  /**
+   * The name to get the util delegate.
+   */
+  public static final String UTIL = "Util";
+
+  /**
+   * The name to get the ValueHandler delegate.
+   */
+  public static final String VALUEHANDLER = "ValueHandler";
+
+  /**
+   * The name to get the PortableRemoteObject delegate.
+   */
+  public static final String PORTABLE_REMOTE_OBJECT = "PortableRemoteObject";
+
+  /**
+   * Get an instance of the given delegate. As in all cases the singleton
+   * instance is used, the caching here would be redundant.
+   * 
+   * @param type a delegate type.
+   * 
+   * @return the associated delegate.
+   * 
+   * @throws InternalError if the delegate class, indicated in the system
+   * properties, cannot be instantiated.
+   */
+  public static Object getInstance(String type)
+    throws InternalError
+  {
+    String propertyName = "javax.rmi.CORBA." + type + "Class";
+    String dcname = System.getProperty(propertyName);
+    if (dcname == null)
+      {
+        // // No javax.rmi.CORBA.XXXClass property sepcified.
+        dcname = "gnu.javax.rmi.CORBA." + type + "DelegateImpl";
+      }
+    try
+      {
+        Class dclass = ObjectCreator.forName(dcname);
+        return dclass.newInstance();
+      }
+    catch (Exception e)
+      {
+        InternalError ierr = new InternalError("Exception when trying to get "
+          + type + "delegate instance:" + dcname);
+        ierr.initCause(e);
+        throw ierr;
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/GetDelegateInstanceException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/GetDelegateInstanceException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* GetDelegateInstanceException.java -- 
+   Copyright (C) 2002, 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 gnu.javax.rmi.CORBA;
+
+public class GetDelegateInstanceException
+  extends Exception
+{
+  private Throwable next;
+  
+  public GetDelegateInstanceException(String msg)
+  {
+    super(msg);
+  }
+  
+  public GetDelegateInstanceException(String msg, Throwable next)
+  {
+    super(msg, next);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,362 @@
+/* PortableRemoteObjectDelegateImpl.java -- 
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.SimpleDelegate;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.Poa.LocalDelegate;
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Poa.AOM;
+
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClassLoader;
+
+import javax.rmi.CORBA.PortableRemoteObjectDelegate;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+/**
+ * Implements PortableRemoteObjectDelegate.
+ * 
+ * @author Wu Gansha (gansha.wu at intel.com) (stub)
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) (implementation)
+ */
+public class PortableRemoteObjectDelegateImpl
+  implements PortableRemoteObjectDelegate
+{
+  /**
+   * <p>
+   * Makes the remote object <code>a_target</code> ready for remote
+   * communication using the same communications runtime as for the passed
+   * <code>a_source</code> parameter. The a_target is connected to the same
+   * ORB (and, if applicable, to the same POA) as the a_source.
+   * 
+   * @param a_target the target to connect to ORB, must be an instance of either
+   * {@link ObjectImpl} (Stubs and old-style ties) or {@link Servant} (POA-bases
+   * ties).
+   * 
+   * @param a_source the object, providing the connection information, must be
+   * an instance of either {@link ObjectImpl} (Stubs and old-style ties) or
+   * {@link Servant} (POA-bases ties).
+   * 
+   * @throws RemoteException if the target is already connected to another ORB.
+   */
+  public void connect(Remote a_target, Remote a_source)
+    throws RemoteException
+  {
+    ORB orb = null;
+    POA poa = null;
+    boolean ok = false;
+
+    try
+      {
+        if (a_source instanceof Servant)
+          {
+            Servant s = (Servant) a_source;
+            orb = s._orb();
+            poa = s._poa();
+            ok = true;
+          }
+
+        if (!ok && a_source instanceof ObjectImpl)
+          {
+            ObjectImpl o = (ObjectImpl) a_source;
+            orb = o._orb();
+            ok = true;
+            try
+              {
+                if (orb instanceof ORB_1_4)
+                  {
+                    // POA information available.
+                    ORB_1_4 xorb = (ORB_1_4) orb;
+                    Delegate d = o._get_delegate();
+
+                    if (d instanceof LocalDelegate)
+                      {
+                        LocalDelegate l = (LocalDelegate) d;
+                        poa = l.poa;
+                      }
+                    else if (d instanceof SimpleDelegate)
+                      {
+                        byte[] ior_key = ((SimpleDelegate) d).getIor().key;
+                        AOM.Obj ref = xorb.rootPOA.findIorKey(ior_key);
+                        if (ref != null)
+                          poa = ref.poa;
+                      }
+                  }
+              }
+            catch (Exception ex)
+              {
+                // OK, POA info is not available, but as ORB is available, we
+                // will connect in a default way.
+              }
+          }
+      }
+    catch (Exception ex)
+      {
+        RuntimeException rex = new RuntimeException("Unable to get info from "
+          + a_source);
+        rex.initCause(ex);
+        throw rex;
+      }
+
+    if (!ok && a_source instanceof Tie)
+      {
+        Tie t = (Tie) a_source;
+        orb = t.orb();
+        poa = null;
+        ok = true;
+      }
+
+    if (orb == null)
+      throw new RemoteException("Unable to determine ORB from " + a_source);
+
+    if (a_target instanceof Stub)
+      {
+        StubDelegateImpl.connect((Stub) a_target, orb, poa);
+      }
+    else if (a_target instanceof Servant)
+      {
+        try
+          {
+            if (poa == null)
+              {
+                poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+                // Activate if not active.
+                if (poa.the_POAManager().get_state().value() == State._HOLDING)
+                  poa.the_POAManager().activate();
+              }
+            poa.servant_to_reference((Servant) a_target);
+          }
+        catch (Exception ex)
+          {
+            throw new Unexpected(ex);
+          }
+      }
+    else if (a_target instanceof org.omg.CORBA.Object)
+      {
+        // Connect as object.
+        orb.connect((org.omg.CORBA.Object) a_target);
+      }
+    else if (a_target instanceof Tie)
+      {
+        // We avoid calling this because it will aways connect to the root poa.
+        ((Tie) a_target).orb(orb);
+      }
+  }
+
+  /**
+   * Narrow the given object to the instance of the given class. The currently
+   * supported narrowing types are:
+   * 
+   * 1. Simple widening conversion.<br>
+   * 2. ObjectImpl -> RMI interface.<br>
+   * 3. ObjectImpl -> ObjectImpl.<br>
+   * 4. Tie -> Remote (implementation)<br>
+   * 5. Remote (implementation) -> Tie.<br>
+   * 
+   * The narrowing has sense only for derived classes.
+   */
+  public Object narrow(Object narrowFrom, Class narrowTo)
+    throws ClassCastException
+  {
+    if (narrowTo == null)
+      throw new ClassCastException("Can't narrow to null class");
+    else if (narrowFrom == null)
+      return null;
+    else
+    // Simple narrowing case.
+    if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
+      return narrowFrom;
+    else if (narrowTo.isInterface() || narrowFrom instanceof ObjectImpl)
+      {
+        // Narrow CORBA object to passed interface.
+
+        String interf = narrowTo.getName();
+        String stubClassName;
+
+        stubClassName = getStubClassName(interf);
+
+        try
+          {
+            // Replace the interface class by the stub class.
+            narrowTo = Util.loadClass(stubClassName, null,
+              narrowTo.getClassLoader());
+          }
+        catch (ClassNotFoundException e)
+          {
+            ClassCastException cex = new ClassCastException("Class not found: "
+              + stubClassName);
+            cex.initCause(e);
+            throw cex;
+          }
+      }
+    else if (narrowFrom instanceof Tie)
+      {
+        // Try to substitute the return tie target as a return value.
+        Remote target = ((Tie) narrowFrom).getTarget();
+        if (target != null && narrowTo.isAssignableFrom(target.getClass()))
+          return target;
+      }
+
+    Object narrowed;
+    try
+      {
+        narrowed = narrowTo.newInstance();
+      }
+    catch (Exception e)
+      {
+        ClassCastException cex = new ClassCastException("Cannot instantiate "
+          + narrowTo.getName());
+        cex.initCause(e);
+        throw cex;
+      }
+
+    if (narrowed instanceof ObjectImpl)
+      {
+        // This also works for the instances of the Stub.
+        ObjectImpl target = (ObjectImpl) narrowed;
+        // Set the delegate, as is done in *Helper.narrow(..).
+        target._set_delegate(((ObjectImpl) narrowFrom)._get_delegate());
+      }
+    else if (narrowed instanceof Tie && narrowFrom instanceof Remote)
+      {
+        // Try to set the narrowing object as a target for the Tie.
+        ((Tie) narrowed).setTarget((Remote) narrowFrom);
+      }
+    else
+      throw new ClassCastException("Narrowing of " + narrowFrom.getClass()
+        + " to " + narrowTo + " is either not possible or not implemented.");
+
+    return narrowed;
+  }
+  
+  /**
+   * Get the Stub class name for the name, representing the given interface.
+   */
+  static String getStubClassName(String interf)
+  {
+    String stubClassName;
+    int p = interf.lastIndexOf('.');
+
+    if (p < 0)
+      // The interface is defined in the default package.
+      stubClassName = "_" + interf + "_Stub";
+    else
+      stubClassName = interf.substring(0, p + 1) + "_"
+        + interf.substring(p + 1) + "_Stub";
+    return stubClassName;
+  }
+  
+  /**
+   * Get stub for the given implementation, searching by class name pattern. The
+   * found stub must implement Remote for this method to succeed.
+   */
+  public Remote toStub(Remote ObjImpl)
+    throws NoSuchObjectException
+  {
+    String icn = ObjImpl.getClass().getName();
+    if (!icn.endsWith("Impl"))
+      throw new BAD_PARAM("Invalid class name '" + icn
+        + "', must end with 'Impl'");
+
+    String sn = "_" + icn.substring(0, icn.length() - "Impl".length())
+      + "_Stub";
+
+    Class stubClass;
+    Object o_stub;
+
+    try
+      {
+        stubClass = RMIClassLoader.loadClass(sn);
+        o_stub = stubClass.newInstance();
+      }
+    catch (Exception e)
+      {
+        NoSuchObjectException n = new NoSuchObjectException(sn);
+        n.initCause(e);
+        throw n;
+      }
+
+    if (!Remote.class.isAssignableFrom(stubClass))
+      throw new ClassCastException(stubClass.getName()
+        + " exists but cannot be returned as it does not inherit from "
+        + Remote.class.getName());
+
+    return (Remote) o_stub;
+  }
+
+  /**
+   * If the object tie is no longer in use, disconnet it from the orb.
+   */
+  public void unexportObject(Remote obj)
+    throws NoSuchObjectException
+  {
+    Util.unexportObject(obj);
+  }
+
+  /**
+   * Find or create a tie for this target and mark it as being used by the given
+   * object.
+   */
+  public void exportObject(Remote obj)
+    throws RemoteException
+  {
+    if (obj instanceof Stub)
+      Util.registerTarget(StubDelegateImpl.getTieFromStub((Stub) obj), obj);
+    else if (obj instanceof Tie)
+      {
+        Tie t = (Tie) obj;
+        Util.registerTarget(t, null);
+      }
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/RmiUtilities.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/RmiUtilities.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,946 @@
+/* RmiUtilities.java --
+   Copyright (C) 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 gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.OrbFunctional;
+import gnu.CORBA.Minor;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.CDR.Vio;
+import gnu.CORBA.CDR.gnuRuntime;
+import gnu.CORBA.CDR.gnuValueStream;
+import gnu.CORBA.CDR.HeadlessInput;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.StringValueHelper;
+import org.omg.CORBA.WStringValueHelper;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueBase;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
+import org.omg.SendingContext.RunTime;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.rmi.Remote;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.TreeSet;
+import java.util.WeakHashMap;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+
+/**
+ * Defines methods that must be accessible in several derived classes.
+ * 
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class RmiUtilities
+{
+  /**
+   * The currently used RMI-IIOP version format.
+   */
+  public static byte VERSION = 1;
+
+  /**
+   * The non - writable class fields.
+   */
+  static final int NON_WRITABLE = Modifier.STATIC | Modifier.TRANSIENT;
+
+  /**
+   * The standard String repository Id.
+   */
+  public static final String RMI_STRING_ID = StringValueHelper.id();
+
+  /**
+   * The standard Class repository Id.
+   */
+  public static final String RMI_CLASS_ID = "RMI:javax.rmi.CORBA.ClassDesc:2BABDA04587ADCCC:CFBF02CF5294176B";
+
+  /**
+   * The standard string array repository Id.
+   */
+  public static final String RMI_STRING_ARRAY_ID = "RMI:[Ljava.lang.String;:071DA8BE7F971128:A0F0A4387A3BB342";
+
+  /**
+   * An instance of the wide string value helper for writing strings.
+   */
+  static WStringValueHelper wStringValueHelper = new WStringValueHelper();
+
+  /**
+   * Set of serializable classes that have .writeObject and .readObject defined.
+   * Contains weak references to ensure that the classes will be unloadable.
+   */
+  WeakHashMap io_format = new WeakHashMap();
+
+  /**
+   * The standard IO format with no .writeObject and .readObject defined.
+   */
+  static final Object STANDARD = new Object();
+
+  /**
+   * The custom IO format with .writeObject and .readObject defined,
+   * defaultWriteObject called.
+   */
+  static final Object CUSTOM_DWO = new Object();
+
+  /**
+   * The custom IO format with .writeObject and .readObject defined,
+   * defaultWriteObject has not been called.
+   */
+  static final Object CUSTOM_NO_DWO = new Object();
+
+  /**
+   * The arguments for readObject.
+   */
+  static final Class[] READ_OBJECT_ARGS = new Class[] { ObjectInputStream.class };
+
+  /**
+   * The arguments for writeObject.
+   */
+  static final Class[] WRITE_OBJECT_ARGS = new Class[] { ObjectOutputStream.class };
+
+  /**
+   * The undocumented field that is heading the Sun's object data, written with
+   * writeObject.
+   */
+  static final int S_X = 16908034;
+
+  /**
+   * Write all fields of the passed value.
+   */
+  void writeFields(OutputStream an_output, Serializable object)
+  {
+    org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+    try
+      {
+        Class o_class = object.getClass();
+        Field[] fields = getWritableFields(o_class);
+        Field f;
+
+        Class fc;
+
+        for (int i = 0; i < fields.length; i++)
+          {
+            f = fields[i];
+            fc = f.getType();
+            Object v = f.get(object);
+
+            if (fc == String.class)
+              {
+                output.write_value((Serializable) v, wStringValueHelper);
+              }
+            else if (fc == int.class)
+              output.write_long(((Integer) v).intValue());
+            else if (fc == long.class)
+              output.write_longlong(((Number) v).longValue());
+            else if (fc == double.class)
+              output.write_double(((Number) v).doubleValue());
+            else if (fc == float.class)
+              output.write_float(((Number) v).floatValue());
+            else if (fc == boolean.class)
+              output.write_boolean(((Boolean) v).booleanValue());
+            else if (fc == short.class)
+              output.write_short(((Number) v).shortValue());
+            else if (fc == byte.class)
+              output.write_octet(((Number) v).byteValue());
+            else if (fc == char.class)
+              output.write_wchar(((Character) v).charValue());
+            else
+              {
+                if (!fc.isInterface() && Remote.class.isAssignableFrom(fc))
+                  fc = getExportedInterface(fc);
+                writeMember(output, v, fc);
+              }
+          }
+      }
+    catch (Exception ex)
+      {
+        MARSHAL m = new MARSHAL("Cannot write " + object);
+        m.minor = Minor.ValueFields;
+        m.initCause(ex);
+        throw m;
+      }
+  }
+
+  /**
+   * Write a memeber (field) of the data structure.
+   */
+  void writeMember(org.omg.CORBA_2_3.portable.OutputStream output,
+    Object object, Class xClass)
+  {
+    if (output instanceof gnuValueStream)
+      {
+        gnuRuntime g = ((gnuValueStream) output).getRunTime();
+        // Reset the target as we are already beyond the critical point
+        // where is must have the value being written.
+        if (g != null)
+          g.target = null;
+      }
+    if (Serializable.class.isAssignableFrom(xClass)
+      || Remote.class.isAssignableFrom(xClass))
+      {
+        // Object handles null reference on its own.
+        if (org.omg.CORBA.Object.class.isAssignableFrom(xClass)
+          || Remote.class.isAssignableFrom(xClass))
+          {
+            if (object == null)
+              output.write_Object(null);
+            else if (isTieRequired(object))
+              exportTie(output, object, xClass);
+            else
+              writeValue(output, (Serializable) object);
+          }
+        else
+          output.write_value((Serializable) object, xClass);
+      }
+    else
+      {
+        MARSHAL m = new MARSHAL(xClass + " is not Serializable");
+        m.minor = Minor.NonSerializable;
+        throw m;
+      }
+  }
+
+  /**
+   * Check if the object must be wrapped into Tie, connected to the ORB and then
+   * the corresponding Stub be written.
+   */
+  public boolean isTieRequired(Object object)
+  {
+    return object instanceof Remote && !(object instanceof Stub);
+  }
+
+  /**
+   * Get the interface under that the class of this object must be exposed. The
+   * interface must be derived from Remote.
+   */
+  Class getExportedInterface(Object object)
+    throws MARSHAL
+  {
+    Class fc = null;
+    Class[] interfaces = object.getClass().getInterfaces();
+    for (int i = 0; i < interfaces.length; i++)
+      {
+        if (!Remote.class.equals(interfaces[i]))
+          if (Remote.class.isAssignableFrom(interfaces[i]))
+            {
+              if (fc == null)
+                fc = interfaces[i];
+              else
+                {
+                  MARSHAL m = new MARSHAL("Both " + fc + " and " + interfaces[i]
+                  + " extends Remote");
+                  m.minor = Minor.TargetConversion;
+                  throw m;
+                }
+            }
+      }
+    if (fc == null)
+      {
+        MARSHAL m = new MARSHAL(object.getClass()
+        + " does not implement any interface, derived from Remote");
+        m.minor = Minor.TargetConversion;
+        throw m;
+      }
+    return fc;
+  }
+
+  /**
+   * Get the persistent hash code for the given class, as defined by OMG
+   * standard. The inheritance, field names and types (but not the visibility)
+   * are taken into consideration as well as the presence of the writeObject
+   * method are taken into consideration. The class name and methods, if any,
+   * are not taken into consideration.
+   */
+  public static long getHashCode(Class c)
+  {
+    Class of = c.isArray() ? c.getComponentType() : null;
+    if (c.isArray()
+      && ((!Serializable.class.isAssignableFrom(of) || of.isPrimitive() || Remote.class.isAssignableFrom(of))))
+      return 0;
+    if (!Serializable.class.isAssignableFrom(c))
+      return 0;
+    try
+      {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        DataOutputStream out = new DataOutputStream(bout);
+
+        Class superClass = c.getSuperclass();
+        if (superClass != null)
+          out.writeLong(getHashCode(superClass));
+
+        int writeObjectPresentCode;
+        try
+          {
+            c.getDeclaredMethod("writeObject",
+              new Class[] { ObjectOutputStream.class });
+            writeObjectPresentCode = 2; // Exists.
+          }
+        catch (NoSuchMethodException e)
+          {
+            writeObjectPresentCode = 1; // Missing.
+          }
+        out.writeInt(writeObjectPresentCode);
+
+        Field[] fields = c.getDeclaredFields();
+
+        Arrays.sort(fields, new Comparator()
+        {
+          public int compare(Object a, Object b)
+          {
+            Field fa = (Field) a;
+            Field fb = (Field) b;
+            return fa.getName().compareTo(fb.getName());
+          }
+        });
+
+        Field f;
+        for (int i = 0; i < fields.length; i++)
+          {
+            f = fields[i];
+            if ((f.getModifiers() & NON_WRITABLE) == 0)
+              {
+                out.writeUTF(f.getName());
+                out.writeUTF(getDescriptor(f.getType()));
+              }
+          }
+
+        out.flush();
+        out.close();
+        MessageDigest shaDigest;
+        try
+          {
+            shaDigest = MessageDigest.getInstance("SHA");
+          }
+        catch (Exception ex)
+          {
+            throw new InternalError("SHA digesting algorithm is not available");
+          }
+
+        // Return the digest value to the calling
+        // method as an array of bytes.
+        byte[] sha = shaDigest.digest(bout.toByteArray());
+
+        long hash = 0;
+        for (int i = 0; i < Math.min(8, sha.length); i++)
+          {
+            hash += (long) (sha[i] & 255) << (i * 8);
+          }
+        return hash;
+      }
+    catch (IOException ioex)
+      {
+        throw new Unexpected(ioex);
+      }
+  }
+
+  /**
+   * Converts to hexadecimal string, supplementing leading zeros.
+   */
+  public static String toHex(long l)
+  {
+    StringBuffer b = new StringBuffer();
+    b.append(Long.toHexString(l).toUpperCase());
+    while (b.length() < 16)
+      b.insert(0, '0');
+    return b.toString();
+  }
+
+  /**
+   * Returns a <code>String</code> representing the type-encoding of a class.
+   */
+  static String getDescriptor(Class type)
+  {
+    if (type.equals(boolean.class))
+      return "Z";
+    if (type.equals(byte.class))
+      return "B";
+    if (type.equals(short.class))
+      return "S";
+    if (type.equals(char.class))
+      return "C";
+    if (type.equals(int.class))
+      return "I";
+    if (type.equals(long.class))
+      return "J";
+    if (type.equals(float.class))
+      return "F";
+    if (type.equals(double.class))
+      return "D";
+    if (type.equals(void.class))
+      return "V";
+    else if (type.isArray())
+      {
+        StringBuffer l = new StringBuffer("[");
+        Class component = type.getComponentType();
+
+        while (component.isArray())
+          {
+            l.append('[');
+            component = component.getComponentType();
+          }
+
+        l.append('L');
+        l.append(component.getName().replace('.', '/'));
+        l.append(';');
+        return l.toString();
+      }
+    else
+      return "L" + type.getName().replace('.', '/') + ';';
+  }
+
+  public static Field[] getWritableFields(Class c)
+  {
+    TreeSet set = new TreeSet(new Comparator()
+    {
+      public int compare(Object a, Object b)
+      {
+        return ((Field) a).getName().compareTo(((Field) b).getName());
+      }
+    });
+
+    while (!c.equals(Object.class))
+      {
+        Field[] f = c.getDeclaredFields();
+        for (int i = 0; i < f.length; i++)
+          {
+            if ((f[i].getModifiers() & NON_WRITABLE) == 0)
+              {
+                f[i].setAccessible(true);
+                set.add(f[i]);
+              }
+          }
+        c = c.getSuperclass();
+      }
+
+    Field[] r = new Field[set.size()];
+    int p = 0;
+    Iterator it = set.iterator();
+    while (it.hasNext())
+      {
+        r[p++] = (Field) it.next();
+      }
+    return r;
+  }
+
+  /**
+   * The method is called for Remotes that are not Stubs. It is assumed, that
+   * the Remote is an implementation. The method searches for the suitable tie
+   * and, if found, exports it by creating and connecting the stub. Such export
+   * is supported since jdk 1.5.
+   */
+  void exportTie(org.omg.CORBA_2_3.portable.OutputStream output,
+    Object implementation, Class interfaceClass)
+  {
+    try
+      {
+        // Remote, but non - stub class (implementation)
+        // must be replaced by stub.
+        Tie t = Util.getTie((Remote) implementation);
+        if (t instanceof Servant)
+          {
+            POA rootPoa = POAHelper.narrow(output.orb().resolve_initial_references(
+              "RootPOA"));
+            org.omg.CORBA.Object co = rootPoa.servant_to_reference((Servant) t);
+            Stub stub = (Stub) PortableRemoteObject.narrow(co, interfaceClass);
+            writeRemoteObject(output, stub);
+
+            if (rootPoa.the_POAManager().get_state().value() == State._HOLDING)
+              rootPoa.the_POAManager().activate();
+          }
+        else if (t instanceof org.omg.CORBA.Object)
+          {
+            org.omg.CORBA.Object co = (org.omg.CORBA.Object) t;
+            output.orb().connect(co);
+
+            Stub stub = (Stub) PortableRemoteObject.narrow(co, interfaceClass);
+            writeRemoteObject(output, stub);
+          }
+      }
+    catch (Exception ex)
+      {
+        MARSHAL m = new MARSHAL("Unable to export " + implementation);
+        m.minor = Minor.TargetConversion;
+        m.initCause(ex);
+        throw m;
+      }
+  }
+
+  /**
+   * Start the ORB, if it is not already runnning.
+   */
+  void ensureOrbRunning(org.omg.CORBA_2_3.portable.OutputStream output)
+  {
+    // Ensure ORB is running.
+    if (output.orb() instanceof OrbFunctional)
+      {
+        ((OrbFunctional) output.orb()).ensureRunning();
+      }
+  }
+
+  /**
+   * Write data to the CORBA output stream. Writes the object contents only; the
+   * header must be already written. For object, containing objects, may be
+   * called recursively.
+   * 
+   * @param an_output a stream to write to, must be
+   * org.omg.CORBA_2_3.portable.OutputStream
+   * @param object an object to write.
+   */
+  public void writeRemoteObject(OutputStream an_output, Object object)
+  {
+    org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+
+    if (isTieRequired(object))
+      {
+        // Find the interface that is implemented by the object and extends
+        // Remote.
+        Class fc = getExportedInterface(object);
+        exportTie(output, object, fc);
+      }
+    else if (object instanceof org.omg.CORBA.Object)
+      {
+        ensureOrbRunning(output);
+        an_output.write_Object((org.omg.CORBA.Object) object);
+      }
+    else if (object != null && object instanceof Serializable)
+      writeFields(an_output, (Serializable) object);
+  }
+
+  /**
+   * Write data to the CORBA output stream. Writes the object contents only; the
+   * header must be already written. For object, containing objects, may be
+   * called recursively.
+   * 
+   * @param an_output a stream to write to, must be
+   * org.omg.CORBA_2_3.portable.OutputStream
+   * @param object an object to write.
+   */
+  public void writeValue(OutputStream an_output, Serializable object)
+  {
+    org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+
+    if (isTieRequired(object))
+      {
+        // Find the interface that is implemented by the object and extends
+        // Remote.
+        Class fc = getExportedInterface(object);
+        exportTie(output, object, fc);
+      }
+    else if (object instanceof org.omg.CORBA.Object)
+      {
+        ensureOrbRunning(output);
+        an_output.write_Object((org.omg.CORBA.Object) object);
+      }
+    else if (object instanceof Externalizable)
+      {
+        try
+          {
+            ObjectOutputStream stream = new CorbaOutput(output, object,
+              this);
+            stream.write(VERSION);
+            ((Externalizable) object).writeExternal(stream);
+          }
+        catch (Exception ex)
+          {
+            MARSHAL m = new MARSHAL("writeExternal failed");
+            m.minor = Minor.Value;
+            m.initCause(ex);
+            throw m;
+          }
+      }
+    else if (object instanceof Serializable)
+      {
+        Object mode = null;
+        synchronized (io_format)
+          {
+            mode = io_format.get(object.getClass());
+            if (mode == STANDARD)
+              {
+                writeFields(an_output, (Serializable) object);
+                return;
+              }
+          }
+        try
+          {
+            Method m = object.getClass().getDeclaredMethod("writeObject",
+              WRITE_OBJECT_ARGS);
+            m.setAccessible(true); // May be private.
+
+            try
+              {
+                ObjectOutputStream stream = new CorbaOutput(output,
+                  object, this);
+
+                // Write version.
+                stream.write(VERSION);
+
+                if (mode == CUSTOM_DWO)
+                  // Write true, supposing that the defaultWriteObject
+                  // has been called.
+                  stream.write(1);
+                else if (mode == CUSTOM_NO_DWO)
+                  // Write false (has not been called)
+                  stream.write(0);
+                else
+                  {
+                    // Measure.
+                    DefaultWriteObjectTester tester = new DefaultWriteObjectTester(object);
+                    m.invoke(object, new Object[] { tester });
+
+                    synchronized (io_format)
+                      {
+                        io_format.put(object.getClass(),
+                          tester.dwo_called ? CUSTOM_DWO : CUSTOM_NO_DWO);
+                        stream.write(tester.dwo_called ? 1 : 0);
+                      }
+                  }
+
+                m.invoke(object, new Object[] { stream });
+                stream.flush();
+              }
+            catch (Exception ex)
+              {
+                MARSHAL mx = new MARSHAL(object.getClass().getName()
+                  + ".writeObject failed");
+                mx.initCause(ex);
+                throw mx;
+              }
+          }
+        catch (NoSuchMethodException e)
+          {
+            // Write in a standard way.
+            writeFields(an_output, (Serializable) object);
+            synchronized (io_format)
+              {
+                io_format.put(object.getClass(), STANDARD);
+              }
+          }
+      }
+  }
+
+  /**
+   * Read data from the CDR input stream. Reads the object contents only; the
+   * header must be already read (the repository id or ids ara passed). For
+   * object, containing objects, may be called recursively.
+   * 
+   * @param an_input the stream to read from, must be
+   * org.omg.CORBA_2_3.portable.InputStream
+   * @param object the instance of the object being read.
+   * @param id the repository Id from the stream in the case when single id was
+   * specified.
+   * @param ids the repository Ids from the stream in the case when multiple ids
+   * were specified.
+   * @param codebase the codebase, if it was included in the header of the value
+   * type. Null if not codebase was included.
+   * 
+   * @return the object, extracted from the stream.
+   */
+  /**
+   * Read value from the input stream in the case when the value is not
+   * Streamable or CustomMarshalled.
+   */
+  public Serializable readValue(InputStream in, int offset, Class clz,
+    String repositoryID, RunTime sender)
+  {
+    if (in instanceof HeadlessInput)
+      ((HeadlessInput) in).subsequentCalls = true;
+
+    gnuRuntime g;
+    Serializable object = null;
+
+    try
+      {
+        g = (gnuRuntime) sender;
+        object = g.target;
+      }
+    catch (ClassCastException e)
+      {
+        // Working with the other CORBA implementation.
+        g = null;
+      }
+
+    org.omg.CORBA_2_3.portable.InputStream input = (org.omg.CORBA_2_3.portable.InputStream) in;
+
+    if (Remote.class.isAssignableFrom(clz)
+      || ValueBase.class.isAssignableFrom(clz))
+      {
+        // Interface is narrowed into Stub.
+        if (clz.isInterface())
+          try
+            {
+              clz = Util.loadClass(
+                PortableRemoteObjectDelegateImpl.getStubClassName(clz.getName()),
+                null, clz.getClassLoader());
+            }
+          catch (ClassNotFoundException e)
+            {
+              MARSHAL m = new MARSHAL("Cannot get stub from interface "
+                + clz.getClass().getName());
+              m.minor = Minor.TargetConversion;
+              m.initCause(e);
+              throw m;
+            }
+
+        // Remote needs special handling.
+        if (ObjectImpl.class.isAssignableFrom(clz))
+          {
+            // First read CORBA object reference.
+            Object ro = input.read_Object();
+
+            ObjectImpl obj = (ObjectImpl) ro;
+            if (obj == null)
+              return null;
+
+            Delegate delegate = obj._get_delegate();
+            object = instantiate(offset, clz, g);
+            ((ObjectImpl) object)._set_delegate(delegate);
+          }
+        // The object - specific data follows.
+      }
+    else if (org.omg.CORBA.Object.class.isAssignableFrom(clz))
+      object = (Serializable) input.read_Object();
+
+    if (object == null)
+      object = instantiate(offset, clz, g);
+    
+    // The sentence below prevents attempt to read the internal fields of the
+    // ObjectImpl (or RMI Stub) that might follow the object definition.
+    // Sun's jre 1.5 does not write this information. The stubs, generated
+    // by rmic, does not contain such fields.
+    if (object instanceof ObjectImpl)
+      return object;
+
+    if (object instanceof Externalizable)
+      {
+        try
+          {
+            CorbaInput stream = new CorbaInput(input, object, this,
+              offset, repositoryID, g);
+
+            byte version = stream.readByte();
+            if (version != 1)
+              throw new MARSHAL("Unsuported RMI-IIOP version " + version);
+
+            ((Externalizable) object).readExternal(stream);
+          }
+        catch (Exception ex)
+          {
+            MARSHAL m = new MARSHAL("readExternal failed");
+            m.initCause(ex);
+            throw m;
+          }
+      }
+    else
+      {
+        Object mode = null;
+        synchronized (io_format)
+          {
+            mode = io_format.get(object.getClass());
+          }
+
+        if (mode == STANDARD)
+          {
+            readFields(offset, repositoryID, object, input, g);
+          }
+        else
+          {
+            try
+              {
+                Method m = object.getClass().getDeclaredMethod("readObject",
+                  READ_OBJECT_ARGS);
+                try
+                  {
+                    m.setAccessible(true); // May be private.
+
+                    CorbaInput stream = new CorbaInput(input,
+                      object, this, offset, repositoryID, g);
+
+                    byte version = stream.readByte();
+                    if (version != 1)
+                      throw new MARSHAL("Unsuported RMI-IIOP version "
+                        + version);
+
+                    // This would indicate is defaultWriteObject has been
+                    // called,
+                    // but the readObject method normally takes care about this.
+                    boolean dwo = stream.readByte() != 0;
+
+                    m.invoke(object, new Object[] { stream });
+                    synchronized (io_format)
+                      {
+                        io_format.put(object.getClass(), dwo ? CUSTOM_DWO
+                          : CUSTOM_NO_DWO);
+                      }
+                  }
+                catch (Exception ex)
+                  {
+                    ex.printStackTrace();
+                    MARSHAL mx = new MARSHAL(object.getClass().getName()
+                      + ".readObject failed");
+                    mx.initCause(ex);
+                    throw mx;
+                  }
+              }
+            catch (NoSuchMethodException e)
+              {
+                // Read in a standard way.
+                synchronized (io_format)
+                  {
+                    io_format.put(object.getClass(), STANDARD);
+                    readFields(offset, repositoryID, object, input, g);
+                  }
+              }
+          }
+      }
+    return object;
+  }
+
+  /**
+   * Create an instance.
+   */
+  Serializable instantiate(int offset, Class clz, gnuRuntime g)
+    throws MARSHAL
+  {
+    Serializable object;
+    try
+      {
+        object = (Serializable) Vio.instantiateAnyWay(clz);
+        g.objectWritten(object, offset);
+      }
+    catch (Exception e)
+      {
+        MARSHAL m = new MARSHAL("Unable to instantiate " + clz);
+        m.minor = Minor.Instantiation;
+        m.initCause(e);
+        throw m;
+      }
+    return object;
+  }
+
+  /**
+   * Read fields of the object.
+   */
+  void readFields(int offset, String repositoryID, Serializable object,
+    org.omg.CORBA_2_3.portable.InputStream input, gnuRuntime r)
+    throws MARSHAL
+  {
+    Field f = null;
+    Class o_class = object.getClass();
+
+    try
+      {
+        // The returned field array must already be in canonical order.
+        Field[] fields = getWritableFields(o_class);
+
+        Class fc;
+
+        for (int i = 0; i < fields.length; i++)
+          {
+            // Full value type header expected ahead.
+            if (input instanceof HeadlessInput)
+              ((HeadlessInput) input).subsequentCalls = true;
+
+            f = fields[i];
+            fc = f.getType();
+
+            Object v;
+
+            if (fc == String.class)
+              {
+                v = input.read_value(wStringValueHelper);
+              }
+            else if (fc == int.class)
+              v = new Integer(input.read_long());
+            else if (fc == long.class)
+              v = new Long(input.read_longlong());
+            else if (fc == double.class)
+              v = new Double(input.read_double());
+            else if (fc == float.class)
+              v = new Float(input.read_float());
+            else if (fc == boolean.class)
+              v = input.read_boolean() ? Boolean.TRUE : Boolean.FALSE;
+            else if (fc == short.class)
+              v = new Short(input.read_short());
+            else if (fc == byte.class)
+              v = new Byte(input.read_octet());
+            else if (fc == char.class)
+              v = new Character(input.read_char());
+            else if (org.omg.CORBA.Object.class.isAssignableFrom(fc)
+              || Remote.class.isAssignableFrom(fc))
+              {
+                v = readValue(input, offset, fc, null, r);
+              }
+            else
+              {
+                v = Vio.read(input, fc);
+              }
+
+            f.set(object, v);
+          }
+      }
+    catch (Exception ex)
+      {
+        MARSHAL m = new MARSHAL("Cannot read " + o_class.getName() + " field "
+          + f);
+        m.initCause(ex);
+        m.minor = Minor.ValueFields;
+        throw m;
+      }
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/StubDelegateImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/StubDelegateImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,310 @@
+/* StubDelegateImpl.java --
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.StubDelegate;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+/**
+ * The default stub delegate.
+ * 
+ * @author Wu Gansha (gansha.wu at intel.com) (stub)
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) (implementation)
+ */
+public class StubDelegateImpl
+  implements StubDelegate
+{
+  /**
+   * <p>
+   * Finds the suitable {@link Tie} for this Stub and connects it to the given
+   * ORB. The tie is found by the name pattern. If the found tie is derived from
+   * {@link org.omg.CORBA.PortableServer.Servant}, it is connected to the root
+   * POA, also activating it (if not already active).
+   * </p>
+   * <p>
+   * This method does not allow to specify, to which POA the found Tie must be
+   * connected and requires to use the deprecated method {@link ORB#connect}.
+   * Many useful POA features remain unaccessible. A better alternative it might
+   * be to generate a {@link org.omg.CORBA.PortableServer.Servant} - derived Tie
+   * (-poa key in rmic) and connect it to POA in one of the many ways, listed in
+   * the description of the {@link orb.omg.PortableServer} package). The
+   * obtained CORBA object can be narrowed into stub using
+   * {@link PortableRemoteObject#narrow}.
+   * </p>
+   * 
+   * @param orb the ORB where the Stub must be connected.
+   * 
+   * @throws RemoteException if the stub is already connected to some other ORB.
+   * If the stub is already connected to the ORB that was passed as parameter,
+   * the method returns without action.
+   * 
+   * @throws BAD_PARAM if the name of this stub does not match the stub name
+   * pattern, "_*_Stub" or if the Tie class, "_*Impl_Tie", does not exists or an
+   * instance of this class cannot be instantiated.
+   */
+  public void connect(Stub self, ORB orb)
+    throws RemoteException
+  {
+    connect(self, orb, null);
+  }
+
+  /**
+   * Connect when the POA is specified.
+   */
+  public static void connect(Stub self, ORB orb, POA poa)
+    throws RemoteException
+  {
+    ORB oorb = null;
+    try
+      {
+        Delegate d = self._get_delegate();
+        if (d != null)
+          oorb = d.orb(self);
+      }
+    catch (Exception e)
+      {
+        // Failed to get Delegate or ORB.
+        // (possible ony for user-written Stubs).
+      }
+
+    if (oorb != null)
+      {
+        if (!oorb.equals(orb))
+          throw new RemoteException("Stub " + self
+            + " is connected to another ORB, " + orb);
+        else
+          return;
+      }
+
+    Tie t = null;
+    if (self instanceof Remote)
+      t = Util.getTie((Remote) self);
+
+    // Find by name pattern.
+    if (t == null)
+      t = getTieFromStub(self);
+
+    Delegate delegate;
+
+    if (t instanceof Servant)
+      {
+        try
+          {
+            if (poa == null)
+              {
+                poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+                // Activate if not active.
+                if (poa.the_POAManager().get_state().value() == State._HOLDING)
+                  poa.the_POAManager().activate();
+              }
+
+            ObjectImpl obj = (ObjectImpl) poa.servant_to_reference((Servant) t);
+            delegate = obj._get_delegate();
+          }
+        catch (Exception ex)
+          {
+            throw new Unexpected(ex);
+          }
+      }
+    else if (t instanceof ObjectImpl)
+      {
+        ObjectImpl o = (ObjectImpl) t;
+        orb.connect(o);
+        delegate = o._get_delegate();
+      }
+    else
+      throw new BAD_PARAM("The Tie must be either Servant or ObjectImpl");
+
+    self._set_delegate(delegate);
+  }
+
+  /**
+   * Locate a tie class, appropriate to the given stub class, by the name
+   * pattern.
+   */
+  public static Tie getTieFromStub(java.lang.Object self)
+  {
+    Tie t;
+    String sn = self.getClass().getName();
+    if (!sn.endsWith("_Stub"))
+      throw new BAD_PARAM("The stub name, " + sn
+        + ", does not match _*_Stub pattern");
+
+    String tn = sn.substring(0, sn.length() - "_Stub".length()) + "Impl_Tie";
+    Class tieClass = null;
+
+    try
+      {
+        tieClass = ObjectCreator.forName(tn);
+        t = (Tie) tieClass.newInstance();
+        if (self instanceof Remote)
+          Util.registerTarget(t, (Remote) self);
+      }
+    catch (Exception e)
+      {
+        BAD_PARAM bad = new BAD_PARAM("Unable to instantiate '" + tn + "'");
+        bad.initCause(e);
+        throw bad;
+      }
+    return t;
+  }
+
+  /**
+   * Compare two stubs for equality.
+   */
+  public boolean equals(Stub self, java.lang.Object obj)
+  {
+    if (obj instanceof ObjectImpl)
+      {
+        ObjectImpl other = (ObjectImpl) obj;
+        Delegate d1 = other._get_delegate();
+        Delegate d2 = self._get_delegate();
+        if (d1 == null || d2 == null)
+          return d1 == d2;
+        else
+          return d1.equals(d2);
+      }
+    else return false;
+  }
+
+  /**
+   * Get the hash code (from IOR reference).
+   */
+  public int hashCode(Stub self)
+  {
+    Delegate d = self._get_delegate();
+    return d==null?0:d.hashCode();
+  }
+
+  /**
+   * Returns the IOR reference of the connected ORB.
+   * 
+   * @see ORB#object_to_string(org.omg.CORBA.Object);
+   */
+  public String toString(Stub self)
+  {
+    try
+      {
+        return self._orb().object_to_string(self);
+      }
+    catch (Exception ex)
+      {
+        return null;
+      }
+  }
+
+  /**
+   * This should never be called. The ORB must be supplied.
+   * 
+   * @see #connect
+   */
+  public void readObject(Stub self, ObjectInputStream input)
+    throws IOException, ClassNotFoundException
+  {
+    readObject(self, input, null);
+  }
+
+  /**
+   * Read as CORBA object when the ORB is known. The ORB must be set under the
+   * previous call of Stub.connect. The Stub is automatically registered with
+   * this ORB.
+   */
+  public void readObject(Stub self, ObjectInputStream input, ORB orb)
+    throws IOException, ClassNotFoundException
+  {
+    byte[] b = (byte[]) input.readObject();
+    BufferredCdrInput in = new BufferredCdrInput(b);
+
+    if (orb != null)
+      in.setOrb(orb);
+
+    ObjectImpl r = (ObjectImpl) in.read_Object();
+
+    self._set_delegate(r._get_delegate());
+  }
+
+  /**
+   * Write as CORBA object. The ORB is taken from the
+   * org.omg.CORBA.portable.Delegate. The Stub is automatically registered with
+   * this ORB (if not already done).
+   */
+  public void writeObject(Stub self, ObjectOutputStream output)
+    throws IOException
+  {
+    writeObject(self, output, null);
+  }
+
+  /**
+   * Write as CORBA object. The ORB must be either set under the previous call
+   * of Stub.connect or it is taken from the org.omg.CORBA.portable.Delegate.
+   * The Stub is automatically registered with this ORB (if not already done).
+   */
+  public void writeObject(Stub self, ObjectOutputStream output, ORB orb)
+    throws IOException
+  {
+    BufferedCdrOutput out = new BufferedCdrOutput();
+    out.setOrb(orb == null ? self._orb() : orb);
+    out.write_Object(self);
+
+    output.writeObject(out.buffer.toByteArray());
+  }
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/TieTargetRecord.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/TieTargetRecord.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* TieTargetRecord.java --
+   Copyright (C) 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 gnu.javax.rmi.CORBA;
+
+import java.util.HashSet;
+
+import javax.rmi.CORBA.Tie;
+
+/**
+ * Represents a Tie, connected to possibly multiple invocation targets.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class TieTargetRecord
+{
+  /**
+   * The associated Tie.
+   */
+  public final Tie tie;
+
+  /**
+   * The objects, exposing the tie.
+   */
+  public HashSet targets = new HashSet();
+
+  /**
+   * Create a new record.
+   */
+  public TieTargetRecord(Tie a_tie)
+  {
+    tie = a_tie;
+  }
+
+  /**
+   * Add a target.
+   */
+  public void add(Object target)
+  {
+    targets.add(target);
+  }
+
+  /**
+   * Remove target.
+   */
+  public void remove(Object target)
+  {
+    targets.remove(target);
+  }
+
+  /**
+   * Return true if the tie has no associated invocation targets.
+   */
+  public boolean unused()
+  {
+    return targets.size() == 0;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/UtilDelegateImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/UtilDelegateImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,754 @@
+/* UtilDelegateImpl.java --
+   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.Minor;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Poa.AOM;
+import gnu.CORBA.Poa.gnuPOA;
+import gnu.CORBA.typecodes.GeneralTypeCode;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.COMM_FAILURE;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.INVALID_TRANSACTION;
+import org.omg.CORBA.INV_OBJREF;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_PERMISSION;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.OMGVMCID;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
+import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.AccessException;
+import java.rmi.MarshalException;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.ServerError;
+import java.rmi.ServerException;
+import java.rmi.UnexpectedException;
+import java.rmi.server.RMIClassLoader;
+import java.util.Hashtable;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.UtilDelegate;
+import javax.rmi.CORBA.ValueHandler;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.TransactionRequiredException;
+import javax.transaction.TransactionRolledbackException;
+
+/**
+ * The implementation of UtilDelegate.
+ * 
+ * @author Wu Gansha (gansha.wu at intel.com) (stub)
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) (implementation)
+ */
+public class UtilDelegateImpl
+  extends RmiUtilities
+  implements UtilDelegate
+{
+  /**
+   * The instance of the value handler, requested once.
+   */
+  static ValueHandler m_ValueHandler;
+
+  /**
+   * The global map of all ties to they records.
+   */
+  static Hashtable m_Ties = new Hashtable();
+
+  /**
+   * The global map of all targets to they records.
+   */
+  static Hashtable m_Targets = new Hashtable();
+
+  /**
+   * The standard package for that the exception names are omitted.
+   */
+  static final String m_StandardPackage = "org.omg.CORBA.";
+
+  /**
+   * Make a deep copy of the object.
+   */
+  public Object copyObject(Object obj, ORB orb)
+    throws RemoteException
+  {
+    // Strings are immutable, can be shared.
+    if (obj instanceof String)
+      return obj;
+    else if (obj == null)
+      return null;
+    else if (obj instanceof String[] || obj instanceof String[][]
+      || obj instanceof String[][][])
+      {
+        // String arrays can be just cloned.
+        return ((Object[]) obj).clone();
+      }
+    else if (obj instanceof Serializable)
+      {
+        try
+          {
+            ByteArrayOutputStream a = new ByteArrayOutputStream();
+            ObjectOutputStream ou = new ObjectOutputStream(a);
+            ou.writeObject(obj);
+            ou.close();
+            ObjectInputStream input = new ObjectInputStream(
+              new ByteArrayInputStream(a.toByteArray()));
+            return input.readObject();
+          }
+        catch (Exception ex)
+          {
+            RemoteException rex = new RemoteException("Cannot copy " + obj);
+            throw rex;
+          }
+      }
+    else
+      return obj;
+  }
+
+  /**
+   * Make a deep copy of the object array.
+   */
+  public Object[] copyObjects(Object[] obj, ORB orb)
+    throws RemoteException
+  {
+    return (Object[]) copyObject(obj, orb);
+  }
+
+  public ValueHandler createValueHandler()
+  {
+    if (m_ValueHandler == null)
+      m_ValueHandler = (ValueHandler) DelegateFactory.getInstance(DelegateFactory.VALUEHANDLER);
+    return m_ValueHandler;
+  }
+
+  /**
+   * Returns the codebase of the given class.
+   */
+  public String getCodebase(Class clz)
+  {
+    return RMIClassLoader.getClassAnnotation(clz);
+  }
+
+  /**
+   * Get the Tie that handles invocations on the given target. If the target/Tie
+   * pair has not been previously registered using {@link #registerTarget},
+   * this method tries to locate a tie class by the name pattern. If this
+   * succeeds, the tie-target pair is also registered.
+   * 
+   * @return the Tie.
+   */
+  public Tie getTie(Remote target)
+  {
+    synchronized (m_Targets)
+      {
+        Tie tie;
+        TieTargetRecord r = ((TieTargetRecord) m_Targets.get(target));
+        if (r == null)
+          {
+            if (target instanceof Stub)
+              {
+                tie = StubDelegateImpl.getTieFromStub(target);
+                registerTarget(tie, target);
+              }
+            else
+              {
+                // Treat this as implementation.
+                String tieClassName = getTieClassName(target.getClass().getName());
+                try
+                  {
+                    Class tieClass = Util.loadClass(tieClassName, null,
+                      target.getClass().getClassLoader());
+                    tie = (Tie) tieClass.newInstance();
+                  }
+                catch (Exception e)
+                  {
+                    MARSHAL m = new MARSHAL("Unable to instantiate "
+                      + tieClassName);
+                    m.minor = Minor.TargetConversion;
+                    m.initCause(e);
+                    throw m;
+                  }
+                tie.setTarget(target);
+                registerTarget(tie, target);
+              }
+          }
+        else
+          tie = r.tie;
+        return tie;
+      }
+  }
+
+  /**
+   * Get the Stub class name for the name, representing the given interface.
+   */
+  private String getTieClassName(String interf)
+  {
+    String stubClassName;
+    int p = interf.lastIndexOf('.');
+
+    if (p < 0)
+      // The interface is defined in the default package.
+      stubClassName = "_" + interf + "_Tie";
+    else
+      stubClassName = interf.substring(0, p + 1) + "_"
+        + interf.substring(p + 1) + "_Tie";
+    return stubClassName;
+  }
+
+  /**
+   * Register the Tie-target pair. As the Tie is a Servant, it can potentially
+   * be connected to several objects and hence may be registered with several
+   * targets.
+   */
+  public void registerTarget(Tie tie, Remote target)
+  {
+    synchronized (m_Ties)
+      {
+        synchronized (m_Targets)
+          {
+            TieTargetRecord r = (TieTargetRecord) m_Ties.get(tie);
+            if (r == null)
+              {
+                // First registration for this Tie.
+                r = new TieTargetRecord(tie);
+                m_Ties.put(tie, r);
+              }
+            if (target != null)
+              {
+                r.add(target);
+                m_Targets.put(target, r);
+              }
+          }
+      }
+  }
+
+  /**
+   * Deactivate the associated Tie, if it is found and is not connected to other
+   * registered targets. Independing from the POA policies, the transparent
+   * reactivation will not be possible.
+   */
+  public void unexportObject(Remote target)
+    throws NoSuchObjectException
+  {
+    synchronized (m_Ties)
+      {
+        synchronized (m_Targets)
+          {
+            TieTargetRecord r = ((TieTargetRecord) m_Targets.get(target));
+            if (r != null)
+              {
+                if (target instanceof org.omg.CORBA.Object)
+                  r.tie.orb().disconnect((org.omg.CORBA.Object) target);
+
+                if (r.unused())
+                  {
+                    m_Targets.remove(target);
+                    m_Ties.remove(r.tie);
+                    r.tie.deactivate();
+
+                    if (r.tie.orb() instanceof ORB_1_4)
+                      {
+                        // Standard case, when more deep cleanup is possible.
+                        // Independing from the POA policies, the object will
+                        // not be activable transparently.
+                        ORB_1_4 orb = (ORB_1_4) r.tie.orb();
+
+                        if (target instanceof org.omg.CORBA.Object)
+                          {
+                            AOM.Obj record = orb.rootPOA.findObject((org.omg.CORBA.Object) target);
+
+                            if (record != null && record.servant == r.tie
+                              && record.poa instanceof gnuPOA)
+                              {
+                                ((gnuPOA) record.poa).aom.remove(record.key);
+                                record.deactivated = true;
+                                record.servant = null;
+                              }
+                          }
+                      }
+                  }
+              }
+          }
+      }
+  }
+
+  /**
+   * Checks if the given stub is local.
+   * 
+   * @param stub a stub to check.
+   * @return true if the stub is local, false otherwise.
+   */
+  public boolean isLocal(Stub stub)
+    throws RemoteException
+  {
+    try
+      {
+        return stub._is_local();
+      }
+    catch (SystemException e)
+      {
+        RemoteException rex = new RemoteException();
+        rex.initCause(e);
+        throw rex;
+      }
+  }
+
+  /**
+   * Load the class. The method uses class loaders from the call stact first. If
+   * this fails, the further behaviour depends on the System Property
+   * "java.rmi.server.useCodebaseOnly" with default value "false".
+   * 
+   * <ul>
+   * <li>Try the current thread context class loader first.</li>
+   * <li>If remoteCodebase is non-null and useCodebaseOnly is "false" then call
+   * java.rmi.server.RMIClassLoader.loadClass (remoteCodebase, className)</li>
+   * <li> If remoteCodebase is null or useCodebaseOnly is true then call
+   * java.rmi.server.RMIClassLoader.loadClass(className)</li>
+   * <li>If a class is still not successfully loaded and the loader != null
+   * then try Class.forName(className, false, loader). </li>
+   * </ul>
+   * 
+   * @param className the name of the class.
+   * @param remoteCodebase the codebase.
+   * @param loader the class loader.
+   * @return the loaded class.
+   * 
+   * @throws ClassNotFoundException of the class cannot be loaded.
+   */
+  public Class loadClass(String className, String remoteCodebase,
+    ClassLoader loader)
+    throws ClassNotFoundException
+  {
+    if (loader == null)
+      loader = Thread.currentThread().getContextClassLoader();
+
+    String p_useCodebaseOnly = System.getProperty("java.rmi.server.useCodebaseOnly");
+
+    boolean useCodebaseOnly = p_useCodebaseOnly != null
+      && p_useCodebaseOnly.trim().equalsIgnoreCase("true");
+
+    try
+      {
+        if (remoteCodebase != null && !useCodebaseOnly)
+          return RMIClassLoader.loadClass(remoteCodebase, className);
+      }
+    catch (Exception e)
+      {
+        // This failed but try others.
+      }
+
+    try
+      {
+        if (remoteCodebase == null || useCodebaseOnly)
+          return RMIClassLoader.loadClass(remoteCodebase, className);
+      }
+    catch (Exception e)
+      {
+        // This failed but try others.
+      }
+
+    if (loader != null)
+      return Class.forName(className, true, loader);
+
+    throw new ClassNotFoundException(className + " at " + remoteCodebase);
+  }
+
+  /**
+   * Converts CORBA {@link SystemException} into RMI {@link RemoteException}.
+   * The exception is converted as defined in the following table:
+   * <p>
+   * <table border = "1">
+   * <tr>
+   * <th>CORBA Exception</th>
+   * <th>RMI Exception</th>
+   * </tr>
+   * <tr>
+   * <td>{@link COMM_FAILURE}</td>
+   * <td>{@link MarshalException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link INV_OBJREF}</td>
+   * <td>{@link  NoSuchObjectException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link NO_PERMISSION}</td>
+   * <td>{@link  AccessException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link MARSHAL}</td>
+   * <td>{@link  MarshalException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link BAD_PARAM} (all other cases)</td>
+   * <td>{@link  MarshalException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link OBJECT_NOT_EXIST}</td>
+   * <td>{@link  NoSuchObjectException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link TRANSACTION_REQUIRED}</td>
+   * <td>{@link  TransactionRequiredException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link TRANSACTION_ROLLEDBACK}</td>
+   * <td>{@link  TransactionRolledbackException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link INVALID_TRANSACTION}</td>
+   * <td>{@link  InvalidTransactionException}</td>
+   * </tr>
+   * <tr>
+   * <td bgcolor="lightgray">Any other {@link SystemException}</td>
+   * <td bgcolor="lightgray">{@link RemoteException}</td>
+   * </tr>
+   * </table>
+   * </p>
+   * <p>
+   * The exception detailed message always consists of
+   * <ol>
+   * <li>the string "CORBA "</li>
+   * <li>the CORBA name of the system exception</li>
+   * <li>single space</li>
+   * <li>the hexadecimal value of the system exception's minor code, preceeded
+   * by 0x (higher bits contain {@link OMGVMCID}).</li>
+   * <li>single space</li>
+   * <li>the {@link CompletionStatus} of the exception: "Yes", "No" or "Maybe".</li>
+   * </ol>
+   * <p>
+   * For instance, if the Internet connection was refused:
+   * </p>
+   * <p>
+   * <pre>
+   * <code>CORBA COMM_FAILURE 0x535500C9 No</code>
+   * </p>
+   * <p>
+   * The original CORBA exception is set as the cause of the RemoteException
+   * being created.
+   * </p>
+   */
+  public RemoteException mapSystemException(SystemException ex)
+  {
+    RemoteException rex;
+
+    String status;
+
+    switch (ex.completed.value())
+      {
+        case CompletionStatus._COMPLETED_MAYBE:
+          status = "Maybe";
+          break;
+
+        case CompletionStatus._COMPLETED_NO:
+          status = "No";
+          break;
+
+        case CompletionStatus._COMPLETED_YES:
+          status = "Yes";
+          break;
+
+        default:
+          status = "Unexpected completion status " + ex.completed.value();
+      }
+
+    String name = ex.getClass().getName();
+
+    if (name.startsWith(m_StandardPackage))
+      name = name.substring(m_StandardPackage.length());
+
+    String message = "CORBA " + name + " 0x" + Integer.toHexString(ex.minor)
+      + " " + status;
+
+    if (ex instanceof COMM_FAILURE)
+      rex = new MarshalException(message, ex);
+    else if (ex instanceof INV_OBJREF)
+      {
+        rex = new NoSuchObjectException(message);
+        rex.detail = ex;
+      }
+    else if (ex instanceof NO_PERMISSION)
+      rex = new AccessException(message, ex);
+    else if (ex instanceof MARSHAL)
+      rex = new MarshalException(message, ex);
+    else if (ex instanceof BAD_PARAM)
+      rex = new MarshalException(message, ex);
+    else if (ex instanceof OBJECT_NOT_EXIST)
+      {
+        rex = new NoSuchObjectException(message);
+        rex.detail = ex;
+      }
+    else if (ex instanceof TRANSACTION_REQUIRED)
+      {
+        rex = new TransactionRequiredException(message);
+        rex.detail = ex;
+      }
+    else if (ex instanceof TRANSACTION_ROLLEDBACK)
+      {
+        rex = new TransactionRolledbackException(message);
+        rex.detail = ex;
+      }
+    else if (ex instanceof INVALID_TRANSACTION)
+      {
+        rex = new InvalidTransactionException(message);
+        rex.detail = ex;
+      }
+    else if (ex instanceof UNKNOWN)
+      rex = wrapException(ex.getCause());
+    else
+      rex = new RemoteException(message, ex);
+
+    return rex;
+  }
+
+  /**
+   * Converts the exception that was thrown by the implementation method on a
+   * server side into RemoteException that can be transferred and re-thrown on a
+   * client side. The method converts exceptions as defined in the following
+   * table: <table border = "1">
+   * <tr>
+   * <th>Exception to map (or subclass)</th>
+   * <th>Maps into</th>
+   * </tr>
+   * <tr>
+   * <td>{@link Error}</td>
+   * <td>{@link ServerError}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link RemoteException}</td>
+   * <td>{@link ServerException}</td>
+   * </tr>
+   * <tr>
+   * <td>{@link SystemException}</td>
+   * <td>wrapException({@link #mapSystemException})</td>
+   * </tr>
+   * <tr>
+   * <td>{@link RuntimeException}</td>
+   * <td><b>rethrows</b></td>
+   * </tr>
+   * <tr>
+   * <td>Any other exception</td>
+   * <td>{@link UnexpectedException}</td>
+   * </tr>
+   * </table>
+   * 
+   * @param ex an exception that was thrown on a server side implementation.
+   * 
+   * @return the corresponding RemoteException unless it is a RuntimeException.
+   * 
+   * @throws RuntimeException the passed exception if it is an instance of
+   * RuntimeException.
+   * 
+   * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0.
+   */
+  public RemoteException wrapException(Throwable ex)
+    throws RuntimeException
+  {
+    if (ex instanceof RuntimeException)
+      throw (RuntimeException) ex;
+    else if (ex instanceof Error)
+      return new ServerError(ex.getMessage(), (Error) ex);
+    else if (ex instanceof RemoteException)
+      return new ServerException(ex.getMessage(), (Exception) ex);
+    else if (ex instanceof SystemException)
+      return wrapException(mapSystemException((SystemException) ex));
+    else
+      return new UnexpectedException("Unexpected", (Exception) ex);
+  }
+
+  /**
+   * Write abstract interface to the CORBA output stream. The write format is
+   * matching CORBA abstract interface. Remotes and CORBA objects are written as
+   * objects, other classes are supposed to be value types and are written as
+   * such. {@link Remote}s are processed as defined in
+   * {@link #writeRemoteObject}. The written data contains discriminator,
+   * defining, that was written. Another method that writes the same content is
+   * {@link org.omg.CORBA_2_3.portable.OutputStream#write_abstract_interface(java.lang.Object)}.
+   * 
+   * @param output a stream to write to, must be
+   * {@link org.omg.CORBA_2_3.portable.OutputStream}.
+   * 
+   * @param object an object to write, must be CORBA object, Remote
+   */
+  public void writeAbstractObject(OutputStream output, Object object)
+  {
+    ((org.omg.CORBA_2_3.portable.OutputStream) output).write_abstract_interface(object);
+  }
+
+  /**
+   * Write the passed java object to the output stream in the form of the CORBA
+   * {@link Any}. This includes creating an writing the object {@link TypeCode}
+   * first. Such Any can be later read by a non-RMI-IIOP CORBA implementation
+   * and manipulated, for instance, by means, provided in
+   * {@link org.omg.DynamicAny.DynAny}. Depending from the passed value, this
+   * method writes CORBA object, value type or value box. For value types Null
+   * is written with the abstract interface, its typecode having repository id
+   * "IDL:omg.org/CORBA/AbstractBase:1.0" and the empty string name.
+   * 
+   * @param output the object to write.
+   * @param object the java object that must be written in the form of the CORBA
+   * {@link Any}.
+   */
+  public void writeAny(OutputStream output, Object object)
+  {
+    Any any = output.orb().create_any();
+    if (object == null)
+      {
+        GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_abstract_interface);
+        t.setId("IDL:omg.org/CORBA/AbstractBase:1.0");
+        t.setName("");
+        any.type(t);
+        output.write_any(any);
+        return;
+      }
+    else if (object instanceof org.omg.CORBA.Object
+      && !(object instanceof Remote))
+      {
+        // Write as value type.
+        boolean inserted = ObjectCreator.insertWithHelper(any, object);
+        if (inserted)
+          {
+            output.write_any(any);
+            return;
+          }
+      }
+
+    if (object instanceof org.omg.CORBA.Object)
+      writeAnyAsRemote(output, object);
+    else if (object instanceof Serializable)
+      {
+        any.insert_Value((Serializable) object);
+        output.write_any(any);
+      }
+    else
+      {
+        MARSHAL m = new MARSHAL(object.getClass().getName()
+          + " must be CORBA Object, Remote or Serializable");
+        m.minor = Minor.NonSerializable;
+        throw m;
+      }
+  }
+
+  /**
+   * Write Any as for remote object.
+   */
+  void writeAnyAsRemote(OutputStream output, Object object)
+  {
+    GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_objref);
+    t.setId(m_ValueHandler.getRMIRepositoryID(object.getClass()));
+    t.setName(object.getClass().getName());
+
+    // Writing Any (typecode, followed by value).
+    output.write_TypeCode(t);
+    writeRemoteObject(output, object);
+  }
+
+  /**
+   * Get the class name excluding the package name.
+   */
+  String getName(String n)
+  {
+    int p = n.lastIndexOf('.');
+    if (p < 0)
+      return n;
+    else
+      return n.substring(p + 1);
+  }
+
+  /**
+   * Read Any from the input stream.
+   */
+  public Object readAny(InputStream input)
+  {
+    return input.read_any();
+  }
+
+  /**
+   * Write the passed parameter to the output stream as CORBA object. If the
+   * parameter is an instance of Remote and not an instance of Stub, the method
+   * instantiates a suitable Tie, connects the parameter to this Tie and then
+   * connects that Tie to the ORB that is requested from the output stream. Then
+   * the object reference is written to the stream, making remote invocations
+   * possible. This method is used in write_value(..) method group in
+   * {@link org.omg.CORBA_2_3.portable.OutputStream} and also may be called
+   * directly from generated Stubs and Ties.
+   * 
+   * @param output a stream to write to, must be
+   * org.omg.CORBA_2_3.portable.OutputStream
+   * @param object an object to write.
+   */
+  public void writeRemoteObject(OutputStream an_output, Object object)
+  {
+    org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+    if (object == null)
+      an_output.write_Object(null);
+    else if (isTieRequired(object))
+      {
+        // Find the interface that is implemented by the object and extends
+        // Remote.
+        Class fc = getExportedInterface(object);
+        exportTie(output, object, fc);
+      }
+    else if (object instanceof org.omg.CORBA.Object)
+      {
+        ensureOrbRunning(output);
+        an_output.write_Object((org.omg.CORBA.Object) object);
+      }
+    else if (object != null && object instanceof Serializable)
+      writeFields(an_output, (Serializable) object);
+  }
+
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,163 @@
+/* ValueHandlerDelegateImpl.java --
+   Copyright (C) 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 gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.CDR.gnuRuntime;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CustomMarshal;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.SendingContext.RunTime;
+
+import java.io.Externalizable;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.rmi.Remote;
+
+import javax.rmi.CORBA.ValueHandler;
+import javax.rmi.CORBA.ValueHandlerMultiFormat;
+
+/**
+ * Implementation of the ValueHandler.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) (implementation)
+ */
+public class ValueHandlerDelegateImpl
+  extends RmiUtilities
+  implements ValueHandler, ValueHandlerMultiFormat
+{
+  /** 
+   * Return the maximal supported stream format version. We currently
+   * support the version 1.
+   * 
+   * TODO Support the version 2.
+   */
+  public byte getMaximumStreamFormatVersion()
+  {
+    return 1;
+  }
+
+  /**
+   * Write value using the given stream format version.
+   */
+  public void writeValue(OutputStream output, Serializable value, byte version)
+  {
+    if (version!=1)
+      throw new BAD_PARAM("Unsupported stream format version "+version);
+    else 
+      writeValue(output, value);
+  }
+
+  /**
+   * This implementation associates RunTime with stream rather than with the
+   * value handler and this method is not used in the implementation. It is
+   * implemented just for the sake of compatibility. 
+   */
+  public RunTime getRunTimeCodeBase()
+  {
+    return new gnuRuntime(null, null);
+  }
+
+  /**
+   * Checks if an instance of this class can write its fields itself.
+   */
+  public boolean isCustomMarshaled(Class clz)
+  {
+    return CustomMarshal.class.isAssignableFrom(clz)
+      || Streamable.class.isAssignableFrom(clz);
+  }
+
+  /**
+   * No replacement, returns the passed parameter.
+   */
+  public Serializable writeReplace(Serializable value)
+  {
+    return value;
+  }
+
+  /**
+   * Compute the repository id in the RMI hashed format.
+   */
+  public String getRMIRepositoryID(final Class cx)
+  {
+    long hash = 0;
+    Class of = cx.isArray() ? cx.getComponentType() : null;
+
+    if (cx.equals(String[].class))
+      return RMI_STRING_ARRAY_ID;
+    else if (cx.equals(String.class))
+      return RMI_STRING_ID;
+    else if (cx.equals(Class.class))
+      return RMI_CLASS_ID;
+    else if (Remote.class.isAssignableFrom(cx)
+      || !Serializable.class.isAssignableFrom(cx)
+      || cx.isInterface()
+      || (cx.isArray() && (!Serializable.class.isAssignableFrom(of)
+        || of.isPrimitive() || Remote.class.isAssignableFrom(of)))
+
+    )
+      // Some classes that have zero hash code and serial no version id
+      // included.
+      return "RMI:" + cx.getName() + ":" + toHex(hash);
+    else if (cx.isArray())
+      // Arrays have the same hashcode and uid as they components.
+      return "RMI:" + cx.getName() + ":" + toHex(getHashCode(of)) + ":"
+        + toHex(getSid(of));
+    else
+      {
+        if (Externalizable.class.isAssignableFrom(cx))
+          hash = 1;
+        else
+          hash = getHashCode(cx);
+
+        return "RMI:" + cx.getName() + ":" + toHex(hash) + ":"
+          + toHex(getSid(cx));
+      }
+  }
+
+  /**
+   * Get the class serial version UID.
+   */
+  long getSid(Class cx)
+  {
+    ObjectStreamClass osc = ObjectStreamClass.lookup(cx);
+    return osc.getSerialVersionUID();
+  }
+}
\ No newline at end of file

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/Password.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/Password.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,285 @@
+/* Password.java -- opaque wrapper around a password.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth;
+
+import gnu.java.security.util.ExpirableObject;
+
+import javax.security.auth.DestroyFailedException;
+
+/**
+ * Immutible, though destroyable, password class.
+ *
+ * <p>Extends {@link ExpirableObject}, implementing {@link doDestroy()}
+ * in which encapsulated {@link char[]}, and {@link byte[]} password fields
+ * are cleared (elements set to zero) in order to thwart memory heap
+ * snooping.
+ */
+public final class Password extends ExpirableObject
+{
+
+  // Constants and variables
+  // -------------------------------------------------------------------------
+
+  /**
+   * Password stored in {@link char[]} format.
+   */
+  private final char[] password;
+
+  /**
+   * Password stored in {@link byte[]} format.
+   */
+  private final byte[] bPassword;
+
+  /**
+   * Indicates whether this Password object's {@link doDestroy()} method has
+   * been called.  See also, {@link ExpirableObject#Destroy()}.
+   */
+  private boolean mIsDestroyed = false;
+
+  // Constructor(s)
+  // -------------------------------------------------------------------------
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * default timeout {@link ExpirableObject#DEFAULT_TIMEOUT}.
+   *
+   * @param password The character array password to associate with this
+   * Password object.
+   */
+  public Password (char[] password)
+  {
+    this (password, 0, password.length, DEFAULT_TIMEOUT);
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * timeout denoted by constructor parameter, <i>delay</i>.
+   *
+   * @param password The character array password to associate with this
+   * Password object.
+   * @param delay The number of miliseconds before this Password object
+   * will be automatically destroyed.
+   */
+  public Password (char[] password, long delay)
+  {
+    this (password, 0, password.length, delay);
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * default timeout {@link ExpirableObject#DEFAULT_TIMEOUT}.
+   *
+   * @param password The character array password to associate with this
+   * Password object.
+   * @param offset The <i>password</i> character array parameter element
+   * marking the beginning of the contained password string.
+   * @param length The number of characters, beginning at <i>offset</i>,
+   * to be copied into this object's {@link password} field.
+   */
+  public Password (char[] password, int offset, int length)
+  {
+    this (password, offset, length, DEFAULT_TIMEOUT);
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * timeout denoted by constructor parameter, <i>delay</i>.
+   *
+   * @param password The character array password to associate with this
+   * Password object.
+   * @param offset The <i>password</i> character array parameter element
+   * marking the beginning of the contained password string.
+   * @param length The number of characters, beginning at <i>offset</i>,
+   * to be copied into this object's {@link password} field.
+   * @param delay The number of miliseconds before this Password object
+   * will be automatically destroyed.
+   */
+  public Password (char[] password, int offset, int length, long delay)
+  {
+    super (delay);
+
+    if (offset < 0 || length < 0 || offset + length > password.length)
+      throw new ArrayIndexOutOfBoundsException ("off=" + offset + " length=" +
+                                                length + " array.length=" +
+                                                password.length);
+
+    int i, j;
+    this.password = new char[length];
+    bPassword = new byte[length];
+
+    for(i = 0, j = offset; i < length; i++, j++)
+      {
+        this.password[i] = (char) password[j];
+        // XXX this should use character encodings, other than ASCII.
+        bPassword[i] = (byte) (password[j] & 0x7F);
+      }
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * default timeout {@link ExpirableObject#DEFAULT_TIMEOUT}.
+   *
+   * @param password The byte array password to associate with this
+   * Password object.
+   */
+  public Password (byte[] password)
+  {
+    this (password, 0, password.length, DEFAULT_TIMEOUT);
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * timeout denoted by constructor parameter, <i>delay</i>.
+   *
+   * @param password The byte array password to associate with this
+   * Password object.
+   * @param delay The number of miliseconds before this Password object
+   * will be automatically destroyed.
+   */
+  public Password (byte[] password, long delay)
+  {
+    this (password, 0, password.length, delay);
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * default timeout {@link ExpirableObject#DEFAULT_TIMEOUT}.
+   *
+   * @param password The byte array password to associate with this
+   * Password object.
+   * @param offset The <i>password</i> byte array parameter element
+   * marking the beginning of the contained password string.
+   * @param length The number of bytes, beginning at <i>offset</i>,
+   * to be copied into this object's {@link password} field.
+   */
+  public Password (byte[] password, int offset, int length)
+  {
+    this (password, offset, length, DEFAULT_TIMEOUT);
+  }
+
+  /**
+   * Create a new expirable Password object that will expire after the
+   * timeout denoted by constructor parameter, <i>delay</i>.
+   *
+   * @param password The byte array password to associate with this
+   * Password object.
+   * @param offset The <i>password</i> byte array parameter element
+   * marking the beginning of the contained password string.
+   * @param length The number of bytes, beginning at <i>offset</i>,
+   * to be copied into this object's {@link bPassword} field.
+   * @param delay The number of miliseconds before this Password object
+   * will be automatically destroyed.
+   */
+  public Password (byte[] password, int offset, int length, long delay)
+  {
+    super (delay);
+
+    if (offset < 0 || length < 0 || offset + length > password.length)
+      throw new ArrayIndexOutOfBoundsException ("off=" + offset + " length=" +
+                                                length + " array.length=" +
+                                                password.length);
+
+    int i, j;
+    this.password = new char[length];
+    bPassword = new byte[length];
+
+    for (i = 0, j = offset; i < length; i++, j++)
+      {
+        this.password[i] = (char) password[j];
+        bPassword[i] = password[j];
+      }
+  }
+
+  // Instance methods
+  // -------------------------------------------------------------------------
+
+  /**
+   * Returns a reference to the {@link char[]} password storage field,
+   * {@link password}.
+   */
+  public synchronized char[] getPassword()
+  {
+    if (mIsDestroyed)
+      throw new IllegalStateException ("Attempted destroyed password access.");
+
+    return password;
+  }
+
+  /**
+   * Returns a reference to the {@link byte[]} password storage field,
+   * {@link bPassword}.
+   */
+  public synchronized byte[] getBytes()
+  {
+    if (mIsDestroyed)
+      throw new IllegalStateException ("Attempted destroyed password access.");
+
+    return bPassword;
+  }
+
+  /**
+   * Sets password field char[], and byte[] array elements to zero.
+   * This method implements base class {@link ExpirableObject} abstract
+   * method, {@link ExpirableObject#doDestroy()}.  See also,
+   * {@link ExpirableObject#destroy()}.
+   */
+  protected synchronized void doDestroy()
+  {
+    if (isDestroyed())
+      return;
+    else
+      {
+        for (int i = 0; i < password.length; i++)
+          password[i] = 0;
+        for (int i = 0; i < bPassword.length; i++)
+          bPassword[i] = 0;
+        mIsDestroyed = true;
+      }
+  }
+
+  /**
+   * Returns true, or false relative to whether, or not this object's
+   * {@link doDestroy()} method has been called.  See also,
+   * {@ExpirableObject#destroy()}.
+   */
+  public synchronized boolean isDestroyed()
+  {
+    return (mIsDestroyed);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AWTCallbackHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AWTCallbackHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AWTCallbackHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AWTCallbackHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,452 @@
+/* AWTCallbackHandler.java -- 
+   Copyright (C) 2004, 2006  Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth.callback;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.GridLayout;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.TextField;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import java.util.Locale;
+
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+
+public class AWTCallbackHandler extends AbstractCallbackHandler
+  implements ActionListener, WindowListener
+{
+
+  // Fields.
+  // -------------------------------------------------------------------------
+
+  protected String actionCommand;
+
+  private static final String ACTION_CANCEL  = "CANCEL";
+  private static final String ACTION_NO      = "NO";
+  private static final String ACTION_NONE    = "NONE";
+  private static final String ACTION_OK      = "OK";
+  private static final String ACTION_YES     = "YES";
+
+  // Constructor.
+  // -------------------------------------------------------------------------
+
+  public AWTCallbackHandler()
+  {
+    super ("AWT");
+    actionCommand = ACTION_NONE;
+  }
+
+  // Instance methods.
+  // -------------------------------------------------------------------------
+
+  protected synchronized void handleChoice(ChoiceCallback c)
+  {
+    Frame ownerFrame = new Frame();
+    Dialog dialog = new Dialog(ownerFrame);
+    String[] choices = c.getChoices();
+    dialog.setTitle(c.getPrompt());
+    Label label = new Label(c.getPrompt());
+    List list = new List(Math.min(5, choices.length),
+                         c.allowMultipleSelections());
+    Panel buttons = new Panel();
+    Button ok = new Button(messages.getString("callback.ok"));
+    ok.setActionCommand(ACTION_OK);
+    ok.addActionListener(this);
+    Button cancel = new Button(messages.getString("callback.cancel"));
+    cancel.setActionCommand(ACTION_CANCEL);
+    cancel.addActionListener(this);
+    for (int i = 0; i < choices.length; i++)
+      {
+        list.add(choices[i]);
+      }
+    if (c.getDefaultChoice() >= 0 && c.getDefaultChoice() < choices.length)
+      {
+        list.select(c.getDefaultChoice());
+      }
+    dialog.setLayout(new BorderLayout());
+    dialog.add(label, BorderLayout.NORTH);
+    dialog.add(list, BorderLayout.CENTER);
+    buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+    buttons.add(cancel);
+    buttons.add(ok);
+    dialog.add(buttons, BorderLayout.SOUTH);
+    dialog.pack();
+    dialog.show();
+    try { wait(); }
+    catch (InterruptedException ie) { }
+    if (actionCommand.equals(ACTION_OK))
+      {
+        if (c.allowMultipleSelections())
+          {
+            c.setSelectedIndexes(list.getSelectedIndexes());
+          }
+        else
+          {
+            c.setSelectedIndex(list.getSelectedIndex());
+          }
+      }
+    dialog.dispose();
+    ownerFrame.dispose();
+  }
+
+  protected synchronized void handleConfirmation(ConfirmationCallback c)
+  {
+    Frame ownerFrame = new Frame();
+    Dialog dialog = new Dialog(ownerFrame);
+    switch (c.getMessageType())
+      {
+      case ConfirmationCallback.ERROR:
+        dialog.setTitle(messages.getString("callback.error"));
+        break;
+      case ConfirmationCallback.INFORMATION:
+        dialog.setTitle(messages.getString("callback.information"));
+        break;
+      case ConfirmationCallback.WARNING:
+        dialog.setTitle(messages.getString("callback.warning"));
+        break;
+      default:
+        dialog.setTitle("");
+      }
+    dialog.setLayout(new GridLayout(2, 1));
+    dialog.add(new Label(c.getPrompt()));
+    Panel buttons = new Panel();
+    buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+    dialog.add(buttons);
+    String[] choices = null;
+    int[] values = null;
+    switch (c.getOptionType())
+      {
+      case ConfirmationCallback.OK_CANCEL_OPTION:
+        choices = new String[] {
+          messages.getString("callback.cancel"),
+          messages.getString("callback.ok")
+        };
+        values = new int[] {
+          ConfirmationCallback.CANCEL, ConfirmationCallback.OK
+        };
+        break;
+      case ConfirmationCallback.YES_NO_CANCEL_OPTION:
+        choices = new String[] {
+          messages.getString("callback.cancel"),
+          messages.getString("callback.no"),
+          messages.getString("callback.yes")
+        };
+        values = new int[] {
+          ConfirmationCallback.CANCEL, ConfirmationCallback.NO,
+          ConfirmationCallback.YES
+        };
+        break;
+      case ConfirmationCallback.YES_NO_OPTION:
+        choices = new String[] {
+          messages.getString("callback.no"),
+          messages.getString("callback.yes")
+        };
+        values = new int[] {
+          ConfirmationCallback.NO, ConfirmationCallback.YES
+        };
+        break;
+      case ConfirmationCallback.UNSPECIFIED_OPTION:
+        choices = c.getOptions();
+        values = new int[choices.length];
+        for (int i = 0; i < values.length; i++)
+          values[i] = i;
+        break;
+      default:
+        throw new IllegalArgumentException();
+      }
+    for (int i = 0; i < choices.length; i++)
+      {
+        Button b = new Button(choices[i]);
+        b.setActionCommand(choices[i]);
+        b.addActionListener(this);
+        buttons.add(b);
+      }
+    dialog.pack();
+    dialog.show();
+    try { wait(); }
+    catch (InterruptedException ie) { }
+    for (int i = 0; i < choices.length; i++)
+      {
+        if (actionCommand.equals(choices[i]))
+          {
+            c.setSelectedIndex(values[i]);
+            break;
+          }
+      }
+    dialog.dispose();
+    ownerFrame.dispose();
+  }
+
+  protected synchronized void handleLanguage(LanguageCallback c)
+  {
+    Locale[] locales = Locale.getAvailableLocales();
+    String[] languages = new String[locales.length];
+    Locale def = Locale.getDefault();
+    int defind = 0;
+    for (int i = 0; i < locales.length; i++)
+      {
+        StringBuffer lang =
+          new StringBuffer(locales[i].getDisplayLanguage(locales[i]));
+        String country = locales[i].getDisplayCountry(locales[i]);
+        String variant = locales[i].getDisplayVariant(locales[i]);
+        if (country.length() > 0 && variant.length() > 0)
+          {
+            lang.append(" (");
+            lang.append(country);
+            lang.append(", ");
+            lang.append(variant);
+            lang.append(")");
+          }
+        else if (country.length() > 0)
+          {
+            lang.append(" (");
+            lang.append(country);
+            lang.append(")");
+          }
+        else if (variant.length() > 0)
+          {
+            lang.append(" (");
+            lang.append(variant);
+            lang.append(")");
+          }
+        languages[i] = lang.toString();
+        if (locales[i].equals(def))
+          defind = i;
+      }
+    ChoiceCallback c2 =
+      new ChoiceCallback(messages.getString("callback.language"), languages,
+                         defind, false);
+    handleChoice(c2);
+    c.setLocale(def);
+    if (c2.getSelectedIndexes() != null && c2.getSelectedIndexes().length > 0)
+      {
+        int index = c2.getSelectedIndexes()[0];
+        if (index >= 0 && index < locales.length)
+          c.setLocale(locales[index]);
+      }
+  }
+
+  protected synchronized void handleName(NameCallback c)
+  {
+    Frame ownerFrame = new Frame();
+    Dialog dialog = new Dialog(ownerFrame);
+    dialog.setTitle(c.getPrompt());
+    dialog.setLayout(new GridLayout(3, 1));
+    Label label = new Label(c.getPrompt());
+    TextField input = new TextField();
+    if (c.getDefaultName() != null)
+      {
+        input.setText(c.getDefaultName());
+      }
+    Panel buttons = new Panel();
+    Button ok = new Button(messages.getString("callback.ok"));
+    ok.setActionCommand(ACTION_OK);
+    ok.addActionListener(this);
+    Button cancel = new Button(messages.getString("callback.cancel"));
+    cancel.setActionCommand(ACTION_CANCEL);
+    cancel.addActionListener(this);
+    dialog.add(label);
+    dialog.add(input);
+    buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+    buttons.add(ok);
+    buttons.add(cancel);
+    dialog.add(buttons);
+    dialog.pack();
+    dialog.show();
+    try { wait(); }
+    catch (InterruptedException ie) { }
+    if (actionCommand.equals(ACTION_OK))
+      {
+        c.setName(input.getText());
+      }
+    dialog.dispose();
+    ownerFrame.dispose();
+  }
+
+  protected synchronized void handlePassword(PasswordCallback c)
+  {
+    Frame ownerFrame = new Frame();
+    Dialog dialog = new Dialog(ownerFrame);
+    dialog.setTitle(c.getPrompt());
+    dialog.setLayout(new GridLayout(3, 1));
+    Label label = new Label(c.getPrompt());
+    TextField input = new TextField();
+    if (!c.isEchoOn())
+      {
+        input.setEchoChar('*');
+      }
+    Panel buttons = new Panel();
+    Button ok = new Button(messages.getString("callback.ok"));
+    ok.setActionCommand(ACTION_OK);
+    ok.addActionListener(this);
+    Button cancel = new Button(messages.getString("callback.cancel"));
+    cancel.setActionCommand(ACTION_CANCEL);
+    cancel.addActionListener(this);
+    dialog.add(label);
+    dialog.add(input);
+    buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+    buttons.add(ok);
+    buttons.add(cancel);
+    dialog.add(buttons);
+    dialog.pack();
+    dialog.show();
+    try { wait(); }
+    catch (InterruptedException ie) { }
+    if (actionCommand.equals(ACTION_OK))
+      {
+        c.setPassword(input.getText().toCharArray());
+      }
+    dialog.dispose();
+    ownerFrame.dispose();
+  }
+
+  protected synchronized void handleTextInput(TextInputCallback c)
+  {
+    Frame ownerFrame = new Frame();
+    Dialog dialog = new Dialog(ownerFrame);
+    dialog.setTitle(c.getPrompt());
+    dialog.setLayout(new BorderLayout());
+    Label label = new Label(c.getPrompt());
+    TextArea text = new TextArea(10, 40);
+    if (c.getDefaultText() != null)
+      {
+        text.setText(c.getDefaultText());
+      }
+    Panel buttons = new Panel();
+    Button ok = new Button(messages.getString("callback.ok"));
+    ok.setActionCommand(ACTION_OK);
+    ok.addActionListener(this);
+    Button cancel = new Button(messages.getString("callback.cancel"));
+    cancel.setActionCommand(ACTION_CANCEL);
+    cancel.addActionListener(this);
+    dialog.add(label, BorderLayout.NORTH);
+    dialog.add(text, BorderLayout.CENTER);
+    buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+    buttons.add(ok);
+    buttons.add(cancel);
+    dialog.add(buttons, BorderLayout.SOUTH);
+    dialog.pack();
+    dialog.show();
+    try { wait(); }
+    catch (InterruptedException ie) { }
+    if (actionCommand.equals(ACTION_OK))
+      {
+        c.setText(text.getText());
+      }
+    dialog.dispose();
+    ownerFrame.dispose();
+  }
+
+  protected synchronized void handleTextOutput(TextOutputCallback c)
+  {
+    Frame ownerFrame = new Frame();
+    Dialog dialog = new Dialog(ownerFrame);
+    dialog.setLayout(new GridLayout(2, 1));
+    switch (c.getMessageType() /*c.getStyle()*/)
+      {
+      case ConfirmationCallback.ERROR:
+        dialog.setTitle(messages.getString("callback.error"));
+        break;
+      case ConfirmationCallback.INFORMATION:
+        dialog.setTitle(messages.getString("callback.information"));
+        break;
+      case ConfirmationCallback.WARNING:
+        dialog.setTitle(messages.getString("callback.warning"));
+        break;
+      default:
+        dialog.setTitle("");
+      }
+    Label label = new Label(c.getMessage());
+    Panel buttons = new Panel();
+    Button ok = new Button(messages.getString("callback.ok"));
+    buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+    buttons.add(ok);
+    ok.addActionListener(this);
+    dialog.add(label);
+    dialog.add(buttons);
+    dialog.pack();
+    dialog.show();
+    try { wait(); }
+    catch (InterruptedException ie) { }
+    dialog.dispose();
+    ownerFrame.dispose();
+  }
+
+  // ActionListener interface implementation.
+  // -------------------------------------------------------------------------
+
+  public synchronized void actionPerformed(ActionEvent ae)
+  {
+    actionCommand = ae.getActionCommand();
+    notifyAll();
+  }
+
+  // WindowListener interface implementation.
+  // -------------------------------------------------------------------------
+
+  public synchronized void windowClosing(WindowEvent we)
+  {
+    actionCommand = ACTION_NONE;
+    notifyAll();
+  }
+
+  public void windowOpened(WindowEvent we) { }
+  public void windowClosed(WindowEvent we) { }
+  public void windowIconified(WindowEvent we) { }
+  public void windowDeiconified(WindowEvent we) { }
+  public void windowActivated(WindowEvent we) { }
+  public void windowDeactivated(WindowEvent we) { }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AbstractCallbackHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AbstractCallbackHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AbstractCallbackHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/AbstractCallbackHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,258 @@
+/* AbstractCallbackHandler.java -- 
+   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth.callback;
+
+import gnu.java.security.Engine;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+public abstract class AbstractCallbackHandler implements CallbackHandler
+{
+
+  // Fields.
+  // -------------------------------------------------------------------------
+
+  private static final String SERVICE = "CallbackHandler";
+
+  protected final ResourceBundle messages;
+
+  private final String name;
+
+  // Constructors.
+  // -------------------------------------------------------------------------
+
+  protected AbstractCallbackHandler (final String name)
+  {
+    super();
+    messages = PropertyResourceBundle.getBundle("gnu/javax/security/auth/callback/MessagesBundle");
+    this.name = name;
+  }
+
+  // Class methods.
+  // -------------------------------------------------------------------------
+
+  public static CallbackHandler getInstance(String type)
+    throws NoSuchAlgorithmException
+  {
+    Provider[] p = Security.getProviders();
+    for (int i = 0; i < p.length; i++)
+      {
+        try
+          {
+            return getInstance(type, p[i]);
+          }
+        catch (NoSuchAlgorithmException ignored)
+          {
+          }
+      }
+    throw new NoSuchAlgorithmException(type);
+  }
+
+  public static CallbackHandler getInstance(String type, String provider)
+    throws NoSuchAlgorithmException, NoSuchProviderException
+  {
+    Provider p = Security.getProvider(provider);
+    if (p == null)
+      {
+        throw new NoSuchProviderException(provider);
+      }
+    return getInstance(type, p);
+  }
+
+  public static CallbackHandler getInstance(String type, Provider provider)
+    throws NoSuchAlgorithmException
+  {
+    try
+      {
+        return (CallbackHandler) Engine.getInstance(SERVICE, type, provider);
+      }
+    catch (InvocationTargetException ite)
+      {
+        Throwable cause = ite.getCause();
+        if (cause instanceof NoSuchAlgorithmException)
+          throw (NoSuchAlgorithmException) cause;
+        NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type);
+        if (cause != null)
+          nsae.initCause (cause);
+        throw nsae;
+      }
+    catch (ClassCastException cce)
+      {
+        NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type);
+        nsae.initCause (cce);
+        throw nsae;
+      }
+  }
+
+  // Instance methods.
+  // -------------------------------------------------------------------------
+
+  public void handle(Callback[] callbacks)
+    throws IOException, UnsupportedCallbackException
+  {
+    if (callbacks == null)
+      throw new NullPointerException();
+    for (int i = 0; i < callbacks.length; i++)
+      {
+        if (callbacks[i] == null)
+          continue;
+        if (callbacks[i] instanceof ChoiceCallback)
+          handleChoice((ChoiceCallback) callbacks[i]);
+        else if (callbacks[i] instanceof ConfirmationCallback)
+          handleConfirmation((ConfirmationCallback) callbacks[i]);
+        else if (callbacks[i] instanceof LanguageCallback)
+          handleLanguage((LanguageCallback) callbacks[i]);
+        else if (callbacks[i] instanceof NameCallback)
+          handleName((NameCallback) callbacks[i]);
+        else if (callbacks[i] instanceof PasswordCallback)
+          handlePassword((PasswordCallback) callbacks[i]);
+        else if (callbacks[i] instanceof TextInputCallback)
+          handleTextInput((TextInputCallback) callbacks[i]);
+        else if (callbacks[i] instanceof TextOutputCallback)
+          handleTextOutput((TextOutputCallback) callbacks[i]);
+        else
+          handleOther(callbacks[i]);
+      }
+  }
+
+  public final String getName ()
+  {
+    return name;
+  }
+
+  // Abstract methods.
+  // -------------------------------------------------------------------------
+
+  /**
+   * Handles a {@link ChoiceCallback}.
+   *
+   * @param callback The choice callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handleChoice(ChoiceCallback callback)
+    throws IOException;
+
+  /**
+   * Handles a {@link ConfirmationCallback}.
+   *
+   * @param callback The confirmation callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handleConfirmation(ConfirmationCallback callback)
+    throws IOException;
+
+  /**
+   * Handles a {@link LanguageCallback}.
+   *
+   * @param callback The language callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handleLanguage(LanguageCallback callback)
+    throws IOException;
+
+  /**
+   * Handles a {@link NameCallback}.
+   *
+   * @param callback The name callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handleName(NameCallback callback)
+    throws IOException;
+
+  /**
+   * Handles a {@link PasswordCallback}.
+   *
+   * @param callback The password callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handlePassword(PasswordCallback callback)
+    throws IOException;
+
+  /**
+   * Handles a {@link TextInputCallback}.
+   *
+   * @param callback The text input callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handleTextInput(TextInputCallback callback)
+    throws IOException;
+
+  /**
+   * Handles a {@link TextOutputCallback}.
+   *
+   * @param callback The text output callback.
+   * @throws IOException If an I/O error occurs.
+   */
+  protected abstract void handleTextOutput(TextOutputCallback callback)
+    throws IOException;
+
+  /**
+   * Handles an unknown callback. The default implementation simply throws
+   * an {@link UnsupportedCallbackException}.
+   *
+   * @param callback The callback to handle.
+   * @throws IOException If an I/O error occurs.
+   * @throws UnsupportedCallbackException If the specified callback is not
+   *   supported.
+   */
+  protected void handleOther(Callback callback)
+    throws IOException, UnsupportedCallbackException
+  {
+    throw new UnsupportedCallbackException(callback);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,299 @@
+/* ConsoleCallbackHandler.java -- 
+   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth.callback;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+
+/**
+ * An implementation of {@link CallbackHandler} that reads and writes
+ * information to and from <code>System.in</code> and <code>System.out</code>.
+ */
+public class ConsoleCallbackHandler extends AbstractCallbackHandler
+{
+
+  // Fields.
+  // -------------------------------------------------------------------------
+
+  private final PrintStream out;
+
+  // Constructors.
+  // -------------------------------------------------------------------------
+
+  public ConsoleCallbackHandler()
+  {
+    this (System.out);
+  }
+
+  public ConsoleCallbackHandler (final PrintStream out)
+  {
+    super ("CONSOLE");
+    this.out = out;
+  }
+
+  // Instance methods.
+  // -------------------------------------------------------------------------
+
+  protected void handleChoice(ChoiceCallback c) throws IOException
+  {
+    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+    out.println(c.getPrompt());
+    out.print('(');
+    String[] choices = c.getChoices();
+    for (int i = 0; i < choices.length; i++)
+      {
+        out.print(choices[i]);
+        if (i != choices.length - 1)
+          out.print(", ");
+      }
+    out.print(") ");
+    if (c.getDefaultChoice() >= 0 && c.getDefaultChoice() < choices.length)
+      {
+        out.print('[');
+        out.print(choices[c.getDefaultChoice()]);
+        out.print("] ");
+      }
+    String reply = in.readLine();
+    if (reply == null || reply.length() == 0)
+      {
+        c.setSelectedIndex(c.getDefaultChoice());
+        return;
+      }
+    if (!c.allowMultipleSelections())
+      {
+        for (int i = 0; i < choices.length; i++)
+          {
+            if (reply.trim().equals(choices[i]))
+              {
+                c.setSelectedIndex(i);
+                return;
+              }
+          }
+        c.setSelectedIndex(c.getDefaultChoice());
+      }
+    else
+      {
+        TreeSet indices = new TreeSet();
+        StringTokenizer tok = new StringTokenizer(reply, ",");
+        String[] replies = new String[tok.countTokens()];
+        int idx = 0;
+        while (tok.hasMoreTokens())
+          {
+            replies[idx++] = tok.nextToken().trim();
+          }
+        for (int i = 0; i < choices.length; i++)
+          for (int j = 0; j < replies.length; i++)
+            {
+              if (choices[i].equals(replies[j]))
+                {
+                  indices.add(Integer.valueOf(i));
+                }
+            }
+        if (indices.size() == 0)
+          c.setSelectedIndex(c.getDefaultChoice());
+        else
+          {
+            int[] ii = new int[indices.size()];
+            int i = 0;
+            for (Iterator it = indices.iterator(); it.hasNext(); )
+              ii[i++] = ((Integer) it.next()).intValue();
+            c.setSelectedIndexes(ii);
+          }
+      }
+  }
+
+  protected void handleConfirmation(ConfirmationCallback c) throws IOException
+  {
+    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+    if (c.getPrompt() != null)
+      out.print(c.getPrompt());
+
+    String[] choices = null;
+    int[] values = null;
+    switch (c.getOptionType())
+      {
+      case ConfirmationCallback.OK_CANCEL_OPTION:
+        out.print(messages.getString("callback.okCancel"));
+        choices = new String[] {
+          messages.getString("callback.ok"),
+          messages.getString("callback.cancel"),
+          messages.getString("callback.shortOk"),
+          messages.getString("callback.shortCancel")
+        };
+        values = new int[] {
+          ConfirmationCallback.OK, ConfirmationCallback.CANCEL,
+          ConfirmationCallback.OK, ConfirmationCallback.CANCEL
+        };
+        break;
+
+      case ConfirmationCallback.YES_NO_CANCEL_OPTION:
+        out.print(messages.getString("callback.yesNoCancel"));
+        choices = new String[] {
+          messages.getString("callback.yes"),
+          messages.getString("callback.no"),
+          messages.getString("callback.cancel"),
+          messages.getString("callback.shortYes"),
+          messages.getString("callback.shortNo"),
+          messages.getString("callback.shortCancel")
+        };
+        values = new int[] {
+          ConfirmationCallback.YES, ConfirmationCallback.NO,
+          ConfirmationCallback.CANCEL, ConfirmationCallback.YES,
+          ConfirmationCallback.NO, ConfirmationCallback.CANCEL
+        };
+        break;
+
+      case ConfirmationCallback.YES_NO_OPTION:
+        out.print(messages.getString("callback.yesNo"));
+        choices = new String[] { messages.getString("callback.yes"),
+                                 messages.getString("callback.no"),
+                                 messages.getString("callback.shortYes"),
+                                 messages.getString("callback.shortNo") };
+        values = new int[] { ConfirmationCallback.YES,
+                             ConfirmationCallback.NO,
+                             ConfirmationCallback.YES,
+                             ConfirmationCallback.NO };
+        int defaultOption = c.getDefaultOption();
+        if (defaultOption > -1 && defaultOption < choices.length)
+          {
+            out.print("[");
+            out.print(choices[defaultOption]);
+            out.print("] ");
+          }
+        break;
+
+      case ConfirmationCallback.UNSPECIFIED_OPTION:
+        choices = c.getOptions();
+        values = new int[choices.length];
+        for (int i = 0; i < values.length; i++)
+          values[i] = i;
+        out.print('(');
+        for (int i = 0; i < choices.length; i++)
+          {
+            out.print(choices[i]);
+            if (i != choices.length - 1)
+              out.print(", ");
+          }
+        out.print(") [");
+        out.print(choices[c.getDefaultOption()]);
+        out.print("] ");
+        break;
+
+      default:
+        throw new IllegalArgumentException();
+      }
+    String reply = in.readLine();
+    if (reply == null)
+      {
+        c.setSelectedIndex(c.getDefaultOption());
+        return;
+      }
+    reply = reply.trim();
+    for (int i = 0; i < choices.length; i++)
+      if (reply.equalsIgnoreCase(choices[i]))
+        {
+          c.setSelectedIndex(values[i]);
+          return;
+        }
+    c.setSelectedIndex(c.getDefaultOption());
+  }
+
+  protected void handleLanguage(LanguageCallback c) throws IOException
+  {
+    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+    out.print(messages.getString("callback.language"));
+    String reply = null;
+    reply = in.readLine();
+    if (reply == null)
+      {
+        c.setLocale(Locale.getDefault());
+      }
+    else
+      {
+        c.setLocale(new Locale(reply.trim()));
+      }
+  }
+
+  protected void handleName(NameCallback c) throws IOException
+  {
+    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+    out.print(c.getPrompt());
+    String name = in.readLine();
+    if (name != null)
+      c.setName(name.trim());
+  }
+
+  protected void handlePassword(PasswordCallback c) throws IOException
+  {
+    out.print(c.getPrompt());
+    BufferedReader in =
+      new BufferedReader(new InputStreamReader(System.in));
+    String pass = in.readLine();
+    c.setPassword(pass.toCharArray());
+  }
+
+  protected void handleTextInput(TextInputCallback c) throws IOException
+  {
+    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+    out.print(c.getPrompt());
+    String text = in.readLine();
+    if (text != null)
+      c.setText(text);
+  }
+
+  protected void handleTextOutput(TextOutputCallback c)
+  {
+    out.print(c.getMessage());
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/DefaultCallbackHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/DefaultCallbackHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/DefaultCallbackHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/DefaultCallbackHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* DefaultCallbackHandler.java -- 
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth.callback;
+
+import java.util.Locale;
+
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+
+/**
+ * This trivial implementation of {@link CallbackHandler} sets its
+ * {@link Callback} arguments to default values, with no user interaction.
+ */
+public class DefaultCallbackHandler extends AbstractCallbackHandler
+{
+
+  // Constructor.
+  // -------------------------------------------------------------------------
+
+  public DefaultCallbackHandler()
+  {
+    super("DEFAULT");
+  }
+
+  // Instance methods.
+  // -------------------------------------------------------------------------
+
+  protected void handleChoice(ChoiceCallback c)
+  {
+    c.setSelectedIndex(c.getDefaultChoice());
+  }
+
+  protected void handleConfirmation(ConfirmationCallback c)
+  {
+    if (c.getOptionType() == ConfirmationCallback.YES_NO_OPTION)
+      c.setSelectedIndex(ConfirmationCallback.NO);
+    else if (c.getOptionType() == ConfirmationCallback.YES_NO_CANCEL_OPTION)
+      c.setSelectedIndex(ConfirmationCallback.NO);
+    else if (c.getOptionType() == ConfirmationCallback.OK_CANCEL_OPTION)
+      c.setSelectedIndex(ConfirmationCallback.OK);
+    else
+      c.setSelectedIndex(c.getDefaultOption());
+  }
+
+  protected void handleLanguage(LanguageCallback c)
+  {
+    c.setLocale(Locale.getDefault());
+  }
+
+  protected void handleName(NameCallback c)
+  {
+    c.setName(System.getProperty("user.name"));
+  }
+
+  protected void handlePassword(PasswordCallback c)
+  {
+    c.setPassword(new char[0]);
+  }
+
+  protected void handleTextInput(TextInputCallback c)
+  {
+    c.setText("");
+  }
+
+  protected void handleTextOutput(TextOutputCallback c)
+  {
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/GnuCallbacks.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/GnuCallbacks.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/GnuCallbacks.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/GnuCallbacks.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* GnuCallbacks.java -- Provider for callback implementations.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth.callback;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+
+public final class GnuCallbacks extends Provider
+{
+  public GnuCallbacks()
+  {
+    super("GNU-CALLBACKS", 2.1, "Implementations of various callback handlers.");
+
+    AccessController.doPrivileged(new PrivilegedAction()
+      {
+        public Object run()
+        {
+          put("CallbackHandler.Default", DefaultCallbackHandler.class.getName());
+          put("CallbackHandler.Console", ConsoleCallbackHandler.class.getName());
+          put("CallbackHandler.AWT", AWTCallbackHandler.class.getName());
+          put("CallbackHandler.Swing", SwingCallbackHandler.class.getName());
+
+          return null;
+        }
+      });
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/SwingCallbackHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/SwingCallbackHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/SwingCallbackHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/callback/SwingCallbackHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,587 @@
+ /* SwingCallbackHandler.java -- 
+    Copyright (C) 2006  Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.javax.security.auth.callback;
+
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import java.io.IOException;
+
+import java.util.Locale;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+
+public class SwingCallbackHandler extends AbstractCallbackHandler
+{
+  public SwingCallbackHandler ()
+  {
+    super ("SWING");
+  }
+
+  protected void handleChoice (final ChoiceCallback callback)
+    throws IOException
+  {
+    final JDialog dialog = new JDialog ();
+    dialog.setResizable (false);
+    Container content = dialog.getContentPane ();
+    GridBagLayout layout = new GridBagLayout ();
+    content.setLayout (layout);
+    JLabel prompt = new JLabel (callback.getPrompt (), JLabel.LEFT);
+    content.add (prompt, new GridBagConstraints (0, 0, 1, 1, 0, 0,
+                                                 GridBagConstraints.WEST,
+                                                 GridBagConstraints.NONE,
+                                                 new Insets (5, 5, 5, 5), 5, 5));
+
+    String[] choices = callback.getChoices ();
+    final JList choicesList = new JList (choices);
+    JScrollPane choicesPane = new JScrollPane (choicesList,
+                                               JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                                               JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+    final int defaultChoice = callback.getDefaultChoice ();
+    choicesList.setSelectedIndex (defaultChoice);
+    choicesList.setSelectionMode (callback.allowMultipleSelections ()
+                                  ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
+                                  : ListSelectionModel.SINGLE_SELECTION);
+    content.add (choicesPane, new GridBagConstraints (0, 1, 1, 1, 1.0, 1.0,
+                                                      GridBagConstraints.CENTER,
+                                                      GridBagConstraints.BOTH,
+                                                      new Insets (0, 10, 0, 10), 5, 5));
+
+    JPanel confirmButtons = new JPanel ();
+    confirmButtons.setLayout (new FlowLayout (FlowLayout.RIGHT));
+    JButton cancel = new JButton (messages.getString ("callback.cancel"));
+    JButton ok = new JButton (messages.getString ("callback.ok"));
+    confirmButtons.add (cancel);
+    confirmButtons.add (ok);
+    content.add (confirmButtons, new GridBagConstraints (0, 2, 1, 1, 0, 0,
+                                                         GridBagConstraints.EAST,
+                                                         GridBagConstraints.NONE,
+                                                         new Insets (5, 5, 5, 5),
+                                                         0, 0));
+    dialog.getRootPane ().setDefaultButton (ok);
+
+    cancel.addActionListener (new ActionListener ()
+      {
+        public void actionPerformed (final ActionEvent ae)
+        {
+          callback.setSelectedIndex (defaultChoice);
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      });
+    ok.addActionListener (new ActionListener ()
+      {
+        public void actionPerformed (final ActionEvent ae)
+        {
+          if (callback.allowMultipleSelections ())
+            {
+              int[] indices = choicesList.getSelectedIndices ();
+              if (indices != null && indices.length > 0)
+                callback.setSelectedIndexes (indices);
+              else
+                callback.setSelectedIndex (defaultChoice);
+            }
+          else
+            {
+              int selected = choicesList.getSelectedIndex ();
+              if (selected != -1)
+                callback.setSelectedIndex (selected);
+              else
+                callback.setSelectedIndex (defaultChoice);
+            }
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      });
+
+    dialog.pack ();
+    dialog.setSize (new Dimension (400, 400));
+    dialog.setVisible (true);
+    waitForInput (dialog, callback);
+  }
+
+  protected void handleConfirmation (final ConfirmationCallback callback)
+    throws IOException
+  {
+    final JDialog dialog = new JDialog ();
+    switch (callback.getMessageType ())
+      {
+      case ConfirmationCallback.ERROR:
+        dialog.setTitle (messages.getString ("callback.error"));
+        break;
+      case ConfirmationCallback.WARNING:
+        dialog.setTitle (messages.getString ("callback.warning"));
+        break;
+      case ConfirmationCallback.INFORMATION:
+        dialog.setTitle (messages.getString ("callback.information"));
+        break;
+      }
+    Container content = dialog.getContentPane ();
+    content.setLayout (new GridBagLayout ());
+
+    String prompt = callback.getPrompt ();
+    if (prompt != null)
+      {
+        content.add (new JLabel (prompt),
+                     new GridBagConstraints (0, 0, 1, 1, 0, 0,
+                                             GridBagConstraints.WEST,
+                                             GridBagConstraints.NONE,
+                                             new Insets (5, 5, 5, 25), 0, 0));
+      }
+
+    final String[] options = callback.getOptions ();
+    ActionListener listener = new ActionListener ()
+      {
+        public void actionPerformed (ActionEvent ae)
+        {
+          String cmd = ae.getActionCommand ();
+          if (options != null)
+            {
+              for (int i = 0; i < options.length; i++)
+                {
+                  if (cmd.equals (options[i]))
+                    {
+                      callback.setSelectedIndex (i);
+                      break;
+                    }
+                }
+            }
+          else
+            {
+              if (cmd.equals ("cancel"))
+                callback.setSelectedIndex (ConfirmationCallback.CANCEL);
+              else if (cmd.equals ("okay"))
+                callback.setSelectedIndex (ConfirmationCallback.OK);
+              else if (cmd.equals ("yes"))
+                callback.setSelectedIndex (ConfirmationCallback.YES);
+              else if (cmd.equals ("no"))
+                callback.setSelectedIndex (ConfirmationCallback.NO);
+            }
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      };
+
+    JPanel buttons = new JPanel ();
+    buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
+    switch (callback.getOptionType ())
+      {
+      case ConfirmationCallback.YES_NO_CANCEL_OPTION:
+        {
+          JButton cancel = new JButton (messages.getString ("callback.cancel"));
+          buttons.add (cancel);
+          cancel.setActionCommand ("cancel");
+          cancel.addActionListener (listener);
+        }
+        /* Fall-through. */
+      case ConfirmationCallback.YES_NO_OPTION:
+        {
+          JButton yes = new JButton (messages.getString ("callback.yes"));
+          JButton no = new JButton (messages.getString ("callback.no"));
+          buttons.add (no);
+          buttons.add (yes);
+          yes.setActionCommand ("yes");
+          yes.addActionListener (listener);
+          no.setActionCommand ("no");
+          no.addActionListener (listener);
+          dialog.getRootPane ().setDefaultButton (yes);
+        }
+        break;
+      case ConfirmationCallback.OK_CANCEL_OPTION:
+        {
+          JButton okay = new JButton (messages.getString ("callback.ok"));
+          JButton cancel = new JButton (messages.getString ("callback.cancel"));
+          buttons.add (cancel);
+          buttons.add (okay);
+          okay.setActionCommand ("okay");
+          okay.addActionListener (listener);
+          cancel.setActionCommand ("cancel");
+          cancel.addActionListener (listener);
+          dialog.getRootPane ().setDefaultButton (okay);
+        }
+        break;
+      case ConfirmationCallback.UNSPECIFIED_OPTION:
+        for (int i = 0; i < options.length; i++)
+          {
+            JButton button = new JButton (options[i]);
+            buttons.add (button);
+            button.setActionCommand (options[i]);
+            button.addActionListener (listener);
+            if (i == options.length - 1)
+              dialog.getRootPane ().setDefaultButton (button);
+          }
+      }
+    content.add (buttons,
+                 new GridBagConstraints (0, GridBagConstraints.RELATIVE,
+                                         1, 1, 1, 1,
+                                         GridBagConstraints.SOUTHEAST,
+                                         GridBagConstraints.BOTH,
+                                         new Insets (5, 5, 5, 5), 0, 0));
+    dialog.setResizable (false);
+    dialog.pack ();
+    dialog.setVisible (true);
+    waitForInput (dialog, callback);
+  }
+
+  protected void handleLanguage (final LanguageCallback callback)
+    throws IOException
+  {
+    Locale locale = Locale.getDefault ();
+    Locale[] locales = Locale.getAvailableLocales ();
+    String[] localeNames = new String[locales.length+1];
+    int defaultIndex = 0;
+    for (int i = 0; i < locales.length; i++)
+      {
+        localeNames[i+1] = locales[i].getDisplayLanguage (locales[i]);
+        String country = locales[i].getDisplayCountry (locales[i]);
+        if (country.length () > 0)
+          localeNames[i+1] += " (" + country + ")";
+        if (locales[i].equals (locale))
+          defaultIndex = i;
+      }
+    locales[0] = locale;
+    localeNames[0] = locale.getDisplayLanguage (locale);
+    String country = locale.getDisplayCountry (locale);
+    if (country.length () > 0)
+      localeNames[0] += " (" + country + ")";
+    ChoiceCallback cb = new ChoiceCallback (messages.getString ("callback.language"),
+                                                                localeNames, 0,
+                                                                false);
+    handleChoice (cb);
+    int selected = cb.getSelectedIndexes ()[0];
+    if (selected > 0)
+      callback.setLocale (locales[selected - 1]);
+    else
+      callback.setLocale (locale);
+  }
+
+  protected void handleName (final NameCallback callback)
+    throws IOException
+  {
+    final JDialog dialog = new JDialog ();
+    Container content = dialog.getContentPane ();
+    content.setLayout (new GridBagLayout ());
+
+    content.add (new JLabel (callback.getPrompt ()),
+                             new GridBagConstraints (0, 0, 1, 1, 0, 0,
+                                                     GridBagConstraints.NORTHEAST,
+                                                     GridBagConstraints.VERTICAL,
+                                                     new Insets (10, 10, 15, 5), 0, 0));
+
+    final JTextField name = new JTextField ();
+    name.setColumns (20);
+    String _name;
+    if ((_name = callback.getDefaultName ()) != null)
+      name.setText (_name);
+    content.add (name, new GridBagConstraints (1, 0, 1, 1, 1, 1,
+                                               GridBagConstraints.NORTHWEST,
+                                               GridBagConstraints.BOTH,
+                                               new Insets (10, 5, 15, 10), 0, 0));
+
+    ActionListener listener = new ActionListener ()
+      {
+        public void actionPerformed (ActionEvent ae)
+        {
+          String cmd = ae.getActionCommand ();
+          if (cmd.equals ("okay"))
+            callback.setName (name.getText ());
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      };
+
+    JPanel buttons = new JPanel ();
+    buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
+    JButton cancel = new JButton (messages.getString ("callback.cancel"));
+    JButton okay = new JButton (messages.getString ("callback.ok"));
+    cancel.setActionCommand ("cancel");
+    cancel.addActionListener (listener);
+    buttons.add (cancel);
+    okay.setActionCommand ("okay");
+    okay.addActionListener (listener);
+    buttons.add (okay);
+    content.add (buttons, new GridBagConstraints (0, 1, 2, 1, 0, 0,
+                                                  GridBagConstraints.SOUTHEAST,
+                                                  GridBagConstraints.NONE,
+                                                  new Insets (0, 10, 10, 10), 0, 0));
+
+    dialog.setResizable (false);
+    dialog.pack ();
+    dialog.setVisible (true);
+    dialog.getRootPane ().setDefaultButton (okay);
+    waitForInput (dialog, callback);
+  }
+
+  protected void handlePassword (final PasswordCallback callback)
+    throws IOException
+  {
+    final JDialog dialog = new JDialog ();
+    Container content = dialog.getContentPane ();
+    content.setLayout (new GridBagLayout ());
+
+    content.add (new JLabel (callback.getPrompt ()),
+                             new GridBagConstraints (0, 0, 1, 1, 0, 0,
+                                                     GridBagConstraints.NORTHEAST,
+                                                     GridBagConstraints.VERTICAL,
+                                                     new Insets (10, 10, 15, 5), 0, 0));
+
+    final JPasswordField password = new JPasswordField ();
+    password.setColumns (20);
+    password.setEchoChar (callback.isEchoOn () ? '\u0000' : '\u2022');
+    content.add (password, new GridBagConstraints (1, 0, 1, 1, 1, 1,
+                                                   GridBagConstraints.NORTHWEST,
+                                                   GridBagConstraints.BOTH,
+                                                   new Insets (10, 5, 15, 10), 0, 0));
+
+    ActionListener listener = new ActionListener ()
+      {
+        public void actionPerformed (ActionEvent ae)
+        {
+          String cmd = ae.getActionCommand ();
+          if (cmd.equals ("okay"))
+            callback.setPassword (password.getPassword ());
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      };
+
+    JPanel buttons = new JPanel ();
+    buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
+    JButton cancel = new JButton (messages.getString ("callback.cancel"));
+    JButton okay = new JButton (messages.getString ("callback.ok"));
+    cancel.setActionCommand ("cancel");
+    cancel.addActionListener (listener);
+    buttons.add (cancel);
+    okay.setActionCommand ("okay");
+    okay.addActionListener (listener);
+    buttons.add (okay);
+    content.add (buttons, new GridBagConstraints (0, 1, 2, 1, 0, 0,
+                                                  GridBagConstraints.SOUTHEAST,
+                                                  GridBagConstraints.NONE,
+                                                  new Insets (0, 10, 10, 10), 0, 0));
+
+    dialog.setResizable (false);
+    dialog.pack ();
+    dialog.setVisible (true);
+    dialog.getRootPane ().setDefaultButton (okay);
+    waitForInput (dialog, callback);
+  }
+
+  protected void handleTextInput (final TextInputCallback callback)
+    throws IOException
+  {
+    final JDialog dialog = new JDialog ();
+    Container content = dialog.getContentPane ();
+    content.setLayout (new GridBagLayout ());
+
+    content.add (new JLabel (callback.getPrompt ()),
+                             new GridBagConstraints (0, 0, 1, 1, 0, 0,
+                                                     GridBagConstraints.NORTHWEST,
+                                                     GridBagConstraints.NONE,
+                                                     new Insets (10, 10, 15, 5), 0, 0));
+    
+    final JTextArea text = new JTextArea (24, 80);
+    text.setEditable (true);
+    String _text;
+    if ((_text = callback.getDefaultText ()) != null)
+      text.setText (_text);
+    text.setFont (new Font ("Monospaced", Font.PLAIN, 12));
+    JScrollPane textPane = new JScrollPane (text,
+                                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+    content.add (textPane,
+                 new GridBagConstraints (0, 1, 1, 1, 1, 1,
+                                         GridBagConstraints.CENTER,
+                                         GridBagConstraints.BOTH,
+                                         new Insets (5, 10, 5, 10), 0, 0));
+
+    ActionListener listener = new ActionListener ()
+      {
+        public void actionPerformed (ActionEvent ae)
+        {
+          String cmd = ae.getActionCommand ();
+          if (cmd.equals ("okay"))
+            callback.setText (text.getText ());
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      };
+
+    JPanel buttons = new JPanel ();
+    buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
+    JButton cancel = new JButton (messages.getString ("callback.cancel"));
+    JButton okay = new JButton (messages.getString ("callback.ok"));
+    cancel.setActionCommand ("cancel");
+    cancel.addActionListener (listener);
+    buttons.add (cancel);
+    okay.setActionCommand ("okay");
+    okay.addActionListener (listener);
+    buttons.add (okay);
+    content.add (buttons, new GridBagConstraints (0, 2, 1, 1, 0, 0,
+                                                  GridBagConstraints.SOUTHEAST,
+                                                  GridBagConstraints.NONE,
+                                                  new Insets (0, 10, 10, 10), 0, 0));
+
+    dialog.setResizable (true);
+    dialog.pack ();
+    dialog.setVisible (true);
+    dialog.getRootPane ().setDefaultButton (okay);
+    waitForInput (dialog, callback);
+  }
+
+  protected void handleTextOutput (final TextOutputCallback callback)
+    throws IOException
+  {
+    final JDialog dialog = new JDialog ();
+    switch (callback.getMessageType ())
+      {
+      case TextOutputCallback.ERROR:
+        dialog.setTitle (messages.getString ("callback.error"));
+        break;
+      case TextOutputCallback.WARNING:
+        dialog.setTitle (messages.getString ("callback.warning"));
+        break;
+      case TextOutputCallback.INFORMATION:
+        dialog.setTitle (messages.getString ("callback.information"));
+        break;
+      }
+    Container content = dialog.getContentPane ();
+    content.setLayout (new GridBagLayout ());
+
+    final JTextArea text = new JTextArea (24, 80);
+    text.setEditable (false);
+    text.setText (callback.getMessage ());
+    text.setFont (new Font ("Monospaced", Font.PLAIN, 12));
+    JScrollPane textPane = new JScrollPane (text,
+                                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+    content.add (textPane,
+                 new GridBagConstraints (0, 0, 1, 1, 1, 1,
+                                         GridBagConstraints.CENTER,
+                                         GridBagConstraints.BOTH,
+                                         new Insets (10, 10, 5, 10), 0, 0));
+
+    ActionListener listener = new ActionListener ()
+      {
+        public void actionPerformed (ActionEvent ae)
+        {
+          dialog.setVisible (false);
+          synchronized (callback)
+            {
+              callback.notify ();
+            }
+        }
+      };
+
+    JButton okay = new JButton (messages.getString ("callback.ok"));
+    okay.setActionCommand ("okay");
+    okay.addActionListener (listener);
+    content.add (okay, new GridBagConstraints (0, 1, 1, 1, 0, 0,
+                                               GridBagConstraints.SOUTHEAST,
+                                               GridBagConstraints.NONE,
+                                               new Insets (0, 10, 10, 10), 0, 0));
+
+    dialog.setResizable (true);
+    dialog.pack ();
+    dialog.setVisible (true);
+    dialog.getRootPane ().setDefaultButton (okay);
+    waitForInput (dialog, callback);
+  }
+
+  private void waitForInput (JDialog dialog, Callback callback)
+  {
+    synchronized (callback)
+      {
+        while (dialog.isVisible ())
+          {
+            try
+              {
+                callback.wait (1000);
+              }
+            catch (InterruptedException ignored)
+              {
+              }
+          }
+      }
+    dialog.dispose ();
+  }
+}
\ No newline at end of file

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,342 @@
+/* ConfigFileParser.java -- JAAS Login Configuration default syntax parser
+   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 gnu.javax.security.auth.login;
+
+import gnu.java.security.Configuration;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.security.auth.login.AppConfigurationEntry;
+
+/**
+ * A parser that knows how to interpret JAAS Login Module Configuration files
+ * written in the <i>default syntax</i> which is interpreted as adhering to
+ * the following grammar:
+ *
+ * <pre>
+ *   CONFIG              ::= APP_OR_OTHER_ENTRY+
+ *   APP_OR_OTHER_ENTRY  ::= APP_NAME_OR_OTHER JAAS_CONFIG_BLOCK
+ *   APP_NAME_OR_OTHER   ::= APP_NAME
+ *                         | 'other'
+ *   JAAS_CONFIG_BLOCK   ::= '{' (LOGIN_MODULE_ENTRY ';')+ '}' ';'
+ *   LOGIN_MODULE_ENTRY  ::= MODULE_CLASS FLAG MODULE_OPTION* ';'
+ *   FLAG                ::= 'required'
+ *                         | 'requisite'
+ *                         | 'sufficient'
+ *                         | 'optional'
+ *   MODULE_OPTION       ::= PARAM_NAME '=' PARAM_VALUE
+ *
+ *   APP_NAME     ::= JAVA_IDENTIFIER
+ *   MODULE_CLASS ::= JAVA_IDENTIFIER ('.' JAVA_IDENTIFIER)*
+ *   PARAM_NAME   ::= STRING
+ *   PARAM_VALUE  ::= '"' STRING '"' | ''' STRING ''' | STRING
+ * </pre>
+ *
+ * <p>This parser handles UTF-8 entities when used as APP_NAME and PARAM_VALUE.
+ * It also checks for the use of Java identifiers used in MODULE_CLASS, thus
+ * minimizing the risks of having {@link java.lang.ClassCastException}s thrown
+ * at runtime due to syntactically invalid names.</p>
+ *
+ * <p>In the above context, a JAVA_IDENTIFIER is a sequence of tokens,
+ * separated by the character '.'. Each of these tokens obeys the following:</p>
+ * 
+ * <ol>
+ *   <li>its first character yields <code>true</code> when used as an input to
+ *   the {@link java.lang.Character#isJavaIdentifierStart(char)}, and</li>
+ *   <li>all remaining characters, yield <code>true</code> when used as an
+ *   input to {@link java.lang.Character#isJavaIdentifierPart(char)}.</li>
+ * </ol>
+ */
+public final class ConfigFileParser
+{
+  private static final Logger log = Logger.getLogger(ConfigFileParser.class.getName());
+  private ConfigFileTokenizer cft;
+  private Map map = new HashMap();
+
+  // default 0-arguments constructor
+
+  /**
+   * Returns the parse result as a {@link Map} where the keys are application
+   * names, and the entries are {@link List}s of {@link AppConfigurationEntry}
+   * entries, one for each login module entry, in the order they were
+   * encountered, for that application name in the just parsed configuration
+   * file.
+   */
+  public Map getLoginModulesMap()
+  {
+    return map;
+  }
+
+  /**
+   * Parses the {@link Reader}'s contents assuming it is in the <i>default
+   * syntax</i>.
+   *
+   * @param r the {@link Reader} whose contents are assumed to be a JAAS Login
+   * Configuration Module file written in the <i>default syntax</i>.
+   * @throws IOException if an exception occurs while parsing the input.
+   */
+  public void parse(Reader r) throws IOException
+  {
+    initParser(r);
+
+    while (parseAppOrOtherEntry())
+      ; // do nothing
+  }
+
+  private void initParser(Reader r) throws IOException
+  {
+    map.clear();
+
+    cft = new ConfigFileTokenizer(r);
+  }
+
+  /**
+   * @return <code>true</code> if an APP_OR_OTHER_ENTRY was correctly parsed.
+   * Returns <code>false</code> otherwise.
+   * @throws IOException if an exception occurs while parsing the input.
+   */
+  private boolean parseAppOrOtherEntry() throws IOException
+  {
+    int c = cft.nextToken();
+    if (c == ConfigFileTokenizer.TT_EOF)
+      return false;
+
+    if (c != ConfigFileTokenizer.TT_WORD)
+      {
+        cft.pushBack();
+        return false;
+      }
+
+    String appName = cft.sval;
+    if (Configuration.DEBUG)
+      log.fine("APP_NAME_OR_OTHER = " + appName);
+    if (cft.nextToken() != '{')
+      abort("Missing '{' after APP_NAME_OR_OTHER");
+
+    List lmis = new ArrayList();
+    while (parseACE(lmis))
+      ; // do nothing
+
+    c = cft.nextToken();
+    if (c != '}')
+      abort("Was expecting '}' but found " + (char) c);
+
+    c = cft.nextToken();
+    if (c != ';')
+      abort("Was expecting ';' but found " + (char) c);
+
+    List listOfACEs = (List) map.get(appName);
+    if (listOfACEs == null)
+      {
+        listOfACEs = new ArrayList();
+        map.put(appName, listOfACEs);
+      }
+    listOfACEs.addAll(lmis);
+    return !appName.equalsIgnoreCase("other");
+  }
+
+  /**
+   * @return <code>true</code> if a LOGIN_MODULE_ENTRY was correctly parsed.
+   * Returns <code>false</code> otherwise. 
+   * @throws IOException if an exception occurs while parsing the input.
+   */
+  private boolean parseACE(List listOfACEs) throws IOException
+  {
+    int c = cft.nextToken();
+    if (c != ConfigFileTokenizer.TT_WORD)
+      {
+        cft.pushBack();
+        return false;
+      }
+
+    String clazz = validateClassName(cft.sval);
+    if (Configuration.DEBUG)
+      log.fine("MODULE_CLASS = " + clazz);
+
+    if (cft.nextToken() != ConfigFileTokenizer.TT_WORD)
+      abort("Was expecting FLAG but found none");
+
+    String flag = cft.sval;
+    if (Configuration.DEBUG)
+      log.fine("DEBUG: FLAG = " + flag);
+    AppConfigurationEntry.LoginModuleControlFlag f = null;
+    if (flag.equalsIgnoreCase("required"))
+      f = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
+    else if (flag.equalsIgnoreCase("requisite"))
+      f = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE;
+    else if (flag.equalsIgnoreCase("sufficient"))
+      f = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT;
+    else if (flag.equalsIgnoreCase("optional"))
+      f = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL;
+    else
+      abort("Unknown Flag: " + flag);
+
+    Map options = new HashMap();
+    String paramName, paramValue;
+    c = cft.nextToken();
+    while (c != ';')
+      {
+        if (c != ConfigFileTokenizer.TT_WORD)
+          abort("Was expecting PARAM_NAME but got '" + ((char) c) + "'");
+
+        paramName = cft.sval;
+        if (Configuration.DEBUG)
+          log.fine("PARAM_NAME = " + paramName);
+        if (cft.nextToken() != '=')
+          abort("Missing '=' after PARAM_NAME");
+
+        c = cft.nextToken();
+        if (c != '"' && c != '\'')
+          {
+          if (Configuration.DEBUG)
+            log.fine("Was expecting a quoted string but got no quote character."
+                     + " Assume unquoted string");
+          }
+        paramValue = expandParamValue(cft.sval);
+        if (Configuration.DEBUG)
+          log.fine("PARAM_VALUE = " + paramValue);
+        options.put(paramName, paramValue);
+
+        c = cft.nextToken();
+      }
+    AppConfigurationEntry ace = new AppConfigurationEntry(clazz, f, options);
+    if (Configuration.DEBUG)
+      log.fine("LOGIN_MODULE_ENTRY = " + ace);
+    listOfACEs.add(ace);
+    return true;
+  }
+
+  private void abort(String m) throws IOException
+  {
+    if (Configuration.DEBUG)
+      {
+        log.fine(m);
+        log.fine("Map (so far) = " + String.valueOf(map));
+      }
+    throw new IOException(m);
+  }
+
+  private String validateClassName(String cn) throws IOException
+  {
+    if (cn.startsWith(".") || cn.endsWith("."))
+      abort("MODULE_CLASS MUST NOT start or end with a '.'");
+
+    String[] tokens = cn.split("\\.");
+    for (int i = 0; i < tokens.length; i++)
+      {
+        String t = tokens[i];
+        if (! Character.isJavaIdentifierStart(t.charAt(0)))
+          abort("Class name [" + cn
+                + "] contains an invalid sub-package identifier: " + t);
+
+        // we dont check the rest of the characters for isJavaIdentifierPart()
+        // because that's what the tokenizer does.
+      }
+    
+    return cn;
+  }
+
+  /**
+   * The documentation of the {@link javax.security.auth.login.Configuration}
+   * states that: <i>"...If a String in the form, ${system.property}, occurs in
+   * the value, it will be expanded to the value of the system property."</i>.
+   * This method ensures this is the case. If such a string can not be expanded
+   * then it is left AS IS, assuming the LoginModule knows what to do with it.
+   *
+   * <p><b>IMPORTANT</b>: This implementation DOES NOT handle embedded ${}
+   * constructs.
+   *
+   * @param s the raw parameter value, incl. eventually strings of the form
+   * <code>${system.property}</code>.
+   * @return the input string with every occurence of
+   * <code>${system.property}</code> replaced with the value of the
+   * corresponding System property at the time of this method invocation. If
+   * the string is not a known System property name, then the complete sequence
+   * (incl. the ${} characters are passed AS IS.
+   */
+  private String expandParamValue(String s)
+  {
+    String result = s;
+    try
+      {
+        int searchNdx = 0;
+        while (searchNdx < result.length())
+          {
+            int i = s.indexOf("${", searchNdx);
+            if (i == -1)
+              break;
+
+            int j = s.indexOf("}", i + 2);
+            if (j == -1)
+              {
+                if (Configuration.DEBUG)
+                  log.fine("Found a ${ prefix with no } suffix. Ignore");
+                break;
+              }
+
+            String sysPropName = s.substring(i + 2, j);
+            if (Configuration.DEBUG)
+              log.fine("Found a reference to System property " + sysPropName);
+            String sysPropValue = System.getProperty(sysPropName);
+            if (Configuration.DEBUG)
+              log.fine("Resolved " + sysPropName + " to '" + sysPropValue + "'");
+            if (sysPropValue != null)
+              {
+                result = s.substring(0, i) + sysPropValue + s.substring(j + 1);
+                searchNdx = i + sysPropValue.length();
+              }
+            else
+              searchNdx = j + 1;
+          }
+      }
+    catch (Exception x)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Exception (ignored) while expanding " + s + ": " + x);
+      }
+
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,244 @@
+/* ConfigFileTokenizer.java -- JAAS Login Configuration default syntax tokenizer
+   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 gnu.javax.security.auth.login;
+
+import gnu.java.security.Configuration;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.logging.Logger;
+
+/**
+ * A UTF-8 friendly, JAAS Login Module Configuration file tokenizer written in
+ * the deault syntax. This class emulates, to a certain extent, the behavior of
+ * a {@link java.io.StreamTokenizer} instance <code>st</code>, when set as
+ * follows:
+ * 
+ *  <pre>
+ *  st.resetSyntax();
+ *  st.lowerCaseMode(false);
+ *  st.slashSlashComments(true);
+ *  st.slashStarComments(true);
+ *  st.eolIsSignificant(false);
+ *  st.wordChars('_', '_');
+ *  st.wordChars('$', '$');
+ *  st.wordChars('A', 'Z');
+ *  st.wordChars('a', 'z');
+ *  st.wordChars('0', '9');
+ *  st.wordChars('.', '.');
+ *  st.whitespaceChars(' ', ' ');
+ *  st.whitespaceChars('\t', '\t');
+ *  st.whitespaceChars('\f', '\f');
+ *  st.whitespaceChars('\r', '\r');
+ *  st.whitespaceChars('\n', '\n');
+ *  st.quoteChar('"');
+ *  st.quoteChar('\'');
+ *  </pre>
+ *
+ * <p>The most important (negative) difference with a
+ * {@link java.io.StreamTokenizer} is that this tokenizer does not properly
+ * handle C++ and Java // style comments in the middle of the line. It only
+ * ignores them if/when found at the start of the line.</p>  
+ */
+public class ConfigFileTokenizer
+{
+  private static final Logger log = Logger.getLogger(ConfigFileParser.class.getName());
+  /** A constant indicating that the end of the stream has been read. */
+  public static final int TT_EOF = -1;
+  /** A constant indicating that a word token has been read. */
+  public static final int TT_WORD = -3;
+  /** A constant indicating that no tokens have been read yet. */
+  private static final int TT_NONE = -4;
+
+  public String sval;
+  public int ttype;
+
+  private BufferedReader br;
+  boolean initialised;
+  private StringBuffer sb;
+  private int sbNdx;
+
+  // Constructor(s)
+  // --------------------------------------------------------------------------
+
+  /** Trivial constructor. */
+  ConfigFileTokenizer(Reader r)
+  {
+    super();
+
+    br = r instanceof BufferedReader ? (BufferedReader) r : new BufferedReader(r);
+    initialised = false;
+  }
+
+  // Class methods
+  // --------------------------------------------------------------------------
+
+  // Instance methods
+  // --------------------------------------------------------------------------
+
+  public int nextToken() throws IOException
+  {
+    if (!initialised)
+      init();
+
+    if (sbNdx >= sb.length())
+      return TT_EOF;
+
+    skipWhitespace();
+
+    if (sbNdx >= sb.length())
+      return TT_EOF;
+
+    int endNdx;
+    if (Character.isJavaIdentifierPart(sb.charAt(sbNdx)))
+      {
+        endNdx = sbNdx + 1;
+        while (Character.isJavaIdentifierPart(sb.charAt(endNdx))
+            || sb.charAt(endNdx) == '.')
+          endNdx++;
+
+        ttype = TT_WORD;
+        sval = sb.substring(sbNdx, endNdx);
+        sbNdx = endNdx;
+        return ttype;
+      }
+
+    int c = sb.charAt(sbNdx);
+    if (c == '{' || c == '}' || c == ';' || c == '=')
+      {
+        ttype = c;
+        sbNdx++;
+        return ttype;
+      }
+
+    if (c == '"' || c == '\'')
+      {
+        ttype = c;
+        String quote = sb.substring(sbNdx, sbNdx + 1);
+        int i = sbNdx + 1;
+        while (true)
+          {
+            // find a candidate
+            endNdx = sb.indexOf(quote, i);
+            if (endNdx == -1)
+              abort("Missing closing quote: " + quote);
+
+            // found one; is it escaped?
+            if (sb.charAt(endNdx - 1) != '\\')
+              break;
+
+            i++;
+            continue;
+          }
+
+        endNdx++;
+        sval = sb.substring(sbNdx, endNdx);
+        sbNdx = endNdx;
+        return ttype;
+      }
+
+    abort("Unknown character: " + sb.charAt(sbNdx));
+    return Integer.MIN_VALUE;
+  }
+
+  public void pushBack()
+  {
+    sbNdx -= ttype != TT_WORD ? 1 : sval.length();
+  }
+
+  private void init() throws IOException
+  {
+    sb = new StringBuffer();
+    String line;
+    while ((line = br.readLine()) != null)
+      {
+        line = line.trim();
+        if (line.length() == 0)
+          continue;
+
+        if (line.startsWith("#") || line.startsWith("//"))
+          continue;
+
+        sb.append(line).append(" ");
+      }
+
+    sbNdx = 0;
+    sval = null;
+    ttype = TT_NONE;
+
+    initialised = true;
+  }
+
+  private void skipWhitespace() throws IOException
+  {
+    int endNdx;
+    while (sbNdx < sb.length())
+      if (Character.isWhitespace(sb.charAt(sbNdx)))
+        {
+          sbNdx++;
+          while (sbNdx < sb.length() && Character.isWhitespace(sb.charAt(sbNdx)))
+            sbNdx++;
+
+          continue;
+        }
+      else if (sb.charAt(sbNdx) == '/' && sb.charAt(sbNdx + 1) == '*')
+        {
+          endNdx = sb.indexOf("*/", sbNdx + 2);
+          if (endNdx == -1)
+            abort("Missing closing */ sequence");
+
+          sbNdx = endNdx + 2;
+          continue;
+        }
+      else
+        break;
+  }
+
+  private void abort(String m) throws IOException
+  {
+    if (Configuration.DEBUG)
+      {
+        log.fine(m);
+        log.fine("sb = " + sb);
+        log.fine("sbNdx = " + sbNdx);
+      }
+    throw new IOException(m);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,466 @@
+/* GnuConfiguration.java -- GNU Classpath implementation of JAAS Configuration
+   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 gnu.javax.security.auth.login;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Security;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.security.auth.AuthPermission;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+
+/**
+ * An implementation of the {@link Configuration} class which interprets JAAS
+ * Login Configuration files written in the <i>default</i> syntax described in
+ * the publicly available documentation of that class. A more formal definition
+ * of this syntax is as follows:
+ * 
+ * <pre>
+ *   CONFIG              ::= APP_OR_OTHER_ENTRY+
+ *   APP_OR_OTHER_ENTRY  ::= APP_NAME_OR_OTHER JAAS_CONFIG_BLOCK
+ *   APP_NAME_OR_OTHER   ::= APP_NAME
+ *                         | 'other'
+ *   JAAS_CONFIG_BLOCK   ::= '{' (LOGIN_MODULE_ENTRY ';')+ '}' ';'
+ *   LOGIN_MODULE_ENTRY  ::= MODULE_CLASS FLAG MODULE_OPTION* ';'
+ *   FLAG                ::= 'required'
+ *                         | 'requisite'
+ *                         | 'sufficient'
+ *                         | 'optional'
+ *   MODULE_OPTION       ::= PARAM_NAME '=' PARAM_VALUE
+ *
+ *   APP_NAME     ::= JAVA_IDENTIFIER
+ *   MODULE_CLASS ::= JAVA_IDENTIFIER ('.' JAVA_IDENTIFIER)*
+ *   PARAM_NAME   ::= STRING
+ *   PARAM_VALUE  ::= '"' STRING '"' | ''' STRING ''' | STRING
+ * </pre>
+ * 
+ * <p>This implementation will specifically attempt to process one or more
+ * Login Configuration files in the following locations, and when found parse
+ * them and merge their contents. The locations, and the order in which they are
+ * investigated, follows:</p>
+ * 
+ * <ol>
+ *   <li>If the following Security properties:
+ *   <i>java.security.auth.login.config.url.<b>N</b></i>, where <i><b>N</b></i>
+ *   is a digit, from <code>1</code> to an arbitrary number, are defined, then
+ *   the value of each of those properties will be considered as a JAAS Login
+ *   Configuration file written in the default syntax. This implementation will
+ *   attempt parsing all such files.
+ *
+ *   <p>It is worth noting the following:
+ *     <ul>
+ *       <li>The GNU Classpath security file, named <i>classpath.security</i>,
+ *       where all Security properties are encoded, is usually located in
+ *       <i>/usr/local/classpath/lib/security</i> folder.</li>
+ *       
+ *       <li>The numbers used in the properties
+ *       <i>java.security.auth.login.config.url.<b>N</b></i> MUST be sequential,
+ *       with no breaks in-between.</li>
+ *     </ul>
+ *   </p>
+ *
+ *   <p>If at least one of the designated Configuration files was found, and
+ *   was parsed correctly, then no other location will be inspected.</p></li>
+ *
+ *   <li>If the System property named <i>java.security.auth.login.config</i>
+ *   is not null or empty, its contents are then interpreted as a URL to a
+ *   JAAS Login Configuration file written in the default syntax.
+ *
+ *   <p>If this System property is defined, and the file it refers to was
+ *   parsed correctly, then no other location will be inspected.</p></li>
+ *
+ *   <li>If a file named <i>.java.login.config</i> or <i>java.login.config</i>
+ *   (in that order) is found in the location referenced by the value of the
+ *   System property <i>user.home</i>, then that file is parsed as a JAAS Login
+ *   Configuration written in the default syntax.</li>
+ *   
+ *   <li>If none of the above resulted in a correctly parsed JAAS Login
+ *   Configuration file, then this implementation will install a <i>Null
+ *   Configuration</i> which basically does not recognize any Application.</li>
+ * </ol>
+ */
+public final class GnuConfiguration extends Configuration
+{
+  private static final Logger log = Logger.getLogger(GnuConfiguration.class.getName());
+  /**
+   * The internal map of login modules keyed by application name. Each entry in
+   * this map is a {@link List} of {@link AppConfigurationEntry}s for that
+   * application name.
+   */
+  private Map loginModulesMap;
+  /** Our reference to our default syntax parser. */
+  private ConfigFileParser cp;
+
+  // Constructor(s)
+  // --------------------------------------------------------------------------
+
+  /** Trivial 0-arguments Constructor. */
+  public GnuConfiguration()
+  {
+    super();
+
+    loginModulesMap = new HashMap();
+    cp = new ConfigFileParser();
+    init();
+  }
+
+  // Class methods
+  // --------------------------------------------------------------------------
+
+  // Instance methods
+  // --------------------------------------------------------------------------
+
+  // Configuration abstract methods implementation ----------------------------
+
+  /* (non-Javadoc)
+   * @see javax.security.auth.login.Configuration#getAppConfigurationEntry(java.lang.String)
+   */
+  public AppConfigurationEntry[] getAppConfigurationEntry(String appName)
+  {
+    if (appName == null)
+      return null;
+
+    appName = appName.trim();
+    if (appName.length() == 0)
+      return null;
+
+    List loginModules = (List) loginModulesMap.get(appName);
+    if (loginModules == null || loginModules.size() == 0)
+      return null;
+
+    if (gnu.java.security.Configuration.DEBUG)
+      log.fine(appName + " -> " + loginModules.size() + " entry(ies)");
+    return (AppConfigurationEntry[]) loginModules.toArray(new AppConfigurationEntry[0]);
+  }
+
+  /**
+   * Refreshes and reloads this <code>Configuration</code>.
+   * 
+   * <p>This method causes this <code>Configuration</code> object to refresh /
+   * reload its contents following the locations and logic described above in
+   * the class documentation section.</p>
+   * 
+   * @throws SecurityException if the caller does not have an
+   * {@link AuthPermission} for the action named
+   * <code>refreshLoginConfiguration</code>.
+   * @see AuthPermission
+   */
+  public void refresh()
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new AuthPermission("refreshLoginConfiguration"));
+
+    loginModulesMap.clear();
+    init();
+  }
+
+  // helper methods -----------------------------------------------------------
+
+  /**
+   * Attempts to find and parse JAAS Login Configuration file(s) written in
+   * the default syntax. The locations searched are as descibed in the class
+   * documentation.
+   */
+  private void init()
+  {
+    if (processSecurityProperties())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("Using login configuration defined by Security property(ies)");
+      }
+    else if (processSystemProperty())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("Using login configuration defined by System property");
+      }
+    else if (processUserHome())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("Using login configuration defined in ${user.home}");
+      }
+    else
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("No login configuration file found");
+      }
+  }
+
+  /**
+   * Attempts to locate and parse one or more JAAS Login Configuration files
+   * defined as the values of the Security properties
+   * <i>java.security.auth.login.config.url.N</i>.
+   * 
+   * @return <code>true</code> if it succeeds, and <code>false</code>
+   *         otherwsie.
+   */
+  private boolean processSecurityProperties()
+  {
+    boolean result = false;
+    int counter = 0;
+    String s;
+    while (true)
+      try
+        {
+          counter++;
+          s = Security.getProperty("java.security.auth.login.config.url."
+                                   + counter);
+          if (s == null)
+            break;
+
+          s = s.trim();
+          if (s.length() != 0)
+            {
+              if (gnu.java.security.Configuration.DEBUG)
+                log.fine("java.security.auth.login.config.url." + counter
+                         + " = " + s);
+              parseConfig(getInputStreamFromURL(s));
+              result = true;
+            }
+        }
+      catch (Throwable t)
+        {
+          if (gnu.java.security.Configuration.DEBUG)
+            log.fine("Exception while handling Security property at #"
+                     + counter + ". Continue: " + t);
+        }
+    return result;
+  }
+
+  /**
+   * Attempts to open a designated string as a well-formed {@link URL}. If a
+   * {@link MalformedURLException} occurs, this method then tries to open that
+   * string as a {@link File} (with the same name). If it succeeds, an
+   * {@link InputStream} is constructed and returned.
+   * 
+   * @param s
+   *          the designated name of either a {@link URL} or a {@link File}
+   *          assumed to contain a JAAS Login Configuration in the default
+   *          syntax.
+   * @return an {@link InputStream} around the data source.
+   * @throws IOException
+   *           if an exception occurs during the operation.
+   */
+  private InputStream getInputStreamFromURL(String s) throws IOException
+  {
+    InputStream result = null;
+    try
+      {
+        URL url = new URL(s);
+        result = url.openStream();
+      }
+    catch (MalformedURLException x)
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("Failed opening as URL: " + s + ". Will try as File");
+        result = new FileInputStream(s);
+      }
+    return result;
+  }
+
+  /**
+   * Attempts to locate and parse a JAAS Login Configuration file defined as the
+   * value of the System property <i>java.security.auth.login.config</i>.
+   * 
+   * @return <code>true</code> if it succeeds, and <code>false</code>
+   *         otherwsie.
+   */
+  private boolean processSystemProperty()
+  {
+    boolean result = false;
+    try
+      {
+        String s = System.getProperty("java.security.auth.login.config");
+        if (s != null)
+          {
+            s = s.trim();
+            if (s.length() != 0)
+              {
+                if (gnu.java.security.Configuration.DEBUG)
+                  log.fine("java.security.auth.login.config = " + s);
+                parseConfig(getInputStreamFromURL(s));
+                result = true;
+              }
+          }
+      }
+    catch (Throwable t)
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("Exception while handling System property. Continue: " + t);
+      }
+    return result;
+  }
+
+  /**
+   * Attempts to locate and parse a JAAS Login Configuration file named either
+   * as <i>.java.login.config</i> or <i>java.login.config</i> (without the
+   * leading dot) in the folder referenced by the System property
+   * <code>user.home</code>.
+   * 
+   * @return <code>true</code> if it succeeds, and <code>false</code>
+   *         otherwsie.
+   */
+  private boolean processUserHome()
+  {
+    boolean result = false;
+    try
+      {
+        File userHome = getUserHome();
+        if (userHome == null)
+          return result;
+
+        File jaasFile;
+        jaasFile = getConfigFromUserHome(userHome, ".java.login.config");
+        if (jaasFile == null)
+          jaasFile = getConfigFromUserHome(userHome, "java.login.config");
+
+        if (jaasFile == null)
+          {
+            if (gnu.java.security.Configuration.DEBUG)
+              log.fine("Login Configuration file, in " + userHome
+                       + ", does not exist or is inaccessible");
+            return result;
+          }
+
+        FileInputStream fis = new FileInputStream(jaasFile);
+        parseConfig(fis);
+        result = true;
+      }
+    catch (Throwable t)
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("Exception (ignored) while handling ${user.home}: " + t);
+      }
+    return result;
+  }
+
+  private void parseConfig(InputStream configStream) throws IOException
+  {
+    cp.parse(new InputStreamReader(configStream, "UTF-8"));
+    Map loginModulesMap = cp.getLoginModulesMap();
+    mergeLoginModules(loginModulesMap);
+  }
+
+  private void mergeLoginModules(Map otherLoginModules)
+  {
+    if (otherLoginModules == null || otherLoginModules.size() < 1)
+      return;
+
+    for (Iterator it = otherLoginModules.keySet().iterator(); it.hasNext();)
+      {
+        String appName = (String) it.next();
+        List thatListOfACEs = (List) otherLoginModules.get(appName);
+        if (thatListOfACEs == null || thatListOfACEs.size() < 1)
+          continue;
+
+        List thisListsOfACEs = (List) loginModulesMap.get(appName);
+        if (thisListsOfACEs == null)
+          loginModulesMap.put(appName, thatListOfACEs);
+        else
+          thisListsOfACEs.addAll(thatListOfACEs);
+      }
+  }
+
+  private File getUserHome()
+  {
+    String uh = System.getProperty("user.home");
+    if (uh == null || uh.trim().length() == 0)
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("User home path is not set or is empty");
+        return null;
+      }
+    uh = uh.trim();
+    File result = new File(uh);
+    if (! result.exists())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("User home '" + uh + "' does not exist");
+        return null;
+      }
+    if (! result.isDirectory())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("User home '" + uh + "' is not a directory");
+        return null;
+      }
+    if (! result.canRead())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("User home '" + uh + "' is not readable");
+        return null;
+      }
+    return result;
+  }
+
+  private File getConfigFromUserHome(File userHome, String fileName)
+  {
+    File result = new File(userHome, fileName);
+    if (! result.exists())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("File '" + fileName + "' does not exist in user's home");
+        return null;
+      }
+    if (! result.isFile())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("File '" + fileName + "' in user's home is not a file");
+        return null;
+      }
+    if (! result.canRead())
+      {
+        if (gnu.java.security.Configuration.DEBUG)
+          log.fine("File '" + fileName + "' in user's home is not readable");
+        return null;
+      }
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,130 @@
+/* AlsaInputPortDevice.java -- ALSA MIDI In Port
+   Copyright (C) 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 gnu.javax.sound.midi.alsa;
+
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Transmitter;
+import gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.AlsaPortInfo;
+
+/**
+ * ALSA MIDI In Port.
+ * 
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class AlsaInputPortDevice extends AlsaPortDevice
+{   
+
+  AlsaInputPortDevice (AlsaPortInfo info)
+  {
+    super(info);
+  }
+    
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#open()
+   */
+  public void open() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#close()
+   */
+  public void close()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#isOpen()
+   */
+  public boolean isOpen()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMicrosecondPosition()
+   */
+  public long getMicrosecondPosition()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMaxReceivers()
+   */
+  public int getMaxReceivers()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+   */
+  public int getMaxTransmitters()
+  {
+    // TODO Auto-generated method stub
+    return 1;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getReceiver()
+   */
+  public Receiver getReceiver() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getTransmitter()
+   */
+  public Transmitter getTransmitter() throws MidiUnavailableException
+  {
+    return new AlsaTransmitter();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,216 @@
+/* AlsaMidiDeviceProvider.java -- The ALSA MIDI Device Provider
+   Copyright (C) 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 gnu.javax.sound.midi.alsa;
+
+import gnu.classpath.Configuration;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+/**
+ * Provide ALSA MIDI devices.
+ * 
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class AlsaMidiDeviceProvider extends MidiDeviceProvider
+{
+  /**
+   * Abstract base for ALSA specific MIDI device info.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  private static abstract class AlsaInfo extends Info
+  {
+    /**
+     * Create an ALSA specific MIDI device info object.
+     * 
+     * @param name the device name
+     * @param description the device description
+     */
+    public AlsaInfo(String name, String description)
+    {
+      super(name, "Alsa", description, "0.0");
+    }
+    
+    abstract MidiDevice getDevice ();
+  } 
+
+  /**
+   * ALSA MIDI Port.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  public static abstract class AlsaPortInfo extends AlsaInfo
+  {
+    long client;
+    long port;
+    
+    /**
+     * Create ALSA MIDI In Port.
+     * 
+     * @param name the device name
+     * @param description the device description
+     * @param client the client ID
+     * @param port the port ID
+     */
+    public AlsaPortInfo(String name, String description, long client, long port)
+    {
+      super(name, description);
+      this.client = client;
+      this.port = port;
+    }
+  } 
+  
+  /**
+   * ALSA Sequencer specific info.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  private static class AlsaSequencerInfo extends AlsaInfo
+  {
+    public AlsaSequencerInfo(String name, String description)
+    {
+      super(name, description);
+    }
+    
+    MidiDevice getDevice()
+    {
+      return AlsaMidiSequencerDevice.getInstance();
+    }
+  }
+  
+  /**
+   * ALSA MIDI In Port.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  private static class AlsaInputPortInfo extends AlsaPortInfo
+  {
+    public AlsaInputPortInfo(String name, String description, long client, long port)
+    {
+      super(name, description, client, port);
+    }
+    
+    MidiDevice getDevice()
+    {
+      return new AlsaInputPortDevice(this);
+    }
+  }
+
+  /**
+   * ALSA MIDI Out Port.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  private static class AlsaOutputPortInfo extends AlsaPortInfo
+  {
+    public AlsaOutputPortInfo(String name, String description, long client, long port)
+    {
+      super(name, description, client, port);
+    }
+    
+    MidiDevice getDevice()
+    {
+      return new AlsaOutputPortDevice(this);
+    }
+  }
+  
+  private static AlsaInfo[] infos;
+  
+  private static native AlsaInfo[] getInputDeviceInfo_();
+  private static native AlsaInfo[] getOutputDeviceInfo_();
+  
+  /**
+   * Initialize the ALSA system
+   */
+  private static native void init_();
+  
+  static
+  {    
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("gjsmalsa");
+      }  
+       
+    init_();
+    
+    AlsaInfo inputs[] = getInputDeviceInfo_();
+    AlsaInfo outputs[] = getOutputDeviceInfo_();
+    
+    infos = new AlsaInfo[inputs.length + outputs.length + 1];
+    infos[0] = new AlsaSequencerInfo ("/dev/snd/seq", "ALSA Sequencer");
+    System.arraycopy(inputs, 0, infos, 1, inputs.length);
+    System.arraycopy(outputs, 0, infos, 1 + inputs.length, outputs.length);
+  }
+  
+  public AlsaMidiDeviceProvider()
+  {
+    // Nothing.
+  }
+  
+  /* (non-Javadoc)
+   * @see javax.sound.midi.spi.MidiDeviceProvider#getDeviceInfo()
+   */
+  public Info[] getDeviceInfo()
+  {
+    return infos;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.spi.MidiDeviceProvider#getDevice(javax.sound.midi.MidiDevice.Info)
+   */
+  public MidiDevice getDevice(Info info)
+  {
+    for (int i = 0; i < infos.length; i++)
+    {
+      if (info.equals(infos[i]))
+      {
+        return infos[i].getDevice();
+      }
+    }
+    throw new IllegalArgumentException("Don't recognize MIDI device " + info);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,519 @@
+/* AlsaMidiSequencerDevice.java -- The ALSA MIDI sequencer device
+   Copyright (C) 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 gnu.javax.sound.midi.alsa;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.midi.ControllerEventListener;
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MetaEventListener;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.Sequencer;
+import javax.sound.midi.Track;
+import javax.sound.midi.Transmitter;
+
+// FIXME: These next two imports are only required by gcj it seems.
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.Sequencer.SyncMode;
+
+/**
+ * The ALSA MIDI sequencer device.  This is a singleton device.
+ * 
+ * @author green at redhat.com
+ *
+ */
+public class AlsaMidiSequencerDevice implements Sequencer
+{
+  // The singleton instance.
+  public final static AlsaMidiSequencerDevice instance = new AlsaMidiSequencerDevice();
+  
+  // A pointer to a native chunk of memory
+  private long nativeState;
+  
+  // The sequence to process
+  private Sequence sequence;
+  
+  /**
+   * A private constructor.  There should only be one instance of this
+   * device. 
+   */
+  private AlsaMidiSequencerDevice()
+  {
+    super();
+  }
+
+  /**
+   * Return the sequencer singleton.
+   * 
+   * @return the sequencer singleton
+   */
+  public static AlsaMidiSequencerDevice getInstance()
+  {
+    return instance;
+  }
+  
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setSequence(javax.sound.midi.Sequence)
+   */
+  public void setSequence(Sequence seq) throws InvalidMidiDataException
+  {
+    sequence = seq;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setSequence(java.io.InputStream)
+   */
+  public void setSequence(InputStream istream) throws IOException,
+      InvalidMidiDataException
+  {
+    // TODO Auto-generated method stub
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getSequence()
+   */
+  public Sequence getSequence()
+  {
+    return sequence;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#start()
+   */
+  public void start()
+  {
+    // TODO Auto-generated method stub
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#stop()
+   */
+  public void stop()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#isRunning()
+   */
+  public boolean isRunning()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#startRecording()
+   */
+  public void startRecording()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#stopRecording()
+   */
+  public void stopRecording()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#isRecording()
+   */
+  public boolean isRecording()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#recordEnable(javax.sound.midi.Track, int)
+   */
+  public void recordEnable(Track track, int channel)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#recordDisable(javax.sound.midi.Track)
+   */
+  public void recordDisable(Track track)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTempoInBPM()
+   */
+  public float getTempoInBPM()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setTempoInBPM(float)
+   */
+  public void setTempoInBPM(float bpm)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTempoInMPQ()
+   */
+  public float getTempoInMPQ()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setTempoInMPQ(float)
+   */
+  public void setTempoInMPQ(float mpq)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setTempoFactor(float)
+   */
+  public void setTempoFactor(float factor)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTempoFactor()
+   */
+  public float getTempoFactor()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTickLength()
+   */
+  public long getTickLength()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTickPosition()
+   */
+  public long getTickPosition()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setTickPosition(long)
+   */
+  public void setTickPosition(long tick)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getMicrosecondLength()
+   */
+  public long getMicrosecondLength()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getMicrosecondPosition()
+   */
+  public long getMicrosecondPosition()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setMicrosecondPosition(long)
+   */
+  public void setMicrosecondPosition(long microsecond)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setMasterSyncMode(javax.sound.midi.Sequencer.SyncMode)
+   */
+  public void setMasterSyncMode(SyncMode sync)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getMasterSyncMode()
+   */
+  public SyncMode getMasterSyncMode()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getMasterSyncModes()
+   */
+  public SyncMode[] getMasterSyncModes()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setSlaveSyncMode(javax.sound.midi.Sequencer.SyncMode)
+   */
+  public void setSlaveSyncMode(SyncMode sync)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getSlaveSyncMode()
+   */
+  public SyncMode getSlaveSyncMode()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getSlaveSyncModes()
+   */
+  public SyncMode[] getSlaveSyncModes()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setTrackMute(int, boolean)
+   */
+  public void setTrackMute(int track, boolean mute)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTrackMute(int)
+   */
+  public boolean getTrackMute(int track)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#setTrackSolo(int, boolean)
+   */
+  public void setTrackSolo(int track, boolean solo)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#getTrackSolo(int)
+   */
+  public boolean getTrackSolo(int track)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#addMetaEventListener(javax.sound.midi.MetaEventListener)
+   */
+  public boolean addMetaEventListener(MetaEventListener listener)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#removeMetaEventListener(javax.sound.midi.MetaEventListener)
+   */
+  public void removeMetaEventListener(MetaEventListener listener)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#addControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
+   */
+  public int[] addControllerEventListener(ControllerEventListener listener,
+                                          int[] controllers)
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Sequencer#removeControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
+   */
+  public int[] removeControllerEventListener(ControllerEventListener listener,
+                                             int[] controllers)
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getDeviceInfo()
+   */
+  public Info getDeviceInfo()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#open()
+   */
+  public void open() throws MidiUnavailableException
+  {
+    synchronized(this)
+    {
+      // Check to see if we're open already.
+      if (nativeState != 0)
+        return;
+     
+      nativeState = open_();
+    }
+  }
+
+  /**
+   * Allocate the native state object, and open the sequencer.
+   * 
+   * @return a long representation of a pointer to the nativeState.
+   */
+  private native long open_();
+  
+  /**
+   * Close the sequencer and free the native state object.
+   */
+  private native void close_(long nativeState);
+  
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#close()
+   */
+  public void close()
+  {
+    synchronized(this)
+    {
+      close_(nativeState);
+      nativeState = 0;
+    }
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#isOpen()
+   */
+  public boolean isOpen()
+  {
+    synchronized(this)
+    {
+      return (nativeState != 0);
+    }
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMaxReceivers()
+   */
+  public int getMaxReceivers()
+  {
+    return -1;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+   */
+  public int getMaxTransmitters()
+  {
+    return -1;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getReceiver()
+   */
+  public Receiver getReceiver() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getTransmitter()
+   */
+  public Transmitter getTransmitter() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,131 @@
+/* AlsaOutputPortDevice.java -- ALSA MIDI Output Port Device
+   Copyright (C) 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 gnu.javax.sound.midi.alsa;
+
+import gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.AlsaPortInfo;
+
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Transmitter;
+
+/**
+ * ALSA MIDI Out Device
+ * 
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class AlsaOutputPortDevice extends AlsaPortDevice
+{
+  AlsaOutputPortDevice (AlsaPortInfo info)
+  {
+    super(info);
+  }
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#open()
+   */
+  public void open() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#close()
+   */
+  public void close()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#isOpen()
+   */
+  public boolean isOpen()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMicrosecondPosition()
+   */
+  public long getMicrosecondPosition()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMaxReceivers()
+   */
+  public int getMaxReceivers()
+  {
+    // TODO Auto-generated method stub
+    return 1;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+   */
+  public int getMaxTransmitters()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getReceiver()
+   */
+  public Receiver getReceiver() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getTransmitter()
+   */
+  public Transmitter getTransmitter() throws MidiUnavailableException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaPortDevice.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaPortDevice.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaPortDevice.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/alsa/AlsaPortDevice.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,153 @@
+/* AlsaPortDevice.java -- ALSA MIDI Port Devices
+   Copyright (C) 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 gnu.javax.sound.midi.alsa;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Transmitter;
+
+// FIXME: This next import is only rquired for gcj it seems.
+import javax.sound.midi.MidiDevice.Info;
+
+import gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.AlsaPortInfo;
+
+/**
+ * ALSA Port Device
+ * 
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public abstract class AlsaPortDevice implements MidiDevice
+{
+  /**
+   * The ALSA Receiver class.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  public class AlsaReceiver implements Receiver
+  {
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long)
+     */
+    public void send(MidiMessage message, long timeStamp)
+        throws IllegalStateException
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Receiver#close()
+     */
+    public void close()
+    {
+      // TODO Auto-generated method stub
+
+    }
+  }
+
+  AlsaMidiDeviceProvider.AlsaPortInfo info;
+    
+  public AlsaPortDevice (AlsaPortInfo info)
+  {
+    this.info = info;
+  }
+    
+  public Info getDeviceInfo()
+  {
+    return info;
+  }
+
+  native void run_receiver_thread_ (long client, long port, Receiver receiver);
+  
+  /**
+   * The ALSA Transmitter class.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  protected class AlsaTransmitter implements Transmitter, Runnable
+  {
+    private Receiver receiver;
+
+    public void run()
+    {
+      run_receiver_thread_ (info.client, info.port, receiver);
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Transmitter#setReceiver(javax.sound.midi.Receiver)
+     */
+    public void setReceiver(Receiver receiver)
+    {
+      synchronized (this)
+      {
+        this.receiver = receiver;
+      }
+      
+      // Create the processing thread
+      new Thread(this).start();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Transmitter#getReceiver()
+     */
+    public Receiver getReceiver()
+    {
+      synchronized (this)
+      {
+        return receiver;
+      }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Transmitter#close()
+     */
+    public void close()
+    {
+      synchronized (this)
+      {
+        receiver.close();
+        receiver = null;
+      }
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* DSSIMidiDeviceProvider.java -- DSSI Device Provider
+   Copyright (C) 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 gnu.javax.sound.midi.dssi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+import java.io.FilenameFilter;
+
+import gnu.classpath.Configuration;
+import gnu.javax.sound.midi.alsa.AlsaMidiSequencerDevice;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+/**
+ * A DSSI MIDI device provider.
+ * 
+ * DSSI (pronounced "dizzy") is an API for audio plugins, with particular 
+ * application for software synthesis plugins with native user interfaces.
+ * 
+ * Read about DSSI at http://dssi.sourceforge.net
+ * 
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class DSSIMidiDeviceProvider extends MidiDeviceProvider
+{
+  /**
+   * The MidiDevice.Info specialized for DSSI synthesizers.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  private static class DSSIInfo extends Info
+  {
+    String soname;
+    long index;
+    
+    public DSSIInfo(String name, String vendor, String description,
+                    String version, String soname, long index)
+    {
+      super(name, vendor, description, version);
+      this.soname = soname;
+      this.index = index;
+    }
+  }
+
+  static native long dlopen_(String soname);
+  static native void dlclose_(long sohandle);
+  static native long getDSSIHandle_(long sohandle, long index);
+  static native String getDSSIName_(long handle);
+  static native String getDSSICopyright_(long handle);
+  static native String getDSSIVendor_(long handle);
+  static native String getDSSILabel_(long handle);
+  
+  private static List examineLibrary(String soname)
+  {
+     List list = new ArrayList();
+     long index = 0;
+     long handle;
+     
+     long sohandle = dlopen_(soname);
+     if (sohandle == 0)
+       return list;
+     do
+     {
+       handle = getDSSIHandle_(sohandle, index);
+       if (handle == 0)
+         break;
+       String name = getDSSILabel_(handle);
+       String copyright = getDSSICopyright_(handle);
+       String label = getDSSIName_(handle);
+       String vendor = getDSSIVendor_(handle);
+       list.add(new DSSIInfo(name, vendor, label, 
+                             "DSSI-1", soname, index));
+       index++;
+     } while (true);
+     
+     // Close the library and free memory
+     dlclose_(sohandle);
+     
+     return list;
+  }
+  
+  private static DSSIInfo[] infos;
+  
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      System.loadLibrary("gjsmdssi");
+
+    File dssidir = new File("/usr/lib/dssi/");
+    String sofiles[] = dssidir.list(new FilenameFilter()
+                                    {
+                                      public boolean accept(File dir, String n)
+                                      {
+                                        return n.endsWith(".so");
+                                      }   
+                                    });
+    List ilist = new ArrayList();
+    for (int i = 0; i < sofiles.length; i++)
+      ilist.addAll(examineLibrary(new File(dssidir, sofiles[i]).getAbsolutePath()));
+    infos = (DSSIInfo[]) ilist.toArray(new DSSIInfo[ilist.size()]);
+  }
+  
+  public DSSIMidiDeviceProvider()
+  {
+    // Empty.
+  }
+  
+  /* Return the Info array.
+   * @see javax.sound.midi.spi.MidiDeviceProvider#getDeviceInfo()
+   */
+  public Info[] getDeviceInfo()
+  {
+    return infos;
+  }
+
+  /* Get a MIDI Device for info.
+   * @see javax.sound.midi.spi.MidiDeviceProvider#getDevice(javax.sound.midi.MidiDevice.Info)
+   */
+  public MidiDevice getDevice(Info info)
+  {
+    for (int i = 0; i < infos.length; i++)
+    {
+      if (info.equals(infos[i]))
+      {
+          return new DSSISynthesizer(infos[i],
+                                     infos[i].soname, 
+                                     infos[i].index);
+      }
+    }
+    throw new IllegalArgumentException("Don't recognize MIDI device " + info);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,745 @@
+/* DSSISynthesizer.java -- DSSI Synthesizer Provider
+   Copyright (C) 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 gnu.javax.sound.midi.dssi;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.sound.midi.Instrument;
+import javax.sound.midi.MidiChannel;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Patch;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.ShortMessage;
+import javax.sound.midi.Soundbank;
+import javax.sound.midi.SoundbankResource;
+import javax.sound.midi.Synthesizer;
+import javax.sound.midi.Transmitter;
+import javax.sound.midi.VoiceStatus;
+
+// FIXME: This import in only required for gcj it seems.
+import javax.sound.midi.MidiDevice.Info;
+
+/**
+ * DSSI soft-synth support.
+ * 
+ * All DSSI soft-synths are expected to be installed in /usr/lib/dssi.
+ * 
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class DSSISynthesizer implements Synthesizer
+{
+  /**
+   * The DSSI Instrument class.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  class DSSIInstrument extends Instrument
+  {
+    DSSIInstrument (Soundbank soundbank, Patch patch, String name)
+    {
+      super (soundbank, patch, name, null);
+    }
+    
+    /* @see javax.sound.midi.SoundbankResource#getData()
+     */
+    public Object getData()
+    {
+      return null;
+    }
+
+  }
+
+/**
+   * DSSISoundbank holds all instruments.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  class DSSISoundbank implements Soundbank
+  {
+    private String name;
+    private String description;
+    private List instruments = new ArrayList();
+    private List resources = new ArrayList();
+    private String vendor;
+    private String version;
+    
+    public DSSISoundbank(String name, String description, String vendor, String version)
+    {
+      this.name = name;
+      this.description = description;
+      this.vendor = vendor;
+      this.version = version;
+    }
+    
+    void add(Instrument instrument)
+    {
+      instruments.add(instrument);
+    }
+    
+    /* @see javax.sound.midi.Soundbank#getName()
+     */
+    public String getName()
+    {
+      return name;
+    }
+
+    /* @see javax.sound.midi.Soundbank#getVersion()
+     */
+    public String getVersion()
+    {
+      return version;
+    }
+
+    /* @see javax.sound.midi.Soundbank#getVendor()
+     */
+    public String getVendor()
+    {
+      return vendor;
+    }
+
+    /* @see javax.sound.midi.Soundbank#getDescription()
+     */
+    public String getDescription()
+    {
+      return description;
+    }
+
+    /* @see javax.sound.midi.Soundbank#getResources()
+     */
+    public SoundbankResource[] getResources()
+    {
+      return (SoundbankResource[])
+        resources.toArray(new SoundbankResource[resources.size()]);
+    }
+
+    /* @see javax.sound.midi.Soundbank#getInstruments()
+     */
+    public Instrument[] getInstruments()
+    {
+      return (Instrument[])
+        instruments.toArray(new Instrument[instruments.size()]);
+    }
+
+    /* @see javax.sound.midi.Soundbank#getInstrument(javax.sound.midi.Patch)
+     */
+    public Instrument getInstrument(Patch patch)
+    {
+      Iterator itr = instruments.iterator();
+      
+      while (itr.hasNext())
+      {
+        Instrument i = (Instrument) itr.next();
+        if (i.getPatch().equals(patch))
+          return i;
+      }
+      
+      return null;
+    }
+  }
+
+/**
+   * The Receiver class receives all MIDI messages from a connected
+   * Transmitter.
+   * 
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  class DSSIReceiver implements Receiver
+  {
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long)
+     */
+    public void send(MidiMessage message, long timeStamp)
+        throws IllegalStateException
+    {
+      if (message instanceof ShortMessage)
+      {
+        ShortMessage smessage = (ShortMessage) message;
+      
+        switch (message.getStatus())
+        {
+        case ShortMessage.NOTE_ON:
+          int velocity = smessage.getData2();
+          if (velocity > 0)
+            channels[smessage.getChannel()].noteOn(smessage.getData1(), 
+                                                   smessage.getData2());
+          else
+            channels[smessage.getChannel()].noteOff(smessage.getData1());
+          break;
+        case ShortMessage.CONTROL_CHANGE:
+          channels[smessage.getChannel()].controlChange(smessage.getData1(),
+                                                        smessage.getData2());
+          break;
+        default:
+          System.out.println ("Unhandled message: " + message.getStatus());
+          break;
+        }
+      }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.Receiver#close()
+     */
+    public void close()
+    {
+      // TODO Auto-generated method stub
+    }
+
+  }
+
+  static native void noteOn_(long handle, int channel, int noteNumber, int velocity);  
+  static native void noteOff_(long handle, int channel, int noteNumber, int velocity);  
+  static native void setPolyPressure_(long handle, int channel, int noteNumber, int pressure);
+  static native int getPolyPressure_(long handle, int channel, int noteNumber);
+  static native void controlChange_(long handle, int channel, int control, int value);
+  static native void open_(long handle);
+  static native void close_(long handle);
+  static native String getProgramName_(long handle, int index);
+  static native int getProgramBank_(long handle, int index);
+  static native int getProgramProgram_(long handle, int index);
+  static native void selectProgram_(long handle, int bank, int program);
+      
+  /**
+   * @author Anthony Green (green at redhat.com)
+   *
+   */
+  public class DSSIMidiChannel implements MidiChannel
+  {
+    int channel = 0;
+    
+    /**
+     * Default contructor.
+     */
+    public DSSIMidiChannel(int channel)
+    {
+      super();
+      this.channel = channel;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#noteOn(int, int)
+     */
+    public void noteOn(int noteNumber, int velocity)
+    {
+      noteOn_(sohandle, channel, noteNumber, velocity);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#noteOff(int, int)
+     */
+    public void noteOff(int noteNumber, int velocity)
+    {
+      noteOff_(sohandle, channel, noteNumber, velocity);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#noteOff(int)
+     */
+    public void noteOff(int noteNumber)
+    {
+      noteOff_(sohandle, channel, noteNumber, -1);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setPolyPressure(int, int)
+     */
+    public void setPolyPressure(int noteNumber, int pressure)
+    {
+      setPolyPressure_(sohandle, channel, noteNumber, pressure);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getPolyPressure(int)
+     */
+    public int getPolyPressure(int noteNumber)
+    {
+      return getPolyPressure_(sohandle, channel, noteNumber);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setChannelPressure(int)
+     */
+    public void setChannelPressure(int pressure)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getChannelPressure()
+     */
+    public int getChannelPressure()
+    {
+      // TODO Auto-generated method stub
+      return 0;
+    }
+
+    /* @see javax.sound.midi.MidiChannel#controlChange(int, int)  */
+    public void controlChange(int controller, int value)
+    {
+      controlChange_(sohandle, channel, controller, value);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getController(int)
+     */
+    public int getController(int controller)
+    {
+      // TODO Auto-generated method stub
+      return 0;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#programChange(int)
+     */
+    public void programChange(int program)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#programChange(int, int)
+     */
+    public void programChange(int bank, int program)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getProgram()
+     */
+    public int getProgram()
+    {
+      // TODO Auto-generated method stub
+      return 0;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setPitchBend(int)
+     */
+    public void setPitchBend(int bend)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getPitchBend()
+     */
+    public int getPitchBend()
+    {
+      // TODO Auto-generated method stub
+      return 0;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#resetAllControllers()
+     */
+    public void resetAllControllers()
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#allNotesOff()
+     */
+    public void allNotesOff()
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#allSoundOff()
+     */
+    public void allSoundOff()
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#localControl(boolean)
+     */
+    public boolean localControl(boolean on)
+    {
+      // TODO Auto-generated method stub
+      return false;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setMono(boolean)
+     */
+    public void setMono(boolean on)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getMono()
+     */
+    public boolean getMono()
+    {
+      // TODO Auto-generated method stub
+      return false;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setOmni(boolean)
+     */
+    public void setOmni(boolean on)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getOmni()
+     */
+    public boolean getOmni()
+    {
+      // TODO Auto-generated method stub
+      return false;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setMute(boolean)
+     */
+    public void setMute(boolean mute)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getMute()
+     */
+    public boolean getMute()
+    {
+      // TODO Auto-generated method stub
+      return false;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#setSolo(boolean)
+     */
+    public void setSolo(boolean solo)
+    {
+      // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see javax.sound.midi.MidiChannel#getSolo()
+     */
+    public boolean getSolo()
+    {
+      // TODO Auto-generated method stub
+      return false;
+    }
+
+  }
+
+  long sohandle;
+  long handle; 
+  private Info info;
+  
+  MidiChannel channels[] = new MidiChannel[16];
+  
+  // The list of known soundbanks, and the default one.
+  List soundbanks = new ArrayList();
+  DSSISoundbank defaultSoundbank;
+  
+  /**
+   * Create a DSSI Synthesizer.
+   * 
+   * @param info the DSSIInfo for this soft-synth
+   * @param soname the name of the .so file for this DSSI synth
+   * @param index the DSSI index for this soft-synth
+   */
+  public DSSISynthesizer(Info info, String soname, long index)
+  {
+    super();
+    this.info = info;
+    sohandle = DSSIMidiDeviceProvider.dlopen_(soname);
+    handle = DSSIMidiDeviceProvider.getDSSIHandle_(sohandle, index);
+    channels[0] = new DSSIMidiChannel(0);
+    defaultSoundbank = new DSSISoundbank("name", "description", 
+                                         "vendor", "version");
+    soundbanks.add(defaultSoundbank);
+    
+    int i = 0;
+    String name;
+    do
+    {
+      name = getProgramName_(sohandle, i);
+      if (name != null)
+      {
+        defaultSoundbank.
+          add(new DSSIInstrument(defaultSoundbank, 
+                                 new Patch(getProgramBank_(sohandle, i),
+                                           getProgramProgram_(sohandle, i)),
+                                 name));
+        i++;
+      }
+    } while (name != null);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#getMaxPolyphony()
+   */
+  public int getMaxPolyphony()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#getLatency()
+   */
+  public long getLatency()
+  {
+    // DSSI and LADSPA provide no way to determine the latency.
+    // Let's just return 0 for now.
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#getChannels()
+   */
+  public MidiChannel[] getChannels()
+  {
+    return channels;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#getVoiceStatus()
+   */
+  public VoiceStatus[] getVoiceStatus()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#isSoundbankSupported(javax.sound.midi.Soundbank)
+   */
+  public boolean isSoundbankSupported(Soundbank soundbank)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* @see javax.sound.midi.Synthesizer#loadInstrument(javax.sound.midi.Instrument)
+   */
+  public boolean loadInstrument(Instrument instrument)
+  {
+    // FIXME: perhaps this isn't quite right.  It can probably
+    // be in any soundbank.
+    if (instrument.getSoundbank() != defaultSoundbank)
+      throw new IllegalArgumentException ("Synthesizer doesn't support this instrument's soundbank");
+      
+    Patch patch = instrument.getPatch();
+    selectProgram_(sohandle, patch.getBank(), patch.getProgram());
+    return true;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#unloadInstrument(javax.sound.midi.Instrument)
+   */
+  public void unloadInstrument(Instrument instrument)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#remapInstrument(javax.sound.midi.Instrument, javax.sound.midi.Instrument)
+   */
+  public boolean remapInstrument(Instrument from, Instrument to)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* @see javax.sound.midi.Synthesizer#getDefaultSoundbank()
+   */
+  public Soundbank getDefaultSoundbank()
+  {
+    return defaultSoundbank;
+  }
+
+  /* @see javax.sound.midi.Synthesizer#getAvailableInstruments()
+   */
+  public Instrument[] getAvailableInstruments()
+  {
+    List instruments = new ArrayList();
+    Iterator itr = soundbanks.iterator();
+    while (itr.hasNext())
+    {
+      Soundbank sb = (Soundbank) itr.next();
+      Instrument ins[] = sb.getInstruments();
+      for (int i = 0; i < ins.length; i++)
+        instruments.add(ins[i]);
+    }
+    return (Instrument[])
+      instruments.toArray(new Instrument[instruments.size()]);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#getLoadedInstruments()
+   */
+  public Instrument[] getLoadedInstruments()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#loadAllInstruments(javax.sound.midi.Soundbank)
+   */
+  public boolean loadAllInstruments(Soundbank soundbank)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#unloadAllInstruments(javax.sound.midi.Soundbank)
+   */
+  public void unloadAllInstruments(Soundbank soundbank)
+  {
+    // TODO Auto-generated method stub
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#loadInstruments(javax.sound.midi.Soundbank, javax.sound.midi.Patch[])
+   */
+  public boolean loadInstruments(Soundbank soundbank, Patch[] patchList)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.Synthesizer#unloadInstruments(javax.sound.midi.Soundbank, javax.sound.midi.Patch[])
+   */
+  public void unloadInstruments(Soundbank soundbank, Patch[] patchList)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /* @see javax.sound.midi.MidiDevice#getDeviceInfo()
+   */
+  public Info getDeviceInfo()
+  {
+    return info;
+  }
+
+  /* @see javax.sound.midi.MidiDevice#open()
+   */
+  public void open() throws MidiUnavailableException
+  {
+    open_(sohandle);
+  }
+
+  /* @see javax.sound.midi.MidiDevice#close()
+   */
+  public void close()
+  {
+    close_(sohandle);
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#isOpen()
+   */
+  public boolean isOpen()
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see javax.sound.midi.MidiDevice#getMicrosecondPosition()
+   */
+  public long getMicrosecondPosition()
+  {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /* @see javax.sound.midi.MidiDevice#getMaxReceivers()
+   */
+  public int getMaxReceivers()
+  {
+    return 1;
+  }
+
+  /* @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+   */
+  public int getMaxTransmitters()
+  {
+    return 0;
+  }
+
+  /* @see javax.sound.midi.MidiDevice#getReceiver()
+   */
+  public Receiver getReceiver() throws MidiUnavailableException
+  {
+    return new DSSIReceiver();
+  }
+
+  /* @see javax.sound.midi.MidiDevice#getTransmitter()
+   */
+  public Transmitter getTransmitter() throws MidiUnavailableException
+  {
+    return null;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* ExtendedMidiFileFormat.java -- extended with track count info.
+   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 gnu.javax.sound.midi.file;
+
+/**
+ * ExtendedMidiFileFormat is a package private class that simply 
+ * adds the number of MIDI tracks for the MidiFileFormat class.
+ *
+ * @author Anthony Green (green at redhat.com)
+ */
+class ExtendedMidiFileFormat
+    extends javax.sound.midi.MidiFileFormat
+{
+  private int ntracks;
+  
+  /**
+   * Get the number of tracks for this MIDI file.
+   * 
+   * @return the number of tracks for this MIDI file
+   */
+  public int getNumberTracks()
+  {
+    return ntracks;
+  }
+  
+  /**
+   * Create an ExtendedMidiFileFormat object from the given parameters.
+   *
+   * @param type the MIDI file type (0, 1, or 2)
+   * @param divisionType the MIDI file division type
+   * @param resolution the MIDI file timing resolution
+   * @param bytes the MIDI file size in bytes
+   * @param microseconds the MIDI file length in microseconds
+   * @param ntracks the number of tracks
+   */
+  public ExtendedMidiFileFormat(int type, float divisionType, int resolution, 
+                                int bytes, long microseconds, int ntracks)
+  {
+    super(type, divisionType, resolution, bytes, microseconds);
+    this.ntracks = ntracks;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* MidiDataInputStream.java -- adds variable length MIDI ints
+   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 gnu.javax.sound.midi.file;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * MidiDataInputStream is simply a DataInputStream with the addition
+ * of special variable length int reading as defined by the MIDI spec.
+ *
+ * @author Anthony Green (green at redhat.com)
+ */
+public class MidiDataInputStream
+    extends DataInputStream
+{
+  /**
+   * Create a MidiDataInputStream.
+   */
+  public MidiDataInputStream(InputStream is)
+  {
+    super(is);
+  }
+  
+  /**
+   * Read an int encoded in the MIDI-style variable length
+   * encoding format.
+   *
+   * @return an int
+   */
+  public int readVariableLengthInt()
+    throws IOException
+  {
+    int c, value = readByte();
+    
+    if ((value & 0x80) != 0)
+      {
+         value &= 0x7F;
+         do
+         {
+           value = (value << 7) + ((c = readByte()) & 0x7F);
+         } while ((c & 0x80) != 0);
+      }
+    
+    return value;   
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,114 @@
+/* MidiDataOutputStream.java -- adds variable length MIDI ints
+   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 gnu.javax.sound.midi.file;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * MidiDataOutputStream is simply a DataOutputStream with the addition
+ * of special variable length int writing as defined by the MIDI spec.
+ *
+ * @author Anthony Green (green at redhat.com)
+ */
+public class MidiDataOutputStream
+    extends DataOutputStream
+{
+  /**
+   * Create a MidiDataOutputStream.
+   */
+  public MidiDataOutputStream(OutputStream os)
+  {
+    super(os);
+  }
+
+  /**
+   * Return the length of a variable length encoded int without
+   * writing it out.
+   *
+   * @return the length of the encoding
+   */
+  public int variableLengthIntLength (int value)
+  {
+    int length = 0;
+    int buffer = value & 0x7F;
+
+    while ((value >>= 7) != 0)
+      {
+	buffer <<= 8;
+	buffer |= ((value & 0x7F) | 0x80);
+      }
+      
+    while (true)
+      {
+	length++;
+	if ((buffer & 0x80) != 0)
+	  buffer >>>= 8;
+	else
+	  break;
+      }
+
+    return length;
+  }
+  
+  /**
+   * Write an int encoded in the MIDI-style variable length
+   * encoding format.
+   */
+  public synchronized void writeVariableLengthInt (int value) 
+    throws IOException
+  {
+    int buffer = value & 0x7F;
+
+    while ((value >>= 7) != 0)
+      {
+	buffer <<= 8;
+	buffer |= ((value & 0x7F) | 0x80);
+      }
+      
+    while (true)
+      {
+	writeByte(buffer & 0xff);
+	if ((buffer & 0x80) != 0)
+	  buffer >>>= 8;
+	else
+	  break;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,378 @@
+/* MidiFileReader.java -- Read MIDI files.
+   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 gnu.javax.sound.midi.file;
+
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MetaMessage;
+import javax.sound.midi.MidiEvent;
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.ShortMessage;
+import javax.sound.midi.SysexMessage;
+import javax.sound.midi.Track;
+
+/**
+ * A MIDI file reader.
+ * 
+ * This code reads MIDI file types 0 and 1.  
+ *
+ * There are many decent documents on the web describing the MIDI file
+ * format.  I didn't bother looking for the official document.  If it
+ * exists, I'm not even sure if it is freely available.  We should
+ * update this comment if we find out anything helpful here.
+ *
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class MidiFileReader extends javax.sound.midi.spi.MidiFileReader 
+{
+  /* Get the MidiFileFormat for the given input stream.
+   * @see javax.sound.midi.spi.MidiFileReader#getMidiFileFormat(java.io.InputStream)
+   */
+  public MidiFileFormat getMidiFileFormat(InputStream in)
+    throws InvalidMidiDataException, IOException
+  {
+    DataInputStream din;
+    if (in instanceof DataInputStream)
+      din = (DataInputStream) in;
+    else
+      din = new DataInputStream(in);
+    
+    int type, ntracks, division, resolution, bytes;
+    float divisionType;
+    
+    if (din.readInt() != 0x4d546864) // "MThd"
+      throw new InvalidMidiDataException("Invalid MIDI chunk header.");
+
+    bytes = din.readInt();
+    if (bytes < 6)
+      throw new 
+	InvalidMidiDataException("Invalid MIDI chunk header length: " + bytes);
+
+    type = din.readShort();
+    if (type < 0 || type > 2)
+      throw new 
+	InvalidMidiDataException("Invalid MIDI file type value: " + type);
+    
+    ntracks = din.readShort();
+    if (ntracks <= 0)
+      throw new 
+	InvalidMidiDataException("Invalid number of MIDI tracks: " + ntracks);
+    
+    division = din.readShort();
+    if ((division & 0x8000) != 0)
+      {
+        division = -((division >>> 8) & 0xFF);
+        switch (division)
+          {
+          case 24:
+            divisionType = Sequence.SMPTE_24;
+            break;
+
+          case 25:
+            divisionType = Sequence.SMPTE_25;
+            break;
+
+          case 29:
+            divisionType = Sequence.SMPTE_30DROP;
+            break;
+
+          case 30:
+            divisionType = Sequence.SMPTE_30;
+            break;
+
+          default:
+            throw new 
+	      InvalidMidiDataException("Invalid MIDI frame division type: "
+				       + division);
+          }
+        resolution = division & 0xff;
+      }
+    else
+      {
+        divisionType = Sequence.PPQ;
+        resolution = division & 0x7fff;
+      }
+    
+    // If we haven't read every byte in the header now, just skip the rest.
+    din.skip(bytes - 6);
+    
+    return new ExtendedMidiFileFormat(type, divisionType, resolution,
+                                      MidiFileFormat.UNKNOWN_LENGTH,
+                                      MidiFileFormat.UNKNOWN_LENGTH, ntracks);
+  }
+
+  /* Get the MidiFileFormat from the given URL.
+   * @see javax.sound.midi.spi.MidiFileReader#getMidiFileFormat(java.net.URL)
+   */
+  public MidiFileFormat getMidiFileFormat(URL url)
+    throws InvalidMidiDataException, IOException
+  {		  
+    InputStream is = url.openStream();
+    try
+      {
+        return getMidiFileFormat(is);
+      }
+    finally
+      {
+        is.close();
+      }
+  }
+
+  /* Get the MidiFileFormat from the given file.
+   * @see javax.sound.midi.spi.MidiFileReader#getMidiFileFormat(java.io.File)
+   */
+  public MidiFileFormat getMidiFileFormat(File file)
+    throws InvalidMidiDataException, IOException
+  {
+    InputStream is = new FileInputStream(file);
+    try
+      {
+        return getMidiFileFormat(is);
+      }
+    finally
+      {
+        is.close();
+      }
+  }
+  
+  /* Get the MIDI Sequence found in this input stream.
+   * @see javax.sound.midi.spi.MidiFileReader#getSequence(java.io.InputStream)
+   */
+  public Sequence getSequence(InputStream is) throws InvalidMidiDataException,
+    IOException
+  {
+    MidiDataInputStream din = new MidiDataInputStream(is);
+    ExtendedMidiFileFormat mff = (ExtendedMidiFileFormat) getMidiFileFormat(din);
+
+    Sequence seq = new Sequence(mff.getDivisionType(), mff.getResolution());
+
+    int ntracks = mff.getNumberTracks();
+
+    while (ntracks-- > 0)
+      {
+        Track track = seq.createTrack();
+        int Mtrk = din.readInt();
+        if (Mtrk != 0x4d54726b)
+          throw new InvalidMidiDataException("Invalid MIDI track header.");
+        int length = din.readInt();
+
+        int runningStatus = -1;
+        int click = 0;
+
+        // Set this to true when we've hit an End of Track meta event.
+        boolean done = false;
+
+        // Read all events.
+        while (! done)
+          {
+            MidiMessage mm;
+            int dtime = din.readVariableLengthInt();
+            click += dtime;
+
+            int sbyte = din.readUnsignedByte();
+
+            if (sbyte < 0xf0)
+              {
+                ShortMessage sm;
+                switch (sbyte & 0xf0)
+                  {
+                  case ShortMessage.NOTE_OFF:
+                  case ShortMessage.NOTE_ON:
+                  case ShortMessage.POLY_PRESSURE:
+                  case ShortMessage.CONTROL_CHANGE:
+                  case ShortMessage.PITCH_BEND:
+                  case ShortMessage.SONG_POSITION_POINTER:
+                    sm = new ShortMessage();
+                    sm.setMessage(sbyte, din.readByte(), din.readByte());
+                    runningStatus = sbyte;
+                    break;
+
+                  case ShortMessage.PROGRAM_CHANGE:
+                  case ShortMessage.CHANNEL_PRESSURE:
+                  case ShortMessage.SONG_SELECT:
+                  case 0xF5: // FIXME: unofficial bus select. Not in spec??
+                    sm = new ShortMessage();
+                    sm.setMessage(sbyte, din.readByte(), 0);
+                    runningStatus = sbyte;
+                    break;
+
+                  case ShortMessage.TUNE_REQUEST:
+                  case ShortMessage.END_OF_EXCLUSIVE:
+                  case ShortMessage.TIMING_CLOCK:
+                  case ShortMessage.START:
+                  case ShortMessage.CONTINUE:
+                  case ShortMessage.STOP:
+                  case ShortMessage.ACTIVE_SENSING:
+                  case ShortMessage.SYSTEM_RESET:
+                    sm = new ShortMessage();
+                    sm.setMessage(sbyte, 0, 0);
+                    runningStatus = sbyte;
+                    break;
+
+                  default:
+                    if (runningStatus != - 1)
+                      {
+                        switch (runningStatus & 0xf0)
+                          {
+                          case ShortMessage.NOTE_OFF:
+                          case ShortMessage.NOTE_ON:
+                          case ShortMessage.POLY_PRESSURE:
+                          case ShortMessage.CONTROL_CHANGE:
+                          case ShortMessage.PITCH_BEND:
+                          case ShortMessage.SONG_POSITION_POINTER:
+                            sm = new ShortMessage();
+                            sm.setMessage(runningStatus, sbyte, din.readByte());
+                            break;
+
+                          case ShortMessage.PROGRAM_CHANGE:
+                          case ShortMessage.CHANNEL_PRESSURE:
+                          case ShortMessage.SONG_SELECT:
+                          case 0xF5: // FIXME: unofficial bus select. Not in
+			             // spec??
+                            sm = new ShortMessage();
+                            sm.setMessage(runningStatus, sbyte, 0);
+                            continue;
+
+                          case ShortMessage.TUNE_REQUEST:
+                          case ShortMessage.END_OF_EXCLUSIVE:
+                          case ShortMessage.TIMING_CLOCK:
+                          case ShortMessage.START:
+                          case ShortMessage.CONTINUE:
+                          case ShortMessage.STOP:
+                          case ShortMessage.ACTIVE_SENSING:
+                          case ShortMessage.SYSTEM_RESET:
+                            sm = new ShortMessage();
+                            sm.setMessage(runningStatus, 0, 0);
+                            continue;
+
+                          default:
+                            throw new 
+			      InvalidMidiDataException("Invalid Short MIDI Event: "
+						       + sbyte);
+                          }
+                      }
+                    else
+                      throw new 
+			InvalidMidiDataException("Invalid Short MIDI Event: "
+						 + sbyte);
+                  }
+                mm = sm;
+              }
+            else if (sbyte == 0xf0 || sbyte == 0xf7)
+              {
+                // System Exclusive event
+                int slen = din.readVariableLengthInt();
+                byte sysex[] = new byte[slen];
+                din.readFully(sysex);
+                SysexMessage sm = new SysexMessage();
+                sm.setMessage(sbyte, sysex, slen);
+                mm = sm;
+                runningStatus = - 1;
+              }
+            else if (sbyte == 0xff)
+              {
+                // Meta Message
+                byte mtype = din.readByte();
+                int mlen = din.readVariableLengthInt();
+                byte meta[] = new byte[mlen];
+                din.readFully(meta);
+                MetaMessage metam = new MetaMessage();
+                metam.setMessage(mtype, meta, mlen);
+                mm = metam;
+
+                if (mtype == 0x2f) // End of Track
+                  done = true;
+
+                runningStatus = - 1;
+              }
+            else
+              {
+                throw new InvalidMidiDataException("Invalid status byte: "
+                                                   + sbyte);
+              }
+
+            track.add(new MidiEvent(mm, click));
+          }
+      }
+
+    return seq;
+  }
+
+  /* Get the MIDI Sequence found at the given URL.
+   * @see javax.sound.midi.spi.MidiFileReader#getSequence(java.net.URL)
+   */
+  public Sequence getSequence(URL url) throws InvalidMidiDataException,
+    IOException 
+  {
+    InputStream is = url.openStream();
+    try
+      {
+	return getSequence(is);
+      }
+    finally
+      {
+	is.close();
+      }
+  }
+
+  /* Get the MIDI Sequence found in the given file.
+   * @see javax.sound.midi.spi.MidiFileReader#getSequence(java.io.File)
+   */
+  public Sequence getSequence(File file) throws InvalidMidiDataException,
+    IOException 
+  {
+    InputStream is = new FileInputStream(file);
+    try
+      {
+	return getSequence(is);
+      }
+    finally
+      {
+	is.close();
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,199 @@
+/* MidiFileWriter.java -- Write MIDI files.
+   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 gnu.javax.sound.midi.file;
+
+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 javax.sound.midi.MetaMessage;
+import javax.sound.midi.MidiEvent;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.Track;
+
+/**
+ * A MIDI file writer.
+ * 
+ * This code writes MIDI file types 0 and 1.  
+ *
+ * There are many decent documents on the web describing the MIDI file
+ * format.  I didn't bother looking for the official document.  If it
+ * exists, I'm not even sure if it is freely available.  We should
+ * update this comment if we find out anything helpful here.
+ *
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class MidiFileWriter
+    extends javax.sound.midi.spi.MidiFileWriter
+{
+  /* Return an array indicating which midi file types are supported.
+   * @see javax.sound.midi.spi.MidiFileWriter#getMidiFileTypes()
+   */
+  public int[] getMidiFileTypes()
+  {
+    return new int[]{0, 1};
+  }
+
+  /* Return an array indicating which midi file types are supported
+   * for a given Sequence.
+   * @see javax.sound.midi.spi.MidiFileWriter#getMidiFileTypes(javax.sound.midi.Sequence)
+   */
+  public int[] getMidiFileTypes(Sequence sequence)
+  {
+    if (sequence.getTracks().length == 1)
+      return new int[]{0};
+    else
+      return new int[]{1};
+  }
+
+  /* Write a sequence to an output stream in standard midi format.
+   * @see javax.sound.midi.spi.MidiFileWriter#write(javax.sound.midi.Sequence, int, java.io.OutputStream)
+   */
+  public int write(Sequence in, int fileType, OutputStream out)
+      throws IOException
+  {
+    MidiDataOutputStream dos = new MidiDataOutputStream (out);
+    Track[] tracks = in.getTracks();
+    dos.writeInt(0x4d546864); // MThd
+    dos.writeInt(6);  
+    dos.writeShort(fileType);
+    dos.writeShort(tracks.length);
+    float divisionType = in.getDivisionType();
+    int resolution = in.getResolution();
+    // FIXME: division computation is incomplete.
+    int division = 0;
+    if (divisionType == Sequence.PPQ)
+      division = resolution & 0x7fff;
+    dos.writeShort(division); 
+    int length = 14;
+    for (int i = 0; i < tracks.length; i++)
+      length += writeTrack(tracks[i], dos);
+    return length;
+  }
+
+  /**
+   * Compute the length of a track as it will be written to the
+   * output stream.
+   *
+   * @param track the track to measure
+   * @param dos a MidiDataOutputStream used for helper method
+   * @return the length of the track
+   */
+  private int computeTrackLength(Track track, MidiDataOutputStream dos)
+  {
+    int count = 0, length = 0, i = 0, eventCount = track.size();
+    long ptick = 0;
+    while (i < eventCount)
+      {
+	MidiEvent me = track.get(i);
+	long tick = me.getTick();
+	length += dos.variableLengthIntLength((int) (tick - ptick));
+	ptick = tick;
+	length += me.getMessage().getLength();
+	i++;
+      } 
+    return length;
+  }
+
+  /**
+   * Write a track to an output stream.
+   *
+   * @param track the track to write
+   * @param dos a MidiDataOutputStream to write to
+   * @return the number of bytes written
+   */
+  private int writeTrack(Track track, MidiDataOutputStream dos)
+    throws IOException
+  {
+    int i = 0, elength = track.size(), trackLength;
+    MidiEvent pme = null;
+    dos.writeInt(0x4d54726b); // "MTrk"
+    trackLength = computeTrackLength(track, dos);
+    dos.writeInt(trackLength);
+    while (i < elength)
+      {
+	MidiEvent me = track.get(i);
+	int dtime = 0;
+	if (pme != null)
+	  dtime = (int) (me.getTick() - pme.getTick());
+	dos.writeVariableLengthInt(dtime); 
+	// FIXME: use running status byte
+	byte msg[] = me.getMessage().getMessage();
+	dos.write(msg);
+	pme = me;
+	i++;
+      } 
+
+    // We're done if the last event was an End of Track meta message.
+    if (pme != null && (pme.getMessage() instanceof MetaMessage))
+      {
+	MetaMessage mm = (MetaMessage) pme.getMessage();
+	if (mm.getType() == 0x2f) // End of Track message
+	  return trackLength + 8;
+      }
+
+    // Write End of Track meta message
+    dos.writeVariableLengthInt(0); // Delta time of 0
+    dos.writeByte(0xff); // Meta Message
+    dos.writeByte(0x2f); // End of Track message
+    dos.writeVariableLengthInt(0); // Length of 0
+
+    return trackLength + 8 + 4;
+  }
+
+  /* Write a Sequence to a file.
+   * @see javax.sound.midi.spi.MidiFileWriter#write(javax.sound.midi.Sequence, int, java.io.File)
+   */
+  public int write(Sequence in, int fileType, File out) throws IOException
+  {
+    OutputStream os = new FileOutputStream(out);
+    try
+      {
+	return write(in, fileType, os);
+      }
+    finally
+      {
+	os.close();
+      } 
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,212 @@
+/* AUReader.java -- Read AU files.
+   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 gnu.javax.sound.sampled.AU;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.sound.sampled.spi.AudioFileReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.nio.ByteBuffer;
+
+public class AUReader extends AudioFileReader
+{
+  private static class AUHeader
+  {
+    // Magic number identifying the file. '.snd' 
+    private static final int MAGIC = 0x2e736e64;
+    
+    public static final int SIZE = 24; // size of the header
+    
+    // Encoding types
+    public static final int ULAW = 1; // 8-bit u-law
+    public static final int PCM8 = 2; // 8-bit PCM
+    public static final int PCM16 = 3; // 16-bit PCM
+    public static final int PCM24 = 4; // 24-bit PCM
+    public static final int PCM32 = 5; // 32-bit PCM
+    public static final int IEEE32 = 6; // 32-bit IEEE f.p.
+    public static final int IEEE64 = 7; // 64-bit IEEE f.p.
+    public static final int G721 = 23; 
+    public static final int G722 = 24; 
+    public static final int G723 = 25; 
+    public static final int G723_5BIT = 26; 
+    public static final int ALAW = 27; // 8-bit a-law
+
+    // Header data.
+    public int headerSize;
+    public int fileSize; // this value may not be set.
+    public int encoding;
+    public int sampleRate;
+    public int channels;
+    public int sampleSizeInBits;
+
+    public AUHeader(InputStream stream)
+      throws IOException, UnsupportedAudioFileException
+    {
+      byte[] hdr = new byte[24];
+      stream.read( hdr );
+      ByteBuffer buf = ByteBuffer.wrap(hdr);
+
+      if( buf.getInt() != MAGIC )
+	throw new UnsupportedAudioFileException("Not an AU format audio file.");
+      headerSize = buf.getInt(); 
+      fileSize = buf.getInt(); 
+      encoding = buf.getInt(); 
+      sampleRate = buf.getInt();
+      channels = buf.getInt(); 
+
+      switch(encoding)
+	{
+	case ULAW: 
+	case PCM8: 
+	case ALAW: 
+	  sampleSizeInBits = 8;
+	  break;
+	case PCM16:
+	  sampleSizeInBits = 16;
+	  break;
+	case PCM24:
+	  sampleSizeInBits = 24;
+	  break;
+	case PCM32:
+	  sampleSizeInBits = 32;
+	  break;
+	default:   // other types exist but are not supported. Yet.
+	  throw new UnsupportedAudioFileException("Unsupported encoding.");
+	}
+    }
+
+  public AudioFormat getAudioFormat()
+    {
+      AudioFormat.Encoding encType = AudioFormat.Encoding.PCM_SIGNED;
+      if(encoding == 1)
+	encType = AudioFormat.Encoding.ULAW;
+      if(encoding == 27)
+	encType = AudioFormat.Encoding.ALAW;
+      
+      return new AudioFormat(encType, 
+			     (float)sampleRate, 
+			     sampleSizeInBits, 
+			     channels, 
+			     (sampleSizeInBits >> 3) * channels, 
+			     (float)sampleRate, 
+			     true);
+    }
+
+  public AudioFileFormat getAudioFileFormat()
+    {
+      return new AudioFileFormat(new AUFormatType(), 
+				 getAudioFormat(), 
+				 AudioSystem.NOT_SPECIFIED);
+    }
+  }
+
+  public static class AUFormatType extends AudioFileFormat.Type
+  {
+    public AUFormatType()
+    {
+      super("AU", ".au");
+    }
+  }
+
+  public AudioFileFormat getAudioFileFormat(File file)
+    throws IOException, UnsupportedAudioFileException
+  {
+    return getAudioFileFormat(new FileInputStream(file));
+  }
+
+  public AudioFileFormat getAudioFileFormat(InputStream stream)
+    throws IOException, UnsupportedAudioFileException
+  {
+    if(!stream.markSupported()) 
+      throw new IOException("Stream must support marking.");    
+
+    stream.mark(25);
+    AUHeader header = new AUHeader(stream);
+    stream.reset();
+
+    return header.getAudioFileFormat();
+  }
+  
+  public AudioFileFormat getAudioFileFormat(URL url)
+    throws IOException, UnsupportedAudioFileException
+  {        
+    return getAudioFileFormat(new BufferedInputStream(url.openStream()));
+  }
+
+  public AudioInputStream getAudioInputStream(File file)
+    throws IOException, UnsupportedAudioFileException
+  {
+    InputStream stream = new FileInputStream(file);
+    long length = file.length();
+
+    AUHeader header = new AUHeader( stream );
+    if( header.headerSize > AUHeader.SIZE )
+      stream.skip(header.headerSize - AUHeader.SIZE);
+
+    length -= header.headerSize;
+
+    return new AudioInputStream(stream, header.getAudioFormat(), length);
+  }
+
+  public AudioInputStream getAudioInputStream(InputStream stream)
+    throws IOException, UnsupportedAudioFileException
+  {
+    AUHeader header = new AUHeader( stream );
+    if( header.headerSize > AUHeader.SIZE )
+      stream.skip(header.headerSize - AUHeader.SIZE);
+
+    return new AudioInputStream(stream, header.getAudioFormat(), 
+				AudioSystem.NOT_SPECIFIED);
+  }
+
+  public AudioInputStream getAudioInputStream(URL url)
+    throws IOException, UnsupportedAudioFileException
+  {
+    return getAudioInputStream(new BufferedInputStream(url.openStream()));
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,236 @@
+/* WAVReader.java -- Read WAV files.
+   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 gnu.javax.sound.sampled.WAV;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.net.URL;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.sound.sampled.spi.AudioFileReader;
+
+/**
+ * A WAV file reader.
+ * 
+ * This code reads WAV files.
+ *
+ * There are many decent documents on the web describing the WAV file
+ * format.  I didn't bother looking for the official document.  If it
+ * exists, I'm not even sure if it is freely available.  We should
+ * update this comment if we find out anything helpful here.  I used
+ * http://www.sonicspot.com/guide/wavefiles.html
+ *
+ * @author Anthony Green (green at redhat.com)
+ *
+ */
+public class WAVReader extends AudioFileReader
+{
+  private static long readUnsignedIntLE (DataInputStream is) 
+    throws IOException
+  {
+    byte[] buf = new byte[4];
+    is.readFully(buf);
+    return (buf[0] & 0xFF 
+	    | ((buf[1] & 0xFF) << 8)
+	    | ((buf[2] & 0xFF) << 16)
+	    | ((buf[3] & 0xFF) << 24));
+  }
+
+  private static short readUnsignedShortLE (DataInputStream is) 
+    throws IOException
+  {
+    byte[] buf = new byte[2];
+    is.readFully(buf);
+    return (short) (buf[0] & 0xFF 
+		    | ((buf[1] & 0xFF) << 8));
+  }
+
+  /* Get an AudioFileFormat from the given File.
+   * @see javax.sound.sampled.spi.AudioFileReader#getAudioFileFormat(java.io.File)
+   */
+  public AudioFileFormat getAudioFileFormat(File file)
+      throws UnsupportedAudioFileException, IOException
+  {
+    InputStream is = new FileInputStream(file);
+    try
+      {
+        return getAudioFileFormat(is);
+      }
+    finally
+      {
+        is.close();
+      }
+  }
+
+  /* Get an AudioFileFormat from the given InputStream.
+   * @see javax.sound.sampled.spi.AudioFileReader#getAudioFileFormat(java.io.InputStream)
+   */
+  public AudioFileFormat getAudioFileFormat(InputStream in)
+      throws UnsupportedAudioFileException, IOException
+  {
+    DataInputStream din;
+
+    if (in instanceof DataInputStream)
+      din = (DataInputStream) in;
+    else
+      din = new DataInputStream(in);
+    
+    if (din.readInt() != 0x52494646) // "RIFF"
+      throw new UnsupportedAudioFileException("Invalid WAV chunk header.");
+
+    // Read the length of this RIFF thing.
+    readUnsignedIntLE(din);
+
+    if (din.readInt() != 0x57415645) // "WAVE"
+      throw new UnsupportedAudioFileException("Invalid WAV chunk header.");
+
+    boolean foundFmt = false;
+    boolean foundData = false;
+
+    short compressionCode = 0, numberChannels = 0, blockAlign = 0, bitsPerSample = 0;
+    long sampleRate = 0, bytesPerSecond = 0;
+    long chunkLength = 0;
+
+    while (! foundData)
+      {
+	int chunkId = din.readInt();
+	chunkLength = readUnsignedIntLE(din);
+	switch (chunkId)
+	  {
+	  case 0x666D7420: // "fmt "
+	    foundFmt = true;
+	    compressionCode = readUnsignedShortLE(din);
+	    numberChannels = readUnsignedShortLE(din);
+	    sampleRate = readUnsignedIntLE(din);
+	    bytesPerSecond = readUnsignedIntLE(din);
+	    blockAlign = readUnsignedShortLE(din);
+	    bitsPerSample = readUnsignedShortLE(din);
+	    din.skip(chunkLength - 16);
+	    break;
+	  case 0x66616374: // "fact"
+	    // FIXME: hold compression format dependent data.
+	    din.skip(chunkLength);
+	    break;
+	  case 0x64617461: // "data"
+	    if (! foundFmt)
+	      throw new UnsupportedAudioFileException("This implementation requires WAV fmt chunks precede data chunks.");
+	    foundData = true;
+	    break;
+	  default:
+	    // Unrecognized chunk.  Skip it.
+	    din.skip(chunkLength);
+	  }
+      }
+
+    AudioFormat.Encoding encoding;
+
+    switch (compressionCode)
+      {
+      case 1: // PCM/uncompressed
+	if (bitsPerSample <= 8)
+	  encoding = AudioFormat.Encoding.PCM_UNSIGNED;
+	else
+	  encoding = AudioFormat.Encoding.PCM_SIGNED;
+	break;
+
+      default:
+	throw new UnsupportedAudioFileException("Unrecognized WAV compression code: 0x" 
+						+ Integer.toHexString(compressionCode));
+      }
+
+    return new AudioFileFormat (AudioFileFormat.Type.WAVE,
+				new AudioFormat(encoding,
+						(float) sampleRate, 
+						bitsPerSample,
+						numberChannels, 
+						((bitsPerSample + 7) / 8) * numberChannels,
+						(float) bytesPerSecond, false),
+				(int) chunkLength);
+  }
+
+  /* Get an AudioFileFormat from the given URL.
+   * @see javax.sound.sampled.spi.AudioFileReader#getAudioFileFormat(java.net.URL)
+   */
+  public AudioFileFormat getAudioFileFormat(URL url)
+      throws UnsupportedAudioFileException, IOException
+  {
+    InputStream is = url.openStream();
+    try
+      {
+        return getAudioFileFormat(is);
+      }
+    finally
+      {
+        is.close();
+      }
+  }
+
+  /* Get an AudioInputStream from the given File.
+   * @see javax.sound.sampled.spi.AudioFileReader#getAudioInputStream(java.io.File)
+   */
+  public AudioInputStream getAudioInputStream(File file)
+      throws UnsupportedAudioFileException, IOException
+  {
+    return getAudioInputStream(new FileInputStream(file));
+  }
+
+  /* Get an AudioInputStream from the given InputStream.
+   * @see javax.sound.sampled.spi.AudioFileReader#getAudioInputStream(java.io.InputStream)
+   */
+  public AudioInputStream getAudioInputStream(InputStream stream)
+      throws UnsupportedAudioFileException, IOException
+  {
+    AudioFileFormat aff = getAudioFileFormat(stream);
+    return new AudioInputStream(stream, aff.getFormat(), (long) aff.getFrameLength());
+  }
+
+  /* Get an AudioInputStream from the given URL.
+   * @see javax.sound.sampled.spi.AudioFileReader#getAudioInputStream(java.net.URL)
+   */
+  public AudioInputStream getAudioInputStream(URL url)
+      throws UnsupportedAudioFileException, IOException
+  {
+    return getAudioInputStream(url.openStream());
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,266 @@
+/* GNULookAndFeel.java -- An example of using the javax.swing UI.
+   Copyright (C) 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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.
+*/
+
+package gnu.javax.swing.plaf.gnu;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JCheckBox;
+import javax.swing.JRadioButton;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.IconUIResource;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+public class GNULookAndFeel extends BasicLookAndFeel
+{
+
+  static Color blueGray = new Color(0xdc, 0xda, 0xd5);
+
+  public boolean isNativeLookAndFeel()    { return true; }
+  public boolean isSupportedLookAndFeel() { return true; }
+  public String getDescription()          { return "GNU Look and Feel"; }
+  public String getID()                   { return "GNULookAndFeel"; }
+  public String getName()                 { return "GNU"; }
+
+  static UIDefaults LAF_defaults;
+
+  private final static String iconspath = "/gnu/javax/swing/plaf/gtk/icons/";
+
+  public UIDefaults getDefaults()
+  {
+    if (LAF_defaults == null)
+      {
+        LAF_defaults = super.getDefaults();
+        Object[] myDefaults = new Object[] {
+          "Button.background", new ColorUIResource(blueGray),
+          "CheckBox.background", new ColorUIResource(blueGray),
+          "CheckBoxMenuItem.background", new ColorUIResource(blueGray),
+          "ToolBar.background", new ColorUIResource(blueGray),
+          "Panel.background", new ColorUIResource(blueGray),
+          "Slider.background", new ColorUIResource(blueGray),
+          "OptionPane.background", new ColorUIResource(blueGray),
+          "ProgressBar.background", new ColorUIResource(blueGray),
+          "TabbedPane.background", new ColorUIResource(blueGray),
+          "Label.background", new ColorUIResource(blueGray),
+          "Menu.background", new ColorUIResource(blueGray),
+          "MenuBar.background", new ColorUIResource(blueGray),
+          "MenuItem.background", new ColorUIResource(blueGray),
+          "ScrollBar.background", new ColorUIResource(blueGray),
+          "CheckBox.icon", new CheckBoxIcon(),
+          "RadioButton.icon", new RadioButtonIcon(),
+          "Tree.hash", new ColorUIResource(Color.black),
+	  
+	"Tree.closedIcon",
+	  new IconUIResource(new ImageIcon
+			     (getClass().getResource
+			      (iconspath + "TreeClosed.png"))),
+	  "Tree.leafIcon",
+	  new IconUIResource(new ImageIcon
+			     (getClass().getResource
+			      (iconspath + "TreeLeaf.png"))),
+	  "Tree.openIcon",
+	  new IconUIResource(new ImageIcon
+			     (getClass().getResource
+			      (iconspath + "TreeOpen.png"))),
+        };
+        LAF_defaults.putDefaults(myDefaults);
+      }
+    return LAF_defaults;
+  }
+  
+  /**
+   * The icon used for CheckBoxes in the BasicLookAndFeel. This is an empty
+   * icon with a size of 13x13 pixels.
+   */
+  static class CheckBoxIcon
+    implements Icon
+  {
+    /**
+     * Returns the height of the icon. The BasicLookAndFeel CheckBox icon
+     * has a height of 13 pixels.
+     *
+     * @return the height of the icon
+     */
+    public int getIconHeight()
+    {
+      return 13;
+    }
+
+    /**
+     * Returns the width of the icon. The BasicLookAndFeel CheckBox icon
+     * has a width of 13 pixels.
+     *
+     * @return the height of the icon
+     */
+    public int getIconWidth()
+    {
+      return 13;
+    }
+
+    /**
+     * Paints the icon. The BasicLookAndFeel CheckBox icon is empty and does
+     * not need to be painted.
+     *
+     * @param c the component to be painted
+     * @param g the Graphics context to be painted with
+     * @param x the x position of the icon
+     * @param y the y position of the icon
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      Color save = g.getColor();
+      g.setColor(c.getForeground());
+      g.drawRect(x, y, getIconWidth(), getIconHeight());    
+      
+      JCheckBox item = (JCheckBox) c;
+      if (item.isSelected()) 
+        {
+          g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
+          g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
+          g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
+          g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
+        }
+      
+      g.setColor(save);
+    }
+  }
+  
+  /**
+   * The icon used for RadioButtons in the GNULookAndFeel. This is an empty
+   * icon with a size of 13x13 pixels.
+   */
+  static class RadioButtonIcon
+    implements Icon
+  {
+    /**
+     * Returns the height of the icon. The GNULookAndFeel RadioButton icon
+     * has a height of 13 pixels.
+     *
+     * @return the height of the icon
+     */
+    public int getIconHeight()
+    {
+      return 13;
+    }
+
+    /**
+     * Returns the width of the icon. The GNULookAndFeel RadioButton icon
+     * has a width of 13 pixels.
+     *
+     * @return the height of the icon
+     */
+    public int getIconWidth()
+    {
+      return 13;
+    }
+
+    /**
+     * Paints the icon. The GNULookAndFeel RadioButton icon is empty and does
+     * not need to be painted.
+     *
+     * @param c the component to be painted
+     * @param g the Graphics context to be painted with
+     * @param x the x position of the icon
+     * @param y the y position of the icon
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      Color savedColor = g.getColor();
+      JRadioButton b = (JRadioButton) c;
+      
+      // draw outer circle
+      if (b.isEnabled())
+        g.setColor(Color.GRAY);
+      else
+        g.setColor(Color.GRAY);
+      g.drawLine(x + 2, y + 1, x + 3, y + 1);
+      g.drawLine(x + 4, y, x + 7, y);
+      g.drawLine(x + 8, y + 1, x + 9, y + 1);
+      g.drawLine(x + 10, y + 2, x + 10, y + 3);
+      g.drawLine(x + 11, y + 4, x + 11, y + 7);
+      g.drawLine(x + 10, y + 8, x + 10, y + 9);
+      g.drawLine(x + 8, y + 10, x + 9, y + 10);
+      g.drawLine(x + 4, y + 11, x + 7, y + 11);
+      g.drawLine(x + 2, y + 10, x + 3, y + 10);
+      g.drawLine(x + 1, y + 9, x + 1, y + 8);
+      g.drawLine(x, y + 7, x, y + 4);
+      g.drawLine(x + 1, y + 2, x + 1, y + 3);
+
+      if (b.getModel().isArmed())
+        {
+          g.setColor(Color.GRAY);
+          g.drawLine(x + 4, y + 1, x + 7, y + 1);
+          g.drawLine(x + 4, y + 10, x + 7, y + 10);
+          g.drawLine(x + 1, y + 4, x + 1, y + 7);
+          g.drawLine(x + 10, y + 4, x + 10, y + 7);
+          g.fillRect(x + 2, y + 2, 8, 8);
+        }
+      else 
+        {
+          // only draw inner highlight if not filled
+          if (b.isEnabled())
+            {
+              g.setColor(Color.WHITE);
+          
+              g.drawLine(x + 2, y + 8, x + 2, y + 9);
+              g.drawLine(x + 1, y + 4, x + 1, y + 7);
+              g.drawLine(x + 2, y + 2, x + 2, y + 3);
+              g.drawLine(x + 3, y + 2, x + 3, y + 2);
+              g.drawLine(x + 4, y + 1, x + 7, y + 1);
+              g.drawLine(x + 8, y + 2, x + 9, y + 2);
+            }
+        }
+
+      // draw outer highlight
+      if (b.isEnabled())
+        {
+          g.setColor(Color.WHITE);
+          
+          // outer
+          g.drawLine(x + 10, y + 1, x + 10, y + 1);
+          g.drawLine(x + 11, y + 2, x + 11, y + 3);
+          g.drawLine(x + 12, y + 4, x + 12, y + 7);
+          g.drawLine(x + 11, y + 8, x + 11, y + 9);
+          g.drawLine(x + 10, y + 10, x + 10, y + 10);
+          g.drawLine(x + 8, y + 11, x + 9, y + 11);
+          g.drawLine(x + 4, y + 12, x + 7, y + 12);
+          g.drawLine(x + 2, y + 11, x + 3, y + 11);
+        }
+      
+      if (b.isSelected())
+        {
+          if (b.isEnabled())
+            g.setColor(Color.BLACK);
+          else
+            g.setColor(Color.GRAY);
+          g.drawLine(x + 4, y + 3, x + 7, y + 3);
+          g.fillRect(x + 3, y + 4, 6, 4);
+          g.drawLine(x + 4, y + 8, x + 7, y + 8);
+        }
+      g.setColor(savedColor);
+    }  
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Error.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Error.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Error.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Inform.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Inform.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Inform.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCup.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCup.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCup.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCupLarge.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCupLarge.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCupLarge.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Question.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Question.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Question.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README Thu Nov  8 16:56:19 2007
@@ -0,0 +1,20 @@
+Images required by Basic Look and Feel
+
+Information based on images from Swing 1.1.1b2
+JavaCup.gif - a picture of the steaming cup of Java - 16x16 - 3 colors
+
+TreeOpen.gif - a picture of an open file folder - 16x13 - 8 colors
+TreeClosed.gif - a picture of a closed file folder - 16x13 - 7 colors
+TreeLeaf.gif - a picture of a small circle with points in four 
+		directions - 16x13 - 2 colors
+
+Information on images used by Gtk Look and Feel, really need to work the
+number of colors down I think.
+
+JavaCup.gif - a picture of Classpath's mascot - 16x16 - 58 colors
+
+TreeOpen.gif - taken from Gnome File Manager - 16x12 - 34 colors
+TreeClosed.gif - taken from Gnome File Manager 14x12 - 28 colors
+TreeLeaf.gif - a blank gif - 16x12 - 1 color
+
+Error.gif - think this will be needed later (taken from gnome)

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeClosed.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeClosed.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeClosed.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf-normal.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf-normal.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf-normal.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeOpen.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeOpen.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeOpen.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Warn.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Warn.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Warn.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/file-folders.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/file-folders.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/file-folders.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png?rev=43913&view=auto

==============================================================================
Binary file - no diff available.

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png

------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,218 @@
+/* CustomizableTheme.java -- A customizable metal theme
+   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 gnu.javax.swing.plaf.metal;
+
+import java.awt.Color;
+
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+
+/**
+ * A Metal theme that can be customized by setting the primary and secondary
+ * colors.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+public class CustomizableTheme
+    extends DefaultMetalTheme
+    implements Cloneable
+{
+
+  /**
+   * The primary1 color.
+   */
+  private ColorUIResource primary1;
+
+  /**
+   * The primary2 color.
+   */
+  private ColorUIResource primary2;
+
+  /**
+   * The primary3 color.
+   */
+  private ColorUIResource primary3;
+
+  /**
+   * The secondary1 color.
+   */
+  private ColorUIResource secondary1;
+
+  /**
+   * The secondary2 color.
+   */
+  private ColorUIResource secondary2;
+
+  /**
+   * The secondary3 color.
+   */
+  private ColorUIResource secondary3;
+
+  /**
+   * Sets the primary1 color of the theme.
+   *
+   * @param c the primary1 color to set
+   */
+  public void setPrimary1(Color c)
+  {
+    primary1 = new ColorUIResource(c);
+  }
+
+  /**
+   * Returns the primary1 color of this theme.
+   *
+   * @return the primary1 color of this theme
+   */
+  public ColorUIResource getPrimary1()
+  {
+    return primary1 == null ? super.getPrimary1() : primary1;
+  }
+
+
+  /**
+   * Sets the primary2 color of the theme.
+   *
+   * @param c the primary2 color to set
+   */
+  public void setPrimary2(Color c)
+  {
+    primary2 = new ColorUIResource(c);
+  }
+
+  /**
+   * Returns the primary2 color of this theme.
+   *
+   * @return the primary2 color of this theme
+   */
+  public ColorUIResource getPrimary2()
+  {
+    return primary2 == null ? super.getPrimary2() : primary2;
+  }
+
+  /**
+   * Sets the primary3 color of the theme.
+   *
+   * @param c the primary3 color to set
+   */
+  public void setPrimary3(Color c)
+  {
+    primary3 = new ColorUIResource(c);
+  }
+
+  /**
+   * Returns the primary3 color of this theme.
+   *
+   * @return the primary3 color of this theme
+   */
+  public ColorUIResource getPrimary3()
+  {
+    return primary3 == null ? super.getPrimary3() : primary3;
+  }
+
+  /**
+   * Sets the secondary1 color of the theme.
+   *
+   * @param c the secondary1 color to set
+   */
+  public void setSecondary1(Color c)
+  {
+    secondary1 = new ColorUIResource(c);
+  }
+
+  /**
+   * Returns the secondary1 color of this theme.
+   *
+   * @return the secondary1 color of this theme
+   */
+  public ColorUIResource getSecondary1()
+  {
+    return secondary1 == null ? super.getSecondary1() : secondary1;
+  }
+
+  /**
+   * Sets the secondary2 color of the theme.
+   *
+   * @param c the secondary2 color to set
+   */
+  public void setSecondary2(Color c)
+  {
+    secondary2 = new ColorUIResource(c);
+  }
+
+  /**
+   * Returns the secondary2 color of this theme.
+   *
+   * @return the secondary2 color of this theme
+   */
+  public ColorUIResource getSecondary2()
+  {
+    return secondary2 == null ? super.getSecondary2() : secondary2;
+  }
+
+  /**
+   * Sets the secondary3 color of the theme.
+   *
+   * @param c the secondary3 color to set
+   */
+  public void setSecondary3(Color c)
+  {
+    secondary3 = new ColorUIResource(c);
+  }
+
+  /**
+   * Returns the secondary3 color of this theme.
+   *
+   * @return the secondary3 color of this theme
+   */
+  public ColorUIResource getSecondary3()
+  {
+    return secondary3 == null ? super.getSecondary3() : secondary3;
+  }
+
+  /**
+   * Returns a clone of this theme.
+   *
+   * @return a clone of this theme
+   */
+  public Object clone()
+    throws CloneNotSupportedException
+  {
+    return super.clone();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,192 @@
+/* CharacterAttributeTranslator.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 gnu.javax.swing.text.html;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.HTML.Attribute;
+import javax.swing.text.html.HTML.Tag;
+
+/**
+ * This is a small utility class to translate HTML character attributes to
+ * Swing StyleConstants
+ */
+public class CharacterAttributeTranslator
+{
+  /**
+   * Maps color name to its hex encoding.
+   */
+  private static final HashMap colorMap = new HashMap();
+  static 
+  {
+    colorMap.put("aqua" , "#00FFFF");
+    colorMap.put("blue" , "#0000FF");
+    colorMap.put("black", "#000000");
+    colorMap.put("fuchsia" , "#FF00FF");
+    colorMap.put("gray" , "#808080");
+    colorMap.put("green" , "#008000");
+    colorMap.put("lime" , "#00FF00");
+    colorMap.put("maroon" , "#800000");
+    colorMap.put("navy" , "#000080");
+    colorMap.put("olive" , "#808000");
+    colorMap.put("purple" , "#800080");
+    colorMap.put("red" , "#FF0000");
+    colorMap.put("silver" , "#C0C0C0");
+    colorMap.put("teal" , "#008080");
+    colorMap.put("white" , "#FFFFFF");
+    colorMap.put("yellow" , "#FFFF00");
+  };
+  
+  /**
+   * Convert the color string represenation into java.awt.Color. The valid
+   * values are like "aqua" , "#00FFFF" or "rgb(1,6,44)".
+   * 
+   * @param colorName the color to convert.
+   * @return the matching java.awt.color
+   */
+  public static Color getColor(String colorName)
+  {
+    colorName = colorName.toLowerCase();
+    try
+      {
+        if (colorName.startsWith("rgb"))
+          {
+            // rgb(red, green, blue) notation.
+            StringTokenizer st = new StringTokenizer(colorName, " ,()");
+            String representation = st.nextToken();
+
+            // Return null if the representation is not supported.
+            if (! representation.equals("rgb"))
+              return null;
+            int red = Integer.parseInt(st.nextToken());
+            int green = Integer.parseInt(st.nextToken());
+            int blue = Integer.parseInt(st.nextToken());
+
+            return new Color(red, green, blue);
+          }
+        else
+          {
+            String s2 = (String) colorMap.get(colorName);
+            if (s2 == null)
+              s2 = colorName;
+            return Color.decode(s2);
+          }
+      }
+    catch (Exception nex)
+      {
+        // Can be either number format exception or illegal argument
+        // exception.
+        return null;
+      }
+  }
+  
+  /**
+   * Translate the HTML character attribute to the Swing style constant.
+   * 
+   * @param charAttr the character attributes of the html tag
+   * @param t the html tag itself
+   * @param a the attribute set where the translated attributes will be stored
+   * 
+   * @return true if some attributes were translated, false otherwise.
+   */
+  public static boolean translateTag(MutableAttributeSet charAttr, 
+				     Tag t, MutableAttributeSet a)
+  {
+    if(t == Tag.FONT)
+      {
+        Object color = a.getAttribute(Attribute.COLOR); 
+	if(color != null)
+	  {
+	    Color c = getColor(color.toString());
+	    if( c == null )
+	      return false;
+	    charAttr.addAttribute(StyleConstants.Foreground, c);
+	    return true;
+	  }
+
+	if(a.getAttribute(Attribute.SIZE) != null)
+	  {
+	    // FIXME
+	    //	    charAttr.addAttribute(StyleConstants.FontSize, 
+	    //				  new java.lang.Integer(72));
+	    return true;
+	  }
+      }
+
+    if( t == Tag.B )
+      {
+	charAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.I )
+      {
+	charAttr.addAttribute(StyleConstants.Italic, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.U )
+      {
+	charAttr.addAttribute(StyleConstants.Underline, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.STRIKE )
+      {
+	charAttr.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.SUP )
+      {
+	charAttr.addAttribute(StyleConstants.Superscript, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.SUB )
+      {
+	charAttr.addAttribute(StyleConstants.Subscript, Boolean.TRUE);
+	return true;
+      }
+    return false;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,213 @@
+/* CombinedAttributes.java -- A two combined sets of 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 gnu.javax.swing.text.html;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+
+/**
+ * Contains the two combined attribute sets what are searched subsequently.
+ * This is used to combine style sheet attributes with the HTML view attributes.
+ * The parent cannot be used as the view may have its own attribute hierarchy.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)  
+ */
+public class CombinedAttributes implements AttributeSet, Serializable
+{
+  /**
+   * Returns the elements from both enumerations.
+   */
+  class CombinedEnumeration implements Enumeration
+  {
+    /**
+     * Create a combined enumeration that enumerates over two enumerations.
+     * 
+     * @param first the first enumeration to enumerate
+     * @param second the second enumeration to enumerate
+     */
+    CombinedEnumeration(Enumeration first, Enumeration second)
+    {
+      a = first;
+      b = second;
+    }
+    
+    /**
+     * The first enumeration (elements returned first)
+     */
+    final Enumeration a;
+    
+    /**
+     * The second enumeration (elements returned later)
+     */
+    final Enumeration b;
+    
+    /** @inheritDoc */
+    public boolean hasMoreElements()
+    {
+      return a.hasMoreElements() || b.hasMoreElements();
+    }
+    
+    /** @inheritDoc */
+    public Object nextElement()
+    {
+      return a.hasMoreElements() ? a.nextElement():b.nextElement();
+    }
+  }
+  
+  
+  /**
+   * The first attribute set.
+   */
+  final AttributeSet a;
+  
+  /**
+   * The second attribute set.
+   */
+  final AttributeSet b;
+  
+  /**
+   * Create the CombinedAttributes what search in the two sets. If any of the
+   * two passed sets is null, another set is returned. Otherwise, the combined
+   * attribute set is returned.
+   * 
+   * @param primary the first set (searched first)
+   * @param secondary the second set (searched later).
+   */
+  public static AttributeSet combine(AttributeSet primary,
+                                     AttributeSet secondary)
+  {
+    if (primary == null)
+      return secondary;
+    else if (secondary == null)
+      return primary;
+    else
+      return new CombinedAttributes(primary, secondary);
+  }
+  
+  /**
+   * Create the CombinedAttributes what search in the two sets.
+   * 
+   * @param primary the first set (searched first)
+   * @param secondary the second set (searched later).
+   */
+  private CombinedAttributes(AttributeSet primary, AttributeSet secondary)
+  {
+    a = primary;
+    b = secondary;
+  }
+
+  /** @inheritDoc */
+  public boolean containsAttribute(Object name, Object value)
+  {
+    return a.containsAttribute(name, value) || b.containsAttribute(name, value);
+  }
+
+  /** @inheritDoc */
+  public boolean containsAttributes(AttributeSet attributes)
+  {
+    Enumeration names = attributes.getAttributeNames();
+    Object name;
+    while (names.hasMoreElements())
+      {
+        name = names.nextElement();
+        if (!containsAttribute(name, attributes.getAttribute(name)))
+          return false;
+      }
+    return true;
+  }
+
+  /** @inheritDoc */
+  public AttributeSet copyAttributes()
+  {
+    SimpleAttributeSet copy = new SimpleAttributeSet();
+    copy.addAttributes(a);
+    copy.addAttributes(b);
+    return copy;
+  }
+
+  /** @inheritDoc */
+  public Object getAttribute(Object key)
+  {
+    Object value = a.getAttribute(key);
+    if (value == null)
+      value = b.getAttribute(key);
+    
+    return value;
+  }
+
+  /** @inheritDoc */
+  public int getAttributeCount()
+  {
+    return a.getAttributeCount()+b.getAttributeCount();
+  }
+
+  /** @inheritDoc */
+  public Enumeration getAttributeNames()
+  {
+    return new CombinedEnumeration(a.getAttributeNames(), b.getAttributeNames());
+  }
+
+  /**
+   * There is no one.
+   * 
+   * @return null, always.
+   */
+  public AttributeSet getResolveParent()
+  {
+    return null;
+  }
+
+  /** @inheritDoc */
+  public boolean isDefined(Object attrName)
+  {
+    return a.isDefined(attrName) || b.isDefined(attrName);
+  }
+
+  /** @inheritDoc */
+  public boolean isEqual(AttributeSet attr)
+  {
+    if (attr.getAttributeCount() == getAttributeCount())
+      return containsAttributes(attr);
+    else
+      return false;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,282 @@
+package gnu.javax.swing.text.html;
+
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * Creates icons for ImageView. The icons reflect the basic ideas of the Sun's
+ * icons as they would be described in the text (sheet of paper with image and
+ * broken sheet of paper with image). They are not pixel to pixel identical and
+ * contain elements from the metal icon factory.
+ * 
+ * @author Audrius Meskauskas (audriusa at bioinformatics.org)
+ */
+public class ImageViewIconFactory
+{
+  private static Icon noImageIcon;
+
+  private static Icon loadingImageIcon;
+  
+  /**
+   * This icon reflects the general concept (broken sheet of paper with
+   * image), but is currently not pixel to pixel identical with the Sun's 
+   * implementation.
+   */
+  public static class NoImageIcon implements Icon, Serializable
+  {
+    /**
+     * Creates a new icon.
+     */
+    public NoImageIcon()
+    {
+      // Nothing to do here.
+    }
+
+    /**
+     * Returns the width of the icon, in pixels.
+     * 
+     * @return The width of the icon.
+     */
+    public int getIconWidth()
+    {
+      return 38;
+    }
+
+    /**
+     * Returns the height of the icon, in pixels.
+     * 
+     * @return The height of the icon.
+     */
+    public int getIconHeight()
+    {
+      return 38;
+    }
+
+    /**
+     * Paints the icon using colors from the {@link MetalLookAndFeel}.
+     * 
+     * @param c
+     *          the component (ignored).
+     * @param g
+     *          the graphics device.
+     * @param x
+     *          the x-coordinate for the top-left of the icon.
+     * @param y
+     *          the y-coordinate for the top-left of the icon.
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      // frame
+      Color savedColor = g.getColor();
+
+      g.setColor(MetalLookAndFeel.getBlack());
+
+      g.drawLine(x, y, x + 19, y);
+
+      g.drawLine(x, y + 1, x, y + 5);
+      g.drawLine(x, y + 13, x, y + 25);
+
+      g.drawLine(x, y + 25, x + 22, y + 25);
+
+      g.drawLine(x + 22, y + 25, x + 22, y + 21);
+      g.drawLine(x + 22, y + 13, x + 22, y + 6);
+
+      g.drawLine(x + 22, y + 6, x + 19, y);
+
+      g.drawLine(x + 17, y + 2, x + 21, y + 6);
+
+      g.drawLine(x + 18, y + 1, x + 19, y + 1);
+
+      g.setColor(MetalLookAndFeel.getControlShadow());
+
+      g.drawLine(x + 1, y + 1, x + 17, y + 1);
+
+      g.drawLine(x + 1, y + 1, x + 1, y + 5);
+      g.drawLine(x + 1, y + 13, x + 1, y + 24);
+
+      g.drawLine(x + 1, y + 24, x + 21, y + 24);
+
+      g.drawLine(x + 21, y + 24, x + 21, y + 21);
+      g.drawLine(x + 21, y + 13, x + 21, y + 7);
+
+      g.drawLine(x + 18, y + 2, x + 20, y + 4);
+
+      // Breaking line
+
+      // Shadow
+      g.drawLine(x + 1, y + 6, x + 20, y + 13);
+      g.drawLine(x + 1, y + 13, x + 20, y + 20);
+
+      // Edge
+      g.setColor(MetalLookAndFeel.getBlack());
+      g.drawLine(x, y + 6, x + 21, y + 14);
+      g.drawLine(x, y + 12, x + 21, y + 20);
+
+      // Picture
+
+      y += 1;
+      x += 3;
+
+      g.setColor(MetalLookAndFeel.getBlack());
+
+      // roof
+      g.drawLine(x + 4, y + 5, x + 8, y + 1);
+      g.drawLine(x + 8, y + 1, x + 15, y + 8);
+
+      // chimney
+      g.drawLine(x + 11, y + 2, x + 11, y + 4);
+      g.drawLine(x + 12, y + 2, x + 12, y + 5);
+
+      g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+      // roof paint
+      int xx = x + 8;
+      for (int i = 0; i < 4; i++)
+        g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
+      g.fillRect(x + 4, y + 6, 9, 2);
+
+      // base of house
+      g.drawLine(x + 3, y + 14, x + 3, y + 18);
+      g.drawLine(x + 3, y + 18, x + 13, y + 18);
+
+      g.setColor(savedColor);
+    }
+  }
+
+  /**
+   * This icon reflects the general concept (sheet of paper with image), but is
+   * currently not pixel to pixel identical with the Sun's implementation.
+   */
+  public static class LoadingImageIcon implements Icon, Serializable
+  {
+
+    /**
+     * Creates a new icon.
+     */
+    public LoadingImageIcon()
+    {
+      // Nothing to do here.
+    }
+
+    /**
+     * Returns the width of the icon, in pixels.
+     * 
+     * @return The width of the icon.
+     */
+    public int getIconWidth()
+    {
+      return 38;
+    }
+
+    /**
+     * Returns the height of the icon, in pixels.
+     * 
+     * @return The height of the icon.
+     */
+    public int getIconHeight()
+    {
+      return 38;
+    }
+
+    /**
+     * Paints the icon using colors from the {@link MetalLookAndFeel}.
+     * 
+     * @param c
+     *          the component (ignored).
+     * @param g
+     *          the graphics device.
+     * @param x
+     *          the x-coordinate for the top-left of the icon.
+     * @param y
+     *          the y-coordinate for the top-left of the icon.
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      // frame
+      Color savedColor = g.getColor();
+
+      g.setColor(Color.black);
+      g.drawLine(x, y, x + 19, y);
+      g.drawLine(x, y + 1, x, y + 25);
+      g.drawLine(x, y + 25, x + 22, y + 25);
+      g.drawLine(x + 22, y + 25, x + 22, y + 6);
+      g.drawLine(x + 22, y + 6, x + 19, y);
+
+      g.drawLine(x + 17, y + 2, x + 21, y + 6);
+      g.drawLine(x + 18, y + 1, x + 19, y + 1);
+
+      g.setColor(new Color(204, 204, 255));
+
+      g.drawLine(x + 1, y + 1, x + 17, y + 1);
+      g.drawLine(x + 1, y + 1, x + 1, y + 24);
+      g.drawLine(x + 1, y + 24, x + 21, y + 24);
+      g.drawLine(x + 21, y + 24, x + 21, y + 7);
+      g.drawLine(x + 18, y + 2, x + 20, y + 4);
+
+      // Picture (house) 
+
+      y += 3;
+      x += 3;
+
+      g.setColor(MetalLookAndFeel.getBlack());
+
+      // roof
+      g.drawLine(x + 1, y + 8, x + 8, y + 1);
+      g.drawLine(x + 8, y + 1, x + 15, y + 8);
+
+      // base of house
+      g.drawLine(x + 3, y + 6, x + 3, y + 15);
+      g.drawLine(x + 3, y + 15, x + 13, y + 15);
+      g.drawLine(x + 13, y + 6, x + 13, y + 15);
+
+      // door frame
+      g.drawLine(x + 6, y + 9, x + 6, y + 15);
+      g.drawLine(x + 6, y + 9, x + 10, y + 9);
+      g.drawLine(x + 10, y + 9, x + 10, y + 15);
+
+      // chimney
+      g.drawLine(x + 11, y + 2, x + 11, y + 4);
+      g.drawLine(x + 12, y + 2, x + 12, y + 5);
+
+      g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+      // roof paint
+      int xx = x + 8;
+      for (int i = 0; i < 4; i++)
+        g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
+      g.fillRect(x + 4, y + 6, 9, 2);
+
+      // door knob
+      g.drawLine(x + 9, y + 12, x + 9, y + 12);
+
+      // house paint
+      g.setColor(MetalLookAndFeel.getPrimaryControl());
+      g.drawLine(x + 4, y + 8, x + 12, y + 8);
+      g.fillRect(x + 4, y + 9, 2, 6);
+      g.fillRect(x + 11, y + 9, 2, 6);
+
+      g.setColor(savedColor);
+    }
+  }
+
+  public static Icon getNoImageIcon()
+  {
+    if (noImageIcon == null)
+      noImageIcon = new NoImageIcon();
+    return noImageIcon;
+  }
+
+  public static Icon getLoadingImageIcon()
+  {
+    if (loadingImageIcon == null)
+      loadingImageIcon = new LoadingImageIcon();
+    return loadingImageIcon;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.text.html package.
+   Copyright (C) 2002 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.swing.text.html</title></head>
+
+<body>
+<p> Provides supporting classes for web browsers,
+ web robots, web page content analysers, web editors and
+ other applications applications working with Hypertext
+ Markup Language (HTML).
+</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,178 @@
+/* GnuParserDelegator.java -- The parser delegator which uses Swing DTD
+   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 gnu.javax.swing.text.html.parser;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Serializable;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.HTMLEditorKit.ParserCallback;
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.ParserDelegator;
+import javax.swing.text.html.parser.TagElement;
+
+/**
+ * This parser delegator uses the different DTD ({@link HTML_401Swing}).
+ * It is derived from the ParserDelegator for the compatibility reasons.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) 
+ */
+public class GnuParserDelegator extends ParserDelegator implements Serializable
+{
+  class gnuParser
+    extends gnu.javax.swing.text.html.parser.support.Parser
+  {
+    private static final long serialVersionUID = 1;
+
+    gnuParser(DTD d)
+    {
+      super(d);
+    }
+
+    protected final void handleComment(char[] comment)
+    {
+      callBack.handleComment(comment, hTag.where.startPosition);
+    }
+
+    protected final void handleEmptyTag(TagElement tag)
+      throws javax.swing.text.ChangedCharSetException
+    {
+      callBack.handleSimpleTag(tag.getHTMLTag(), getAttributes(),
+                               hTag.where.startPosition
+                              );
+    }
+
+    protected final void handleEndTag(TagElement tag)
+    {
+      callBack.handleEndTag(tag.getHTMLTag(), hTag.where.startPosition);
+    }
+
+    protected final void handleError(int line, String message)
+    {
+      callBack.handleError(message, hTag.where.startPosition);
+    }
+
+    protected final void handleStartTag(TagElement tag)
+    {
+      htmlAttributeSet attributes = gnu.getAttributes();
+
+      if (tag.fictional())
+        attributes.addAttribute(ParserCallback.IMPLIED, Boolean.TRUE);
+
+      callBack.handleStartTag(tag.getHTMLTag(), attributes,
+                              hTag.where.startPosition
+                             );
+    }
+
+    protected final void handleText(char[] text)
+    {
+      callBack.handleText(text, hTag.where.startPosition);
+    }
+
+    DTD getDTD()
+    {
+      // Accessing the inherited gnu.javax.swing.text.html.parser.support.Parser
+      // field. super. is a workaround, required to support JDK1.3's javac.
+      return super.dtd;
+    }
+  }
+
+  /**
+   * Use serialVersionUID for interoperability.
+   */
+  private static final long serialVersionUID = -1276686502624777206L;
+
+  private DTD theDtd; 
+
+  /**
+   * The callback.
+   * This is package-private to avoid an accessor method.
+   */
+  HTMLEditorKit.ParserCallback callBack;
+
+  /**
+   * The reference to the working class of HTML parser that is
+   * actually used to parse the document.
+   * This is package-private to avoid an accessor method.
+   */
+  gnuParser gnu;
+  
+  /**
+   * Create the parser that uses the given DTD to parse the document.
+   * 
+   * @param theDtd the DTD
+   */
+  public GnuParserDelegator(DTD theDtd)
+  {
+    this.theDtd = theDtd;
+    gnu = new gnuParser(theDtd);
+  }
+
+  /**
+   * Parses the HTML document, calling methods of the provided callback. This
+   * method must be multithread - safe.
+   * 
+   * @param reader The reader to read the HTML document from
+   * @param a_callback The callback that is notifyed about the presence of HTML
+   *          elements in the document.
+   * @param ignoreCharSet If thrue, any charset changes during parsing are
+   *          ignored.
+   * @throws java.io.IOException
+   */
+  public void parse(Reader reader,
+                                 HTMLEditorKit.ParserCallback a_callback,
+                                 boolean ignoreCharSet) throws IOException
+  {
+    callBack = a_callback;
+    gnu.parse(reader);
+
+    callBack.handleEndOfLineString(gnu.getEndOfLineSequence());
+    try
+      {
+        callBack.flush();
+      }
+    catch (BadLocationException ex)
+      {
+        // Convert this into the supported type of exception.
+        throw new IOException(ex.getMessage());
+      }
+  }
+}





More information about the llvm-commits mailing list