From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../gnu/javax/print/ipp/DocPrintJobImpl.java | 471 +++++++++++ .../gnu/javax/print/ipp/IppDelimiterTag.java | 99 +++ .../gnu/javax/print/ipp/IppException.java | 88 ++ .../javax/print/ipp/IppMultiDocPrintService.java | 87 ++ .../gnu/javax/print/ipp/IppPrintService.java | 924 +++++++++++++++++++++ .../classpath/gnu/javax/print/ipp/IppRequest.java | 875 +++++++++++++++++++ .../classpath/gnu/javax/print/ipp/IppResponse.java | 787 ++++++++++++++++++ .../gnu/javax/print/ipp/IppStatusCode.java | 185 +++++ .../gnu/javax/print/ipp/IppUtilities.java | 553 ++++++++++++ .../classpath/gnu/javax/print/ipp/IppValueTag.java | 170 ++++ .../gnu/javax/print/ipp/MultiDocPrintJobImpl.java | 80 ++ .../javax/print/ipp/attribute/CharsetSyntax.java | 115 +++ .../print/ipp/attribute/DefaultValueAttribute.java | 59 ++ .../print/ipp/attribute/DetailedStatusMessage.java | 93 +++ .../print/ipp/attribute/DocumentAccessError.java | 93 +++ .../print/ipp/attribute/NaturalLanguageSyntax.java | 117 +++ .../print/ipp/attribute/RequestedAttributes.java | 132 +++ .../javax/print/ipp/attribute/StatusMessage.java | 92 ++ .../print/ipp/attribute/UnknownAttribute.java | 190 +++++ .../ipp/attribute/defaults/CopiesDefault.java | 118 +++ .../attribute/defaults/DocumentFormatDefault.java | 106 +++ .../ipp/attribute/defaults/FinishingsDefault.java | 263 ++++++ .../attribute/defaults/JobHoldUntilDefault.java | 149 ++++ .../ipp/attribute/defaults/JobPriorityDefault.java | 118 +++ .../ipp/attribute/defaults/JobSheetsDefault.java | 122 +++ .../print/ipp/attribute/defaults/MediaDefault.java | 105 +++ .../defaults/MultipleDocumentHandlingDefault.java | 152 ++++ .../ipp/attribute/defaults/NumberUpDefault.java | 114 +++ .../defaults/OrientationRequestedDefault.java | 154 ++++ .../attribute/defaults/PrintQualityDefault.java | 141 ++++ .../defaults/PrinterResolutionDefault.java | 119 +++ .../print/ipp/attribute/defaults/SidesDefault.java | 150 ++++ .../print/ipp/attribute/job/AttributesCharset.java | 93 +++ .../attribute/job/AttributesNaturalLanguage.java | 95 +++ .../attribute/job/JobDetailedStatusMessages.java | 92 ++ .../ipp/attribute/job/JobDocumentAccessErrors.java | 93 +++ .../gnu/javax/print/ipp/attribute/job/JobId.java | 87 ++ .../javax/print/ipp/attribute/job/JobMoreInfo.java | 87 ++ .../print/ipp/attribute/job/JobPrinterUri.java | 87 ++ .../print/ipp/attribute/job/JobStateMessage.java | 92 ++ .../gnu/javax/print/ipp/attribute/job/JobUri.java | 87 ++ .../ipp/attribute/printer/CharsetConfigured.java | 86 ++ .../ipp/attribute/printer/DocumentFormat.java | 111 +++ .../printer/MultipleOperationTimeOut.java | 86 ++ .../printer/NaturalLanguageConfigured.java | 86 ++ .../ipp/attribute/printer/PrinterCurrentTime.java | 107 +++ .../attribute/printer/PrinterDriverInstaller.java | 88 ++ .../ipp/attribute/printer/PrinterStateMessage.java | 94 +++ .../print/ipp/attribute/printer/PrinterUpTime.java | 86 ++ .../ipp/attribute/supported/CharsetSupported.java | 88 ++ .../attribute/supported/CompressionSupported.java | 161 ++++ .../supported/DocumentFormatSupported.java | 92 ++ .../attribute/supported/FinishingsSupported.java | 302 +++++++ .../GeneratedNaturalLanguageSupported.java | 89 ++ .../attribute/supported/IppVersionsSupported.java | 122 +++ .../attribute/supported/JobHoldUntilSupported.java | 134 +++ .../attribute/supported/JobSheetsSupported.java | 148 ++++ .../ipp/attribute/supported/MediaSupported.java | 116 +++ .../MultipleDocumentHandlingSupported.java | 176 ++++ .../supported/MultipleDocumentJobsSupported.java | 119 +++ .../attribute/supported/OperationsSupported.java | 231 ++++++ .../supported/OrientationRequestedSupported.java | 178 ++++ .../attribute/supported/PageRangesSupported.java | 117 +++ .../attribute/supported/PrintQualitySupported.java | 169 ++++ .../supported/PrinterResolutionSupported.java | 142 ++++ .../attribute/supported/PrinterUriSupported.java | 89 ++ .../ipp/attribute/supported/SidesSupported.java | 137 +++ .../supported/UriAuthenticationSupported.java | 142 ++++ .../attribute/supported/UriSecuritySupported.java | 127 +++ 69 files changed, 11457 insertions(+) create mode 100644 libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppException.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppPrintService.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppRequest.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppResponse.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppUtilities.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/IppValueTag.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java create mode 100644 libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java (limited to 'libjava/classpath/gnu/javax/print/ipp') 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 IppPrintService 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. + *

+ * 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.
+ * 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). + *

