summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/javax/print
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/javax/print')
-rw-r--r--libjava/classpath/gnu/javax/print/CupsIppOperation.java99
-rw-r--r--libjava/classpath/gnu/javax/print/CupsMediaMapping.java176
-rw-r--r--libjava/classpath/gnu/javax/print/CupsPrintService.java104
-rw-r--r--libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java260
-rw-r--r--libjava/classpath/gnu/javax/print/CupsServer.java288
-rw-r--r--libjava/classpath/gnu/javax/print/PrintAttributeException.java148
-rw-r--r--libjava/classpath/gnu/javax/print/PrintFlavorException.java120
-rw-r--r--libjava/classpath/gnu/javax/print/PrintUriException.java140
-rw-r--r--libjava/classpath/gnu/javax/print/PrinterDialog.java1722
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java471
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java99
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppException.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppPrintService.java924
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppRequest.java875
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppResponse.java787
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java185
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppUtilities.java553
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppValueTag.java170
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java80
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java115
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java59
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java117
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java132
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java190
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java118
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java106
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java263
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java149
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java118
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java122
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java105
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java152
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java114
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java154
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java141
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java119
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java150
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java95
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java111
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java107
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java94
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java161
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java302
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java89
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java122
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java134
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java148
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java116
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java176
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java119
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java231
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java178
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java117
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java169
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java142
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java89
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java137
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java142
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java127
78 files changed, 14514 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/javax/print/CupsIppOperation.java b/libjava/classpath/gnu/javax/print/CupsIppOperation.java
new file mode 100644
index 000000000..96744c1f3
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsIppOperation.java
@@ -0,0 +1,99 @@
+/* CupsIppOperation.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;
+
+
+/**
+ * Operations as provided by CUPS up to version 1.1
+ * <p>
+ * See: CUPS Implementation of IPP, chapter 3.2<br>
+ * http://www.cups.org/doc-1.1/ipp.html
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CupsIppOperation
+{
+
+ /** Get the default destination - since CUPS 1.0 */
+ public static final int CUPS_GET_DEFAULT = 0x4001;
+
+ /** Get all of the available printers - since CUPS 1.0 */
+ public static final int CUPS_GET_PRINTERS = 0x4002;
+
+ /** Add or modify a printer - since CUPS 1.0 */
+ public static final int CUPS_ADD_MODIFY_PRINTER = 0x4003;
+
+ /** Delete a printer - since CUPS 1.0 */
+ public static final int CUPS_DELETE_PRINTER = 0x4004;
+
+ /** Get all of the available printer classes - since CUPS 1.0 */
+ public static final int CUPS_GET_CLASSES = 0x4005;
+
+ /** Add or modify a printer class - since CUPS 1.0 */
+ public static final int CUPS_ADD_MODIFY_CLASS = 0x4006;
+
+ /** Delete a printer class - since CUPS 1.0 */
+ public static final int CUPS_DELETE_CLASS = 0x4007;
+
+ /** Accept jobs on a printer or printer class - since CUPS 1.0 */
+ public static final int CUPS_ACCEPT_JOBS = 0x4008;
+
+ /** Reject jobs on a printer or printer class - since CUPS 1.0 */
+ public static final int CUPS_REJECT_JOBS = 0x4009;
+
+ /** Set the default destination - since CUPS 1.0 */
+ public static final int CUPS_SET_DEFAULT = 0x400A;
+
+ /** Get all of the available PPDs - since CUPS 1.1 */
+ public static final int CUPS_GET_DEVICES = 0x400B;
+
+ /** Get all of the available PPDs - since CUPS 1.1 */
+ public static final int CUPS_GET_PPDS = 0x400C;
+
+ /** Move a job to a different printer - since CUPS 1.1 */
+ public static final int CUPS_MOVE_JOB = 0x400D;
+
+
+ private CupsIppOperation()
+ {
+ // not to be instantiated
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsMediaMapping.java b/libjava/classpath/gnu/javax/print/CupsMediaMapping.java
new file mode 100644
index 000000000..49bd94d6f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsMediaMapping.java
@@ -0,0 +1,176 @@
+/* CupsMediaMapping.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.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.print.attribute.standard.MediaSizeName;
+
+/**
+ * Provides the currently known mappings of the media attribute
+ * values of the CUPS printing system to the IPP standard values.
+ * <p>
+ * The mapping is used to build up print service specific mappings
+ * for use of media attribute translation between Java JPS API and
+ * CUPS.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class CupsMediaMapping
+{
+ // the mapping map
+ private static final HashMap ippByCups = new HashMap();
+
+ /**
+ * Initialize currently known mappings.
+ */
+ static
+ {
+ ippByCups.put("Postcard", MediaSizeName.JAPANESE_POSTCARD);
+ ippByCups.put("Statement", MediaSizeName.INVOICE);
+
+ ippByCups.put("Letter", MediaSizeName.NA_LETTER);
+ ippByCups.put("Executive", MediaSizeName.EXECUTIVE);
+ ippByCups.put("Legal", MediaSizeName.NA_LEGAL);
+
+ ippByCups.put("A0", MediaSizeName.ISO_A0);
+ ippByCups.put("A1", MediaSizeName.ISO_A1);
+ ippByCups.put("A2", MediaSizeName.ISO_A2);
+ ippByCups.put("A3", MediaSizeName.ISO_A3);
+ ippByCups.put("A4", MediaSizeName.ISO_A4);
+ ippByCups.put("A5", MediaSizeName.ISO_A5);
+ ippByCups.put("A6", MediaSizeName.ISO_A6);
+ ippByCups.put("A7", MediaSizeName.ISO_A7);
+ ippByCups.put("A8", MediaSizeName.ISO_A8);
+ ippByCups.put("A9", MediaSizeName.ISO_A9);
+ ippByCups.put("A10", MediaSizeName.ISO_A10);
+
+ ippByCups.put("B0", MediaSizeName.JIS_B0);
+ ippByCups.put("B1", MediaSizeName.JIS_B1);
+ ippByCups.put("B2", MediaSizeName.JIS_B2);
+ ippByCups.put("B3", MediaSizeName.JIS_B3);
+ ippByCups.put("B4", MediaSizeName.JIS_B4);
+ ippByCups.put("B5", MediaSizeName.JIS_B5);
+ ippByCups.put("B6", MediaSizeName.JIS_B6);
+ ippByCups.put("B7", MediaSizeName.JIS_B7);
+ ippByCups.put("B8", MediaSizeName.JIS_B8);
+ ippByCups.put("B9", MediaSizeName.JIS_B9);
+ ippByCups.put("B10", MediaSizeName.JIS_B10);
+
+ ippByCups.put("ISOB0", MediaSizeName.ISO_B0);
+ ippByCups.put("ISOB1", MediaSizeName.ISO_B1);
+ ippByCups.put("ISOB2", MediaSizeName.ISO_B2);
+ ippByCups.put("ISOB3", MediaSizeName.ISO_B3);
+ ippByCups.put("ISOB4", MediaSizeName.ISO_B4);
+ ippByCups.put("ISOB5", MediaSizeName.ISO_B5);
+ ippByCups.put("ISOB6", MediaSizeName.ISO_B6);
+ ippByCups.put("ISOB7", MediaSizeName.ISO_B7);
+ ippByCups.put("ISOB8", MediaSizeName.ISO_B8);
+ ippByCups.put("ISOB9", MediaSizeName.ISO_B9);
+ ippByCups.put("ISOB10", MediaSizeName.ISO_B10);
+ ippByCups.put("EnvISOB0", MediaSizeName.ISO_B0);
+ ippByCups.put("EnvISOB1", MediaSizeName.ISO_B1);
+ ippByCups.put("EnvISOB2", MediaSizeName.ISO_B2);
+ ippByCups.put("EnvISOB3", MediaSizeName.ISO_B3);
+ ippByCups.put("EnvISOB4", MediaSizeName.ISO_B4);
+ ippByCups.put("EnvISOB5", MediaSizeName.ISO_B5);
+ ippByCups.put("EnvISOB6", MediaSizeName.ISO_B6);
+ ippByCups.put("EnvISOB7", MediaSizeName.ISO_B7);
+ ippByCups.put("EnvISOB8", MediaSizeName.ISO_B8);
+ ippByCups.put("EnvISOB9", MediaSizeName.ISO_B9);
+ ippByCups.put("EnvISOB10", MediaSizeName.ISO_B10);
+
+ ippByCups.put("C0", MediaSizeName.ISO_C0);
+ ippByCups.put("C1", MediaSizeName.ISO_C1);
+ ippByCups.put("C2", MediaSizeName.ISO_C2);
+ ippByCups.put("C3", MediaSizeName.ISO_C3);
+ ippByCups.put("C4", MediaSizeName.ISO_C4);
+ ippByCups.put("C5", MediaSizeName.ISO_C5);
+ ippByCups.put("C6", MediaSizeName.ISO_C6);
+
+ ippByCups.put("EnvPersonal", MediaSizeName.PERSONAL_ENVELOPE);
+ ippByCups.put("EnvMonarch", MediaSizeName.MONARCH_ENVELOPE);
+ ippByCups.put("Monarch", MediaSizeName.MONARCH_ENVELOPE);
+ ippByCups.put("Env9", MediaSizeName.NA_NUMBER_9_ENVELOPE);
+ ippByCups.put("Env10", MediaSizeName.NA_NUMBER_10_ENVELOPE);
+ ippByCups.put("Env11", MediaSizeName.NA_NUMBER_11_ENVELOPE);
+ ippByCups.put("Env12", MediaSizeName.NA_NUMBER_12_ENVELOPE);
+ ippByCups.put("Env14", MediaSizeName.NA_NUMBER_14_ENVELOPE);
+ ippByCups.put("c8x10", MediaSizeName.NA_8X10);
+
+ ippByCups.put("EnvDL", MediaSizeName.ISO_DESIGNATED_LONG);
+ ippByCups.put("DL", MediaSizeName.ISO_DESIGNATED_LONG);
+ ippByCups.put("EnvC0", MediaSizeName.ISO_C0);
+ ippByCups.put("EnvC1", MediaSizeName.ISO_C1);
+ ippByCups.put("EnvC2", MediaSizeName.ISO_C2);
+ ippByCups.put("EnvC3", MediaSizeName.ISO_C3);
+ ippByCups.put("EnvC4", MediaSizeName.ISO_C4);
+ ippByCups.put("EnvC5", MediaSizeName.ISO_C5);
+ ippByCups.put("EnvC6", MediaSizeName.ISO_C6);
+ }
+
+ /**
+ * Returns the IPP media name of the given cups name.
+ *
+ * @param cupsName the name in cups
+ * @return The IPP name if a mapping is known, <code>null</code> otherwise.
+ */
+ public static final String getIppName(String cupsName)
+ {
+ return (String) ippByCups.get(cupsName);
+ }
+
+ /**
+ * Returns the mapping map for iteration.
+ *
+ * @return The mapping map as unmodifiable map.
+ */
+ public static final Map getMappingMap()
+ {
+ return Collections.unmodifiableMap(ippByCups);
+ }
+
+ private CupsMediaMapping()
+ {
+ // not to be instantiated
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsPrintService.java b/libjava/classpath/gnu/javax/print/CupsPrintService.java
new file mode 100644
index 000000000..f3bec996c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsPrintService.java
@@ -0,0 +1,104 @@
+/* CupsPrintService.java -- Cups specific implementation subclass
+ 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.IppMultiDocPrintService;
+import gnu.javax.print.ipp.IppResponse;
+
+import java.net.URI;
+
+import javax.print.DocFlavor;
+import javax.print.attribute.AttributeSet;
+
+/**
+ * Implementation of the PrintService/MultiDocPrintService
+ * interface for Cups printers (supports Cups 1.1 and up)
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CupsPrintService extends IppMultiDocPrintService
+{
+
+ /**
+ * Creates a <code>CupsPrintService</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 CupsPrintService(URI uri, String username, String password)
+ throws IppException
+ {
+ super(uri, username, password);
+ }
+
+ /**
+ * Overridden for CUPS specific handling of the media attribute.
+ */
+ protected Object handleSupportedAttributeValuesResponse(IppResponse response,
+ Class category)
+ {
+ // TODO Implement different behaviour of cups here - actually the Media
+ // printing attribute stuff. For now just use IPP reference implementation.
+ return super.handleSupportedAttributeValuesResponse(response, category);
+ }
+
+ /**
+ * Overridden for CUPS specific handling of the media attribute.
+ */
+ public Object getDefaultAttributeValue(Class category)
+ {
+ // TODO Implement media attribute behaviour for cups here
+ //if (category.equals(Media.class)
+
+ return super.getDefaultAttributeValue(category);
+ }
+
+ /**
+ * Overridden as CUPS does not implement Validate-Job correctly.
+ */
+ public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)
+ {
+ // TODO Implement a heuristic unsupported attribute identification.
+ return super.getUnsupportedAttributes(flavor, attributes);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java b/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java
new file mode 100644
index 000000000..d537c398f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java
@@ -0,0 +1,260 @@
+/* CupsPrintServiceLookup.java -- Implementation based on CUPS
+ 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 java.util.ArrayList;
+
+import javax.print.DocFlavor;
+import javax.print.MultiDocPrintService;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+
+/**
+ * The platform default implementation based on CUPS.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class CupsPrintServiceLookup extends PrintServiceLookup
+{
+ private CupsServer server;
+
+ /**
+ * Default constructor checking security access.
+ */
+ public CupsPrintServiceLookup()
+ {
+ // security
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
+ // use the localhost cups server
+ server = new CupsServer(null, null);
+ }
+
+ /**
+ * This is the printer marked as default in CUPS.
+ *
+ * @return The default lookup service or
+ * <code>null</code> if there is no default.
+ */
+ public PrintService getDefaultPrintService()
+ {
+ try
+ {
+ return server.getDefaultPrinter();
+ }
+ catch (IppException e)
+ {
+ // if discovery fails treat as if there is none
+ return null;
+ }
+ }
+
+ /**
+ * All printers and printer classes of the CUPS server are checked.
+ * If flavors or attributes are null the constraint is not used.
+ *
+ * @param flavors the document flavors which have to be supported.
+ * @param attributes the attributes which have to be supported.
+ *
+ * @return The multidoc print services of the implementing lookup service
+ * for the given parameters, or an array of length 0 if none is available.
+ */
+ public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
+ AttributeSet attributes)
+ {
+ ArrayList result = new ArrayList();
+ PrintService[] services = getPrintServices();
+
+ for (int i=0; i < services.length; i++)
+ {
+ if (checkMultiDocPrintService(flavors, attributes, services[i]))
+ result.add(services[i]);
+ }
+
+ return (MultiDocPrintService[]) result.toArray(
+ new MultiDocPrintService[result.size()]);
+ }
+
+ /**
+ * These are all printers and printer classes of the CUPS server.
+ *
+ * @return All known print services regardless of supported features,
+ * or an array of length 0 if none is available.
+ */
+ public PrintService[] getPrintServices()
+ {
+ ArrayList result = new ArrayList();
+
+ try
+ {
+ result.addAll(server.getAllPrinters());
+ result.addAll(server.getAllClasses());
+ }
+ catch (IppException e)
+ {
+ // ignore as this method cannot throw exceptions
+ // if print service discovery fails - bad luck
+ }
+ return (PrintService[]) result.toArray(new PrintService[result.size()]);
+ }
+
+
+ /**
+ * All printers and printer classes of the CUPS server are checked.
+ * If flavor or attributes are null the constraint is not used.
+ *
+ * @param flavor the document flavor which has to be supported.
+ * @param attributes the attributes which have to be supported.
+ *
+ * @return The print services of the implementing lookup service
+ * for the given parameters, or an array of length 0 if none is available.
+ */
+ public PrintService[] getPrintServices(DocFlavor flavor,
+ AttributeSet attributes)
+ {
+ ArrayList result = new ArrayList();
+ PrintService[] services = getPrintServices();
+
+ for (int i=0; i < services.length; i++)
+ {
+ if (checkPrintService(flavor, attributes, services[i]))
+ result.add(services[i]);
+ }
+
+ return (PrintService[]) result.toArray(new PrintService[result.size()]);
+ }
+
+ /**
+ * Checks the given print service - own method so it can be used also
+ * to check application registered print services from PrintServiceLookup.
+ *
+ * @param flavor the document flavor which has to be supported.
+ * @param attributes the attributes which have to be supported.
+ * @param service the service to check
+ *
+ * @return <code>true</code> if all constraints match, <code>false</code>
+ * otherwise.
+ */
+ public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
+ PrintService service)
+ {
+ boolean allAttributesSupported = true;
+ if (flavor == null || service.isDocFlavorSupported(flavor))
+ {
+ if (attributes == null || attributes.size() == 0)
+ return allAttributesSupported;
+
+ Attribute[] atts = attributes.toArray();
+ for (int i = 0; i < atts.length; i++)
+ {
+ if (! service.isAttributeCategorySupported(atts[i].getCategory()))
+ {
+ allAttributesSupported = false;
+ break;
+ }
+ }
+ return allAttributesSupported;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks the given print service - own method so it can be used also
+ * to check application registered print services from PrintServiceLookup.
+ *
+ * @param flavors the document flavors which have to be supported.
+ * @param attributes the attributes which have to be supported.
+ * @param service the service to check
+ *
+ * @return <code>true</code> if all constraints match, <code>false</code>
+ * otherwise.
+ */
+ public boolean checkMultiDocPrintService(DocFlavor[] flavors,
+ AttributeSet attributes, PrintService service)
+ {
+ if (service instanceof MultiDocPrintService)
+ {
+ boolean allFlavorsSupported = true;
+ boolean allAttributesSupported = true;
+
+ if (flavors == null || flavors.length != 0)
+ allFlavorsSupported = true;
+ else
+ {
+ for (int k = 0; k < flavors.length; k++)
+ {
+ if (! service.isDocFlavorSupported(flavors[k]))
+ {
+ allFlavorsSupported = false;
+ break;
+ }
+ }
+ }
+
+ if (attributes == null || attributes.size() == 0)
+ allAttributesSupported = true;
+ else
+ {
+ Attribute[] atts = attributes.toArray();
+ for (int j = 0; j < atts.length; j++)
+ {
+ if (! service.isAttributeCategorySupported(
+ atts[j].getCategory()))
+ {
+ allAttributesSupported = false;
+ break;
+ }
+ }
+ }
+
+ if (allAttributesSupported && allFlavorsSupported)
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsServer.java b/libjava/classpath/gnu/javax/print/CupsServer.java
new file mode 100644
index 000000000..6dbcfc732
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsServer.java
@@ -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@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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/PrintAttributeException.java b/libjava/classpath/gnu/javax/print/PrintAttributeException.java
new file mode 100644
index 000000000..5bcc59fc9
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrintAttributeException.java
@@ -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@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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/PrintFlavorException.java b/libjava/classpath/gnu/javax/print/PrintFlavorException.java
new file mode 100644
index 000000000..a9342db96
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrintFlavorException.java
@@ -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@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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/PrintUriException.java b/libjava/classpath/gnu/javax/print/PrintUriException.java
new file mode 100644
index 000000000..9c13c132a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrintUriException.java
@@ -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@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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/PrinterDialog.java b/libjava/classpath/gnu/javax/print/PrinterDialog.java
new file mode 100644
index 000000000..6557baf4f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrinterDialog.java
@@ -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@gmx.de)
+ */
+public final class PrinterDialog extends JDialog implements ActionListener
+{
+
+ /**
+ * The General Panel used in the printing dialog.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class GeneralPanel extends JPanel
+ {
+ /**
+ * Handles the copies attribute.
+ * @author Wolfgang Baer (WBaer@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@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@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 =
+ getSelectedPrintService().getAttribute(PrinterMakeAndModel.class);
+ typValue.setText(att1 == null ? "" : att1.getValue());
+
+ PrinterInfo att2 =
+ getSelectedPrintService().getAttribute(PrinterInfo.class);
+ infoValue.setText(att2 == null ? "" : att2.getValue());
+
+ PrinterIsAcceptingJobs att3 =
+ getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class);
+ PrinterState att4 =
+ 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@gmx.de)
+ */
+ final class PageSetupPanel extends JPanel
+ {
+ /**
+ * Handles the orientation attribute.
+ * @author Wolfgang Baer (WBaer@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@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@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@gmx.de)
+ */
+ final class AppearancePanel extends JPanel
+ {
+ /**
+ * Handles the print quality attribute.
+ * @author Wolfgang Baer (WBaer@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@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@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@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);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java b/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java
new file mode 100644
index 000000000..8cfd6880d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java
@@ -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@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);
+ }
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java b/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java
new file mode 100644
index 000000000..1c074a8dd
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java
@@ -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@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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppException.java b/libjava/classpath/gnu/javax/print/ipp/IppException.java
new file mode 100644
index 000000000..c34a8f227
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppException.java
@@ -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@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);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java b/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java
new file mode 100644
index 000000000..59c3408d5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java
@@ -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@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);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java b/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java
new file mode 100644
index 000000000..9ce41c774
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java
@@ -0,0 +1,924 @@
+/* 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@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<Class<? extends Attribute>, Set<Attribute>> printerAttr;
+
+ /** The set of listeners.*/
+ private HashSet<PrintServiceAttributeListener> 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<DocFlavor> flavors;
+
+ /** The standard printer URI. */
+ private PrinterURI printerUri;
+
+ /** The list of all supported printer URIs. */
+ private ArrayList<PrinterURI> 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<PrintServiceAttributeListener>();
+
+ 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<Class<? extends Attribute>, Set<Attribute>> 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 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 <T extends Attribute> Set<T> getPrinterAttributeSet(Class<T> attributeClass)
+ {
+ Set<Attribute> set = printerAttr.get(attributeClass);
+ Set<T> attSet = new HashSet<T>();
+ for (Attribute att : set)
+ attSet.add(attributeClass.cast(att));
+ return attSet;
+ }
+
+ /**
+ * 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<? extends Attribute> attributeClass)
+ {
+ Set<Attribute> 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 = 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<DocFlavor>();
+ Set<DocumentFormatSupported> flavorAttributes = getPrinterAttributeSet(DocumentFormatSupported.class);
+ if (flavorAttributes != null)
+ {
+ for (DocumentFormatSupported dfs : flavorAttributes)
+ {
+ String mimeType = dfs.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
+ }
+ }
+
+ if (this.getClass()
+ .isAssignableFrom(gnu.javax.print.CupsPrintService.class))
+ {
+// CUPS always provides filters to convert from Postscript.
+// This logic looks odd, but it's what OpenJDK does.
+ flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
+ flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
+ }
+ }
+
+ // printer uris
+ Set<PrinterUriSupported> uris = getPrinterAttributeSet(PrinterUriSupported.class);
+ printerUris = new ArrayList<PrinterURI>(uris.size());
+ for (PrinterUriSupported uri : uris)
+ {
+ 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 <T extends PrintServiceAttribute> T getAttribute(Class<T> 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<T> set = getPrinterAttributeSet(category);
+ if (set != null && set.size() > 0)
+ return set.iterator().next();
+
+ return null;
+ }
+
+ /**
+ * @see javax.print.PrintService#getAttributes()
+ */
+ public PrintServiceAttributeSet getAttributes()
+ {
+ PrintServiceAttributeSet set = new HashPrintServiceAttributeSet();
+
+ for (Set<Attribute> attrSet : printerAttr.values())
+ {
+ for (Attribute attr : attrSet)
+ {
+ if (attr instanceof PrintServiceAttribute)
+ set.add(attr);
+ }
+ }
+
+ return AttributeSetUtilities.unmodifiableView(set);
+ }
+
+ /**
+ * @see javax.print.PrintService#getDefaultAttributeValue(java.lang.Class)
+ */
+ public Object getDefaultAttributeValue(Class<? extends Attribute> 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<Class<? extends Attribute>> categories =
+ new HashSet<Class<? extends Attribute>>();
+
+ // 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<FinishingsSupported> 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 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<? extends Attribute> 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<? extends Attribute> category)
+ {
+ List<Map<Class<? extends Attribute>, Set<Attribute>>> printerAtts =
+ response.getPrinterAttributes();
+
+ // only one will be returned
+ Map<Class<? extends Attribute>, Set<Attribute>> printerAttribute = printerAtts.get(0);
+ Class<? extends Attribute> suppCategory = IppUtilities.getSupportedCategory(category);
+ Set<Attribute> attr = 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.iterator().next();
+ 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.iterator().next();
+ 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))
+ {
+ if (attr.size() == 1) // number-up maybe in rangeofintegers
+ return attr.iterator().next();
+
+ int[][] members = new int[attr.size()][2];
+ Iterator<Attribute> it = attr.iterator();
+ for (int j = 0; j < attr.size(); j++)
+ {
+ int value = ((NumberUpSupported) it.next()).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 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<Map<Class<? extends Attribute>, Set<Attribute>>> unsupportedMaps =
+ response.getUnsupportedAttributes();
+ if (unsupportedMaps.size() == 0)
+ return null;
+
+ Map<Class<? extends Attribute>, Set<Attribute>> unsupportedAttr = unsupportedMaps.get(0);
+ if (unsupportedAttr.size() == 0)
+ return null;
+
+ // Convert the return map with unsupported attributes
+ // into an AttribueSet instance
+ HashAttributeSet set = new HashAttributeSet();
+ for (Set<Attribute> unsupported : unsupportedAttr.values())
+ {
+ for (Attribute att : unsupported)
+ set.add(att);
+ }
+
+ return set;
+ }
+
+ /**
+ * @see PrintService#isAttributeCategorySupported(Class)
+ */
+ public boolean isAttributeCategorySupported(Class<? extends Attribute> 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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppRequest.java b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
new file mode 100644
index 000000000..ae1f2c409
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
@@ -0,0 +1,875 @@
+/* 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@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@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
+ {
+ String[] values = attribute.getValues();
+
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.KEYWORD);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(values[0].length());
+ out.write(values[0].getBytes());
+
+ for (int i=1; i < values.length; i++)
+ {
+ out.writeByte(IppValueTag.KEYWORD);
+ out.writeShort(0x0000); // length for additional value
+ out.writeShort(values[i].length());
+ out.write(values[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);
+ RequestedAttributes reqAttrs
+ = (RequestedAttributes)attributes.get(RequestedAttributes.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 if (reqAttrs != null)
+ {
+ write(reqAttrs);
+ attributes.remove(RequestedAttributes.class);
+ logger.log(Component.IPP, "RequestedAttributes: <" + reqAttrs + ">");
+ }
+ else
+ {
+ throw 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);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppResponse.java b/libjava/classpath/gnu/javax/print/ipp/IppResponse.java
new file mode 100644
index 000000000..703bdc1eb
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppResponse.java
@@ -0,0 +1,787 @@
+/* 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@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@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<Class<? extends Attribute>, Set<Attribute>> 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<Class<? extends Attribute>, Set<Attribute>>();
+ tag = parseAttributes(tmp, stream);
+ operationAttributes.add(tmp);
+ break;
+ case IppDelimiterTag.JOB_ATTRIBUTES_TAG:
+ tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>();
+ tag = parseAttributes(tmp, stream);
+ jobAttributes.add(tmp);
+ break;
+ case IppDelimiterTag.PRINTER_ATTRIBUTES_TAG:
+ tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>();
+ tag = parseAttributes(tmp, stream);
+ printerAttributes.add(tmp);
+ break;
+ case IppDelimiterTag.UNSUPPORTED_ATTRIBUTES_TAG:
+ System.out.println("Called");
+ tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>();
+ 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<Class<? extends Attribute>, Set<Attribute>> 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:
+ // 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 " + tag);
+ case IppValueTag.NO_VALUE:
+ attribute = null;
+
+ break;
+ 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<Class<? extends Attribute>, Set<Attribute>> attributeGroup,
+ Attribute attribute)
+ {
+ Class<? extends Attribute> clazz = attribute.getCategory();
+ Set<Attribute> attributeValues = attributeGroup.get(clazz);
+
+ if (attributeValues == null) // first attribute of this category
+ {
+ attributeValues = new HashSet<Attribute>();
+ 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<Map<Class<? extends Attribute>, Set<Attribute>>> operationAttributes;
+ List<Map<Class<? extends Attribute>, Set<Attribute>>> printerAttributes;
+ List<Map<Class<? extends Attribute>, Set<Attribute>>> jobAttributes;
+ List<Map<Class<? extends Attribute>, Set<Attribute>>> 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<Map<Class<? extends Attribute>, Set<Attribute>>>();
+ jobAttributes =
+ new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>();
+ printerAttributes =
+ new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>();
+ unsupportedAttributes =
+ new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>();
+ }
+
+ /**
+ * 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 group maps.
+ */
+ public List<Map<Class<? extends Attribute>, Set<Attribute>>> 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 group maps.
+ */
+ public List<Map<Class<? extends Attribute>, Set<Attribute>>> 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 group maps.
+ */
+ public List<Map<Class<? extends Attribute>, Set<Attribute>>> 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 group maps.
+ */
+ public List<Map<Class<? extends Attribute>, Set<Attribute>>> getUnsupportedAttributes()
+ {
+ return unsupportedAttributes;
+ }
+
+ /**
+ * Returns the data of the response.
+ *
+ * @return The data as byte[].
+ */
+ public byte[] getData()
+ {
+ return data;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java b/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java
new file mode 100644
index 000000000..a3b245c43
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java
@@ -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@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
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java b/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java
new file mode 100644
index 000000000..fa987ec3f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java
@@ -0,0 +1,553 @@
+/* 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@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<String,Class<? extends Attribute>> classesByName =
+ new HashMap<String,Class<? extends Attribute>>();
+ // The map -> StandardAttribute class to SupportedAttribute category name
+ private static HashMap<Class<? extends Attribute>,SupportedValuesAttribute> instanceByClass =
+ new HashMap<Class<? extends Attribute>,SupportedValuesAttribute>();
+
+ /**
+ * 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<? extends Attribute> getClass(String name)
+ {
+ return 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<? extends Attribute> clazz)
+ {
+ return 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<? extends Attribute> getSupportedCategory(Class<? extends Attribute> clazz)
+ {
+ return 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] = Integer.valueOf(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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java b/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java
new file mode 100644
index 000000000..def9545a3
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java
@@ -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@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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java b/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java
new file mode 100644
index 000000000..89163dc99
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java
@@ -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@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.");
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java b/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java
new file mode 100644
index 000000000..cd112f459
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java
@@ -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@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();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java
new file mode 100644
index 000000000..cc40db22e
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java
@@ -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 - &gt; Name-default -&gt; Name-supported.
+ *
+ * @author Wolfgang Baer (WBaer@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();
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java
new file mode 100644
index 000000000..2d005a82e
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return DetailedStatusMessage.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "detailed-status-message".
+ */
+ public String getName()
+ {
+ return "detailed-status-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java
new file mode 100644
index 000000000..56b55ba76
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return DocumentAccessError.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-access-error".
+ */
+ public String getName()
+ {
+ return "document-access-error";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java b/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java
new file mode 100644
index 000000000..a648c8cec
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java
@@ -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@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();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java b/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java
new file mode 100644
index 000000000..4c129f6d5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java
@@ -0,0 +1,132 @@
+/* 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 gnu.java.lang.CPStringBuilder;
+
+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@gmx.de)
+ */
+public final class RequestedAttributes implements Attribute
+{
+ private ArrayList<String> 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<String>();
+ 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 String[] getValues()
+ {
+ return attributes.toArray(new String[attributes.size()]);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DocumentFormat</code> itself.
+ */
+ public Class<? extends Attribute> 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()
+ {
+ CPStringBuilder b = new CPStringBuilder();
+
+ 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();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java
new file mode 100644
index 000000000..0701008ef
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return StatusMessage.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "status-message".
+ */
+ public String getName()
+ {
+ return "status-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java b/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java
new file mode 100644
index 000000000..a03beccbe
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java
@@ -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@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<? extends Attribute> 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.";
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java
new file mode 100644
index 000000000..39d8fe1c0
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java
@@ -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@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 &lt; 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<? extends Attribute> 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());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java
new file mode 100644
index 000000000..5eff91498
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java
@@ -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@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<? extends Attribute> 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());
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java
new file mode 100644
index 000000000..9d4a06002
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java
@@ -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@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<? extends Attribute> 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()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java
new file mode 100644
index 000000000..7c29f231c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java
@@ -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@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<? extends Attribute> 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());
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java
new file mode 100644
index 000000000..9430250ae
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java
@@ -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@gmx.de)
+ */
+public final class JobPriorityDefault extends IntegerSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>JobPriorityDefault</code> object.
+ *
+ * @param value the priority
+ *
+ * @exception IllegalArgumentException if value &lt; 1 or value &gt; 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<? extends Attribute> 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());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java
new file mode 100644
index 000000000..6bf027eda
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java
@@ -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@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<? extends Attribute> 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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java
new file mode 100644
index 000000000..5945d0b9b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java
@@ -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@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<? extends Attribute> 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());
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java
new file mode 100644
index 000000000..1563db82c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java
@@ -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@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<? extends Attribute> 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()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java
new file mode 100644
index 000000000..8e2d076d5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java
@@ -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@gmx.de)
+ */
+public final class NumberUpDefault extends IntegerSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>NumberUpDefault</code> object.
+ *
+ * @param value the value
+ * @throws IllegalArgumentException if value &lt; 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<? extends Attribute> 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());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java
new file mode 100644
index 000000000..4563ec525
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java
@@ -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@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<? extends Attribute> 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()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java
new file mode 100644
index 000000000..7b123eeb4
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java
@@ -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@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<? extends Attribute> 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()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java
new file mode 100644
index 000000000..2c84b99ba
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java
@@ -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@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<? extends Attribute> 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);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java
new file mode 100644
index 000000000..a50560ae9
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java
@@ -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@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<? extends Attribute> 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()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java
new file mode 100644
index 000000000..4fe2ce0d5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return AttributesCharset.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "attributes-charset".
+ */
+ public String getName()
+ {
+ return "attributes-charset";
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java
new file mode 100644
index 000000000..151cec439
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return AttributesNaturalLanguage.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "attributes-natural-language".
+ */
+ public String getName()
+ {
+ return "attributes-natural-language";
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java
new file mode 100644
index 000000000..5b83344a9
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java
@@ -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@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<? extends Attribute> 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";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java
new file mode 100644
index 000000000..c3fff057c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java
@@ -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@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<? extends Attribute> 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";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java
new file mode 100644
index 000000000..78c866723
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java
@@ -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@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 &lt; 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<? extends Attribute> getCategory()
+ {
+ return JobId.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-id".
+ */
+ public String getName()
+ {
+ return "job-id";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java
new file mode 100644
index 000000000..569400f40
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return JobMoreInfo.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-more-info".
+ */
+ public String getName()
+ {
+ return "job-more-info";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java
new file mode 100644
index 000000000..1375a2419
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return JobPrinterUri.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-printer-uri".
+ */
+ public String getName()
+ {
+ return "job-printer-uri";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java
new file mode 100644
index 000000000..d65126621
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return JobStateMessage.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-state-message".
+ */
+ public String getName()
+ {
+ return "job-state-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java
new file mode 100644
index 000000000..4b545b956
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return JobUri.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-uri".
+ */
+ public String getName()
+ {
+ return "job-uri";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java
new file mode 100644
index 000000000..42430377c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return CharsetConfigured.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "charset-configured".
+ */
+ public String getName()
+ {
+ return "charset-configured";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java
new file mode 100644
index 000000000..9a5e01e1d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java
@@ -0,0 +1,111 @@
+/* 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.Attribute;
+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@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<? extends Attribute> getCategory()
+ {
+ return DocumentFormat.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-format".
+ */
+ public String getName()
+ {
+ return "document-format";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java
new file mode 100644
index 000000000..bb00b8891
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java
@@ -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@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<? extends Attribute> 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";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java
new file mode 100644
index 000000000..8dc05fe58
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return NaturalLanguageConfigured.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "natural-language-configured".
+ */
+ public String getName()
+ {
+ return "natural-language-configured";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java
new file mode 100644
index 000000000..361916773
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java
@@ -0,0 +1,107 @@
+/* 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.Attribute;
+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@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<? extends Attribute> getCategory()
+ {
+ return PrinterCurrentTime.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-current-time".
+ */
+ public String getName()
+ {
+ return "printer-current-time";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java
new file mode 100644
index 000000000..28a2f4485
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return PrinterDriverInstaller.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-driver-installer".
+ */
+ public String getName()
+ {
+ return "printer-driver-installer";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java
new file mode 100644
index 000000000..07c458889
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java
@@ -0,0 +1,94 @@
+/* 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.Attribute;
+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@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<? extends Attribute> getCategory()
+ {
+ return PrinterStateMessage.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-state-message".
+ */
+ public String getName()
+ {
+ return "printer-state-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java
new file mode 100644
index 000000000..7bec92ed3
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java
@@ -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@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<? extends Attribute> getCategory()
+ {
+ return PrinterUpTime.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-up-time".
+ */
+ public String getName()
+ {
+ return "printer-up-time";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java
new file mode 100644
index 000000000..22b484ef8
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java
@@ -0,0 +1,88 @@
+/* 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.Attribute;
+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@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<? extends Attribute> getCategory()
+ {
+ return CharsetSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "charset-supported".
+ */
+ public String getName()
+ {
+ return "charset-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java
new file mode 100644
index 000000000..768091cb2
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java
@@ -0,0 +1,161 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ Compression[] result = new Compression[set.size()];
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ result[j] = ((CompressionSupported) tmp).getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java
new file mode 100644
index 000000000..03449fa4f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java
@@ -0,0 +1,92 @@
+/* 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.Attribute;
+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@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<? extends Attribute> getCategory()
+ {
+ return DocumentFormatSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-format-supported".
+ */
+ public String getName()
+ {
+ return "document-format-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java
new file mode 100644
index 000000000..f271fa71b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java
@@ -0,0 +1,302 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ Finishings[] result = new Finishings[set.size()];
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ result[j] = ((FinishingsSupported) tmp).getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java
new file mode 100644
index 000000000..df1d33007
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java
@@ -0,0 +1,89 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java
new file mode 100644
index 000000000..072d7499a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java
@@ -0,0 +1,122 @@
+/* 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.Attribute;
+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@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 the category of this class.
+ *
+ * @return The class <code>IppVersionsSupported</code> itself.
+ */
+ public Class<? extends Attribute> 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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java
new file mode 100644
index 000000000..2add4a0cd
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java
@@ -0,0 +1,134 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java
new file mode 100644
index 000000000..aeb86ff10
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java
@@ -0,0 +1,148 @@
+/* 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@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<? extends Attribute> 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<Attribute> set)
+ {
+ ArrayList<JobSheets> result = new ArrayList<JobSheets>();
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ JobSheets att = ((JobSheetsSupported) tmp).getAssociatedAttribute();
+ if (att != null)
+ result.add(att);
+ j++;
+ }
+ return result.toArray(new JobSheets[result.size()]);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java
new file mode 100644
index 000000000..2684ebbec
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java
@@ -0,0 +1,116 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ Media tmp2;
+ ArrayList<Media> result = new ArrayList<Media>();
+ for (Attribute tmp : set)
+ {
+ tmp2 = (Media) IppUtilities.getEnumAttribute("media", tmp.toString());
+ if (tmp2 != null)
+ result.add(tmp2);
+ }
+ return result.toArray(new Media[result.size()]);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java
new file mode 100644
index 000000000..73e5921f1
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java
@@ -0,0 +1,176 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ MultipleDocumentHandling[] result = new MultipleDocumentHandling[set.size()];
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ result[j] = ((MultipleDocumentHandlingSupported) tmp).getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java
new file mode 100644
index 000000000..1b2998456
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java
@@ -0,0 +1,119 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java
new file mode 100644
index 000000000..a059c89a5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java
@@ -0,0 +1,231 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java
new file mode 100644
index 000000000..4b87c53a5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java
@@ -0,0 +1,178 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ OrientationRequested[] result = new OrientationRequested[set.size()];
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ result[j] = ((OrientationRequestedSupported) tmp).getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java
new file mode 100644
index 000000000..c58f76748
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java
@@ -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.Attribute;
+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@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<? extends Attribute> 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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java
new file mode 100644
index 000000000..25cbf9f0b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java
@@ -0,0 +1,169 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ PrintQuality[] result = new PrintQuality[set.size()];
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ result[j] = ((PrintQualitySupported) tmp).getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java
new file mode 100644
index 000000000..eb50aaac5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java
@@ -0,0 +1,142 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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<Attribute> set)
+ {
+ PrinterResolution[] result = new PrinterResolution[set.size()];
+ int j = 0;
+ for (Attribute tmp : set)
+ {
+ result[j] = ((PrinterResolutionSupported) tmp).getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java
new file mode 100644
index 000000000..0eed39c6c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java
@@ -0,0 +1,89 @@
+/* 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.Attribute;
+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@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<? extends Attribute> getCategory()
+ {
+ return PrinterUriSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-uri-supported".
+ */
+ public String getName()
+ {
+ return "printer-uri-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java
new file mode 100644
index 000000000..eff82c143
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java
@@ -0,0 +1,137 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java
new file mode 100644
index 000000000..dc1a29f5c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java
@@ -0,0 +1,142 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java
new file mode 100644
index 000000000..03396978f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java
@@ -0,0 +1,127 @@
+/* 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.Attribute;
+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@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<? extends Attribute> 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;
+ }
+
+}