+ * + * @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 true if, false 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; + +/** + * IppException 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 IppException. + */ + public IppException() + { + super(); + } + + /** + * Creates an IppException. + * @param s the message of the exception. + */ + public IppException(String s) + { + super(s); + } + + /** + * Creates an IppException. + * @param e the exception cause this one. + */ + public IppException(Exception e) + { + super(e); + } + + /** + * Creates an IppException. + * @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 IppMultiDocPrintService 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, Set> printerAttr; + + /** The set of listeners.*/ + private HashSet printServiceAttributeListener; + + /** The username. */ + private transient String user; + + /** The password of the user. */ + private transient String passwd; + + /** The name of this print service. */ + private String name; + + /** The list of supported document flavors. */ + private List flavors; + + /** The standard printer URI. */ + private PrinterURI printerUri; + + /** The list of all supported printer URIs. */ + private ArrayList printerUris; + + /** + * Logger for tracing - enable by passing + * -Dgnu.classpath.debug.components=ipp to the vm. + */ + static final Logger logger = SystemLogger.SYSTEM; + + /** + * requesting-user-name defaults to the executing user. + */ + public static final RequestingUserName REQUESTING_USER_NAME; + + /** + * job-name defaults to "Java Printing". + */ + public static final JobName JOB_NAME; + + static + { + JOB_NAME = new JobName("Java Printing", null); + REQUESTING_USER_NAME = new RequestingUserName( + SystemProperties.getProperty("user.name", ""), null); + } + + // TODO Implement service listener notification and change detection. + + /** + * Creates a IppPrintService object. + * + * @param uri the URI of the IPP printer. + * @param username the user of this print service. + * @param password the password of the user. + * + * @throws IppException if an error during connection occurs. + */ + public IppPrintService(URI uri, String username, String password) + throws IppException + { + printerUri = new PrinterURI(uri); + user = username; + passwd = password; + + printServiceAttributeListener = + new HashSet(); + + printerAttr = getPrinterAttributes(); + processResponse(); + } + + /** + * Fetches all printer attributes from the IPP printer. + * + * @return The Map with the printer attributes. + * @throws IppException if an error occurs. + */ + private Map, Set> 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 Set getPrinterAttributeSet(Class attributeClass) + { + Set set = printerAttr.get(attributeClass); + Set attSet = new HashSet(); + 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 DefaultValueAttribute. + */ + private Attribute getPrinterDefaultAttribute(Class attributeClass) + { + Set set = printerAttr.get(attributeClass); + return ((DefaultValueAttribute) set.toArray()[0]).getAssociatedAttribute(); + } + + /** + * Processes the response, sorts and splits the attributes. + */ + private void processResponse() + { + // printer name + PrinterName[] tmp = getPrinterAttributeSet(PrinterName.class).toArray(new PrinterName[1]); + name = tmp[0].getValue(); + + // supported flavors + // TODO Check if charsets-supported are charsets that are actually supported + // for text doc flavors as cups doesn't send charset parameters + + // utf-8 is supported at least - so we go with this only for now + flavors = new ArrayList(); + Set flavorAttributes = getPrinterAttributeSet(DocumentFormatSupported.class); + if (flavorAttributes != null) + { + for (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 uris = getPrinterAttributeSet(PrinterUriSupported.class); + printerUris = new ArrayList(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 getAttribute(Class category) + { + if (category == null) + throw new NullPointerException("category may not be null"); + + if (! PrintServiceAttribute.class.isAssignableFrom(category)) + throw new IllegalArgumentException( + "category must be of type PrintServiceAttribute"); + + Set set = getPrinterAttributeSet(category); + if (set != null && set.size() > 0) + return set.iterator().next(); + + return null; + } + + /** + * @see javax.print.PrintService#getAttributes() + */ + public PrintServiceAttributeSet getAttributes() + { + PrintServiceAttributeSet set = new HashPrintServiceAttributeSet(); + + for (Set 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 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 PrinterName here. + * @see javax.print.PrintService#getName() + */ + public String getName() + { + return name; + } + + /** + * We currently provide no factories - just returns null. + * @see javax.print.PrintService#getServiceUIFactory() + */ + public ServiceUIFactory getServiceUIFactory() + { + // SUN does not provide any service factory for + // print services (tested on linux/windows) + + // for the moment we do the same - just return null + // later on we could provide at least the about UI dialog + return null; + } + + /** + * @see javax.print.PrintService#getSupportedAttributeCategories() + */ + public Class[] getSupportedAttributeCategories() + { + Set> categories = + new HashSet>(); + + // Should only be job template attributes as of section 4.2 + if (printerAttr.containsKey(JobPrioritySupported.class)) + categories.add(JobPriority.class); + if (printerAttr.containsKey(JobHoldUntilSupported.class)) + categories.add(JobHoldUntil.class); + if (printerAttr.containsKey(JobSheetsSupported.class)) + categories.add(JobSheets.class); + if (printerAttr.containsKey(MultipleDocumentHandlingSupported.class)) + categories.add(MultipleDocumentHandling.class); + if (printerAttr.containsKey(CopiesSupported.class)) + categories.add(Copies.class); + if (printerAttr.containsKey(FinishingsSupported.class)) + { + // if only none finishing is supported - it does not count as supported + Set set = getPrinterAttributeSet(FinishingsSupported.class); + if (! (set.size() == 1 && set.contains(FinishingsSupported.NONE))) + categories.add(Finishings.class); + } + if (printerAttr.containsKey(PageRangesSupported.class)) + categories.add(PageRanges.class); + if (printerAttr.containsKey(SidesSupported.class)) + categories.add(Sides.class); + if (printerAttr.containsKey(NumberUpSupported.class)) + categories.add(NumberUp.class); + if (printerAttr.containsKey(OrientationRequestedSupported.class)) + categories.add(OrientationRequested.class); + if (printerAttr.containsKey(MediaSupported.class)) + categories.add(Media.class); + if (printerAttr.containsKey(PrinterResolutionSupported.class)) + categories.add(PrinterResolution.class); + if (printerAttr.containsKey(PrintQualitySupported.class)) + categories.add(PrintQuality.class); + + // Chromaticity, Destination, MediaPrintableArea, + // SheetCollate, PresentationDirection - not IPP attributes + + // attributes outside section 4.2 + if (printerAttr.containsKey(CompressionSupported.class)) + categories.add(Compression.class); + if (printerAttr.containsKey(JobImpressionsSupported.class)) + categories.add(JobImpressions.class); + if (printerAttr.containsKey(JobKOctetsSupported.class)) + categories.add(JobKOctets.class); + if (printerAttr.containsKey(JobMediaSheetsSupported.class)) + categories.add(JobMediaSheets.class); + + // always supported as required by IPP specification + categories.add(Fidelity.class); + categories.add(JobName.class); + categories.add(RequestingUserName.class); + + return 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 + * handleSupportedAttributeValuesResponse(IppResponse, Class) only. + * + * @see PrintService#getSupportedAttributeValues(Class, DocFlavor, AttributeSet) + * @see #handleSupportedAttributeValuesResponse(IppResponse, Class) + */ + public Object getSupportedAttributeValues(Class category, + DocFlavor flavor, AttributeSet attributes) + { + // We currently ignore the attribute set - there is nothing in the IPP + // specification which would come closer to what we do here. + + if (category == null) + throw new NullPointerException("category may not be null"); + + if (!Attribute.class.isAssignableFrom(category)) + throw new IllegalArgumentException("category must be of type Attribute"); + + if (flavor != null && !isDocFlavorSupported(flavor)) + throw new IllegalArgumentException("flavor is not supported"); + + if (!isAttributeCategorySupported(category)) + return null; + + // always supported + if (category.equals(Fidelity.class)) + return new Fidelity[] { Fidelity.FIDELITY_FALSE, Fidelity.FIDELITY_TRUE }; + if (category.equals(JobName.class)) + return JOB_NAME; + if (category.equals(RequestingUserName.class)) + return REQUESTING_USER_NAME; + + // map category to category-supported + String categoryName = IppUtilities.getSupportedAttrName(category); + + IppResponse response = null; + try + { + IppRequest request = new IppRequest(printerUri.getURI(), user, passwd); + request.setOperationID( + (short) OperationsSupported.GET_PRINTER_ATTRIBUTES.getValue()); + request.setOperationAttributeDefaults(); + request.addOperationAttribute(new RequestedAttributes(categoryName)); + request.addOperationAttribute(printerUri); + + if (flavor != null) + { + DocumentFormat f = DocumentFormat.createDocumentFormat(flavor); + request.addOperationAttribute(f); + } + + response = request.send(); + + int status = response.getStatusCode(); + if (! (status == IppStatusCode.SUCCESSFUL_OK + || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES + || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) ) + { + logger.log(Component.IPP, "Statuscode not OK - got:" + status); + } + } + catch (IOException e) + { + // method cannot throw exception - just log + logger.log(Component.IPP, "IOException", e); + } + catch (IppException e) + { + // method cannot throw exception - just log + logger.log(Component.IPP, "IPPException", e); + } + + return handleSupportedAttributeValuesResponse(response, category); + } + + /** + * Called to handle the supported attribute values response for the given + * category. This might be overridden by subclasses with different requirements + * for parsing/handling the response from the GetPrinterAttributes. + * + * @param response the response of the GetPrinterAttributes IPP request + * @param category the category for which the supported values are requested + * @return A object indicating the supported values for the given attribute + * category, or null if this print service doesn't support the + * given attribute category at all. + * + * @see #getSupportedAttributeValues(Class, DocFlavor, AttributeSet) + */ + protected Object handleSupportedAttributeValuesResponse(IppResponse response, + Class category) + { + List, Set>> printerAtts = + response.getPrinterAttributes(); + + // only one will be returned + Map, Set> printerAttribute = printerAtts.get(0); + Class suppCategory = IppUtilities.getSupportedCategory(category); + Set 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 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, Set>> unsupportedMaps = + response.getUnsupportedAttributes(); + if (unsupportedMaps.size() == 0) + return null; + + Map, Set> 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 unsupported : unsupportedAttr.values()) + { + for (Attribute att : unsupported) + set.add(att); + } + + return set; + } + + /** + * @see PrintService#isAttributeCategorySupported(Class) + */ + public boolean isAttributeCategorySupported(Class category) + { + if (category == null) + throw new NullPointerException("category may not be null"); + + if (! Attribute.class.isAssignableFrom(category)) + throw new IllegalArgumentException("category must be of type Attribute"); + + return Arrays.asList(getSupportedAttributeCategories()).contains(category); + } + + /** + * @see PrintService#isAttributeValueSupported(Attribute, DocFlavor, AttributeSet) + */ + public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, + AttributeSet attributes) + { + // just redirect to getSupportedAttributeValues + Object values = getSupportedAttributeValues(attrval.getCategory(), + flavor, attributes); + // null means none supported + if (values == null) + return false; + + // object may be an array + if (values.getClass().isArray()) + return Arrays.asList((Object[]) values).contains(attrval); + + // may be a single instance of the category (value is irrelevant) + if (values.getClass().equals(attrval.getCategory())) + return true; + + // a single instance of another class to give the bounds + // copies + if (values.getClass().equals(CopiesSupported.class)) + return ((CopiesSupported) values).contains((IntegerSyntax) attrval); + // number up + if (values.getClass().equals(NumberUpSupported.class)) + return ((NumberUpSupported) values).contains((IntegerSyntax) attrval); + // job priority + if (values.getClass().equals(JobPrioritySupported.class)) + { + JobPriority priority = (JobPriority) attrval; + JobPrioritySupported maxSupported = (JobPrioritySupported) values; + if (priority.getValue() < maxSupported.getValue()) + return true; + } + + // I am unsure if these might also show up - not yet found a printer where + // Suns implementation supports them: + // JobImpressionsSupported, JobKOctetsSupported, JobMediaSheetsSupported + + return false; + } + + + /** + * @see javax.print.PrintService#isDocFlavorSupported(DocFlavor) + */ + public boolean isDocFlavorSupported(DocFlavor flavor) + { + if (flavor == null) + throw new NullPointerException("DocFlavor may not be null."); + + return flavors.contains(flavor); + } + + + /** + * @see PrintService#addPrintServiceAttributeListener(PrintServiceAttributeListener) + */ + public void addPrintServiceAttributeListener( + PrintServiceAttributeListener listener) + { + printServiceAttributeListener.add(listener); + } + + /** + * @see PrintService#removePrintServiceAttributeListener(PrintServiceAttributeListener) + */ + public void removePrintServiceAttributeListener( + PrintServiceAttributeListener listener) + { + printServiceAttributeListener.remove(listener); + } + + /** + * Returns "IppPrinter: " + getName() + * @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; + +/** + * IppRequest models a request to an IPP compatible + * server as described in RFC 2910 - IPP/1.1: Encoding and Transport. + *

+ * The byte stream is structured as follows (for an official description + * please have a look at the RFC document mentioned above): + *

    + *
  • version-number - 2 bytes - required
  • + *
  • operation-id - 2 bytes - required
  • + *
  • request-id - 4 bytes - required
  • + *
  • attribute-group - n bytes - 0 or more
  • + *
  • end-of-attributes-tag - 1 byte - required
  • + *
  • data - q bytes - optional
  • + *
+ *

+ * + * @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. + *

+ * The syntax value is defined as 11 octets follwing the + * DateAndTime format of RFC 1903. (see IppResponse) + *

+ * + * @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. + *

+ * 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. + *

+ * + * @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 null. + */ + 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 null. + */ + 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; + +/** + * IppResponse 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 +{ + + /** + * ResponseReader is responsible for parsing an IPP 1.1 + * response stream. It provides access to the attribute groups after parsing + * via getter methods. + *

+ * The enconding of a response is structured as follows (for an official + * description please have a look at the RFC document mentioned above): + *

    + *
  • version-number - 2 bytes - required
  • + *
  • status-code - 2 bytes - required
  • + *
  • request-id - 4 bytes - required
  • + *
  • attribute-group - n bytes - 0 or more
  • + *
  • end-of-attributes-tag - 1 byte - required
  • + *
  • data - q bytes - optional
  • + *
+ *

+ * Where each attribute-group (if any) is encoded as follows: + *

    + *
  • begin-attribute-group-tag - 1 byte
  • + *
  • attribute - p bytes - 0 or more
  • + *
+ *

+ * Encoding of attributes: + *

    + *
  • attribute-with-one-value - q bytes
  • + *
  • additional-value - r bytes - 0 or more
  • + *
+ *

+ * Encoding of attribute-with-one-value: + *

    + *
  • value-tag - 1 byte
  • + *
  • name-length (value is u) - 2 bytes
  • + *
  • name - u bytes
  • + *
  • value-length (value is v) - 2 bytes
  • + *
  • value - v bytes
  • + *
+ *

+ * Encoding of additional value: + *

    + *
  • value-tag - 1 byte
  • + *
  • name-length (value is 0x0000) - 2 bytes
  • + *
  • value-length (value is w) - 2 bytes
  • + *
  • value - w bytes
  • + *
+ *

+ * + * @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, Set> 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, Set>(); + tag = parseAttributes(tmp, stream); + operationAttributes.add(tmp); + break; + case IppDelimiterTag.JOB_ATTRIBUTES_TAG: + tmp = new HashMap, Set>(); + tag = parseAttributes(tmp, stream); + jobAttributes.add(tmp); + break; + case IppDelimiterTag.PRINTER_ATTRIBUTES_TAG: + tmp = new HashMap, Set>(); + tag = parseAttributes(tmp, stream); + printerAttributes.add(tmp); + break; + case IppDelimiterTag.UNSUPPORTED_ATTRIBUTES_TAG: + System.out.println("Called"); + tmp = new HashMap, Set>(); + 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, Set> 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, Set> attributeGroup, + Attribute attribute) + { + Class clazz = attribute.getCategory(); + Set attributeValues = attributeGroup.get(clazz); + + if (attributeValues == null) // first attribute of this category + { + attributeValues = new HashSet(); + attributeGroup.put(clazz, attributeValues); + } + + attributeValues.add(attribute); + } + + /** + * Parses a name with or without language attribute value from the byte[] + * and returns the result as an object[]. + * @param value the byte[] + * @param lastAttr the last attribute + * @return The attribute. + */ + private PrinterStateReasons parsePrinterStateReasons(byte[] value, Attribute lastAttr) + { + String str = new String(value); + PrinterStateReasons attribute; + + if (lastAttr instanceof PrinterStateReasons) + attribute = (PrinterStateReasons) lastAttr; + else + attribute = new PrinterStateReasons(); + + // special case indicating no reasons + if (str.equals("none")) + return attribute; + + Severity severity = null; + PrinterStateReason reason = null; + + if (str.endsWith(Severity.WARNING.toString())) + severity = Severity.WARNING; + else if (str.endsWith(Severity.REPORT.toString())) + severity = Severity.REPORT; + else if (str.endsWith(Severity.ERROR.toString())) + severity = Severity.ERROR; + + if (severity != null) + str = str.substring(0, str.lastIndexOf('-')); + else // we must associate a severity + severity = Severity.REPORT; + + reason = (PrinterStateReason) + IppUtilities.getEnumAttribute("printer-state-reason", str); + + attribute.put(reason , severity); + return attribute; + } + + /** + * Parses a name with or without language attribute value from the byte[] + * and returns the result as an object[]. + * @param value the byte[] + * @param lastAttr the last attribute + * @return The attribute. + */ + private JobStateReasons parseJobStateReasons(byte[] value, Attribute lastAttr) + { + String str = new String(value); + JobStateReasons attribute; + + if (lastAttr instanceof JobStateReasons) + attribute = (JobStateReasons) lastAttr; + else + attribute = new JobStateReasons(); + + // special case indicating no reasons + if (str.equals("none")) + return attribute; + + JobStateReason reason = (JobStateReason) + IppUtilities.getEnumAttribute("job-state-reason", str); + + attribute.add(reason); + return attribute; + } + + /** + * Parses a DateTime syntax attribute and returns the constructed Date + * object. + *

+ * The syntax value is defined as 11 octets follwing the DateAndTime format + * of RFC 1903: + *

    + *
  • field | octets | contents | range
  • + *
  • 1 | 1-2 | year | 0..65536
  • + *
  • 2 | 3 | month | 1..12
  • + *
  • 3 | 4 | day | 1..31
  • + *
  • 4 | 5 | hour | 0..23
  • + *
  • 5 | 6 | minutes | 0..59
  • + *
  • 6 | 7 | seconds | 0..60 (use 60 for leap-second)
  • + *
  • 7 | 8 | deci-seconds | 0..9
  • + *
  • 8 | 9 | direction from UTC | '+' / '-'
  • + *
  • 9 | 10 | hours from UTC | 0..11
  • + *
  • 10 | 11 | minutes from UTC | 0..59
  • + *
+ *

+ * + * @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, Set>> operationAttributes; + List, Set>> printerAttributes; + List, Set>> jobAttributes; + List, Set>> unsupportedAttributes; + + byte[] data; + + /** + * Creates an IppResponse 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, Set>>(); + jobAttributes = + new ArrayList, Set>>(); + printerAttributes = + new ArrayList, Set>>(); + unsupportedAttributes = + new ArrayList, Set>>(); + } + + /** + * 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, Set>> 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, Set>> 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, Set>> 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, Set>> 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. + *

+ * Also provides mapping from the attribute name values to + * the actual class object. Used to construct objects via reflection. + *

+ * + * @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> classesByName = + new HashMap>(); + // The map -> StandardAttribute class to SupportedAttribute category name + private static HashMap,SupportedValuesAttribute> instanceByClass = + new HashMap,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 Class object. + */ + public static Class 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 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 getSupportedCategory(Class 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 EnumSyntax 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 IntegerSyntax 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 TextSyntax 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. + *

+ * 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. + *

+ * + * @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 true if, false 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 IppPrintService 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; + +/** + * CharsetSyntax 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 CharsetSyntax 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 - > Name-default -> 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 DetailedStatusMessage object with the given value + * and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 DetailedStatusMessage itself. + */ + public Class getCategory() + { + return DetailedStatusMessage.class; + } + + + /** + * Returns the name of this attribute. + * + * @return The name "detailed-status-message". + */ + public String getName() + { + return "detailed-status-message"; + } + +} 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 DocumentAccessError object with the given value + * and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 DocumentAccessError itself. + */ + public Class getCategory() + { + return DocumentAccessError.class; + } + + + /** + * Returns the name of this attribute. + * + * @return The name "document-access-error". + */ + public String getName() + { + return "document-access-error"; + } + +} 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; + +/** + * NaturalLanguageSyntax 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 NaturalLanguageSyntax 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; + +/** + * RequestedAttributes specifies the requested + * attributes in an IPP request operation. + * + * @author Wolfgang Baer (WBaer@gmx.de) + */ +public final class RequestedAttributes implements Attribute +{ + private ArrayList attributes; + + /** + * Creates a RequestedAttributes object with + * the initial value. + * + * @param value the string for the ipp name + * + * @exception NullPointerException if value is null + */ + public RequestedAttributes(String value) + { + if (value == null) + throw new NullPointerException(); + + attributes = new ArrayList(); + attributes.add(value); + } + + /** + * Adds the IPP name value to the set. + * + * @param value the string for the ipp name + */ + public void addValue(String value) + { + attributes.add(value); + } + + /** + * Returns the values. + * + * @return The values as list. + */ + public String[] getValues() + { + return attributes.toArray(new String[attributes.size()]); + } + + /** + * Returns category of this class. + * + * @return The class DocumentFormat itself. + */ + public Class getCategory() + { + return RequestedAttributes.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "requested-attributes". + */ + public String getName() + { + return "requested-attributes"; + } + + /** + * Returns the string representation for this object. + * + * @return The string representation. + */ + public String toString() + { + 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 StatusMessage object with the given value + * and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 StatusMessage itself. + */ + public Class 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 UnknownAttribute 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 UnknownAttribute itself. + */ + public Class getCategory() + { + return UnknownAttribute.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name attributes IPP name. + */ + public String getName() + { + return name; + } + + /** + * Returns the value tag + * @return The tag. + * + * @see gnu.javax.print.ipp.IppValueTag + */ + public byte getValueTag() + { + return tag; + } + + /** + * Returns the name of the attribute. + * @return The name. + */ + public String getAttributeName() + { + return name; + } + + /** + * Returns the attribute value origin byte array. + * @return The value. + */ + public byte[] getAttributeValue() + { + return value; + } + + /** + * Returns the attribute value decoded as String. + * @return The value as String. + */ + public String getAttributeValueAsString() + { + return new String(value); + } + + /** + * Returns the attribute value decoded as int. + * @return The value as int. + */ + public int getAttributeValueAsInt() + { + return IppUtilities.convertToInt(value); + } + + /** + * Returns the attribute value decoded as an URI. + * @return The value as URI. + */ + public URI getAttributeValueAsUri() + { + try + { + return new URI(new String(value)); + } + catch (URISyntaxException e) + { + return null; + } + } + + /** + * Provides a string representation for some default + * tag types (e.g. int, rangeofinteger, string, uri). + * For other more complex types "No conversion found." + * is returned. + */ + public String toString() + { + switch (tag) + { + case IppValueTag.INTEGER: + return "" + getAttributeValueAsInt(); + case IppValueTag.RANGEOFINTEGER: + int lower = IppUtilities.convertToInt(value[0], value[1], + value[2], value[3]); + int upper = IppUtilities.convertToInt(value[4], value[5], + value[6], value[7]); + return lower + "-" + upper; + case IppValueTag.URI: + return getAttributeValueAsUri().toString(); + case IppValueTag.KEYWORD: + case IppValueTag.URI_SCHEME: + case IppValueTag.CHARSET: + case IppValueTag.NATURAL_LANGUAGE: + case IppValueTag.MIME_MEDIA_TYPE: + case IppValueTag.NAME_WITHOUT_LANGUAGE: + case IppValueTag.TEXT_WITHOUT_LANGUAGE: + return getAttributeValueAsString(); + default: + return "No conversion found."; + } + } +} 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; + +/** + * CopiesDefault provides the default value + * for the copies attribute. + * + * @author Wolfgang Baer (WBaer@gmx.de) + */ +public final class CopiesDefault extends IntegerSyntax + implements DefaultValueAttribute +{ + + /** + * Creates a CopiesDefault object. + * + * @param value the number of copies + * + * @exception IllegalArgumentException if value < 1 + */ + public CopiesDefault(int value) + { + super(value); + + if (value < 1) + throw new IllegalArgumentException("value may not be less than 1"); + } + + /** + * Tests if the given object is equal to this object. + * + * @param obj the object to test + * + * @return true if both objects are equal, + * false otherwise. + */ + public boolean equals(Object obj) + { + if(! (obj instanceof CopiesDefault)) + return false; + + return super.equals(obj); + } + + /** + * Returns category of this class. + * + * @return The class CopiesDefault itself. + */ + public Class getCategory() + { + return CopiesDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "copies-default". + */ + public String getName() + { + return "copies-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + *

May return null if no value exists in JPS API.

+ * + * @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; + +/** + * DocumentFormatDefault specifies the default document + * format of a printer. + * + * @author Wolfgang Baer (WBaer@gmx.de) + * + */ +public final class DocumentFormatDefault extends TextSyntax + implements DefaultValueAttribute +{ + + /** + * Creates a DocumentFormatDefault object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 DocumentFormatDefault itself. + */ + public Class getCategory() + { + return DocumentFormatDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "document-format-default". + */ + public String getName() + { + return "document-format-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return new DocumentFormat(getValue(), getLocale()); + } + +} 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 FinishingsDefault 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 FinishingsDefault object. + * + * @param value the value + */ + protected FinishingsDefault(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return the class FinishingsDefault itself + */ + public Class getCategory() + { + return FinishingsDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "finishings-default". + */ + public String getName() + { + return "finishings-default"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the lowest used value by the enumerations of this class. + * . + * @return The lowest value used. + */ + protected int getOffset() + { + return 3; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return IppUtilities.getEnumAttribute("finishings", new Integer(getValue())); + } +} 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 JobHoldUntilDefault object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobHoldUntilDefault itself. + */ + public Class getCategory() + { + return JobHoldUntilDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "job-hold-until-default". + */ + public String getName() + { + return "job-hold-until-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + // FIXME Same Mapping problem as in IppPrintService + return new JobHoldUntil(new Date()); + } + +} 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 JobPriorityDefault object. + * + * @param value the priority + * + * @exception IllegalArgumentException if value < 1 or value > 100 + */ + public JobPriorityDefault(int value) + { + super(value); + + if (value < 1 || value > 100) + throw new IllegalArgumentException("value out of range"); + } + + /** + * Tests if the given object is equal to this object. + * + * @param obj the object to test + * + * @return true if both objects are equal, + * false otherwise. + */ + public boolean equals(Object obj) + { + if(! (obj instanceof JobPriorityDefault)) + return false; + + return super.equals(obj); + } + + /** + * Returns category of this class. + * + * @return The class JobPriorityDefault itself. + */ + public Class getCategory() + { + return JobPriorityDefault.class; + } + + /** + * Returns name of this class. + * + * @return The anme "job-priority-default". + */ + public String getName() + { + return "job-priority-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return new JobPriority(getValue()); + } +} 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 JobSheetsDefault object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobSheetsDefault itself. + */ + public Class getCategory() + { + return JobSheetsDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "job-sheets-default". + */ + public String getName() + { + return "job-sheets-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + *

May return null if no value exists in JPS API.

+ * + * @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 MediaDefault object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 MediaDefault itself. + */ + public Class getCategory() + { + return MediaDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "media-default". + */ + public String getName() + { + return "media-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return IppUtilities.getEnumAttribute("media" , getValue()); + } + +} 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; + + +/** + * MultipleDocumentHandlingDefault 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 MultipleDocumentHandlingDefault object. + * + * @param value the enum value + */ + protected MultipleDocumentHandlingDefault(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class MultipleDocumentHandlingDefault itself. + */ + public Class getCategory() + { + return MultipleDocumentHandlingDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "multiple-document-handling-default". + */ + public String getName() + { + return "multiple-document-handling-default"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return IppUtilities.getEnumAttribute("multiple-document-handling", + new Integer(getValue())); + } +} 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 NumberUpDefault object. + * + * @param value the value + * @throws IllegalArgumentException if value < 1 + */ + public NumberUpDefault(int value) + { + super(value); + } + + /** + * Tests if the given object is equal to this object. + * + * @param obj the object to test + * + * @return true if both objects are equal, + * false otherwise. + */ + public boolean equals(Object obj) + { + if(! (obj instanceof NumberUpDefault)) + return false; + + return super.equals(obj); + } + + /** + * Returns category of this class. + * + * @return The class NumberUpDefault itself. + */ + public Class getCategory() + { + return NumberUpDefault.class; + } + + /** + * Returns name of this class. + * + * @return The name "number-up-default". + */ + public String getName() + { + return "number-up-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + *

May return null if no value exists in JPS API.

+ * + * @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 OrientationRequestedDefault 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 OrientationRequestedDefault object. + * + * @param value the value + */ + protected OrientationRequestedDefault(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class OrientationRequestedDefault itself. + */ + public Class getCategory() + { + return OrientationRequestedDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "orientation-requested-default". + */ + public String getName() + { + return "orientation-requested-default"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the lowest used value by the enumerations of this class. + * . + * @return The lowest value used. + */ + protected int getOffset() + { + return 3; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return IppUtilities.getEnumAttribute("orientation-requested", + new Integer(getValue())); + } +} 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; + + +/** + * PrintQualityDefault 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 PrintQualityDefault object. + * + * @param value the value of the enum + */ + protected PrintQualityDefault(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class PrintQualityDefault itself. + */ + public Class getCategory() + { + return PrintQualityDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "print-quality-default". + */ + public String getName() + { + return "print-quality-default"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the lowest used value by the enumerations of this class. + * . + * @return The lowest value used. + */ + protected int getOffset() + { + return 3; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return IppUtilities.getEnumAttribute( + "print-quality", new Integer(getValue())); + } +} 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 PrinterResolutionDefault 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 ResolutionSyntax 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 true if both objects are equal, + * false otherwise. + */ + public boolean equals(Object obj) + { + if(! (obj instanceof PrinterResolutionDefault)) + return false; + + return super.equals(obj); + } + + /** + * Returns category of this class. + * + * @return The class PrinterResolutionDefault itself. + */ + public Class getCategory() + { + return PrinterResolutionDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-resolution-default". + */ + public String getName() + { + return "printer-resolution-default"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return new PrinterResolution(getCrossFeedResolutionDphi(), + getFeedResolutionDphi(), 1); + } +} 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; + + +/** + * SidesDefault 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 SidesDefault object. + * + * @param value the value of the enum + */ + protected SidesDefault(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class SidesDefault itself. + */ + public Class getCategory() + { + return SidesDefault.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "sides-default". + */ + public String getName() + { + return "sides-default"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the equally enum of the standard attribute class + * of this DefaultValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Attribute getAssociatedAttribute() + { + return IppUtilities.getEnumAttribute("sides", new Integer(getValue())); + } +} 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. + *

+ * 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.
+ * All clients and IPP objects must support the 'utf-8' charset. + *

+ * + * @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 AttributesCharset object. + * + * @param value the charset string value. + */ + public AttributesCharset(String value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class AttributesCharset itself. + */ + public Class 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. + *

+ * 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. + *

+ * + * @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 AttributesNaturalLanguage object. + * + * @param value the language string value. + */ + public AttributesNaturalLanguage(String value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class AttributesNaturalLanguage itself. + */ + public Class getCategory() + { + return AttributesNaturalLanguage.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "attributes-natural-language". + */ + public String getName() + { + return "attributes-natural-language"; + } +} 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 JobDetailedStatusMessages object with the given value + * and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobDetailedStatusMessages itself. + */ + public Class getCategory() + { + return JobDetailedStatusMessages.class; + } + + + /** + * Returns the name of this attribute. + * + * @return The name "job-detailed-status-messages". + */ + public String getName() + { + return "job-detailed-status-messages"; + } + +} 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 JobDocumentAccessErrors object with the given value + * and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobDocumentAccessErrors itself. + */ + public Class getCategory() + { + return JobDocumentAccessErrors.class; + } + + + /** + * Returns the name of this attribute. + * + * @return The name "job-document-access-errors". + */ + public String getName() + { + return "job-document-access-errors"; + } + +} 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 JobId 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 IntegerSyntax with the given value. + * + * @param value the integer to set + * @throws IllegalArgumentException if value is < 1 + */ + public JobId(int value) + { + super(value); + + if (value < 1) + throw new IllegalArgumentException("job-id may not be less than 1"); + } + + /** + * Returns category of this class. + * + * @return The class JobId itself. + */ + public Class 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 JobMoreInfo 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 JobMoreInfo itself. + */ + public Class getCategory() + { + return JobMoreInfo.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "job-more-info". + */ + public String getName() + { + return "job-more-info"; + } + +} 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 JobPrinterUri 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 JobPrinterUri itself. + */ + public Class getCategory() + { + return JobPrinterUri.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "job-printer-uri". + */ + public String getName() + { + return "job-printer-uri"; + } + +} 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 JobStateMessage object with the given value + * and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobStateMessage itself. + */ + public Class getCategory() + { + return JobStateMessage.class; + } + + + /** + * Returns the name of this attribute. + * + * @return The name "job-state-message". + */ + public String getName() + { + return "job-state-message"; + } + +} 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 JobUri 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 JobUri itself. + */ + public Class 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 CharsetConfigured object. + * + * @param value the charset string value. + */ + public CharsetConfigured(String value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class CharsetConfigured itself. + */ + public Class 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; + +/** + * DocumentFormatSupported 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 DocumentFormat object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 DocumentFormat itself. + */ + public Class 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 MultipleOperationTimeOut with the given value. + * + * @param value the integer to set + */ + public MultipleOperationTimeOut(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class MultipleOperationTimeOut itself. + */ + public Class getCategory() + { + return MultipleOperationTimeOut.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "multiple-operation-time-out". + */ + public String getName() + { + return "multiple-operation-time-out"; + } + +} 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 NaturalLanguageConfigured object. + * + * @param value the charset string value. + */ + public NaturalLanguageConfigured(String value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class NaturalLanguageConfigured itself. + */ + public Class getCategory() + { + return NaturalLanguageConfigured.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "natural-language-configured". + */ + public String getName() + { + return "natural-language-configured"; + } + +} 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 PrinterCurrentTime 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 true if both objects are equal, + * false otherwise. + */ + public boolean equals(Object obj) + { + if(! (obj instanceof PrinterCurrentTime)) + return false; + + return super.equals(obj); + } + + /** + * Returns category of this class. + * + * @return The class PrinterCurrentTime itself. + */ + public Class getCategory() + { + return PrinterCurrentTime.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-current-time". + */ + public String getName() + { + return "printer-current-time"; + } + +} 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 PrinterDriverInstaller 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 PrinterDriverInstaller itself. + */ + public Class getCategory() + { + return PrinterDriverInstaller.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-driver-installer". + */ + public String getName() + { + return "printer-driver-installer"; + } + +} 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 PrinterStateMessage object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 PrinterStateMessage itself. + */ + public Class getCategory() + { + return PrinterStateMessage.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-state-message". + */ + public String getName() + { + return "printer-state-message"; + } + +} 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 PrinterUpTime with the given value. + * + * @param value the integer to set + */ + public PrinterUpTime(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class PrinterUpTime itself. + */ + public Class getCategory() + { + return PrinterUpTime.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-up-time". + */ + public String getName() + { + return "printer-up-time"; + } + +} 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 CharsetSupported object. + * + * @param value the charset string value. + */ + public CharsetSupported(String value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class CharsetSupported itself. + */ + public Class 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; + + +/** + * CompressionSupported 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 CompressionSupported object. + * + * @param value the enum value + */ + protected CompressionSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class CompressionSupported itself. + */ + public Class getCategory() + { + return CompressionSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "compression-supported". + */ + public String getName() + { + return "compression-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Compression getAssociatedAttribute() + { + return (Compression) IppUtilities.getEnumAttribute( + "compression", new Integer(getValue())); + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static Compression[] + getAssociatedAttributeArray(Set set) + { + 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; + +/** + * DocumentFormatSupported 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 DocumentFormatSupported object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 DocumentFormatSupported itself. + */ + public Class getCategory() + { + return DocumentFormatSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "document-format-supported". + */ + public String getName() + { + return "document-format-supported"; + } + +} 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 FinishingsSupported 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 FinishingsSupported object. + * + * @param value the value + */ + protected FinishingsSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return the class FinishingsSupported itself + */ + public Class getCategory() + { + return FinishingsSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "finishings-supported". + */ + public String getName() + { + return "finishings-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the lowest used value by the enumerations of this class. + * . + * @return The lowest value used. + */ + protected int getOffset() + { + return 3; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public Finishings getAssociatedAttribute() + { + return (Finishings) IppUtilities.getEnumAttribute( + "finishings", new Integer(getValue())); + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static Finishings[] + getAssociatedAttributeArray(Set set) + { + 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 GeneratedNaturalLanguageSupported object. + * + * @param value the charset string value. + */ + public GeneratedNaturalLanguageSupported(String value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class GeneratedNaturalLanguageSupported itself. + */ + public Class getCategory() + { + return GeneratedNaturalLanguageSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "generated-natural-language-supported". + */ + public String getName() + { + return "generated-natural-language-supported"; + } + +} 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 IppVersionsSupported object. + * + * @param value the enum value + */ + public IppVersionsSupported(int value) + { + super(value); + } + + /** + * Returns the category of this class. + * + * @return The class IppVersionsSupported itself. + */ + public Class getCategory() + { + return IppVersionsSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "ipp-versions-supported". + */ + public String getName() + { + return "ipp-versions-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + +} 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 JobHoldUntilSupported object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobHoldUntilSupported itself. + */ + public Class getCategory() + { + return JobHoldUntilSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "job-hold-until-supported". + */ + public String getName() + { + return "job-hold-until-supported"; + } + +} 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 JobSheetsSupported object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 JobSheetsSupported itself. + */ + public Class getCategory() + { + return JobSheetsSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "job-sheets-supported". + */ + public String getName() + { + return "job-sheets-supported"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + *

May return null if no value exists in JPS API.

+ * + * @return The enum of the standard attribute class. + */ + public JobSheets getAssociatedAttribute() + { + if (this.equals(JobSheetsDefault.NONE)) + return JobSheets.NONE; + if (this.equals(JobSheetsDefault.STANDARD)) + return JobSheets.STANDARD; + + return null; + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static JobSheets[] + getAssociatedAttributeArray(Set set) + { + ArrayList result = new ArrayList(); + 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 MediaSupported object with the + * given value and locale. + * + * @param value the value for this syntax + * @param locale the locale to use, if null 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 MediaSupported itself. + */ + public Class getCategory() + { + return MediaSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "media-supported". + */ + public String getName() + { + return "media-supported"; + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + */ + public static Media[] getAssociatedAttributeArray(Set set) + { + Media tmp2; + ArrayList result = new ArrayList(); + 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; + + +/** + * MultipleDocumentHandlingSupported 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 MultipleDocumentHandlingSupported object. + * + * @param value the enum value + */ + protected MultipleDocumentHandlingSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class MultipleDocumentHandlingSupported itself. + */ + public Class getCategory() + { + return MultipleDocumentHandlingSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "multiple-document-handling-supported". + */ + public String getName() + { + return "multiple-document-handling-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public MultipleDocumentHandling getAssociatedAttribute() + { + return (MultipleDocumentHandling) IppUtilities.getEnumAttribute( + "multiple-document-handling", new Integer(getValue())); + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static MultipleDocumentHandling[] + getAssociatedAttributeArray(Set set) + { + 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; + +/** + * MultipleDocumentJobsSupported 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 MultipleDocumentJobsSupported object. + * + * @param value the enum value + */ + protected MultipleDocumentJobsSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class MultipleDocumentJobsSupported itself. + */ + public Class getCategory() + { + return MultipleDocumentJobsSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "multiple-document-jobs-supported". + */ + public String getName() + { + return "multiple-document-jobs-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + +} 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; + +/** + * OperationsSupported 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 OperationsSupported object. + * + * @param value the enum value + */ + protected OperationsSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class OperationsSupported itself. + */ + public Class getCategory() + { + return OperationsSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "operations-supported". + */ + public String getName() + { + return "operations-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + // we start with 2 + protected int getOffset() + { + return 2; + } +} 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 OrientationRequestedSupported 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 OrientationRequestedSupported object. + * + * @param value the value + */ + protected OrientationRequestedSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class OrientationRequestedSupported itself. + */ + public Class getCategory() + { + return OrientationRequestedSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "orientation-requested-supported". + */ + public String getName() + { + return "orientation-requested-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the lowest used value by the enumerations of this class. + * . + * @return The lowest value used. + */ + protected int getOffset() + { + return 3; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public OrientationRequested getAssociatedAttribute() + { + return (OrientationRequested) IppUtilities.getEnumAttribute( + "orientation-requested", new Integer(getValue())); + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static OrientationRequested[] + getAssociatedAttributeArray(Set set) + { + 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; + +/** + * PageRangesSupported 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 PageRangesSupported object. + * + * @param value the enum value + */ + protected PageRangesSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class PageRangesSupported itself. + */ + public Class getCategory() + { + return PageRangesSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "page-ranges-supported". + */ + public String getName() + { + return "page-ranges-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } +} 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; + + +/** + * PrintQualitySupported 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 PrintQualitySupported object. + * + * @param value the value of the enum + */ + protected PrintQualitySupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class PrintQualitySupported itself. + */ + public Class getCategory() + { + return PrintQualitySupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "print-quality-supported". + */ + public String getName() + { + return "print-quality-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + + /** + * Returns the lowest used value by the enumerations of this class. + * . + * @return The lowest value used. + */ + protected int getOffset() + { + return 3; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public PrintQuality getAssociatedAttribute() + { + return (PrintQuality) IppUtilities.getEnumAttribute( + "print-quality", new Integer(getValue())); + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static PrintQuality[] getAssociatedAttributeArray(Set set) + { + 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 PrinterResolutionSupported 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 PrinterResolutionSupported 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 true if both objects are equal, + * false otherwise. + */ + public boolean equals(Object obj) + { + if(! (obj instanceof PrinterResolutionSupported)) + return false; + + return super.equals(obj); + } + + /** + * Returns category of this class. + * + * @return The class PrinterResolutionSupported itself. + */ + public Class getCategory() + { + return PrinterResolutionSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-resolution-supported". + */ + public String getName() + { + return "printer-resolution-supported"; + } + + /** + * Returns the equally enum of the standard attribute class + * of this SupportedValuesAttribute enum. + * + * @return The enum of the standard attribute class. + */ + public PrinterResolution getAssociatedAttribute() + { + return new PrinterResolution(getCrossFeedResolutionDphi(), + getFeedResolutionDphi(), 1); + } + + /** + * Constructs an array from a set of -supported attributes. + * @param set set to process + * @return The constructed array. + * + * @see #getAssociatedAttribute() + */ + public static PrinterResolution[] + getAssociatedAttributeArray(Set set) + { + 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 PrinterUriSupported 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 PrinterUriSupported itself. + */ + public Class getCategory() + { + return PrinterUriSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "printer-uri-supported". + */ + public String getName() + { + return "printer-uri-supported"; + } + +} 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; + + +/** + * SidesSupported 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 SidesSupported object. + * + * @param value the value of the enum + */ + protected SidesSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class SidesSupported itself. + */ + public Class getCategory() + { + return SidesSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "sides-supported". + */ + public String getName() + { + return "sides-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } +} 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 UriAuthenticationSupported object. + * + * @param value the enum value + */ + public UriAuthenticationSupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class UriAuthenticationSupported itself. + */ + public Class getCategory() + { + return UriAuthenticationSupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "uri-authentication-supported". + */ + public String getName() + { + return "uri-authentication-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + +} 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 UriSecuritySupported object. + * + * @param value the enum value + */ + public UriSecuritySupported(int value) + { + super(value); + } + + /** + * Returns category of this class. + * + * @return The class UriSecuritySupported itself. + */ + public Class getCategory() + { + return UriSecuritySupported.class; + } + + /** + * Returns the name of this attribute. + * + * @return The name "uri-security-supported". + */ + public String getName() + { + return "uri-security-supported"; + } + + /** + * Returns a table with the enumeration values represented as strings + * for this object. + * + * @return The enumeration values as strings. + */ + protected String[] getStringTable() + { + return stringTable; + } + + /** + * Returns a table with the enumeration values for this object. + * + * @return The enumeration values. + */ + protected EnumSyntax[] getEnumValueTable() + { + return enumValueTable; + } + +} -- cgit v1.2.3