diff options
Diffstat (limited to 'libjava/classpath/gnu/javax')
79 files changed, 2091 insertions, 2078 deletions
diff --git a/libjava/classpath/gnu/javax/print/CupsIppOperation.java b/libjava/classpath/gnu/javax/print/CupsIppOperation.java index e9151691124..96744c1f362 100644 --- a/libjava/classpath/gnu/javax/print/CupsIppOperation.java +++ b/libjava/classpath/gnu/javax/print/CupsIppOperation.java @@ -1,4 +1,4 @@ -/* CupsIppOperation.java -- +/* CupsIppOperation.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,55 +45,55 @@ package gnu.javax.print; * See: CUPS Implementation of IPP, chapter 3.2<br> * http://www.cups.org/doc-1.1/ipp.html * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class CupsIppOperation { /** Get the default destination - since CUPS 1.0 */ - public static final int CUPS_GET_DEFAULT = 0x4001; - + public static final int CUPS_GET_DEFAULT = 0x4001; + /** Get all of the available printers - since CUPS 1.0 */ public static final int CUPS_GET_PRINTERS = 0x4002; - + /** Add or modify a printer - since CUPS 1.0 */ public static final int CUPS_ADD_MODIFY_PRINTER = 0x4003; - + /** Delete a printer - since CUPS 1.0 */ public static final int CUPS_DELETE_PRINTER = 0x4004; - + /** Get all of the available printer classes - since CUPS 1.0 */ public static final int CUPS_GET_CLASSES = 0x4005; - + /** Add or modify a printer class - since CUPS 1.0 */ public static final int CUPS_ADD_MODIFY_CLASS = 0x4006; - + /** Delete a printer class - since CUPS 1.0 */ public static final int CUPS_DELETE_CLASS = 0x4007; - + /** Accept jobs on a printer or printer class - since CUPS 1.0 */ public static final int CUPS_ACCEPT_JOBS = 0x4008; - + /** Reject jobs on a printer or printer class - since CUPS 1.0 */ public static final int CUPS_REJECT_JOBS = 0x4009; - + /** Set the default destination - since CUPS 1.0 */ public static final int CUPS_SET_DEFAULT = 0x400A; - + /** Get all of the available PPDs - since CUPS 1.1 */ public static final int CUPS_GET_DEVICES = 0x400B; - + /** Get all of the available PPDs - since CUPS 1.1 */ public static final int CUPS_GET_PPDS = 0x400C; - + /** Move a job to a different printer - since CUPS 1.1 */ public static final int CUPS_MOVE_JOB = 0x400D; - - + + private CupsIppOperation() - { + { // not to be instantiated } - + } diff --git a/libjava/classpath/gnu/javax/print/CupsMediaMapping.java b/libjava/classpath/gnu/javax/print/CupsMediaMapping.java index eaf2d5e54ae..49bd94d6f3d 100644 --- a/libjava/classpath/gnu/javax/print/CupsMediaMapping.java +++ b/libjava/classpath/gnu/javax/print/CupsMediaMapping.java @@ -1,4 +1,4 @@ -/* CupsMediaMapping.java -- +/* CupsMediaMapping.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -52,12 +52,12 @@ import javax.print.attribute.standard.MediaSizeName; * for use of media attribute translation between Java JPS API and * CUPS. * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class CupsMediaMapping { - // the mapping map + // the mapping map private static final HashMap ippByCups = new HashMap(); /** @@ -67,11 +67,11 @@ public class CupsMediaMapping { ippByCups.put("Postcard", MediaSizeName.JAPANESE_POSTCARD); ippByCups.put("Statement", MediaSizeName.INVOICE); - + ippByCups.put("Letter", MediaSizeName.NA_LETTER); ippByCups.put("Executive", MediaSizeName.EXECUTIVE); ippByCups.put("Legal", MediaSizeName.NA_LEGAL); - + ippByCups.put("A0", MediaSizeName.ISO_A0); ippByCups.put("A1", MediaSizeName.ISO_A1); ippByCups.put("A2", MediaSizeName.ISO_A2); @@ -83,7 +83,7 @@ public class CupsMediaMapping ippByCups.put("A8", MediaSizeName.ISO_A8); ippByCups.put("A9", MediaSizeName.ISO_A9); ippByCups.put("A10", MediaSizeName.ISO_A10); - + ippByCups.put("B0", MediaSizeName.JIS_B0); ippByCups.put("B1", MediaSizeName.JIS_B1); ippByCups.put("B2", MediaSizeName.JIS_B2); @@ -95,7 +95,7 @@ public class CupsMediaMapping ippByCups.put("B8", MediaSizeName.JIS_B8); ippByCups.put("B9", MediaSizeName.JIS_B9); ippByCups.put("B10", MediaSizeName.JIS_B10); - + ippByCups.put("ISOB0", MediaSizeName.ISO_B0); ippByCups.put("ISOB1", MediaSizeName.ISO_B1); ippByCups.put("ISOB2", MediaSizeName.ISO_B2); @@ -118,7 +118,7 @@ public class CupsMediaMapping ippByCups.put("EnvISOB8", MediaSizeName.ISO_B8); ippByCups.put("EnvISOB9", MediaSizeName.ISO_B9); ippByCups.put("EnvISOB10", MediaSizeName.ISO_B10); - + ippByCups.put("C0", MediaSizeName.ISO_C0); ippByCups.put("C1", MediaSizeName.ISO_C1); ippByCups.put("C2", MediaSizeName.ISO_C2); @@ -136,7 +136,7 @@ public class CupsMediaMapping ippByCups.put("Env12", MediaSizeName.NA_NUMBER_12_ENVELOPE); ippByCups.put("Env14", MediaSizeName.NA_NUMBER_14_ENVELOPE); ippByCups.put("c8x10", MediaSizeName.NA_8X10); - + ippByCups.put("EnvDL", MediaSizeName.ISO_DESIGNATED_LONG); ippByCups.put("DL", MediaSizeName.ISO_DESIGNATED_LONG); ippByCups.put("EnvC0", MediaSizeName.ISO_C0); @@ -145,12 +145,12 @@ public class CupsMediaMapping ippByCups.put("EnvC3", MediaSizeName.ISO_C3); ippByCups.put("EnvC4", MediaSizeName.ISO_C4); ippByCups.put("EnvC5", MediaSizeName.ISO_C5); - ippByCups.put("EnvC6", MediaSizeName.ISO_C6); + ippByCups.put("EnvC6", MediaSizeName.ISO_C6); } - + /** * Returns the IPP media name of the given cups name. - * + * * @param cupsName the name in cups * @return The IPP name if a mapping is known, <code>null</code> otherwise. */ @@ -158,10 +158,10 @@ public class CupsMediaMapping { return (String) ippByCups.get(cupsName); } - + /** * Returns the mapping map for iteration. - * + * * @return The mapping map as unmodifiable map. */ public static final Map getMappingMap() @@ -169,7 +169,7 @@ public class CupsMediaMapping return Collections.unmodifiableMap(ippByCups); } - private CupsMediaMapping() + private CupsMediaMapping() { // not to be instantiated } diff --git a/libjava/classpath/gnu/javax/print/CupsPrintService.java b/libjava/classpath/gnu/javax/print/CupsPrintService.java index 4f77523c530..f3bec996c49 100644 --- a/libjava/classpath/gnu/javax/print/CupsPrintService.java +++ b/libjava/classpath/gnu/javax/print/CupsPrintService.java @@ -48,9 +48,9 @@ import javax.print.DocFlavor; import javax.print.attribute.AttributeSet; /** - * Implementation of the PrintService/MultiDocPrintService + * Implementation of the PrintService/MultiDocPrintService * interface for Cups printers (supports Cups 1.1 and up) - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class CupsPrintService extends IppMultiDocPrintService @@ -58,26 +58,26 @@ public final class CupsPrintService extends IppMultiDocPrintService /** * Creates a <code>CupsPrintService</code> object. - * + * * @param uri the URI of the IPP printer. * @param username the user of this print service. * @param password the password of the user. - * + * * @throws IppException if an error during connection occurs. */ public CupsPrintService(URI uri, String username, String password) throws IppException { super(uri, username, password); - } - + } + /** * Overridden for CUPS specific handling of the media attribute. */ - protected Object handleSupportedAttributeValuesResponse(IppResponse response, + protected Object handleSupportedAttributeValuesResponse(IppResponse response, Class category) { - // TODO Implement different behaviour of cups here - actually the Media + // TODO Implement different behaviour of cups here - actually the Media // printing attribute stuff. For now just use IPP reference implementation. return super.handleSupportedAttributeValuesResponse(response, category); } @@ -89,7 +89,7 @@ public final class CupsPrintService extends IppMultiDocPrintService { // TODO Implement media attribute behaviour for cups here //if (category.equals(Media.class) - + return super.getDefaultAttributeValue(category); } diff --git a/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java b/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java index 1aa83218a8d..d537c398fa6 100644 --- a/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java +++ b/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java @@ -51,12 +51,12 @@ import javax.print.attribute.AttributeSet; /** * The platform default implementation based on CUPS. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class CupsPrintServiceLookup extends PrintServiceLookup -{ - private CupsServer server; +{ + private CupsServer server; /** * Default constructor checking security access. @@ -67,14 +67,14 @@ public class CupsPrintServiceLookup extends PrintServiceLookup SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPrintJobAccess(); - + // use the localhost cups server server = new CupsServer(null, null); } /** * This is the printer marked as default in CUPS. - * + * * @return The default lookup service or * <code>null</code> if there is no default. */ @@ -83,21 +83,21 @@ public class CupsPrintServiceLookup extends PrintServiceLookup try { return server.getDefaultPrinter(); - } + } catch (IppException e) { // if discovery fails treat as if there is none return null; - } + } } - + /** * All printers and printer classes of the CUPS server are checked. * If flavors or attributes are null the constraint is not used. - * + * * @param flavors the document flavors which have to be supported. * @param attributes the attributes which have to be supported. - * + * * @return The multidoc print services of the implementing lookup service * for the given parameters, or an array of length 0 if none is available. */ @@ -105,49 +105,49 @@ public class CupsPrintServiceLookup extends PrintServiceLookup AttributeSet attributes) { ArrayList result = new ArrayList(); - PrintService[] services = getPrintServices(); - + PrintService[] services = getPrintServices(); + for (int i=0; i < services.length; i++) { if (checkMultiDocPrintService(flavors, attributes, services[i])) - result.add(services[i]); + result.add(services[i]); } - + return (MultiDocPrintService[]) result.toArray( new MultiDocPrintService[result.size()]); } /** * These are all printers and printer classes of the CUPS server. - * - * @return All known print services regardless of supported features, + * + * @return All known print services regardless of supported features, * or an array of length 0 if none is available. */ public PrintService[] getPrintServices() { ArrayList result = new ArrayList(); - + try { result.addAll(server.getAllPrinters()); result.addAll(server.getAllClasses()); } catch (IppException e) - { + { // ignore as this method cannot throw exceptions // if print service discovery fails - bad luck } return (PrintService[]) result.toArray(new PrintService[result.size()]); } - - + + /** * All printers and printer classes of the CUPS server are checked. * If flavor or attributes are null the constraint is not used. - * + * * @param flavor the document flavor which has to be supported. * @param attributes the attributes which have to be supported. - * + * * @return The print services of the implementing lookup service * for the given parameters, or an array of length 0 if none is available. */ @@ -156,25 +156,25 @@ public class CupsPrintServiceLookup extends PrintServiceLookup { ArrayList result = new ArrayList(); PrintService[] services = getPrintServices(); - + for (int i=0; i < services.length; i++) { if (checkPrintService(flavor, attributes, services[i])) result.add(services[i]); } - + return (PrintService[]) result.toArray(new PrintService[result.size()]); } - + /** * Checks the given print service - own method so it can be used also * to check application registered print services from PrintServiceLookup. - * + * * @param flavor the document flavor which has to be supported. * @param attributes the attributes which have to be supported. * @param service the service to check - * - * @return <code>true</code> if all constraints match, <code>false</code> + * + * @return <code>true</code> if all constraints match, <code>false</code> * otherwise. */ public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes, @@ -185,7 +185,7 @@ public class CupsPrintServiceLookup extends PrintServiceLookup { if (attributes == null || attributes.size() == 0) return allAttributesSupported; - + Attribute[] atts = attributes.toArray(); for (int i = 0; i < atts.length; i++) { @@ -197,29 +197,29 @@ public class CupsPrintServiceLookup extends PrintServiceLookup } return allAttributesSupported; } - + return false; } - + /** * Checks the given print service - own method so it can be used also * to check application registered print services from PrintServiceLookup. - * + * * @param flavors the document flavors which have to be supported. * @param attributes the attributes which have to be supported. * @param service the service to check - * - * @return <code>true</code> if all constraints match, <code>false</code> + * + * @return <code>true</code> if all constraints match, <code>false</code> * otherwise. */ - public boolean checkMultiDocPrintService(DocFlavor[] flavors, + public boolean checkMultiDocPrintService(DocFlavor[] flavors, AttributeSet attributes, PrintService service) - { + { if (service instanceof MultiDocPrintService) - { + { boolean allFlavorsSupported = true; boolean allAttributesSupported = true; - + if (flavors == null || flavors.length != 0) allFlavorsSupported = true; else @@ -233,7 +233,7 @@ public class CupsPrintServiceLookup extends PrintServiceLookup } } } - + if (attributes == null || attributes.size() == 0) allAttributesSupported = true; else @@ -249,11 +249,11 @@ public class CupsPrintServiceLookup extends PrintServiceLookup } } } - + if (allAttributesSupported && allFlavorsSupported) return true; - } - + } + return false; } diff --git a/libjava/classpath/gnu/javax/print/CupsServer.java b/libjava/classpath/gnu/javax/print/CupsServer.java index 0486e69deb0..6dbcfc7325e 100644 --- a/libjava/classpath/gnu/javax/print/CupsServer.java +++ b/libjava/classpath/gnu/javax/print/CupsServer.java @@ -1,4 +1,4 @@ -/* CupsServer.java -- +/* CupsServer.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,25 +58,25 @@ import java.util.Set; * compatible server. It mainly consists of its URI and optional * user and password combination if access is restricted. * <p> - * It provides methods for retrival of valid CUPS printer uris + * It provides methods for retrival of valid CUPS printer uris * that are used to construct IppPrintService objects. * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class CupsServer { - /** + /** * The URI of the CUPS server. * This is something like: http://localhost:631 */ private transient URI uri; - + /** * The optional username. */ private transient String username; - + /** * The optional password for the user. */ @@ -84,11 +84,11 @@ public class CupsServer /** * Creates a <code>CupsServer</code> object which - * tries to connect to a cups server. + * tries to connect to a cups server. * * If <code>gnu.javax.print.server</code> is explicitly set, then * that hostname will be used. Otherwise it will default to localhost. - * + * * @param username the username * @param password the password for the username. */ @@ -100,13 +100,13 @@ public class CupsServer this.uri = null; try { - String serv = System.getProperty("gnu.javax.print.server"); - if( serv != null ) - this.uri = new URI("http://"+serv+":631"); + String serv = System.getProperty("gnu.javax.print.server"); + if( serv != null ) + this.uri = new URI("http://"+serv+":631"); } catch(URISyntaxException use) { - throw new RuntimeException("gnu.javax.print.CupsServer value is not a valid hostname."); + throw new RuntimeException("gnu.javax.print.CupsServer value is not a valid hostname."); } catch(SecurityException se) { @@ -114,20 +114,20 @@ public class CupsServer try { - if( this.uri == null ) - this.uri = new URI("http://localhost:631"); + if( this.uri == null ) + this.uri = new URI("http://localhost:631"); } catch (URISyntaxException e) { // does not happen } } - + /** * Creates a <code>CupsServer</code> object which * tries to connect to a running cups server on the * given URI. - * + * * @param uri the URI of the server. * @param username the username * @param password the password for the username. @@ -138,75 +138,75 @@ public class CupsServer this.username = username; this.password = password; } - + /** * Requests the default printer from this CUPS server. * This is always returned as IppPrintService. - * + * * @return The default printer. * @throws IppException if problems during request/response processing occur. */ public IppPrintService getDefaultPrinter() throws IppException - { + { IppResponse response = null; - + try { - IppRequest request = new IppRequest(uri, username, password); - request.setOperationID((short)CupsIppOperation.CUPS_GET_DEFAULT); - request.setOperationAttributeDefaults(); - - RequestedAttributes requestedAttrs + IppRequest request = new IppRequest(uri, username, password); + request.setOperationID((short)CupsIppOperation.CUPS_GET_DEFAULT); + request.setOperationAttributeDefaults(); + + RequestedAttributes requestedAttrs = new RequestedAttributes("printer-uri-supported"); request.addOperationAttribute(requestedAttrs); - + response = request.send(); - } + } catch (IOException e) { throw new IppException("IOException in IPP request/response.", e); - } - + } + Map printerAttributes = (Map) response.getPrinterAttributes().get(0); Set uris = (Set) printerAttributes.get(PrinterUriSupported.class); PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0]; - - IppPrintService service + + IppPrintService service = new CupsPrintService(uri.getURI(), username, password); - + return service; } - + /** * Requests all printers from this CUPS server. - * + * * @return The list of available printers. * @throws IppException if problems during request/response processing occur. */ public List getAllPrinters() throws IppException - { + { IppResponse response = null; - + try { - IppRequest request = new IppRequest(uri, username, password); - request.setOperationID((short)CupsIppOperation.CUPS_GET_PRINTERS); + IppRequest request = new IppRequest(uri, username, password); + request.setOperationID((short)CupsIppOperation.CUPS_GET_PRINTERS); request.setOperationAttributeDefaults(); - - RequestedAttributes requestedAttrs + + RequestedAttributes requestedAttrs = new RequestedAttributes("printer-uri-supported"); request.addOperationAttribute(requestedAttrs); - + response = request.send(); - } + } catch (IOException e) { throw new IppException("IOException in IPP request/response.", e); - } + } List prAttr = response.getPrinterAttributes(); List services = new ArrayList(); - + for (int i=0; i < prAttr.size(); i++) { Map printerAttributes = (Map) prAttr.get(i); @@ -224,50 +224,50 @@ public class CupsServer // do nothing, we only catch the IppException which could be // thrown during instantiation as single printers may be discovered // correctly but not usable due to other security restrictions - } - } - + } + } + return services; } - + /** * Requests all classes from this CUPS server. Classes in cups are - * collections of printers. This means jobs directed to a class + * collections of printers. This means jobs directed to a class * are forwarded to the first available printer of the collection. - * + * * @return The list of available classes. * @throws IppException if problems during request/response processing occur. */ public List getAllClasses() throws IppException - { + { IppResponse response = null; - + try { - IppRequest request = new IppRequest(uri, username, password); - request.setOperationID((short)CupsIppOperation.CUPS_GET_CLASSES); + IppRequest request = new IppRequest(uri, username, password); + request.setOperationID((short)CupsIppOperation.CUPS_GET_CLASSES); request.setOperationAttributeDefaults(); - - RequestedAttributes requestedAttrs + + RequestedAttributes requestedAttrs = new RequestedAttributes("printer-uri-supported"); request.addOperationAttribute(requestedAttrs); - + response = request.send(); - } + } catch (IOException e) { throw new IppException("IOException in IPP request/response.", e); - } - + } + List prAttr = response.getPrinterAttributes(); - List services = new ArrayList(); - + List services = new ArrayList(); + for (int i=0; i < prAttr.size(); i++) { Map printerAttributes = (Map) prAttr.get(i); Set uris = (Set) printerAttributes.get(PrinterUriSupported.class); PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0]; - + try { CupsPrintService cups = new CupsPrintService(uri.getURI(), @@ -279,9 +279,9 @@ public class CupsServer // do nothing, we only catch the IppException which could be // thrown during instantiation as single printers may be discovered // correctly but not usable due to other security restrictions - } - } - + } + } + return services; } diff --git a/libjava/classpath/gnu/javax/print/PrintAttributeException.java b/libjava/classpath/gnu/javax/print/PrintAttributeException.java index 345193d93f7..5bcc59fc97c 100644 --- a/libjava/classpath/gnu/javax/print/PrintAttributeException.java +++ b/libjava/classpath/gnu/javax/print/PrintAttributeException.java @@ -1,4 +1,4 @@ -/* PrintAttributeException.java -- +/* PrintAttributeException.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,25 +46,25 @@ import javax.print.attribute.Attribute; * A <code>PrintException</code> further refining the exception * cause by providing an implementation of the print exception * interface <code>AttributeException</code>. - * + * * @see javax.print.PrintException * @see javax.print.AttributeException - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class PrintAttributeException extends PrintException +public final class PrintAttributeException extends PrintException implements AttributeException { private Class[] categories; private Attribute[] values; - + /** * Constructs a <code>PrintAttributeException</code> * with the given unsupported attributes and/or values. - * - * @param unsupportedAttributes the unsupported categories, + * + * @param unsupportedAttributes the unsupported categories, * may be <code>null</code>. - * @param unsupportedValues the unsupported attribute values, + * @param unsupportedValues the unsupported attribute values, * may be <code>null</code>. */ public PrintAttributeException(Class[] unsupportedAttributes, @@ -78,11 +78,11 @@ public final class PrintAttributeException extends PrintException /** * Constructs a <code>PrintAttributeException</code> * with the given unsupported attributes and/or values. - * + * * @param e chained exception - * @param unsupportedAttributes the unsupported categories, + * @param unsupportedAttributes the unsupported categories, * may be <code>null</code>. - * @param unsupportedValues the unsupported attribute values, + * @param unsupportedValues the unsupported attribute values, * may be <code>null</code>. */ public PrintAttributeException(Exception e, @@ -96,11 +96,11 @@ public final class PrintAttributeException extends PrintException /** * Constructs a <code>PrintAttributeException</code> * with the given unsupported attributes and/or values. - * + * * @param s detailed message - * @param unsupportedAttributes the unsupported categories, + * @param unsupportedAttributes the unsupported categories, * may be <code>null</code>. - * @param unsupportedValues the unsupported attribute values, + * @param unsupportedValues the unsupported attribute values, * may be <code>null</code>. */ public PrintAttributeException(String s, @@ -114,12 +114,12 @@ public final class PrintAttributeException extends PrintException /** * Constructs a <code>PrintAttributeException</code> * with the given unsupported attributes and/or values. - * + * * @param s detailed message * @param e chained exception - * @param unsupportedAttributes the unsupported categories, + * @param unsupportedAttributes the unsupported categories, * may be <code>null</code>. - * @param unsupportedValues the unsupported attribute values, + * @param unsupportedValues the unsupported attribute values, * may be <code>null</code>. */ public PrintAttributeException(String s, Exception e, diff --git a/libjava/classpath/gnu/javax/print/PrintFlavorException.java b/libjava/classpath/gnu/javax/print/PrintFlavorException.java index 1885e9851a1..a9342db961c 100644 --- a/libjava/classpath/gnu/javax/print/PrintFlavorException.java +++ b/libjava/classpath/gnu/javax/print/PrintFlavorException.java @@ -1,4 +1,4 @@ -/* PrintFlavorException.java -- +/* PrintFlavorException.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,21 +46,21 @@ import javax.print.PrintException; * A <code>PrintException</code> further refining the exception * cause by providing an implementation of the print exception * interface <code>FlavorException</code>. - * + * * @see javax.print.PrintException * @see javax.print.FlavorException - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public class PrintFlavorException extends PrintException +public class PrintFlavorException extends PrintException implements FlavorException { private DocFlavor[] flavors; - + /** * Constructs a <code>PrintFlavorException</code> * with the given unsupported doc flavor array - * + * * @param unsupportedFlavors the unsupported document flavors. */ public PrintFlavorException(DocFlavor[] unsupportedFlavors) @@ -72,7 +72,7 @@ public class PrintFlavorException extends PrintException /** * Constructs a <code>PrintFlavorException</code> * with the given unsupported doc flavor array - * + * * @param e chained exception * @param unsupportedFlavors the unsupported document flavors. */ @@ -85,7 +85,7 @@ public class PrintFlavorException extends PrintException /** * Constructs a <code>PrintFlavorException</code> * with the given unsupported doc flavor array - * + * * @param s detailed message * @param unsupportedFlavors the unsupported document flavors. */ @@ -98,12 +98,12 @@ public class PrintFlavorException extends PrintException /** * Constructs a <code>PrintFlavorException</code> * with the given unsupported doc flavor array - * + * * @param s detailed message * @param e chained exception * @param unsupportedFlavors the unsupported document flavors. */ - public PrintFlavorException(String s, Exception e, + public PrintFlavorException(String s, Exception e, DocFlavor[] unsupportedFlavors) { super(s, e); diff --git a/libjava/classpath/gnu/javax/print/PrintUriException.java b/libjava/classpath/gnu/javax/print/PrintUriException.java index d031000cadb..9c13c132a50 100644 --- a/libjava/classpath/gnu/javax/print/PrintUriException.java +++ b/libjava/classpath/gnu/javax/print/PrintUriException.java @@ -1,4 +1,4 @@ -/* PrintUriException.java -- +/* PrintUriException.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,13 +47,13 @@ import javax.print.URIException; * A <code>PrintException</code> further refining the exception * cause by providing an implementation of the print exception * interface <code>URIException</code>. - * + * * @see javax.print.PrintException * @see javax.print.URIException - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class PrintUriException extends PrintException +public final class PrintUriException extends PrintException implements URIException { private int reason; @@ -65,20 +65,20 @@ public final class PrintUriException extends PrintException * * @param reason the reason for the exception. * @param unsupportedUri the URI which is unsupported. - * + * * @see URIException */ public PrintUriException(int reason, URI unsupportedUri) { super(); this.reason = reason; - uri = unsupportedUri; + uri = unsupportedUri; } /** * Constructs a <code>PrintUriException</code> with the given reason * and unsupported URI instance. - * + * * @param e chained exception * @param reason the reason for the exception. * @param unsupportedUri the URI which is unsupported. @@ -87,13 +87,13 @@ public final class PrintUriException extends PrintException { super(e); this.reason = reason; - uri = unsupportedUri; + uri = unsupportedUri; } /** * Constructs a <code>PrintUriException</code> with the given reason * and unsupported URI instance. - * + * * @param s detailed message * @param reason the reason for the exception. * @param unsupportedUri the URI which is unsupported. @@ -102,24 +102,24 @@ public final class PrintUriException extends PrintException { super(s); this.reason = reason; - uri = unsupportedUri; + uri = unsupportedUri; } /** * Constructs a <code>PrintUriException</code> with the given reason * and unsupported URI instance. - * + * * @param s detailed message * @param e chained exception * @param reason the reason for the exception. * @param unsupportedUri the URI which is unsupported. */ - public PrintUriException(String s, Exception e, + public PrintUriException(String s, Exception e, int reason, URI unsupportedUri) { super(s, e); this.reason = reason; - uri = unsupportedUri; + uri = unsupportedUri; } /** diff --git a/libjava/classpath/gnu/javax/print/PrinterDialog.java b/libjava/classpath/gnu/javax/print/PrinterDialog.java index 54d6b87b47c..6557baf4f81 100644 --- a/libjava/classpath/gnu/javax/print/PrinterDialog.java +++ b/libjava/classpath/gnu/javax/print/PrinterDialog.java @@ -98,12 +98,12 @@ import javax.swing.event.ChangeListener; * Implementation of the PrinterDialog used by * {@link javax.print.ServiceUI} for visual selection * of print services and its attributes. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class PrinterDialog extends JDialog implements ActionListener { - + /** * The General Panel used in the printing dialog. * @author Wolfgang Baer (WBaer@gmx.de) @@ -114,57 +114,57 @@ public final class PrinterDialog extends JDialog implements ActionListener * Handles the copies attribute. * @author Wolfgang Baer (WBaer@gmx.de) */ - final class CopiesAndSorted extends JPanel + final class CopiesAndSorted extends JPanel implements ChangeListener, ActionListener - { - private JCheckBox sort; + { + private JCheckBox sort; private JSpinner copies; private JLabel copies_lb; private SpinnerNumberModel copiesModel; - + CopiesAndSorted() { - copies_lb = new JLabel(getLocalizedString("lb.copies")); + copies_lb = new JLabel(getLocalizedString("lb.copies")); sort = new JCheckBox(getLocalizedString("cb.sort")); sort.addActionListener(this); - + copiesModel = new SpinnerNumberModel(1, 1, 9999, 1); copies = new JSpinner(copiesModel); copies.addChangeListener(this); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.insets = new Insets(5, 5, 5, 5); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.copies"))); - + c.anchor = GridBagConstraints.WEST; - + c.gridx = 0; c.gridy = 0; add(copies_lb, c); - + c.gridx = 1; c.gridy = 0; add(copies, c); - + c.gridx = 0; c.gridy = 1; add(sort, c); } - + // copies jspinner state public void stateChanged(ChangeEvent event) { int value = ((Integer) copies.getValue()).intValue(); atts.add(new Copies(value)); - + if (value > 1 && categorySupported(SheetCollate.class)) sort.setEnabled(true); else - sort.setEnabled(false); + sort.setEnabled(false); } // sorted checkbox state @@ -180,30 +180,30 @@ public final class PrinterDialog extends JDialog implements ActionListener * selected attributes are supported. */ void updateForSelectedService() - { + { if (categorySupported(Copies.class)) { copies.setEnabled(true); copies_lb.setEnabled(true); - + Copies copies = (Copies) attribute(Copies.class); if (copies != null) copiesModel.setValue(new Integer(copies.getValue())); - - if (((Integer)copiesModel.getValue()).intValue() > 1 + + if (((Integer)copiesModel.getValue()).intValue() > 1 && categorySupported(SheetCollate.class)) { sort.setEnabled(true); Attribute collate = attribute(SheetCollate.class); if (collate != null && collate.equals(SheetCollate.COLLATED)) - sort.setSelected(true); + sort.setSelected(true); } else sort.setEnabled(false); } else { - copies.setEnabled(false); + copies.setEnabled(false); copies_lb.setEnabled(false); } } @@ -213,18 +213,18 @@ public final class PrinterDialog extends JDialog implements ActionListener * Handles the print ranges attribute. * @author Wolfgang Baer (WBaer@gmx.de) */ - final class PrintRange extends JPanel + final class PrintRange extends JPanel implements ActionListener, FocusListener - { - private JLabel to; - private JRadioButton all_rb, pages_rb; + { + private JLabel to; + private JRadioButton all_rb, pages_rb; private JTextField from_tf, to_tf; - + PrintRange() - { + { to = new JLabel(getLocalizedString("lb.to")); to.setEnabled(false); - + all_rb = new JRadioButton(getLocalizedString("rbt.all")); all_rb.setSelected(true); all_rb.setActionCommand("ALL"); @@ -233,86 +233,86 @@ public final class PrinterDialog extends JDialog implements ActionListener pages_rb.setActionCommand("PAGES"); pages_rb.setEnabled(false); pages_rb.addActionListener(this); - + ButtonGroup group = new ButtonGroup(); group.add(all_rb); group.add(pages_rb); - + from_tf = new JTextField("1", 4); from_tf.setEnabled(false); from_tf.addFocusListener(this); to_tf = new JTextField("1", 4); to_tf.setEnabled(false); to_tf.addFocusListener(this); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.printrange"))); - + c.insets = new Insets(15, 5, 5, 5); c.gridx = 0; c.gridy = 0; add(all_rb, c); - + c.insets = new Insets(5, 5, 15, 5); c.gridx = 0; c.gridy = 1; add(pages_rb, c); - + c.gridx = 1; c.gridy = 1; add(from_tf, c); - + c.gridx = 2; c.gridy = 1; add(to, c); - + c.insets = new Insets(5, 5, 15, 15); c.gridx = 3; c.gridy = 1; add(to_tf, c); } - + // focus pagerange public void focusGained(FocusEvent event) { updatePageRanges(); } - + public void focusLost(FocusEvent event) { updatePageRanges(); } - + // updates the range after user changed it private void updatePageRanges() { int lower = Integer.parseInt(from_tf.getText()); int upper = Integer.parseInt(to_tf.getText()); - + if (lower > upper) { upper = lower; - to_tf.setText("" + lower); + to_tf.setText("" + lower); } - + PageRanges range = new PageRanges(lower, upper); atts.add(range); } // page range change public void actionPerformed(ActionEvent e) - { + { // if ALL is selected we must use a full-range object if (e.getActionCommand().equals("ALL")) { from_tf.setEnabled(false); to.setEnabled(false); to_tf.setEnabled(false); - + atts.add(new PageRanges(1, Integer.MAX_VALUE)); } else @@ -321,9 +321,9 @@ public final class PrinterDialog extends JDialog implements ActionListener to.setEnabled(true); to_tf.setEnabled(true); all_rb.setSelected(false); - } + } } - + /** * Called to update for new selected * print service. Tests if currently @@ -339,12 +339,12 @@ public final class PrinterDialog extends JDialog implements ActionListener { from_tf.setEnabled(true); to.setEnabled(true); - to_tf.setEnabled(true); + to_tf.setEnabled(true); all_rb.setSelected(false); pages_rb.setSelected(true); - + int[][] members = range.getMembers(); - // Although passed in attributes may contain more than one + // Although passed in attributes may contain more than one // range we only take the first one from_tf.setText("" + members[0][0]); to_tf.setText("" + members[0][1]); @@ -365,15 +365,15 @@ public final class PrinterDialog extends JDialog implements ActionListener * and its location and description attributes. * @author Wolfgang Baer (WBaer@gmx.de) */ - final class PrintServices extends JPanel + final class PrintServices extends JPanel implements ActionListener - { + { private JLabel name, status, typ, info; - private JLabel statusValue, typValue, infoValue; - private JButton attributes; - private JComboBox services_cob; + private JLabel statusValue, typValue, infoValue; + private JButton attributes; + private JComboBox services_cob; private JCheckBox fileRedirection_cb; - + PrintServices() { name = new JLabel(getLocalizedString("lb.name")); @@ -383,79 +383,79 @@ public final class PrinterDialog extends JDialog implements ActionListener typValue = new JLabel(); infoValue = new JLabel(); statusValue = new JLabel(); - + attributes = new JButton(getLocalizedString("bt.attributes")); attributes.setEnabled(false); attributes.setActionCommand("ATTRIBUTES"); attributes.addActionListener(this); - + services_cob = new JComboBox(getPrintServices()); services_cob.setActionCommand("SERVICE"); services_cob.addActionListener(this); - + fileRedirection_cb = new JCheckBox(getLocalizedString("cb.output")); fileRedirection_cb.setEnabled(false); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.printservice"))); - + c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.LINE_END; c.gridx = 0; c.gridy = 0; add(name, c); - + c.gridx = 0; c.gridy = 1; add(status, c); - + c.gridx = 0; c.gridy = 2; add(typ, c); - + c.gridx = 0; c.gridy = 3; add(info, c); - + c.gridx = 2; c.gridy = 3; c.weightx = 1; add(fileRedirection_cb, c); - + c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; c.weightx = 1.5; add(services_cob, c); - + c.gridx = 1; c.gridy = 1; c.gridwidth = 2; c.weightx = 1; add(statusValue, c); - + c.gridx = 1; c.gridy = 2; c.gridwidth = 2; c.weightx = 1; add(typValue, c); - + c.gridx = 1; c.gridy = 3; c.gridwidth = 2; c.weightx = 1; add(infoValue, c); - + c.gridx = 2; c.gridy = 0; c.weightx = 1.5; add(attributes, c); } - + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("SERVICE")) @@ -465,13 +465,13 @@ public final class PrinterDialog extends JDialog implements ActionListener } else if (e.getActionCommand().equals("ATTRIBUTES")) { - // TODO LowPriority-Enhancement: As tests have shown this button + // TODO LowPriority-Enhancement: As tests have shown this button // is even gray and not enabled under Windows - Its a good place - // to provide a classpath specific browsing dialog for all - // attributes not in the default printing dialog. + // to provide a classpath specific browsing dialog for all + // attributes not in the default printing dialog. } - } - + } + /** * Called to update for new selected * print service. Tests if currently @@ -482,30 +482,30 @@ public final class PrinterDialog extends JDialog implements ActionListener PrinterMakeAndModel att1 = getSelectedPrintService().getAttribute(PrinterMakeAndModel.class); typValue.setText(att1 == null ? "" : att1.getValue()); - - PrinterInfo att2 = + + PrinterInfo att2 = getSelectedPrintService().getAttribute(PrinterInfo.class); infoValue.setText(att2 == null ? "" : att2.getValue()); - + PrinterIsAcceptingJobs att3 = getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class); PrinterState att4 = getSelectedPrintService().getAttribute(PrinterState.class); - - String status = att4.toString(); + + String status = att4.toString(); if (att3 == PrinterIsAcceptingJobs.ACCEPTING_JOBS) status += " - " + getLocalizedString("lb.acceptingjobs"); else if (att3 == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) status += " - " + getLocalizedString("lb.notacceptingjobs"); - + statusValue.setText(status); - + if (categorySupported(Destination.class)) { fileRedirection_cb.setEnabled(false); } } - + } private PrintServices printserv_panel; @@ -516,7 +516,7 @@ public final class PrinterDialog extends JDialog implements ActionListener * Constructs the General Panel. */ public GeneralPanel() - { + { setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); printserv_panel = new PrintServices(); @@ -534,7 +534,7 @@ public final class PrinterDialog extends JDialog implements ActionListener add(Box.createRigidArea(new Dimension(0, 12))); add(layout_panel); } - + /** * Calls update on all internal panels to adjust * for a new selected print service. @@ -560,7 +560,7 @@ public final class PrinterDialog extends JDialog implements ActionListener final class Orientation extends JPanel implements ActionListener { private JRadioButton portrait, landscape, rev_portrait, rev_landscape; - + Orientation() { portrait = new JRadioButton(getLocalizedString("rbt.portrait")); @@ -571,38 +571,38 @@ public final class PrinterDialog extends JDialog implements ActionListener rev_portrait.addActionListener(this); rev_landscape = new JRadioButton(getLocalizedString("rbt.revlandscape")); rev_landscape.addActionListener(this); - + ButtonGroup group = new ButtonGroup(); group.add(portrait); group.add(landscape); group.add(rev_portrait); group.add(rev_landscape); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.orientation"))); - + c.insets = new Insets(5, 5, 5, 5); c.gridx = 0; c.gridy = 0; add(portrait, c); - + c.gridx = 0; c.gridy = 1; add(landscape, c); - + c.gridx = 0; c.gridy = 2; add(rev_portrait, c); - + c.gridx = 0; c.gridy = 3; add(rev_landscape, c); } - + // event handling orientation public void actionPerformed(ActionEvent e) { @@ -613,9 +613,9 @@ public final class PrinterDialog extends JDialog implements ActionListener else if (e.getSource() == rev_portrait) atts.add(OrientationRequested.REVERSE_PORTRAIT); else - atts.add(OrientationRequested.REVERSE_LANDSCAPE); + atts.add(OrientationRequested.REVERSE_LANDSCAPE); } - + /** * Called to update for new selected * print service. Tests if currently @@ -629,7 +629,7 @@ public final class PrinterDialog extends JDialog implements ActionListener landscape.setEnabled(true); rev_landscape.setEnabled(true); rev_portrait.setEnabled(true); - + Attribute orientation = attribute(OrientationRequested.class); if (orientation != null) { @@ -639,7 +639,7 @@ public final class PrinterDialog extends JDialog implements ActionListener portrait.setSelected(true); else if (orientation.equals(OrientationRequested.REVERSE_PORTRAIT)) rev_portrait.setSelected(true); - else + else rev_landscape.setSelected(true); } else @@ -651,7 +651,7 @@ public final class PrinterDialog extends JDialog implements ActionListener portrait.setSelected(true); else if (defaultValue.equals(OrientationRequested.REVERSE_PORTRAIT)) rev_portrait.setSelected(true); - else + else rev_landscape.setSelected(true); } } @@ -661,7 +661,7 @@ public final class PrinterDialog extends JDialog implements ActionListener landscape.setEnabled(false); rev_landscape.setEnabled(false); rev_portrait.setEnabled(false); - } + } } } @@ -673,84 +673,84 @@ public final class PrinterDialog extends JDialog implements ActionListener { private JLabel size_lb, source_lb; private JComboBox size, source; - + MediaTypes() { size_lb = new JLabel(getLocalizedString("lb.size")); source_lb = new JLabel(getLocalizedString("lb.source")); - + size = new JComboBox(); size.setEditable(false); size.addActionListener(this); source = new JComboBox(); source.setEditable(false); size.addActionListener(this); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.medias"))); - + c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.LINE_END; c.gridx = 0; c.gridy = 0; add(size_lb, c); - + c.gridx = 0; c.gridy = 1; add(source_lb, c); - + c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; c.weightx = 1.5; add(size, c); - + c.gridx = 1; c.gridy = 1; c.weightx = 1.5; add(source, c); } - + public void actionPerformed(ActionEvent event) - { + { if (event.getSource() == size) { Object obj = size.getSelectedItem(); if (obj instanceof Media) - atts.add((Media) obj); + atts.add((Media) obj); } - + // we ignore source events currently - // as only the automatic selection is used. + // as only the automatic selection is used. } - + /** * Called to update for new selected * print service. Tests if currently * selected attributes are supported. */ void updateForSelectedService() - { + { if (categorySupported(Media.class)) { Media[] medias = (Media[]) getSelectedPrintService() .getSupportedAttributeValues(Media.class, flavor, null); - + size.removeAllItems(); if (medias.length == 0) - size.addItem(getLocalizedString("lb.automatically")); + size.addItem(getLocalizedString("lb.automatically")); else for (int i=0; i < medias.length; i++) size.addItem(medias[i]); - + Media media = (Media) attribute(Media.class); if (media != null) size.setSelectedItem(media); - + // this is currently ignored source.removeAllItems(); source.addItem(getLocalizedString("lb.automatically")); @@ -759,7 +759,7 @@ public final class PrinterDialog extends JDialog implements ActionListener { size.removeAllItems(); source.removeAllItems(); - + size.addItem(getLocalizedString("lb.automatically")); source.addItem(getLocalizedString("lb.automatically")); } @@ -774,14 +774,14 @@ public final class PrinterDialog extends JDialog implements ActionListener { private JLabel left, right, top, bottom; private JTextField left_tf, right_tf, top_tf, bottom_tf; - + Margins() { left = new JLabel(getLocalizedString("lb.left")); right = new JLabel(getLocalizedString("lb.right")); top = new JLabel(getLocalizedString("lb.top")); bottom = new JLabel(getLocalizedString("lb.bottom")); - + left_tf = new JTextField(7); left_tf.addFocusListener(this); right_tf = new JTextField(7); @@ -790,67 +790,67 @@ public final class PrinterDialog extends JDialog implements ActionListener top_tf.addFocusListener(this); bottom_tf = new JTextField(7); bottom_tf.addFocusListener(this); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.margins"))); - + c.insets = new Insets(5, 5, 5, 5); c.gridx = 0; c.gridy = 0; add(left, c); - + c.gridx = 1; c.gridy = 0; add(right, c); - + c.insets = new Insets(5, 5, 5, 5); c.gridx = 0; c.gridy = 1; add(left_tf, c); - + c.gridx = 1; c.gridy = 1; add(right_tf, c); - + c.insets = new Insets(10, 5, 5, 5); c.gridx = 0; c.gridy = 2; add(top, c); - + c.gridx = 1; c.gridy = 2; add(bottom, c); - + c.insets = new Insets(0, 5, 5, 5); c.gridx = 0; c.gridy = 3; add(top_tf, c); - + c.gridx = 1; c.gridy = 3; add(bottom_tf, c); } - + public void focusGained(FocusEvent event) { updateMargins(); } - + public void focusLost(FocusEvent event) { updateMargins(); } - + // updates the margins after user changed it private void updateMargins() { // We currently do not support this attribute // as it is not in the IPP spec and therefore not in CUPS } - + /** * Called to update for new selected * print service. Tests if currently @@ -867,7 +867,7 @@ public final class PrinterDialog extends JDialog implements ActionListener left_tf.setEnabled(true); right_tf.setEnabled(true); top_tf.setEnabled(true); - bottom_tf.setEnabled(true); + bottom_tf.setEnabled(true); } else { @@ -878,8 +878,8 @@ public final class PrinterDialog extends JDialog implements ActionListener left_tf.setEnabled(false); right_tf.setEnabled(false); top_tf.setEnabled(false); - bottom_tf.setEnabled(false); - } + bottom_tf.setEnabled(false); + } } } @@ -887,8 +887,8 @@ public final class PrinterDialog extends JDialog implements ActionListener private Orientation orientation_panel; private Margins margins_panel; - /** - * Constructs the page setup user interface. + /** + * Constructs the page setup user interface. */ public PageSetupPanel() { @@ -909,7 +909,7 @@ public final class PrinterDialog extends JDialog implements ActionListener add(Box.createRigidArea(new Dimension(0, 12))); add(layout_panel); } - + /** * Calls update on all internal panels to adjust * for a new selected print service. @@ -936,7 +936,7 @@ public final class PrinterDialog extends JDialog implements ActionListener { private JRadioButton low, normal, high; private ButtonGroup group; - + Quality() { low = new JRadioButton(getLocalizedString("rbt.low")); @@ -945,33 +945,33 @@ public final class PrinterDialog extends JDialog implements ActionListener normal.addActionListener(this); high = new JRadioButton(getLocalizedString("rbt.high")); high.addActionListener(this); - + group = new ButtonGroup(); group.add(low); group.add(normal); group.add(high); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.quality"))); - + c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(5, 5, 5, 5); c.gridx = 0; c.gridy = 0; add(low, c); - + c.gridx = 0; c.gridy = 1; add(normal, c); - + c.gridx = 0; c.gridy = 2; add(high, c); } - + public void actionPerformed(ActionEvent e) { if (e.getSource() == low) @@ -979,9 +979,9 @@ public final class PrinterDialog extends JDialog implements ActionListener else if (e.getSource() == normal) atts.add(PrintQuality.NORMAL); else - atts.add(PrintQuality.HIGH); + atts.add(PrintQuality.HIGH); } - + /** * Called to update for new selected * print service. Tests if currently @@ -994,17 +994,17 @@ public final class PrinterDialog extends JDialog implements ActionListener low.setEnabled(true); normal.setEnabled(true); high.setEnabled(true); - - Object defaultValue = defaultValue(PrintQuality.class); + + Object defaultValue = defaultValue(PrintQuality.class); Attribute quality = attribute(PrintQuality.class); - + if (quality != null) { if (quality.equals(PrintQuality.DRAFT)) low.setSelected(true); else if (quality.equals(PrintQuality.NORMAL)) normal.setSelected(true); - else + else high.setSelected(true); } else @@ -1013,81 +1013,81 @@ public final class PrinterDialog extends JDialog implements ActionListener low.setSelected(true); else if (defaultValue.equals(PrintQuality.NORMAL)) normal.setSelected(true); - else + else high.setSelected(true); - } + } } else { low.setEnabled(false); normal.setEnabled(false); high.setEnabled(false); - } + } } } - + /** * Handles the job attributes as requesting username, jobname etc. * @author Wolfgang Baer (WBaer@gmx.de) */ final class JobAttributes extends JPanel implements ActionListener, ChangeListener, FocusListener - { - private JLabel jobname, username, priority_lb; - private JTextField jobname_tf, username_tf; - private JCheckBox cover; + { + private JLabel jobname, username, priority_lb; + private JTextField jobname_tf, username_tf; + private JCheckBox cover; private JSpinner priority; private SpinnerNumberModel model; - + JobAttributes() { jobname = new JLabel(getLocalizedString("lb.jobname")); username = new JLabel(getLocalizedString("lb.username")); priority_lb = new JLabel(getLocalizedString("lb.priority")); - + cover = new JCheckBox(getLocalizedString("cb.cover")); cover.addActionListener(this); - + model = new SpinnerNumberModel(1, 1, 100, 1); priority = new JSpinner(model); priority.addChangeListener(this); - + jobname_tf = new JTextField(); jobname_tf.addFocusListener(this); username_tf = new JTextField(); username_tf.addFocusListener(this); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.jobattributes"))); - + c.insets = new Insets(10, 5, 10, 5); c.gridx = 0; c.gridy = 0; add(cover, c); - + c.anchor = GridBagConstraints.LINE_END; c.gridx = 1; c.gridy = 0; c.weightx = 2; add(priority_lb, c); - + c.gridx = 2; c.gridy = 0; c.weightx = 0.5; add(priority, c); - + c.anchor = GridBagConstraints.LINE_END; c.gridx = 0; c.gridy = 1; add(jobname, c); - + c.gridx = 0; c.gridy = 2; add(username, c); - + c.anchor = GridBagConstraints.CENTER; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; @@ -1095,13 +1095,13 @@ public final class PrinterDialog extends JDialog implements ActionListener c.gridwidth = 2; c.weightx = 1.5; add(jobname_tf, c); - + c.insets = new Insets(10, 5, 15, 5); c.gridx = 1; c.gridy = 2; add(username_tf, c); } - + public void actionPerformed(ActionEvent event) { if (cover.isSelected()) @@ -1109,23 +1109,23 @@ public final class PrinterDialog extends JDialog implements ActionListener else atts.add(JobSheets.NONE); } - + public void stateChanged(ChangeEvent event) { int value = ((Integer) priority.getValue()).intValue(); - atts.add(new JobPriority(value)); + atts.add(new JobPriority(value)); } - + public void focusGained(FocusEvent event) - { + { updateTextfields(event); } - + public void focusLost(FocusEvent event) { updateTextfields(event); } - + private void updateTextfields(FocusEvent event) { if (event.getSource() == jobname_tf) @@ -1141,59 +1141,59 @@ public final class PrinterDialog extends JDialog implements ActionListener */ void updateForSelectedService() { - // JobPriority + // JobPriority if (categorySupported(JobPriority.class)) { JobPriority prio = (JobPriority) attribute(JobPriority.class); - JobPriority value = (JobPriority) defaultValue(JobPriority.class); + JobPriority value = (JobPriority) defaultValue(JobPriority.class); priority.setEnabled(true); if (prio != null) model.setValue(new Integer(prio.getValue())); else model.setValue(new Integer(value.getValue())); - } + } else - priority.setEnabled(false); - + priority.setEnabled(false); + // Requesting username if (categorySupported(RequestingUserName.class)) { Attribute user = attribute(RequestingUserName.class); Object value = defaultValue(RequestingUserName.class); - username.setEnabled(true); + username.setEnabled(true); if (user != null) username_tf.setText(user.toString()); else username_tf.setText(value.toString()); } else - username.setEnabled(false); - + username.setEnabled(false); + // Job Name if (categorySupported(JobName.class)) { Attribute job = attribute(JobName.class); Object value = defaultValue(JobName.class); - jobname.setEnabled(true); + jobname.setEnabled(true); if (job != null) jobname_tf.setText(job.toString()); else jobname_tf.setText(value.toString()); } else - jobname.setEnabled(false); - + jobname.setEnabled(false); + // Job sheets if (categorySupported(JobSheets.class)) { Attribute sheet = attribute(JobSheets.class); Object value = defaultValue(JobSheets.class); - cover.setEnabled(true); + cover.setEnabled(true); if (sheet != null) { if (sheet.equals(JobSheets.NONE)) cover.setSelected(false); - else + else cover.setSelected(true); } else @@ -1205,53 +1205,53 @@ public final class PrinterDialog extends JDialog implements ActionListener } } else - cover.setEnabled(false); + cover.setEnabled(false); } } - + /** * Handles the sides attributes. * @author Wolfgang Baer (WBaer@gmx.de) */ final class SidesPanel extends JPanel implements ActionListener - { + { private JRadioButton oneside, calendar, duplex; - + SidesPanel() - { + { oneside = new JRadioButton(getLocalizedString("rbt.onesided")); oneside.addActionListener(this); calendar = new JRadioButton(getLocalizedString("rbt.calendar")); calendar.addActionListener(this); duplex = new JRadioButton(getLocalizedString("rbt.duplex")); duplex.addActionListener(this); - + ButtonGroup group = new ButtonGroup(); group.add(oneside); group.add(calendar); group.add(duplex); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.sides"))); - + c.insets = new Insets(5, 5, 5, 5); c.gridx = 0; c.gridy = 0; add(oneside, c); - + c.gridx = 0; c.gridy = 1; add(calendar, c); - + c.gridx = 0; c.gridy = 2; add(duplex, c); } - + public void actionPerformed(ActionEvent e) { if (e.getSource() == calendar) @@ -1261,7 +1261,7 @@ public final class PrinterDialog extends JDialog implements ActionListener else atts.add(Sides.TWO_SIDED_LONG_EDGE); } - + /** * Called to update for new selected * print service. Tests if currently @@ -1274,8 +1274,8 @@ public final class PrinterDialog extends JDialog implements ActionListener oneside.setEnabled(true); calendar.setEnabled(true); duplex.setEnabled(true); - - Object defaultValue = defaultValue(Sides.class); + + Object defaultValue = defaultValue(Sides.class); Attribute sides = attribute(Sides.class); if (sides != null) { @@ -1297,14 +1297,14 @@ public final class PrinterDialog extends JDialog implements ActionListener } } else - { + { oneside.setEnabled(false); calendar.setEnabled(false); duplex.setEnabled(false); - } + } } } - + /** * Handles the chromaticity attributes. * @author Wolfgang Baer (WBaer@gmx.de) @@ -1312,43 +1312,43 @@ public final class PrinterDialog extends JDialog implements ActionListener final class Color extends JPanel implements ActionListener { private JRadioButton bw, color; - + Color() { bw = new JRadioButton(getLocalizedString("rbt.blackwhite")); bw.addActionListener(this); color = new JRadioButton(getLocalizedString("rbt.color")); color.addActionListener(this); - + ButtonGroup group = new ButtonGroup(); group.add(bw); group.add(color); - + GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); - + setLayout(layout); setBorder(new TitledBorder(getLocalizedString("title.color"))); - + c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(5, 5, 5, 5); c.gridx = 0; c.gridy = 0; add(bw, c); - + c.gridx = 0; c.gridy = 1; add(color, c); } - + public void actionPerformed(ActionEvent e) { if (e.getSource() == bw) - atts.add(Chromaticity.MONOCHROME); + atts.add(Chromaticity.MONOCHROME); else atts.add(Chromaticity.COLOR); } - + /** * Called to update for new selected * print service. Tests if currently @@ -1359,68 +1359,68 @@ public final class PrinterDialog extends JDialog implements ActionListener if (categorySupported(Chromaticity.class)) { bw.setEnabled(true); - color.setEnabled(true); - - Object defaultValue = defaultValue(Chromaticity.class); + color.setEnabled(true); + + Object defaultValue = defaultValue(Chromaticity.class); Attribute chromaticity = attribute(Chromaticity.class); if (chromaticity != null) { if (chromaticity.equals(Chromaticity.MONOCHROME)) bw.setSelected(true); - else + else color.setSelected(true); } else { if (defaultValue.equals(Chromaticity.MONOCHROME)) bw.setSelected(true); - else + else color.setSelected(true); } } else - { + { bw.setEnabled(false); color.setEnabled(false); } } } - + private Quality quality_panel; private JobAttributes jobAttr_panel; private SidesPanel sides_panel; private Color chromaticy_panel; - + /** * Creates the panel for appearance attributes. */ public AppearancePanel() { setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - + quality_panel = new Quality(); jobAttr_panel = new JobAttributes(); sides_panel = new SidesPanel(); chromaticy_panel = new Color(); - + JPanel layout_panel = new JPanel(); layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS)); layout_panel.add(chromaticy_panel); layout_panel.add(Box.createRigidArea(new Dimension(10, 0))); layout_panel.add(quality_panel); - + JPanel layout2_panel = new JPanel(); layout2_panel.setLayout(new BoxLayout(layout2_panel, BoxLayout.LINE_AXIS)); layout2_panel.add(sides_panel); layout2_panel.add(Box.createRigidArea(new Dimension(10, 0))); layout2_panel.add(jobAttr_panel); - + setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(layout_panel); add(Box.createRigidArea(new Dimension(0, 12))); add(layout2_panel); } - + /** * Calls update on all internal panels to adjust * for a new selected print service. @@ -1442,47 +1442,47 @@ public final class PrinterDialog extends JDialog implements ActionListener private GeneralPanel general_panel; private PageSetupPanel pagesetup_panel; private AppearancePanel appearance_panel; - + private PrintService[] services; private PrintService defaultService; private PrintService selectedService; private DocFlavor flavor; private PrintRequestAttributeSet attributes; - - private boolean onlyPageDialog; - private PrintRequestAttributeSet atts; - + + private boolean onlyPageDialog; + private PrintRequestAttributeSet atts; + private final static ResourceBundle messages; static - { + { messages = ResourceBundle.getBundle("gnu/javax/print/PrinterDialog"); } - + // TODO LowPriority: Include checks so that if a specific value formerly // selected is no more supported by the new service changes to the default. - + /** * Class private constructs a printer dialog. - * + * * @param gc the screen to use. <code>null</code> is default screen. * @param services the print services to browse (not null). * @param defaultService the default service. If <code>null</code> * the first of the print services in the services array will be used. * @param flavor the flavours to be printed. - * @param attributes the attributes requested. Will be updated + * @param attributes the attributes requested. Will be updated * by selections done by the user in the dialog. * @param onlyPageDialog if true a page settings only dialog is constructed. - * + * * @throws HeadlessException if GraphicsEnvironment is headless */ - private PrinterDialog(GraphicsConfiguration gc, PrintService[] services, - PrintService defaultService, DocFlavor flavor, + private PrinterDialog(GraphicsConfiguration gc, PrintService[] services, + PrintService defaultService, DocFlavor flavor, PrintRequestAttributeSet attributes, boolean onlyPageDialog, String title) throws HeadlessException { super((Frame)null, title, true, gc); - + setResizable(false); setDefaultCloseOperation(DISPOSE_ON_CLOSE); @@ -1493,97 +1493,97 @@ public final class PrinterDialog extends JDialog implements ActionListener for(int i=0; i < services.length; i++) if (services[i].isDocFlavorSupported(flavor)) list.add(services[i]); - + if (defaultService != null && (! list.contains(defaultService))) defaultService = (PrintService) list.get(0); - + PrintService[] newServices = new PrintService[list.size()]; this.services = (PrintService[]) list.toArray(newServices); } else this.services = services; - + if (defaultService == null) this.defaultService = services[0]; else this.defaultService = defaultService; - + this.selectedService = this.defaultService; this.flavor = flavor; - + // the attributes given by the user this.attributes = attributes; // the one to work with during browsing this.atts = new HashPrintRequestAttributeSet(attributes); - + this.onlyPageDialog = onlyPageDialog; - - initUI(onlyPageDialog); + + initUI(onlyPageDialog); pack(); updateAll(); } - + /** * Constructs a page settings only dialog. - * + * * @param gc the screen to use. <code>null</code> is default screen. * @param service the print service for the page dialog. * the first of the print services in the services array will be used. * @param flavor the flavours to be printed. - * @param attributes the attributes requested. Will be updated - * by selections done by the user in the dialog. - * + * @param attributes the attributes requested. Will be updated + * by selections done by the user in the dialog. + * * @throws HeadlessException if GraphicsEnvironment is headless */ - public PrinterDialog(GraphicsConfiguration gc, PrintService service, + public PrinterDialog(GraphicsConfiguration gc, PrintService service, DocFlavor flavor, PrintRequestAttributeSet attributes) throws HeadlessException { - this(gc, new PrintService[] {service}, service, flavor, attributes, - true, getLocalizedString("title.pagedialog")); + this(gc, new PrintService[] {service}, service, flavor, attributes, + true, getLocalizedString("title.pagedialog")); } - + /** * Constructs a printer dialog. - * + * * @param gc the screen to use. <code>null</code> is default screen. * @param services the print services to browse (not null). * @param defaultService the default service. If <code>null</code> * the first of the print services in the services array will be used. * @param flavor the flavours to be printed. - * @param attributes the attributes requested. Will be updated - * by selections done by the user in the dialog. - * + * @param attributes the attributes requested. Will be updated + * by selections done by the user in the dialog. + * * @throws HeadlessException if GraphicsEnvironment is headless */ - public PrinterDialog(GraphicsConfiguration gc, PrintService[] services, - PrintService defaultService, DocFlavor flavor, + public PrinterDialog(GraphicsConfiguration gc, PrintService[] services, + PrintService defaultService, DocFlavor flavor, PrintRequestAttributeSet attributes) throws HeadlessException { - this(gc, services, defaultService, flavor, attributes, + this(gc, services, defaultService, flavor, attributes, false, getLocalizedString("title.printdialog")); } // initializes the gui parts private void initUI(boolean onlyPageDialog) - { + { JPanel buttonPane = new JPanel(); - + if (onlyPageDialog) { JPanel pane = new JPanel(); pane.setLayout(new BorderLayout()); pagesetup_panel = new PageSetupPanel(); pane.add(pagesetup_panel, BorderLayout.CENTER); - + ok_bt = new JButton(getLocalizedString("bt.OK")); ok_bt.addActionListener(this); cancel_bt = new JButton(getLocalizedString("bt.cancel")); - cancel_bt.addActionListener(this); - - getContentPane().add(pane, BorderLayout.CENTER); + cancel_bt.addActionListener(this); + + getContentPane().add(pane, BorderLayout.CENTER); } else { @@ -1607,14 +1607,14 @@ public final class PrinterDialog extends JDialog implements ActionListener // Put everything together getContentPane().add(pane, BorderLayout.CENTER); } - + buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(ok_bt); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(cancel_bt); - + getContentPane().add(buttonPane, BorderLayout.PAGE_END); } @@ -1635,17 +1635,17 @@ public final class PrinterDialog extends JDialog implements ActionListener { return selectedService; } - + /** * Sets the currently selected print service. - * + * * @param service the service selected. */ protected void setSelectedPrintService(PrintService service) { selectedService = service; } - + /** * Returns the print service array. * @return The print services. @@ -1654,7 +1654,7 @@ public final class PrinterDialog extends JDialog implements ActionListener { return services; } - + /** * Calls update on all panels to adjust * for a new selected print service. @@ -1662,57 +1662,57 @@ public final class PrinterDialog extends JDialog implements ActionListener void updateAll() { pagesetup_panel.update(); - + if (! onlyPageDialog) { general_panel.update(); appearance_panel.update(); - } + } } - + boolean categorySupported(Class category) { return getSelectedPrintService(). isAttributeCategorySupported(category); } - + Object defaultValue(Class category) { return getSelectedPrintService(). getDefaultAttributeValue(category); } - + Attribute attribute(Class category) { return atts.get(category); } - - /** + + /** * Action handler for Print/Cancel buttons. * If cancel is pressed we reset the attributes * and the selected service. - * + * * @param e the ActionEvent */ public void actionPerformed(ActionEvent e) { if (e.getSource() == ok_bt) { - setVisible(false); + setVisible(false); attributes.addAll(atts); dispose(); } else { - setVisible(false); + setVisible(false); selectedService = null; dispose(); } } - + /** * Retrieves localized messages from the resource bundle. - * + * * @param key the key * @return The localized value for the key. */ diff --git a/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java b/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java index d391afc7e1a..8cfd6880d50 100644 --- a/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java +++ b/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java @@ -76,52 +76,52 @@ import javax.print.event.PrintJobEvent; import javax.print.event.PrintJobListener; /** - * Implementation of the DocPrintJob interface. Implementation is + * Implementation of the DocPrintJob interface. Implementation is * specific to the <code>IppPrintService</code> implementation. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class DocPrintJobImpl implements CancelablePrintJob { /** The print service this job is bound to. */ private IppPrintService service; - + /** The set of print job listeners. */ private HashSet printJobListener = new HashSet(); - + /** The print job attributes listeners. */ private ArrayList attributesListener = new ArrayList(); /** The print job attributes listeners associated attribute set. */ private ArrayList attributesListenerAttributes = new ArrayList(); - + /** The username. */ private String username; /** The password of the user. */ private String password; - + /** Returned job uri. */ private JobUri jobUri = null; /** Returned job id. */ private JobId jobId = null; - + /** The requesting-username for later canceling */ private RequestingUserName requestingUser; - + /** The print job sets. */ private PrintJobAttributeSet oldSet = new HashPrintJobAttributeSet(); private PrintJobAttributeSet currentSet = new HashPrintJobAttributeSet(); - - /** + + /** * State variable if we already started printing. */ private boolean printing = false; - + // TODO Implement complete PrintJobListener notification // TODO Implement PrintJobAttributeListener notification /** * Constructs a DocPrintJobImpl instance bound to the given print service. - * + * * @param service the print service instance. * @param user the user of this print service. * @param passwd the password of the user. @@ -141,7 +141,7 @@ public class DocPrintJobImpl implements CancelablePrintJob { if (listener == null) return; - + attributesListener.add(listener); attributesListenerAttributes.add(attributes); } @@ -153,7 +153,7 @@ public class DocPrintJobImpl implements CancelablePrintJob { if (listener == null) return; - + printJobListener.add(listener); } @@ -181,30 +181,30 @@ public class DocPrintJobImpl implements CancelablePrintJob { 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 + + // 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 + // save user name so we can make a cancel operation under same user if (! mergedAtts.containsKey(RequestingUserName.class)) { mergedAtts.add(IppPrintService.REQUESTING_USER_NAME); @@ -212,53 +212,53 @@ public class DocPrintJobImpl implements CancelablePrintJob } else { - requestingUser = (RequestingUserName) + 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) + catch (URISyntaxException e) { - // does not happen + // does not happen } - - IppRequest request = - new IppRequest(uri, username, password); - + + 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 + + // Get and set the printdata based on the // representation classname - String className = flavor.getRepresentationClassName(); - - if (className.equals("[B")) + String className = flavor.getRepresentationClassName(); + + if (className.equals("[B")) { request.setData((byte[]) doc.getPrintData()); response = request.send(); @@ -275,7 +275,7 @@ public class DocPrintJobImpl implements CancelablePrintJob try { // CUPS only supports UTF-8 currently so we convert - // We also assume that char[] is always utf-16 - correct ? + // 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(); @@ -285,7 +285,7 @@ public class DocPrintJobImpl implements CancelablePrintJob 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 @@ -300,13 +300,13 @@ public class DocPrintJobImpl implements CancelablePrintJob 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 ? + // We also assume that String is always utf-16 - correct ? String str = (String) doc.getPrintData(); request.setData(str.getBytes("utf-16")); response = request.send(); @@ -316,7 +316,7 @@ public class DocPrintJobImpl implements CancelablePrintJob 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(); @@ -332,22 +332,22 @@ public class DocPrintJobImpl implements CancelablePrintJob // For the future :-) throw new PrintException("Not yet supported."); } - else + 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 @@ -356,7 +356,7 @@ public class DocPrintJobImpl implements CancelablePrintJob 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 } @@ -364,18 +364,18 @@ public class DocPrintJobImpl implements CancelablePrintJob { // 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]; + jobId = (JobId) ((HashSet)jobAttributes.get(JobId.class)).toArray()[0]; } /** @@ -385,7 +385,7 @@ public class DocPrintJobImpl implements CancelablePrintJob { if (listener == null) return; - + int index = attributesListener.indexOf(listener); if (index != -1) { @@ -401,10 +401,10 @@ public class DocPrintJobImpl implements CancelablePrintJob { if (listener == null) return; - + printJobListener.remove(listener); } - + /** * @see CancelablePrintJob#cancel() */ @@ -414,23 +414,23 @@ public class DocPrintJobImpl implements CancelablePrintJob { throw new PrintException("print job is not yet send"); } - + IppResponse response = null; - + try { - IppRequest request = new IppRequest(jobUri.getURI(), username, password); + 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(); - } + 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 @@ -438,15 +438,15 @@ public class DocPrintJobImpl implements CancelablePrintJob { notifyPrintJobListeners(new PrintJobEvent( this, PrintJobEvent.JOB_FAILED)); - throw new PrintException("Canceling failed - received statuscode " + Integer.toHexString(status)); + throw new PrintException("Canceling failed - received statuscode " + Integer.toHexString(status)); } - else + else { notifyPrintJobListeners(new PrintJobEvent( this, PrintJobEvent.JOB_CANCELED)); } } - + private void notifyPrintJobListeners(PrintJobEvent e) { Iterator it = printJobListener.iterator(); @@ -463,9 +463,9 @@ public class DocPrintJobImpl implements CancelablePrintJob l.printJobFailed(e); else if (e.getPrintEventType() == PrintJobEvent.NO_MORE_EVENTS) l.printJobNoMoreEvents(e); - else + else l.printJobRequiresAttention(e); - } + } } - + } diff --git a/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java b/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java index ce6bb4f7e64..1c074a8dd62 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java @@ -1,4 +1,4 @@ -/* IppDelimiterTag.java -- +/* IppDelimiterTag.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,57 +42,57 @@ package gnu.javax.print.ipp; /** * IPP Delimiter Tags as described in RFC 2910 section 3.5.1. * <p> - * Every delimiter tag value can occur in the protocol field + * Every delimiter tag value can occur in the protocol field * begin-attribute-group-tag and indicates that the following * attributes will be part of the named group.<br> * The end-of-attributes-tag signals the end of the attributes * section in the IPP request/response and therefore the beginning - * of the data section (if any). + * of the data section (if any). * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class IppDelimiterTag { /** Start of the operation attributes group section. */ public static final byte OPERATION_ATTRIBUTES_TAG = 0x01; - + /** Start of the job attributes group section. */ public static final byte JOB_ATTRIBUTES_TAG = 0x02; - + /** End of the attributes section and begin of data section. */ public static final byte END_OF_ATTRIBUTES_TAG = 0x03; - + /** Start of the printer attributes group section. */ public static final byte PRINTER_ATTRIBUTES_TAG = 0x04; - + /** Start of the unsupported attributes group section. */ public static final byte UNSUPPORTED_ATTRIBUTES_TAG = 0x05; - - + + // 0x00 reserved for definition in a future IETF // standards track document - + // 0x06-0x0f reserved for future delimiters in IETF // standards track documents - + private IppDelimiterTag() { // not to be instantiated } - + /** - * Tests if given value corresponds to a + * Tests if given value corresponds to a * delimiter tag value. - * + * * @param value the value to test for * @return <code>true</code> if, <code>false</code> otherwise. */ - public static boolean isDelimiterTag(byte value) + 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 index 27b156fd857..c34a8f22740 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppException.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppException.java @@ -1,4 +1,4 @@ -/* IppException.java -- +/* IppException.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,7 +44,7 @@ import javax.print.PrintException; * <code>IppException</code> signals exception thrown by * the IPP implementation for various things like a failed * ipp request or a wrapped io exception. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class IppException extends PrintException @@ -65,7 +65,7 @@ public class IppException extends PrintException { super(s); } - + /** * Creates an <code>IppException</code>. * @param e the exception cause this one. diff --git a/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java b/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java index df2a4793c72..59c3408d5ec 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java @@ -1,4 +1,4 @@ -/* IppMultiDocPrintService.java -- +/* IppMultiDocPrintService.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,25 +47,25 @@ import javax.print.MultiDocPrintService; /** * Implementation of the MultiDocPrintService interface * for IPP based printers. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public class IppMultiDocPrintService extends IppPrintService +public class IppMultiDocPrintService extends IppPrintService implements MultiDocPrintService { /** The username. */ private transient String user; - + /** The password of the user. */ private transient String passwd; /** * Creates a <code>IppMultiDocPrintService</code> object. - * + * * @param uri the URI of the IPP printer. * @param username the user of this print service. * @param password the password of the user. - * + * * @throws IppException if an error during connection occurs. */ public IppMultiDocPrintService(URI uri, String username, String password) @@ -74,12 +74,12 @@ public class IppMultiDocPrintService extends IppPrintService super(uri, username, password); user = username; passwd = password; - } + } /** * @see MultiDocPrintService#createMultiDocPrintJob() */ - public MultiDocPrintJob 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 index 56a41381fb6..9ce41c774c9 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java @@ -1,4 +1,4 @@ -/* IppPrintService.java -- +/* IppPrintService.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -130,175 +130,180 @@ 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 printerAttr; - + private Map<Class<? extends Attribute>, Set<Attribute>> printerAttr; + /** The set of listeners.*/ - private HashSet printServiceAttributeListener; - + private HashSet<PrintServiceAttributeListener> printServiceAttributeListener; + /** The username. */ private transient String user; - + /** The password of the user. */ private transient String passwd; - + /** The name of this print service. */ private String name; - + /** The list of supported document flavors. */ - private List flavors; - + private List<DocFlavor> flavors; + /** The standard printer URI. */ private PrinterURI printerUri; - + /** The list of all supported printer URIs. */ - private ArrayList printerUris; - + private ArrayList<PrinterURI> printerUris; + /** * Logger for tracing - enable by passing * -Dgnu.classpath.debug.components=ipp to the vm. */ static final Logger logger = SystemLogger.SYSTEM; - - /** + + /** * requesting-user-name defaults to the executing user. */ public static final RequestingUserName REQUESTING_USER_NAME; - - /** + + /** * job-name defaults to "Java Printing". */ public static final JobName JOB_NAME; - + static { JOB_NAME = new JobName("Java Printing", null); REQUESTING_USER_NAME = new RequestingUserName( - SystemProperties.getProperty("user.name", ""), null); + SystemProperties.getProperty("user.name", ""), null); } - + // TODO Implement service listener notification and change detection. - + /** * Creates a <code>IppPrintService</code> object. - * + * * @param uri the URI of the IPP printer. * @param username the user of this print service. * @param password the password of the user. - * + * * @throws IppException if an error during connection occurs. */ - public IppPrintService(URI uri, String username, String password) + public IppPrintService(URI uri, String username, String password) throws IppException { printerUri = new PrinterURI(uri); user = username; passwd = password; - - printServiceAttributeListener = new HashSet(); - + + printServiceAttributeListener = + new HashSet<PrintServiceAttributeListener>(); + printerAttr = getPrinterAttributes(); processResponse(); } - + /** * Fetches all printer attributes from the IPP printer. - * + * * @return The Map with the printer attributes. * @throws IppException if an error occurs. */ - private Map getPrinterAttributes() throws IppException + private Map<Class<? extends Attribute>, Set<Attribute>> getPrinterAttributes() + throws IppException { IppResponse response = null; - + try { - IppRequest request = new IppRequest(printerUri.getURI(), user, passwd); - + IppRequest request = new IppRequest(printerUri.getURI(), user, passwd); + int operation = OperationsSupported.GET_PRINTER_ATTRIBUTES.getValue(); - request.setOperationID((short) operation); - request.setOperationAttributeDefaults(); + request.setOperationID((short) operation); + request.setOperationAttributeDefaults(); request.addOperationAttribute(printerUri); - + response = request.send(); - } + } catch (IOException e) { throw new IppException("IOException in IPP request/response.", e); - } - - return (Map) response.getPrinterAttributes().get(0); + } + + return response.getPrinterAttributes().get(0); } - + /** - * Extracts the set of attribute values for a given + * 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) + private <T extends Attribute> Set<T> getPrinterAttributeSet(Class<T> attributeClass) { - return (Set) printerAttr.get(attributeClass); + Set<Attribute> set = printerAttr.get(attributeClass); + Set<T> attSet = new HashSet<T>(); + for (Attribute att : set) + attSet.add(attributeClass.cast(att)); + return attSet; } - + /** - * Extracts the default attribute value for the given + * Extracts the default attribute value for the given * default attribute category from the printer attributes map. - * + * * @param attributeClass the category * @return The default attribute. - * + * * @throws ClassCastException if attributClass is not an * instance of <code>DefaultValueAttribute</code>. */ - private Attribute getPrinterDefaultAttribute(Class attributeClass) + private Attribute getPrinterDefaultAttribute(Class<? extends Attribute> attributeClass) { - Set set = (Set) printerAttr.get(attributeClass); + Set<Attribute> set = printerAttr.get(attributeClass); return ((DefaultValueAttribute) set.toArray()[0]).getAssociatedAttribute(); } - + /** * Processes the response, sorts and splits the attributes. */ private void processResponse() { // printer name - PrinterName[] tmp = (PrinterName[]) getPrinterAttributeSet( - PrinterName.class).toArray(new PrinterName[1]); + 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); + flavors = new ArrayList<DocFlavor>(); + Set<DocumentFormatSupported> flavorAttributes = getPrinterAttributeSet(DocumentFormatSupported.class); if (flavorAttributes != null) { - for (Iterator it = flavorAttributes.iterator(); it.hasNext();) + for (DocumentFormatSupported dfs : flavorAttributes) { - String mimeType = ((DocumentFormatSupported) it.next()).getValue(); - + 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"; } @@ -307,21 +312,22 @@ public class IppPrintService implements PrintService 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 }; - + 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(); @@ -336,7 +342,7 @@ public class IppPrintService implements PrintService } } 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")); @@ -357,54 +363,52 @@ public class IppPrintService implements PrintService } } - 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); - } + 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()); - Iterator it = uris.iterator(); - while (it.hasNext()) + Set<PrinterUriSupported> uris = getPrinterAttributeSet(PrinterUriSupported.class); + printerUris = new ArrayList<PrinterURI>(uris.size()); + for (PrinterUriSupported uri : uris) { - PrinterUriSupported uri = (PrinterUriSupported) it.next(); printerUris.add( new PrinterURI(uri.getURI())); } } /** * We always return a implementation implementing CancelablePrintJob. - * + * * @see javax.print.PrintService#createPrintJob() */ public DocPrintJob createPrintJob() { return new DocPrintJobImpl(this, user, passwd); } - + /** * @see javax.print.PrintService#getAttribute(java.lang.Class) */ - public PrintServiceAttribute getAttribute(Class category) + public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) throw new NullPointerException("category may not be null"); - + if (! PrintServiceAttribute.class.isAssignableFrom(category)) throw new IllegalArgumentException( "category must be of type PrintServiceAttribute"); - - Set set = getPrinterAttributeSet(category); - if (set != null && set.size() > 0) - return (PrintServiceAttribute) set.toArray()[0]; - + + Set<T> set = getPrinterAttributeSet(category); + if (set != null && set.size() > 0) + return set.iterator().next(); + return null; } @@ -414,81 +418,78 @@ public class IppPrintService implements PrintService public PrintServiceAttributeSet getAttributes() { PrintServiceAttributeSet set = new HashPrintServiceAttributeSet(); - - Iterator it = printerAttr.values().iterator(); - while (it.hasNext()) - { - Iterator it2 = ((Set) it.next()).iterator(); - while (it2.hasNext()) + + for (Set<Attribute> attrSet : printerAttr.values()) + { + for (Attribute attr : attrSet) { - Attribute attr = (Attribute) it2.next(); if (attr instanceof PrintServiceAttribute) set.add(attr); } } - + return AttributeSetUtilities.unmodifiableView(set); } /** * @see javax.print.PrintService#getDefaultAttributeValue(java.lang.Class) */ - public Object getDefaultAttributeValue(Class category) - { + public Object getDefaultAttributeValue(Class<? extends Attribute> category) + { // required attributes if (category.equals(Fidelity.class)) - return Fidelity.FIDELITY_FALSE; + 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) + if (category.equals(JobPriority.class) && printerAttr.containsKey(JobPriorityDefault.class)) return getPrinterDefaultAttribute(JobPriorityDefault.class); - if (category.equals(JobHoldUntil.class) + if (category.equals(JobHoldUntil.class) && printerAttr.containsKey(JobHoldUntilDefault.class)) return getPrinterDefaultAttribute(JobHoldUntilDefault.class); - if (category.equals(JobSheets.class) + if (category.equals(JobSheets.class) && printerAttr.containsKey(JobSheetsDefault.class)) return getPrinterDefaultAttribute(JobSheetsDefault .class); - if (category.equals(MultipleDocumentHandling.class) + if (category.equals(MultipleDocumentHandling.class) && printerAttr.containsKey(MultipleDocumentHandlingDefault.class)) return getPrinterDefaultAttribute(MultipleDocumentHandlingDefault.class); - if (category.equals(Copies.class) + if (category.equals(Copies.class) && printerAttr.containsKey(CopiesDefault.class)) return getPrinterDefaultAttribute(CopiesDefault.class); - if (category.equals(Finishings.class) + if (category.equals(Finishings.class) && printerAttr.containsKey(FinishingsDefault.class)) return getPrinterDefaultAttribute(FinishingsDefault.class); - if (category.equals(Sides.class) + if (category.equals(Sides.class) && printerAttr.containsKey(SidesDefault.class)) return getPrinterDefaultAttribute(SidesDefault.class); - if (category.equals(NumberUp.class) + if (category.equals(NumberUp.class) && printerAttr.containsKey(NumberUpDefault.class)) return getPrinterDefaultAttribute(NumberUpDefault.class); - if (category.equals(OrientationRequested.class) + if (category.equals(OrientationRequested.class) && printerAttr.containsKey(OrientationRequestedDefault.class)) return getPrinterDefaultAttribute(OrientationRequestedDefault.class); - if (category.equals(Media.class) + if (category.equals(Media.class) && printerAttr.containsKey(MediaDefault.class)) return getPrinterDefaultAttribute(MediaDefault.class); - if (category.equals(PrinterResolution.class) + if (category.equals(PrinterResolution.class) && printerAttr.containsKey(PrinterResolutionDefault.class)) return getPrinterDefaultAttribute(PrinterResolutionDefault.class); - if (category.equals(PrintQuality.class) + if (category.equals(PrintQuality.class) && printerAttr.containsKey(PrintQualityDefault.class)) return getPrinterDefaultAttribute(PrintQualityDefault.class); - if (category.equals(Compression.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; + return null; } - + /** * We return the value of <code>PrinterName</code> here. * @see javax.print.PrintService#getName() @@ -506,7 +507,7 @@ public class IppPrintService implements PrintService { // 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; @@ -515,11 +516,12 @@ public class IppPrintService implements PrintService /** * @see javax.print.PrintService#getSupportedAttributeCategories() */ - public Class[] getSupportedAttributeCategories() + public Class<?>[] getSupportedAttributeCategories() { - Set categories = new HashSet(); - - // Should only be job template attributes as of section 4.2 + Set<Class<? extends Attribute>> categories = + new HashSet<Class<? extends Attribute>>(); + + // Should only be job template attributes as of section 4.2 if (printerAttr.containsKey(JobPrioritySupported.class)) categories.add(JobPriority.class); if (printerAttr.containsKey(JobHoldUntilSupported.class)) @@ -527,14 +529,14 @@ public class IppPrintService implements PrintService if (printerAttr.containsKey(JobSheetsSupported.class)) categories.add(JobSheets.class); if (printerAttr.containsKey(MultipleDocumentHandlingSupported.class)) - categories.add(MultipleDocumentHandling.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))) + Set<FinishingsSupported> set = getPrinterAttributeSet(FinishingsSupported.class); + if (! (set.size() == 1 && set.contains(FinishingsSupported.NONE))) categories.add(Finishings.class); } if (printerAttr.containsKey(PageRangesSupported.class)) @@ -551,11 +553,11 @@ public class IppPrintService implements PrintService categories.add(PrinterResolution.class); if (printerAttr.containsKey(PrintQualitySupported.class)) categories.add(PrintQuality.class); - - // Chromaticity, Destination, MediaPrintableArea, + + // Chromaticity, Destination, MediaPrintableArea, // SheetCollate, PresentationDirection - not IPP attributes - - // attributes outside section 4.2 + + // attributes outside section 4.2 if (printerAttr.containsKey(CompressionSupported.class)) categories.add(Compression.class); if (printerAttr.containsKey(JobImpressionsSupported.class)) @@ -564,13 +566,13 @@ public class IppPrintService implements PrintService categories.add(JobKOctets.class); if (printerAttr.containsKey(JobMediaSheetsSupported.class)) categories.add(JobMediaSheets.class); - + // always supported as required by IPP specification categories.add(Fidelity.class); categories.add(JobName.class); categories.add(RequestingUserName.class); - return (Class[]) categories.toArray(new Class[categories.size()]); + return categories.toArray(new Class[categories.size()]); } /** @@ -578,12 +580,12 @@ public class IppPrintService implements PrintService * attribute values totally different may override this methods. Subclass only in * need of handling the response differently may override the method * <code>handleSupportedAttributeValuesResponse(IppResponse, Class)</code> only. - * + * * @see PrintService#getSupportedAttributeValues(Class, DocFlavor, AttributeSet) * @see #handleSupportedAttributeValuesResponse(IppResponse, Class) */ - public Object getSupportedAttributeValues(Class category, DocFlavor flavor, - AttributeSet attributes) + public Object getSupportedAttributeValues(Class<? extends Attribute> category, + DocFlavor flavor, AttributeSet attributes) { // We currently ignore the attribute set - there is nothing in the IPP // specification which would come closer to what we do here. @@ -620,7 +622,7 @@ public class IppPrintService implements PrintService request.setOperationAttributeDefaults(); request.addOperationAttribute(new RequestedAttributes(categoryName)); request.addOperationAttribute(printerUri); - + if (flavor != null) { DocumentFormat f = DocumentFormat.createDocumentFormat(flavor); @@ -628,7 +630,7 @@ public class IppPrintService implements PrintService } response = request.send(); - + int status = response.getStatusCode(); if (! (status == IppStatusCode.SUCCESSFUL_OK || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES @@ -647,41 +649,42 @@ public class IppPrintService implements PrintService // method cannot throw exception - just log logger.log(Component.IPP, "IPPException", e); } - + return handleSupportedAttributeValuesResponse(response, category); } - + /** * Called to handle the supported attribute values response for the given * category. This might be overridden by subclasses with different requirements * for parsing/handling the response from the GetPrinterAttributes. - * + * * @param response the response of the GetPrinterAttributes IPP request * @param category the category for which the supported values are requested - * @return A object indicating the supported values for the given attribute - * category, or <code>null</code> if this print service doesn't support the + * @return A object indicating the supported values for the given attribute + * category, or <code>null</code> if this print service doesn't support the * given attribute category at all. - * + * * @see #getSupportedAttributeValues(Class, DocFlavor, AttributeSet) */ - protected Object handleSupportedAttributeValuesResponse(IppResponse response, - Class category) + protected Object handleSupportedAttributeValuesResponse(IppResponse response, + Class<? extends Attribute> category) { - List printerAtts = response.getPrinterAttributes(); - + List<Map<Class<? extends Attribute>, Set<Attribute>>> printerAtts = + response.getPrinterAttributes(); + // only one will be returned - Map printerAttribute = (Map) printerAtts.get(0); - Class suppCategory = IppUtilities.getSupportedCategory(category); - Set attr = (Set) printerAttribute.get(suppCategory); - - // We sometime assume its a single instance with arbritrary value just indicating + Map<Class<? extends Attribute>, Set<Attribute>> printerAttribute = printerAtts.get(0); + Class<? extends Attribute> suppCategory = IppUtilities.getSupportedCategory(category); + Set<Attribute> attr = printerAttribute.get(suppCategory); + + // We sometime assume its a single instance with arbritrary value just indicating // support or an array which is returned. This is because I sometimes just choosed - // what sounds right to me - as I have yet to find a printer which supports every + // what sounds right to me - as I have yet to find a printer which supports every // special category in the SUN implementation to see what they return :-) - + // Map whats in the JSP API if (suppCategory.equals(JobPrioritySupported.class)) - return (JobPrioritySupported) attr.toArray(new JobPrioritySupported[1])[0]; + return (JobPrioritySupported) attr.iterator().next(); if (suppCategory.equals(JobHoldUntilSupported.class)) return new JobHoldUntil(new Date()); if (suppCategory.equals(JobSheetsSupported.class)) @@ -689,11 +692,11 @@ public class IppPrintService implements PrintService if (suppCategory.equals(MultipleDocumentHandlingSupported.class)) return MultipleDocumentHandlingSupported.getAssociatedAttributeArray(attr); if (suppCategory.equals(CopiesSupported.class)) - return (CopiesSupported) attr.toArray(new CopiesSupported[1])[0]; + 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) }; + return new PageRanges[] { new PageRanges(1, Integer.MAX_VALUE) }; if (suppCategory.equals(OrientationRequestedSupported.class)) return OrientationRequestedSupported.getAssociatedAttributeArray(attr); if (suppCategory.equals(MediaSupported.class)) @@ -707,36 +710,34 @@ public class IppPrintService implements PrintService // Special handling as it might also be in range of integers if (suppCategory.equals(NumberUpSupported.class)) { - NumberUpSupported[] tmp = (NumberUpSupported[]) - attr.toArray(new NumberUpSupported[attr.size()]); - if (attr.size() == 1) // number-up maybe in rangeofintegers - return tmp[0]; + return attr.iterator().next(); int[][] members = new int[attr.size()][2]; + Iterator<Attribute> it = attr.iterator(); for (int j = 0; j < attr.size(); j++) { - int value = tmp[j].getMembers()[0][0]; + 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 (DocFlavor[]) flavors.toArray(new DocFlavor[flavors.size()]); + return flavors.toArray(new DocFlavor[flavors.size()]); } /** - * This is done by a validate-job operation and actually implemented in + * 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. * @@ -744,7 +745,7 @@ public class IppPrintService implements PrintService */ public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes) - { + { if (flavor != null && !isDocFlavorSupported(flavor)) throw new IllegalArgumentException("flavor is not supported"); @@ -757,21 +758,21 @@ public class IppPrintService implements PrintService 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 @@ -791,41 +792,39 @@ public class IppPrintService implements PrintService logger.log(Component.IPP, "IPPException", e); } - // Validate Jobs returns only Unsupported and Operation - List unsupportedMaps = response.getUnsupportedAttributes(); + // Validate Jobs returns only Unsupported and Operation + List<Map<Class<? extends Attribute>, Set<Attribute>>> unsupportedMaps = + response.getUnsupportedAttributes(); if (unsupportedMaps.size() == 0) - return null; - - Map unsupportedAttr = (Map) unsupportedMaps.get(0); + return null; + + Map<Class<? extends Attribute>, Set<Attribute>> unsupportedAttr = unsupportedMaps.get(0); if (unsupportedAttr.size() == 0) return null; - - // Convert the return map with unsupported attributes + + // Convert the return map with unsupported attributes // into an AttribueSet instance HashAttributeSet set = new HashAttributeSet(); - Iterator it = unsupportedAttr.values().iterator(); - while (it.hasNext()) + for (Set<Attribute> unsupported : unsupportedAttr.values()) { - Set unsupported = (Set) it.next(); - Iterator it2 = unsupported.iterator(); - while (it2.hasNext()) - set.add((Attribute) it2.next()); + for (Attribute att : unsupported) + set.add(att); } - + return set; } /** * @see PrintService#isAttributeCategorySupported(Class) */ - public boolean isAttributeCategorySupported(Class category) + public boolean isAttributeCategorySupported(Class<? extends Attribute> category) { if (category == null) throw new NullPointerException("category may not be null"); - + if (! Attribute.class.isAssignableFrom(category)) throw new IllegalArgumentException("category must be of type Attribute"); - + return Arrays.asList(getSupportedAttributeCategories()).contains(category); } @@ -835,28 +834,28 @@ public class IppPrintService implements PrintService public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes) { - // just redirect to getSupportedAttributeValues - Object values = getSupportedAttributeValues(attrval.getCategory(), - flavor, 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 + + // a single instance of another class to give the bounds // copies if (values.getClass().equals(CopiesSupported.class)) - return ((CopiesSupported) values).contains((IntegerSyntax) attrval); + return ((CopiesSupported) values).contains((IntegerSyntax) attrval); // number up if (values.getClass().equals(NumberUpSupported.class)) - return ((NumberUpSupported) values).contains((IntegerSyntax) attrval); + return ((NumberUpSupported) values).contains((IntegerSyntax) attrval); // job priority if (values.getClass().equals(JobPrioritySupported.class)) { @@ -865,15 +864,15 @@ public class IppPrintService implements PrintService 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: + + // 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) */ @@ -881,11 +880,11 @@ public class IppPrintService implements PrintService { if (flavor == null) throw new NullPointerException("DocFlavor may not be null."); - + return flavors.contains(flavor); } - + /** * @see PrintService#addPrintServiceAttributeListener(PrintServiceAttributeListener) */ @@ -894,7 +893,7 @@ public class IppPrintService implements PrintService { printServiceAttributeListener.add(listener); } - + /** * @see PrintService#removePrintServiceAttributeListener(PrintServiceAttributeListener) */ @@ -903,7 +902,7 @@ public class IppPrintService implements PrintService { printServiceAttributeListener.remove(listener); } - + /** * Returns "IppPrinter: " + <code>getName()</code> * @return The string representation. @@ -911,15 +910,15 @@ public class IppPrintService implements PrintService 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 index 869f8224be9..a0de6592fea 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppRequest.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java @@ -1,4 +1,4 @@ -/* IppRequest.java -- +/* IppRequest.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -112,37 +112,37 @@ import javax.print.attribute.standard.Sides; * <li>data - q bytes - optional</li> * </ul> * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class IppRequest { /** - * The printer-poll timeout. + * 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 @@ -218,7 +218,7 @@ public class IppRequest out.write(name.getBytes()); } else - out.writeShort(0x0000); // only name-length + out.writeShort(0x0000); // only name-length out.writeShort(8); // range is 8 bytes out.writeInt(ranges[i][0]); @@ -283,7 +283,7 @@ public class IppRequest } out.writeByte(directionFromUTC); - out.writeByte(offsetInMillis / 3600000); // hours + out.writeByte(offsetInMillis / 3600000); // hours out.writeByte((offsetInMillis % 3600000) / 60000); // minutes } @@ -295,7 +295,7 @@ public class IppRequest * of NAME value-tag in IPP this method checks for these attributes and * writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream. * </p> - * + * * @param attribute the attribute * @param out the stream to write to * @throws IOException if thrown by the stream @@ -314,11 +314,11 @@ public class IppRequest 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()); + out.write(attribute.getValue().getBytes()); } /** @@ -347,8 +347,8 @@ public class IppRequest * @throws IOException if thrown by the stream */ private void write(CharsetSyntax attribute) throws IOException - { - String name = ((Attribute) attribute).getName(); + { + String name = ((Attribute) attribute).getName(); out.writeByte(IppValueTag.CHARSET); out.writeShort(name.length()); out.write(name.getBytes()); @@ -371,7 +371,7 @@ public class IppRequest out.writeShort(attribute.getValue().length()); out.write(attribute.getValue().getBytes()); } - + /** * Writes an attribute in RequestedAttributes into the stream. * @param attribute the attribute @@ -380,32 +380,32 @@ public class IppRequest */ private void write(RequestedAttributes attribute) throws IOException { - List values = attribute.getValues(); - + String[] values = attribute.getValues(); + String name = ((Attribute) attribute).getName(); out.writeByte(IppValueTag.KEYWORD); out.writeShort(name.length()); - out.write(name.getBytes()); - out.writeShort(((String) values.get(0)).length()); - out.write(((String) values.get(0)).getBytes()); - - for (int i=1; i < values.size(); i++) + out.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(((String) values.get(i)).length()); - out.write(((String) values.get(i)).getBytes()); + 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. */ @@ -413,23 +413,23 @@ public class IppRequest 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() + ">"); - + + 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: <" + + 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); @@ -470,26 +470,26 @@ public class IppRequest .getName() + "> Value: <" + jobUri.toString() + ">"); } else if (reqAttrs != null) - { - write(reqAttrs); - attributes.remove(RequestedAttributes.class); - logger.log(Component.IPP, "RequestedAttributes: <" + reqAttrs + ">"); - } + { + 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. */ @@ -500,9 +500,9 @@ public class IppRequest for (int i = 0; i < attributeArray.length; i++) { logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i] - .getCategory().getName() + "> Value: <" - + attributeArray[i].toString() + ">"); - + .getCategory().getName() + "> Value: <" + + attributeArray[i].toString() + ">"); + if (attributeArray[i] instanceof IntegerSyntax) write((IntegerSyntax) attributeArray[i]); else if (attributeArray[i] instanceof TextSyntax) @@ -551,8 +551,8 @@ public class IppRequest /** The operation type of this request. */ private short operation_id; - /** - * The request id of this request. This is + /** + * The request id of this request. This is * assigned automatically by the constructor. */ private final int request_id; @@ -564,48 +564,48 @@ public class IppRequest 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(), + 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"); - } + 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 + // 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()); @@ -614,7 +614,7 @@ public class IppRequest /** * 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() @@ -624,7 +624,7 @@ public class IppRequest /** * Returns the id of this request. - * + * * @return The request ID. */ public int getRequestID() @@ -632,11 +632,11 @@ public class IppRequest return request_id; } - /** - * Sets the data of the request. The data used in this + /** + * 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) @@ -644,11 +644,11 @@ public class IppRequest data = stream; } - /** - * Sets the data of the request. The data used in this + /** + * 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) @@ -658,7 +658,7 @@ public class IppRequest /** * Sets the operation id for this request. - * + * * @param id the operation id. */ public void setOperationID(short id) @@ -668,7 +668,7 @@ public class IppRequest /** * Adds the default values for the operation - * attributes "attributes-charset" and + * attributes "attributes-charset" and * "attributes-natural-language" */ public void setOperationAttributeDefaults() @@ -679,64 +679,64 @@ public class IppRequest operationAttributes.add(AttributesCharset.UTF8); operationAttributes.add(AttributesNaturalLanguage.EN); } - + /** * Add the job attribute of this request to the given * attribute set. - * + * * @param attribute the job attribute. */ public void addJobAttribute(Attribute attribute) { if (jobAttributes == null) jobAttributes = new HashAttributeSet(); - + jobAttributes.add(attribute); } - + /** * Sets the printer attribute of this request to the given * attribute set. - * + * * @param attribute the printer attribute. */ public void addPrinterAttributes(Attribute attribute) { if (printerAttributes == null) printerAttributes = new HashAttributeSet(); - + printerAttributes.add(attribute); } /** * Adds the given attribute to the operation attributes set. - * + * * @param attribute the operation attribute to add. */ public void addOperationAttribute(Attribute attribute) { if (operationAttributes == null) operationAttributes = new HashAttributeSet(); - + operationAttributes.add(attribute); } - + /** * Filters from the given attribute set the job operation out * and adds them to the operation attributes set. - * + * * @param set the attributes to filter, may not be <code>null</code>. */ public void addAndFilterJobOperationAttributes(AttributeSet set) { if (operationAttributes == null) operationAttributes = new HashAttributeSet(); - + // document-natural-language - not defined in JPS attributes // document-format - specified outside, special treatment Attribute[] tmp = set.toArray(); - for (int i = 0; i < tmp.length; i++) - { + 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) @@ -745,27 +745,27 @@ public class IppRequest || tmp[i].getCategory().equals(Compression.class) || tmp[i].getCategory().equals(DocumentName.class) || tmp[i].getCategory().equals(RequestingUserName.class)) - - operationAttributes.add(tmp[i]); - } + + operationAttributes.add(tmp[i]); + } } - + /** * Filters from the given attribute set the job template attributes * out and adds them to the job attributes set. - * + * * @param set the attributes to filter, may not be <code>null</code>. */ public void addAndFilterJobTemplateAttributes(AttributeSet set) { if (jobAttributes == null) jobAttributes = new HashAttributeSet(); - + // document-natural-language - not defined in JPS attributes // document-format - specified outside, special treatment Attribute[] tmp = set.toArray(); - for (int i = 0; i < tmp.length; i++) - { + 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) @@ -780,67 +780,67 @@ public class IppRequest || tmp[i].getCategory().equals(PrintQuality.class) || tmp[i].getCategory().equals(SheetCollate.class) || tmp[i].getCategory().equals(Sides.class)) - - jobAttributes.add(tmp[i]); - } + + 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. + * @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(); + + 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); - + + 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); - + 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); + 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; + int len = 0; while( (len = ((InputStream) data).read(readbuf)) > 0) out.write(readbuf, 0, len); } @@ -848,27 +848,27 @@ public class IppRequest { out.write((byte[]) data); } - + out.flush(); - stream.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()); + { + 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 " + 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 index 81a1eb47b03..703bdc1eb90 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppResponse.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppResponse.java @@ -1,4 +1,4 @@ -/* IppResponse.java -- +/* IppResponse.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -99,9 +99,9 @@ import javax.print.attribute.standard.PrinterStateReasons; import javax.print.attribute.standard.Severity; /** - * <code>IppResponse</code> models a response received from an IPP + * <code>IppResponse</code> models a response received from an IPP * compatible server as described in RFC 2910 IPP 1.1 Encoding and Transport. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public class IppResponse @@ -112,7 +112,7 @@ public class IppResponse * response stream. It provides access to the attribute groups after parsing * via getter methods. * <p> - * The enconding of a response is structured as follows (for an official + * The enconding of a response is structured as follows (for an official * description please have a look at the RFC document mentioned above): * <ul> * <li>version-number - 2 bytes - required</li> @@ -122,19 +122,19 @@ public class IppResponse * <li>end-of-attributes-tag - 1 byte - required</li> * <li>data - q bytes - optional</li> * </ul> - * </p><p> + * </p><p> * Where each attribute-group (if any) is encoded as follows: * <ul> * <li>begin-attribute-group-tag - 1 byte</li> * <li>attribute - p bytes - 0 or more</li> * </ul> - * </p><p> + * </p><p> * Encoding of attributes: * <ul> * <li>attribute-with-one-value - q bytes</li> * <li>additional-value - r bytes - 0 or more</li> * </ul> - * </p><p> + * </p><p> * Encoding of attribute-with-one-value: * <ul> * <li>value-tag - 1 byte</li> @@ -143,7 +143,7 @@ public class IppResponse * <li>value-length (value is v) - 2 bytes</li> * <li>value - v bytes</li> * </ul> - * </p><p> + * </p><p> * Encoding of additional value: * <ul> * <li>value-tag - 1 byte</li> @@ -152,21 +152,21 @@ public class IppResponse * <li>value - w bytes</li> * </ul> * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ class ResponseReader { /** The IPP version defaults to 1.1 */ private static final short VERSION = 0x0101; - + /** * Parses the inputstream containing the response of the IPP request. * @param input the inputstream * @throws IppException if unexpected exceptions occur. * @throws IOException if IO problems with the underlying inputstream occur. */ - public void parseResponse(InputStream input) + public void parseResponse(InputStream input) throws IppException, IOException { DataInputStream stream = new DataInputStream(input); @@ -179,12 +179,12 @@ public class IppResponse throw new IppException("Version mismatch - " + "implementation does not support other versions than IPP 1.1"); - logger.log(Component.IPP, "Statuscode: " + logger.log(Component.IPP, "Statuscode: " + Integer.toHexString(status_code) + " Request-ID: " + request_id); byte tag = 0; boolean proceed = true; - HashMap tmp; + HashMap<Class<? extends Attribute>, Set<Attribute>> tmp; // iterate over attribute-groups until end-of-attributes-tag is found while (proceed) { @@ -200,23 +200,23 @@ public class IppResponse proceed = false; break; case IppDelimiterTag.OPERATION_ATTRIBUTES_TAG: - tmp = new HashMap(); + tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>(); tag = parseAttributes(tmp, stream); operationAttributes.add(tmp); break; case IppDelimiterTag.JOB_ATTRIBUTES_TAG: - tmp = new HashMap(); + tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>(); tag = parseAttributes(tmp, stream); jobAttributes.add(tmp); break; case IppDelimiterTag.PRINTER_ATTRIBUTES_TAG: - tmp = new HashMap(); + tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>(); tag = parseAttributes(tmp, stream); printerAttributes.add(tmp); break; case IppDelimiterTag.UNSUPPORTED_ATTRIBUTES_TAG: System.out.println("Called"); - tmp = new HashMap(); + tmp = new HashMap<Class<? extends Attribute>, Set<Attribute>>(); tag = parseAttributes(tmp, stream); unsupportedAttributes.add(tmp); break; @@ -247,7 +247,8 @@ public class IppResponse * @throws IppException if unexpected exceptions occur. * @throws IOException if IO problems with the underlying inputstream occur. */ - private byte parseAttributes(Map attributes, DataInputStream stream) + private byte parseAttributes(Map<Class<? extends Attribute>, Set<Attribute>> attributes, + DataInputStream stream) throws IppException, IOException { Attribute lastAttribute = null; @@ -294,7 +295,7 @@ public class IppResponse // (4) The value itself value = new byte[valueLength]; - stream.read(value); + stream.read(value); // the value itself switch (tag) @@ -304,12 +305,12 @@ public class IppResponse case IppValueTag.UNKNOWN: // TODO implement out-of-band handling // We currently throw an exception to see when it occurs - not yet :-) - throw new IppException( + throw new IppException( "Unexpected name value for out-of-band value tag " + tag); case IppValueTag.NO_VALUE: - attribute = null; + attribute = null; - break; + break; case IppValueTag.INTEGER: int intValue = IppUtilities.convertToInt(value); attribute = IppUtilities.getIntegerAttribute(name, intValue); @@ -319,11 +320,11 @@ public class IppResponse // 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)); + int intVal = IppUtilities.convertToInt(value); + attribute = IppUtilities.getEnumAttribute(name, new Integer(intVal)); break; case IppValueTag.OCTECTSTRING_UNSPECIFIED: @@ -347,7 +348,7 @@ public class IppResponse 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 @@ -362,7 +363,7 @@ public class IppResponse 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")) + 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); @@ -375,19 +376,19 @@ public class IppResponse 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); + 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 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); @@ -397,13 +398,13 @@ public class IppResponse 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: + + // 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 @@ -429,13 +430,13 @@ public class IppResponse 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); @@ -445,7 +446,7 @@ public class IppResponse attribute = new CharsetConfigured(str); else if (name.equals("charset-supported")) // setOf attribute = new CharsetSupported(str); - + break; case IppValueTag.NATURAL_LANGUAGE: str = new String(value); @@ -455,7 +456,7 @@ public class IppResponse 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); @@ -465,7 +466,7 @@ public class IppResponse 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 " @@ -473,11 +474,11 @@ public class IppResponse } if (attribute == null) - attribute = new UnknownAttribute(tag, name, value); - + attribute = new UnknownAttribute(tag, name, value); + addAttribute(attributes, attribute); lastAttribute = attribute; - + logger.log(Component.IPP, "Attribute: " + name + " Value: " + attribute.toString()); } @@ -492,20 +493,21 @@ public class IppResponse * @param attribute * the attribute to add */ - private void addAttribute(Map attributeGroup, Attribute attribute) + private void addAttribute(Map<Class<? extends Attribute>, Set<Attribute>> attributeGroup, + Attribute attribute) { - Class clazz = attribute.getCategory(); - Set attributeValues = (Set) attributeGroup.get(clazz); + Class<? extends Attribute> clazz = attribute.getCategory(); + Set<Attribute> attributeValues = attributeGroup.get(clazz); if (attributeValues == null) // first attribute of this category { - attributeValues = new HashSet(); + attributeValues = new HashSet<Attribute>(); attributeGroup.put(clazz, attributeValues); } attributeValues.add(attribute); } - + /** * Parses a name with or without language attribute value from the byte[] * and returns the result as an object[]. @@ -516,39 +518,39 @@ public class IppResponse private PrinterStateReasons parsePrinterStateReasons(byte[] value, Attribute lastAttr) { String str = new String(value); - PrinterStateReasons attribute; - + PrinterStateReasons attribute; + if (lastAttr instanceof PrinterStateReasons) attribute = (PrinterStateReasons) lastAttr; else attribute = new PrinterStateReasons(); - + // special case indicating no reasons - if (str.equals("none")) + 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 + str = str.substring(0, str.lastIndexOf('-')); + else // we must associate a severity severity = Severity.REPORT; - - reason = (PrinterStateReason) + + 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[]. @@ -559,24 +561,24 @@ public class IppResponse private JobStateReasons parseJobStateReasons(byte[] value, Attribute lastAttr) { String str = new String(value); - JobStateReasons attribute; - + JobStateReasons attribute; + if (lastAttr instanceof JobStateReasons) attribute = (JobStateReasons) lastAttr; else attribute = new JobStateReasons(); - + // special case indicating no reasons - if (str.equals("none")) + if (str.equals("none")) return attribute; - - JobStateReason reason = (JobStateReason) + + 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. @@ -597,7 +599,7 @@ public class IppResponse * <li>10 | 11 | minutes from UTC | 0..59</li> * </ul> * </p> - * + * * @param value the byte[] * @return The date object. */ @@ -625,28 +627,28 @@ public class IppResponse return cal.getTime(); } } - + /** * Logger for tracing - enable by passing * -Dgnu.classpath.debug.components=ipp to the vm. */ static final Logger logger = SystemLogger.SYSTEM; - + URI uri; short operation_id; short status_code; int request_id; - List operationAttributes; - List printerAttributes; - List jobAttributes; - List unsupportedAttributes; + List<Map<Class<? extends Attribute>, Set<Attribute>>> operationAttributes; + List<Map<Class<? extends Attribute>, Set<Attribute>>> printerAttributes; + List<Map<Class<? extends Attribute>, Set<Attribute>>> jobAttributes; + List<Map<Class<? extends Attribute>, Set<Attribute>>> unsupportedAttributes; byte[] data; /** * Creates an <code>IppResponse</code> instance. - * + * * @param uri the uri the request was directy to. * @param operation_id the operation id of the request. */ @@ -654,15 +656,19 @@ public class IppResponse { this.uri = uri; this.operation_id = operation_id; - operationAttributes = new ArrayList(); - jobAttributes = new ArrayList(); - printerAttributes = new ArrayList(); - unsupportedAttributes = new ArrayList(); + operationAttributes = + new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>(); + jobAttributes = + new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>(); + printerAttributes = + new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>(); + unsupportedAttributes = + new ArrayList<Map<Class<? extends Attribute>, Set<Attribute>>>(); } /** * Sets the data received from the request sent. - * + * * @param input the input stream received. * @throws IppException if parsing fails. */ @@ -703,10 +709,10 @@ public class IppResponse * Returns the set of job attributes group maps. * There may occur more than one group of type job attribute in a response * because of e.g. multiple job or print service informations requested. - * - * @return The list of job attribute grou maps. + * + * @return The list of job attribute group maps. */ - public List getJobAttributes() + public List<Map<Class<? extends Attribute>, Set<Attribute>>> getJobAttributes() { return jobAttributes; } @@ -715,10 +721,10 @@ public class IppResponse * Returns the set of operation attributes group maps. * There may occur more than one group of type job attribute in a response * because of e.g. multiple job or print service informations requested. - * - * @return The list of operation attribute grou maps. + * + * @return The list of operation attribute group maps. */ - public List getOperationAttributes() + public List<Map<Class<? extends Attribute>, Set<Attribute>>> getOperationAttributes() { return operationAttributes; } @@ -727,17 +733,17 @@ public class IppResponse * Returns the set of printer attributes group maps. * There may occur more than one group of type job attribute in a response * because of e.g. multiple job or print service informations requested. - * - * @return The list of printer attribute grou maps. + * + * @return The list of printer attribute group maps. */ - public List getPrinterAttributes() + public List<Map<Class<? extends Attribute>, Set<Attribute>>> getPrinterAttributes() { return printerAttributes; } /** * Returns the ID of the initial request. - * + * * @return The request ID. */ public int getRequestID() @@ -748,7 +754,7 @@ public class IppResponse /** * Returns the status code of the response. * Defined in {@link IppStatusCode}. - * + * * @return The status code. */ public short getStatusCode() @@ -760,17 +766,17 @@ public class IppResponse * Returns the set of unsupported attributes group maps. * There may occur more than one group of type job attribute in a response * because of e.g. multiple job or print service informations requested. - * - * @return The list of unsupported attribute grou maps. + * + * @return The list of unsupported attribute group maps. */ - public List getUnsupportedAttributes() + public List<Map<Class<? extends Attribute>, Set<Attribute>>> getUnsupportedAttributes() { return unsupportedAttributes; } /** * Returns the data of the response. - * + * * @return The data as byte[]. */ public byte[] getData() diff --git a/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java b/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java index d2cb8391f45..a3b245c43b8 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java @@ -1,4 +1,4 @@ -/* IppStatusCode.java -- +/* IppStatusCode.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,20 +39,20 @@ package gnu.javax.print.ipp; /** - * IPP Status codes as described in RFC 2911 APPENDIX B + * 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. +{ + /** + * 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. */ @@ -67,7 +67,7 @@ public final class IppStatusCode // 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; @@ -80,9 +80,9 @@ public final class IppStatusCode /** 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. + * For example if the request is directed at a job already finished. */ public static final int CLIENT_ERROR_NOT_POSSIBLE = 0x0404; @@ -106,16 +106,16 @@ public final class IppStatusCode /** * Indicates that the supplied attributes or values of attributes are not - * supported by the printer object. Returning this code depends on the + * 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 + 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. */ @@ -127,8 +127,8 @@ public final class IppStatusCode /** 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 + /** + * 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; @@ -136,13 +136,13 @@ public final class IppStatusCode /** 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 + /** + * 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; @@ -164,7 +164,7 @@ public final class IppStatusCode /** 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. */ @@ -174,11 +174,11 @@ public final class IppStatusCode 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 + 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 index 3038998879c..fa987ec3f43 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java @@ -1,4 +1,4 @@ -/* IppUtilities.java -- +/* IppUtilities.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -140,28 +140,30 @@ import javax.print.attribute.standard.Sides; * Also provides mapping from the attribute name values to * the actual class object. Used to construct objects via reflection. * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class IppUtilities { // These are reused in the reflection code to not instantiate an array everytime private static Object[] INTEGER_ATT_VALUE = new Object[1]; - private static Class[] INTEGER_CLASS_ARRAY = new Class[] {int.class}; + private static 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}; - + 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(); + private static HashMap<String,Class<? extends Attribute>> classesByName = + new HashMap<String,Class<? extends Attribute>>(); // The map -> StandardAttribute class to SupportedAttribute category name - private static HashMap instanceByClass = new HashMap(); + private static HashMap<Class<? extends Attribute>,SupportedValuesAttribute> instanceByClass = + new HashMap<Class<? extends Attribute>,SupportedValuesAttribute>(); /** * All the currently needed attributes */ static { - // enums + // enums classesByName.put(JobState.ABORTED.getName(), JobState.class); classesByName.put(Sides.DUPLEX.getName(), Sides.class); classesByName.put(SheetCollate.COLLATED.getName(), SheetCollate.class); @@ -174,113 +176,113 @@ public final class IppUtilities 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(ReferenceUriSchemesSupported.FILE.getName(), + ReferenceUriSchemesSupported.class); classesByName.put(PrinterStateReason.DOOR_OPEN.getName(), - PrinterStateReason.class); - classesByName.put(PresentationDirection.TOLEFT_TOTOP.getName(), + PrinterStateReason.class); + classesByName.put(PresentationDirection.TOLEFT_TOTOP.getName(), PresentationDirection.class); - classesByName.put(PDLOverrideSupported.ATTEMPTED.getName(), + classesByName.put(PDLOverrideSupported.ATTEMPTED.getName(), PDLOverrideSupported.class); - classesByName.put(OrientationRequested.PORTRAIT.getName(), + classesByName.put(OrientationRequested.PORTRAIT.getName(), OrientationRequested.class); - classesByName.put(MultipleDocumentHandling.SINGLE_DOCUMENT.getName(), + classesByName.put(MultipleDocumentHandling.SINGLE_DOCUMENT.getName(), MultipleDocumentHandling.class); - classesByName.put(JobStateReason.JOB_QUEUED.getName(), + 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(), + 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(), + + // the boolean types + classesByName.put(ColorSupported.SUPPORTED.getName(), ColorSupported.class); + classesByName.put(PrinterIsAcceptingJobs.ACCEPTING_JOBS.getName(), PrinterIsAcceptingJobs.class); - classesByName.put(MultipleDocumentJobsSupported.SUPPORTED.getName(), + classesByName.put(MultipleDocumentJobsSupported.SUPPORTED.getName(), MultipleDocumentJobsSupported.class); - classesByName.put(PageRangesSupported.SUPPORTED.getName(), + classesByName.put(PageRangesSupported.SUPPORTED.getName(), PageRangesSupported.class); - + // TextSyntax derived attributes - classesByName.put("media-default", MediaDefault.class); + 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("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", + 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", + 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); - + 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("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("printer-up-time", PrinterUpTime.class); classesByName.put("pages-per-minute", PagesPerMinute.class); - classesByName.put("pages-per-minute-color", PagesPerMinuteColor.class); + classesByName.put("pages-per-minute-color", PagesPerMinuteColor.class); classesByName.put("job-k-octets-processed", JobKOctetsProcessed.class); - classesByName.put("number-of-intervening-jobs", + classesByName.put("number-of-intervening-jobs", NumberOfInterveningJobs.class); - classesByName.put("job-impressions-completed", - JobImpressionsCompleted.class); - classesByName.put("job-media-sheets-completed", + classesByName.put("job-impressions-completed", + JobImpressionsCompleted.class); + classesByName.put("job-media-sheets-completed", JobMediaSheetsCompleted.class); - classesByName.put("multiple-operation-time-out", + 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)); @@ -299,7 +301,7 @@ public final class IppUtilities // 4.4 printer attributes instanceByClass.put(Compression.class, CompressionSupported.COMPRESS); } - + private IppUtilities() { // not to be instantiated @@ -308,38 +310,38 @@ public final class IppUtilities /** * Returns the implementing class object for given * attribute name objects. - * + * * @param name the attribute name * @return The <code>Class</code> object. */ - public static Class getClass(String name) + public static Class<? extends Attribute> getClass(String name) { - return (Class) classesByName.get(name); + return classesByName.get(name); } - + /** - * Returns the name of the supported attribute + * 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) + public static String getSupportedAttrName(Class<? extends Attribute> clazz) { - return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getName(); + return instanceByClass.get(clazz).getName(); } - + /** - * Returns the category of the supported attribute + * 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) + public static Class<? extends Attribute> getSupportedCategory(Class<? extends Attribute> clazz) { - return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getCategory(); - } + return instanceByClass.get(clazz).getCategory(); + } /** * Helper method to convert to an int. @@ -351,7 +353,7 @@ public final class IppUtilities 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 @@ -376,22 +378,22 @@ public final class IppUtilities { return (short) ((b1 << 8) | (b2 & 0xff)); } - + /** * Instantiates an <code>EnumSyntax</code> based attribute with the given IPP * name and the given value (Enums maybe int or String based). - * + * * @param name the attribute name of the subclass. * @param value the integer value of the specific enum. * @return The Attribute (a subclass of EnumSyntax) */ public static Attribute getEnumAttribute(String name, Object value) { - Class attrClass = getClass(name); - + Class<?> attrClass = getClass(name); + // There might be unknown enums we have no mapped class for if (attrClass == null) - return null; + return null; try { @@ -423,33 +425,33 @@ public final class IppUtilities { // should not happen, all fields are public } - + return null; } - - - + + + /** - * Instantiates an <code>IntegerSyntax</code> based attribute with the + * Instantiates an <code>IntegerSyntax</code> based attribute with the * given IPP name for the given int value. - * + * * @param name the attribute name of the subclass. * @param value the integer value * @return The Attribute (a subclass of IntegerSyntax) */ public static Attribute getIntegerAttribute(String name, int value) - { - Class attrClass = getClass(name); - + { + Class<?> attrClass = getClass(name); + // There might be unknown attributes we have no mapped class for if (attrClass == null) return null; try { - INTEGER_ATT_VALUE[0] = new Integer(value); - Constructor c = attrClass.getDeclaredConstructor(INTEGER_CLASS_ARRAY); - return (Attribute) c.newInstance(INTEGER_ATT_VALUE); + INTEGER_ATT_VALUE[0] = Integer.valueOf(value); + Constructor<?> c = attrClass.getDeclaredConstructor(INTEGER_CLASS_ARRAY); + return (Attribute) c.newInstance(INTEGER_ATT_VALUE); } catch (SecurityException e) { @@ -471,21 +473,21 @@ public final class IppUtilities { // should not happen, all fields are public } - + return null; - } - + } + /** * Instantiates an <code>TextSyntax</code> based attribute with the given * IPP name for the given text value (will be decoded). - * + * * @param name the attribute name of the subclass. * @param tag the tag defined in {@link IppValueTag} * @param value the byte[] value to be decoded based on the tag value. * @return The Attribute (a subclass of TextSyntax) */ public static Attribute getTextAttribute(String name, byte tag, byte[] value) - { + { // without language tag is rather easy - default locale if (tag == IppValueTag.NAME_WITHOUT_LANGUAGE || tag == IppValueTag.TEXT_WITHOUT_LANGUAGE) @@ -504,7 +506,7 @@ public final class IppUtilities 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 @@ -512,18 +514,18 @@ public final class IppUtilities TEXT_ATT_VALUE[0] = text; TEXT_ATT_VALUE[1] = locale; - } - - Class attrClass = getClass(name); - + } + + 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); + Constructor<?> c = attrClass.getDeclaredConstructor(TEXT_CLASS_ARRAY); + return (Attribute) c.newInstance(TEXT_ATT_VALUE); } catch (SecurityException e) { @@ -545,7 +547,7 @@ public final class IppUtilities { // 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 index 0c81befca08..def9545a38b 100644 --- a/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java +++ b/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java @@ -1,4 +1,4 @@ -/* IppValueTag.java -- +/* IppValueTag.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,96 +44,96 @@ package gnu.javax.print.ipp; * 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 + * out of band values for reporting requested attributes as * unsupported, unknown etc. back to the client. * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class IppValueTag -{ - +{ + /** Out of band value for unsupported attributes. */ public static final byte UNSUPPORTED = 0x10; - + // 0x11 reserved for 'default' for definition in a future - // IETF standards track document - + // 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; - + public static final byte KEYWORD = 0x44; + /** Indicates a value of syntax type URI. */ - public static final byte URI = 0x45; - + 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; - + public static final byte CHARSET = 0x47; + /** Indicates a value of syntax type language. */ - public static final byte NATURAL_LANGUAGE =0x48; - + public static final byte NATURAL_LANGUAGE =0x48; + /** Indicates a value of syntax type mime media. */ public static final byte MIME_MEDIA_TYPE = 0x49; @@ -145,15 +145,15 @@ public final class IppValueTag { // not to be instantiated; } - + /** - * Tests if given value corresponds to a + * Tests if given value corresponds to a * value tag value. - * + * * @param value the value to test for * @return <code>true</code> if, <code>false</code> otherwise. */ - public static boolean isValueTag(byte value) + public static boolean isValueTag(byte value) { if(value == 0x10 || value == 0x12 || value == 0x13 || value == 0x21 || value == 0x22 || value == 0x23 @@ -163,8 +163,8 @@ public final class IppValueTag || 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 index 1167f52c3b7..89163dc9933 100644 --- a/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java +++ b/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java @@ -45,18 +45,18 @@ import javax.print.PrintException; import javax.print.attribute.PrintRequestAttributeSet; /** - * Implementation of the MultiDocPrintJob interface. Implementation + * Implementation of the MultiDocPrintJob interface. Implementation * is specific to the <code>IppPrintService</code> implementation. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public class MultiDocPrintJobImpl extends DocPrintJobImpl +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. diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java b/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java index 0db846cbab9..cd112f4594f 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java @@ -1,4 +1,4 @@ -/* CharsetSyntax.java -- +/* CharsetSyntax.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,7 +41,7 @@ package gnu.javax.print.ipp.attribute; import java.io.Serializable; /** - * <code>CharsetSyntax</code> is the abstract base class of all attribute + * <code>CharsetSyntax</code> is the abstract base class of all attribute * classes which provide a charset (US-ASCII) string as value. * * @author Wolfgang Baer (WBaer@gmx.de) @@ -62,7 +62,7 @@ public abstract class CharsetSyntax implements Cloneable, Serializable { if (value == null) throw new NullPointerException("value may not be null"); - + this.value = value; } @@ -98,14 +98,14 @@ public abstract class CharsetSyntax implements Cloneable, Serializable if (! (obj instanceof CharsetSyntax)) return false; - CharsetSyntax tmp = (CharsetSyntax) obj; + 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() diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java index 0f1084f4958..cc40db22ef7 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java @@ -1,4 +1,4 @@ -/* DefaultValueAttribute.java -- +/* DefaultValueAttribute.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,18 +41,18 @@ package gnu.javax.print.ipp.attribute; import javax.print.attribute.Attribute; /** - * Marker interface for all attribute classes describing attributes + * 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 index 433b6f35a38..2d005a82ec9 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java @@ -1,4 +1,4 @@ -/* DetailedStatusMessage.java -- +/* DetailedStatusMessage.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,12 +45,12 @@ import javax.print.attribute.TextSyntax; /** * DetailedStatusMessage attribute as described in RFC 2911 section - * 3.1.6 Operation Response Status Codes and Status Message + * 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 +public final class DetailedStatusMessage extends TextSyntax implements Attribute { @@ -74,7 +74,7 @@ public final class DetailedStatusMessage extends TextSyntax * * @return The class <code>DetailedStatusMessage</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return DetailedStatusMessage.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java index 3433e3ed731..56b55ba760f 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java @@ -1,4 +1,4 @@ -/* DocumentAccessError.java -- +/* DocumentAccessError.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,12 +45,12 @@ import javax.print.attribute.TextSyntax; /** * DocumentAccessError attribute as described in RFC 2911 section - * 3.1.6 Operation Response Status Codes and Status Message + * 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 +public final class DocumentAccessError extends TextSyntax implements Attribute { @@ -74,7 +74,7 @@ public final class DocumentAccessError extends TextSyntax * * @return The class <code>DocumentAccessError</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return DocumentAccessError.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java b/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java index c90af3eb8e5..a648c8cece7 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java @@ -1,4 +1,4 @@ -/* NaturalLanguageSyntax.java -- +/* NaturalLanguageSyntax.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,13 +41,13 @@ package gnu.javax.print.ipp.attribute; import java.io.Serializable; /** - * <code>NaturalLanguageSyntax</code> is the abstract base class of all - * attribute classes which provide a natural language (US-ASCII) + * <code>NaturalLanguageSyntax</code> is the abstract base class of all + * attribute classes which provide a natural language (US-ASCII) * string as value. * * @author Wolfgang Baer (WBaer@gmx.de) */ -public abstract class NaturalLanguageSyntax +public abstract class NaturalLanguageSyntax implements Cloneable, Serializable { private final String value; @@ -64,7 +64,7 @@ public abstract class NaturalLanguageSyntax { if (value == null) throw new NullPointerException("value may not be null"); - + this.value = value; } @@ -100,14 +100,14 @@ public abstract class NaturalLanguageSyntax if (! (obj instanceof NaturalLanguageSyntax)) return false; - NaturalLanguageSyntax tmp = (NaturalLanguageSyntax) obj; + 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() diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java b/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java index 814fe2d0a74..4c129f6d574 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java @@ -1,4 +1,4 @@ -/* RequestedAttributes.java -- +/* RequestedAttributes.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,15 +48,15 @@ import javax.print.attribute.Attribute; /** * <code>RequestedAttributes</code> specifies the requested * attributes in an IPP request operation. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class RequestedAttributes implements Attribute { - private ArrayList attributes; + private ArrayList<String> attributes; /** - * Creates a <code>RequestedAttributes</code> object with + * Creates a <code>RequestedAttributes</code> object with * the initial value. * * @param value the string for the ipp name @@ -67,29 +67,29 @@ public final class RequestedAttributes implements Attribute { if (value == null) throw new NullPointerException(); - - attributes = new ArrayList(); + + attributes = new ArrayList<String>(); attributes.add(value); } - + /** * Adds the IPP name value to the set. - * + * * @param value the string for the ipp name */ public void addValue(String value) { attributes.add(value); } - + /** * Returns the values. - * + * * @return The values as list. */ - public List getValues() + public String[] getValues() { - return attributes; + return attributes.toArray(new String[attributes.size()]); } /** @@ -97,7 +97,7 @@ public final class RequestedAttributes implements Attribute * * @return The class <code>DocumentFormat</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return RequestedAttributes.class; } @@ -120,13 +120,13 @@ public final class RequestedAttributes implements Attribute 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 index 692b26ed562..0701008ef33 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java @@ -1,4 +1,4 @@ -/* StatusMessage.java -- +/* StatusMessage.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,9 +45,9 @@ import javax.print.attribute.TextSyntax; /** * StatusMessage attribute as described in RFC 2911 section - * 3.1.6 Operation Response Status Codes and Status Message + * 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 @@ -73,7 +73,7 @@ public final class StatusMessage extends TextSyntax implements Attribute * * @return The class <code>StatusMessage</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return StatusMessage.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java b/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java index 233431ad39c..a03beccbe3b 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java @@ -1,4 +1,4 @@ -/* UnknownAttribute.java -- +/* UnknownAttribute.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,7 +49,7 @@ 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 @@ -61,7 +61,7 @@ public final class UnknownAttribute implements Attribute /** * Creates a <code>UnknownAttribute</code> object with the given values. * - * @param tag the value tag + * @param tag the value tag * @param name the attribute name * @param value the byte[] with the value */ @@ -77,7 +77,7 @@ public final class UnknownAttribute implements Attribute * * @return The class <code>UnknownAttribute</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return UnknownAttribute.class; } @@ -91,18 +91,18 @@ public final class UnknownAttribute implements Attribute { 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. @@ -111,7 +111,7 @@ public final class UnknownAttribute implements Attribute { return name; } - + /** * Returns the attribute value origin byte array. * @return The value. @@ -120,7 +120,7 @@ public final class UnknownAttribute implements Attribute { return value; } - + /** * Returns the attribute value decoded as String. * @return The value as String. @@ -129,7 +129,7 @@ public final class UnknownAttribute implements Attribute { return new String(value); } - + /** * Returns the attribute value decoded as int. * @return The value as int. @@ -138,7 +138,7 @@ public final class UnknownAttribute implements Attribute { return IppUtilities.convertToInt(value); } - + /** * Returns the attribute value decoded as an URI. * @return The value as URI. @@ -159,7 +159,7 @@ public final class UnknownAttribute implements Attribute * 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. + * is returned. */ public String toString() { @@ -168,9 +168,9 @@ public final class UnknownAttribute implements Attribute case IppValueTag.INTEGER: return "" + getAttributeValueAsInt(); case IppValueTag.RANGEOFINTEGER: - int lower = IppUtilities.convertToInt(value[0], value[1], + int lower = IppUtilities.convertToInt(value[0], value[1], value[2], value[3]); - int upper = IppUtilities.convertToInt(value[4], value[5], + int upper = IppUtilities.convertToInt(value[4], value[5], value[6], value[7]); return lower + "-" + upper; case IppValueTag.URI: @@ -186,5 +186,5 @@ public final class UnknownAttribute implements Attribute 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 index 225a0895a0f..39d8fe1c097 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java @@ -1,4 +1,4 @@ -/* CopiesDefault.java -- +/* CopiesDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,13 +46,13 @@ import javax.print.attribute.standard.Copies; /** * <code>CopiesDefault</code> provides the default value * for the copies attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class CopiesDefault extends IntegerSyntax implements DefaultValueAttribute { - + /** * Creates a <code>CopiesDefault</code> object. * @@ -67,13 +67,13 @@ public final class CopiesDefault extends IntegerSyntax if (value < 1) throw new IllegalArgumentException("value may not be less than 1"); } - + /** * Tests if the given object is equal to this object. * * @param obj the object to test * - * @return <code>true</code> if both objects are equal, + * @return <code>true</code> if both objects are equal, * <code>false</code> otherwise. */ public boolean equals(Object obj) @@ -89,7 +89,7 @@ public final class CopiesDefault extends IntegerSyntax * * @return The class <code>CopiesDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return CopiesDefault.class; } @@ -103,15 +103,15 @@ public final class CopiesDefault extends IntegerSyntax { return "copies-default"; } - + /** * Returns the equally enum of the standard attribute class * of this DefaultValuesAttribute enum. * <p>May return null if no value exists in JPS API.</p> - * + * * @return The enum of the standard attribute class. */ - public Attribute getAssociatedAttribute() + 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 index fe40aee7222..5eff914982c 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java @@ -1,4 +1,4 @@ -/* DocumentFormatDefault.java -- +/* DocumentFormatDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,16 +49,16 @@ import javax.print.attribute.TextSyntax; /** * <code>DocumentFormatDefault</code> specifies the default document * format of a printer. - * + * * @author Wolfgang Baer (WBaer@gmx.de) * */ -public final class DocumentFormatDefault extends TextSyntax +public final class DocumentFormatDefault extends TextSyntax implements DefaultValueAttribute { /** - * Creates a <code>DocumentFormatDefault</code> object with the + * Creates a <code>DocumentFormatDefault</code> object with the * given value and locale. * * @param value the value for this syntax @@ -77,7 +77,7 @@ public final class DocumentFormatDefault extends TextSyntax * * @return The class <code>DocumentFormatDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return DocumentFormatDefault.class; } @@ -95,12 +95,12 @@ public final class DocumentFormatDefault extends TextSyntax /** * Returns the equally enum of the standard attribute class * of this DefaultValuesAttribute enum. - * + * * @return The enum of the standard attribute class. */ - public Attribute getAssociatedAttribute() + 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 index d3dd99c06d2..9d4a060029b 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java @@ -48,7 +48,7 @@ import javax.print.attribute.EnumSyntax; /** * The <code>FinishingsDefault</code> attribute provides the supported * values for finishings of a job. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class FinishingsDefault extends EnumSyntax @@ -57,108 +57,108 @@ public final class FinishingsDefault extends EnumSyntax /** 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. + * 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. + * 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. + + /** + * 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. + + /** + * 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) + * 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 + * 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 + * 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. + * the bottom edge. */ public static final FinishingsDefault EDGE_STITCH_BOTTOM = new FinishingsDefault(27); - + /** - * Bind the document(s) with two staples (wire stitches) along the + * 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 + * 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 + * 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 + * 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, + 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-left", + "staple-top-right", "staple-bottom-right", "edge-stitch-left", "edge-stitch-top", @@ -168,14 +168,14 @@ public final class FinishingsDefault extends EnumSyntax "staple-dual-top", "staple-dual-right", "staple-dual-bottom" }; - - private static final FinishingsDefault[] enumValueTable = { NONE, STAPLE, null, - COVER, BIND, + + private static final FinishingsDefault[] enumValueTable = { NONE, STAPLE, null, + COVER, BIND, SADDLE_STITCH, - EDGE_STITCH, null, - null, null, null, - null, null, null, - null, null, null, + EDGE_STITCH, null, + null, null, null, + null, null, null, + null, null, null, STAPLE_TOP_LEFT, STAPLE_BOTTOM_LEFT, STAPLE_TOP_RIGHT, @@ -188,10 +188,10 @@ public final class FinishingsDefault extends EnumSyntax STAPLE_DUAL_TOP, STAPLE_DUAL_RIGHT, STAPLE_DUAL_BOTTOM }; - + /** * Constructs a <code>FinishingsDefault</code> object. - * + * * @param value the value */ protected FinishingsDefault(int value) @@ -204,7 +204,7 @@ public final class FinishingsDefault extends EnumSyntax * * @return the class <code>FinishingsDefault</code> itself */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return FinishingsDefault.class; } @@ -218,7 +218,7 @@ public final class FinishingsDefault extends EnumSyntax { return "finishings-default"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -249,14 +249,14 @@ public final class FinishingsDefault extends EnumSyntax { 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() + 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 index a0baac7273a..7c29f231c4a 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java @@ -1,4 +1,4 @@ -/* JobHoldUntilDefault.java -- +/* JobHoldUntilDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -50,57 +50,57 @@ 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 +public final class JobHoldUntilDefault extends TextSyntax implements DefaultValueAttribute { - - // a keyword/name based attribute in IPP + + // 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 = + public static final JobHoldUntilDefault NO_HOLD = new JobHoldUntilDefault("no-hold", null); - + /** Job should be hold indefinitely. */ - public static final JobHoldUntilDefault INDEFINITE = + public static final JobHoldUntilDefault INDEFINITE = new JobHoldUntilDefault("indefinite", null); - + /** Job should be processed during the day. */ - public static final JobHoldUntilDefault DAY_TIME = + public static final JobHoldUntilDefault DAY_TIME = new JobHoldUntilDefault("day-time", null); - + /** Job should be processed in the evening. */ - public static final JobHoldUntilDefault EVENING = + public static final JobHoldUntilDefault EVENING = new JobHoldUntilDefault("evening", null); - + /** Job should be processed during night. */ - public static final JobHoldUntilDefault NIGHT = + public static final JobHoldUntilDefault NIGHT = new JobHoldUntilDefault("night", null); - + /** Job should be processed during the weekend. */ - public static final JobHoldUntilDefault WEEKEND = + public static final JobHoldUntilDefault WEEKEND = new JobHoldUntilDefault("weekend", null); - - /** - * Job should be processed as second-shift - * (after close of business). + + /** + * Job should be processed as second-shift + * (after close of business). */ - public static final JobHoldUntilDefault SECOND_SHIFT = + public static final JobHoldUntilDefault SECOND_SHIFT = new JobHoldUntilDefault("second-shift", null); - - /** - * Job should be processed as third-shift - * (after midnight). + + /** + * Job should be processed as third-shift + * (after midnight). */ - public static final JobHoldUntilDefault THIRD_SHIFT = - new JobHoldUntilDefault("third-shift", null); + public static final JobHoldUntilDefault THIRD_SHIFT = + new JobHoldUntilDefault("third-shift", null); /** - * Creates a <code>JobHoldUntilDefault</code> object with the + * Creates a <code>JobHoldUntilDefault</code> object with the * given value and locale. * * @param value the value for this syntax @@ -119,7 +119,7 @@ public final class JobHoldUntilDefault extends TextSyntax * * @return The class <code>JobHoldUntilDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobHoldUntilDefault.class; } @@ -133,14 +133,14 @@ public final class JobHoldUntilDefault extends TextSyntax { 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() + 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 index de6ad5a8af2..9430250ae79 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java @@ -1,4 +1,4 @@ -/* JobPriorityDefault.java -- +/* JobPriorityDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,13 +47,13 @@ import javax.print.attribute.standard.JobPriority; /** * JobPriorityDefault attribute provides the default value of * the printer object for the job-priority attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class JobPriorityDefault extends IntegerSyntax implements DefaultValueAttribute { - + /** * Creates a <code>JobPriorityDefault</code> object. * @@ -74,7 +74,7 @@ public final class JobPriorityDefault extends IntegerSyntax * * @param obj the object to test * - * @return <code>true</code> if both objects are equal, + * @return <code>true</code> if both objects are equal, * <code>false</code> otherwise. */ public boolean equals(Object obj) @@ -90,7 +90,7 @@ public final class JobPriorityDefault extends IntegerSyntax * * @return The class <code>JobPriorityDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobPriorityDefault.class; } @@ -104,14 +104,14 @@ public final class JobPriorityDefault extends IntegerSyntax { 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() + 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 index 8f92891238b..6bf027edadd 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java @@ -1,4 +1,4 @@ -/* JobSheetsDefault.java -- +/* JobSheetsDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,26 +49,26 @@ 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 +public final class JobSheetsDefault extends TextSyntax implements DefaultValueAttribute { - //a keyword/name based attribute in IPP + //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 = + public static final JobSheetsDefault NONE = new JobSheetsDefault("none", Locale.getDefault()); - + /** A job sheet is the default */ - public static final JobSheetsDefault STANDARD = + public static final JobSheetsDefault STANDARD = new JobSheetsDefault("standard", Locale.getDefault()); - + /** - * Creates a <code>JobSheetsDefault</code> object with the + * Creates a <code>JobSheetsDefault</code> object with the * given value and locale. * * @param value the value for this syntax @@ -81,13 +81,13 @@ public final class JobSheetsDefault extends TextSyntax { super(value, locale); } - + /** * Returns category of this class. * * @return The class <code>JobSheetsDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobSheetsDefault.class; } @@ -101,21 +101,21 @@ public final class JobSheetsDefault extends TextSyntax { return "job-sheets-default"; } - + /** * Returns the equally enum of the standard attribute class * of this DefaultValuesAttribute enum. * <p>May return null if no value exists in JPS API.</p> - * + * * @return The enum of the standard attribute class. */ - public Attribute getAssociatedAttribute() + 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 index b4e626da6b0..5945d0b9b1f 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java @@ -1,4 +1,4 @@ -/* MediaDefault.java -- +/* MediaDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,15 +49,15 @@ 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 +public final class MediaDefault extends TextSyntax implements DefaultValueAttribute { - + /** - * Creates a <code>MediaDefault</code> object with the + * Creates a <code>MediaDefault</code> object with the * given value and locale. * * @param value the value for this syntax @@ -70,13 +70,13 @@ public final class MediaDefault extends TextSyntax { super(value, locale); } - + /** * Returns category of this class. * * @return The class <code>MediaDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return MediaDefault.class; } @@ -90,14 +90,14 @@ public final class MediaDefault extends TextSyntax { 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() + 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 index 0cc324352d8..1563db82c21 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java @@ -47,49 +47,49 @@ import javax.print.attribute.EnumSyntax; /** * <code>MultipleDocumentHandlingDefault</code> provides the * default value for the MultipleDocumentHandling attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class MultipleDocumentHandlingDefault extends EnumSyntax implements DefaultValueAttribute { - + //a keyword based attribute in IPP - int values just starting at 0 - - /** - * Supports only multiple documents treated as a single document. This + + /** + * 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. + * with a new sheet. */ public static final MultipleDocumentHandlingDefault SINGLE_DOCUMENT_NEW_SHEET = new MultipleDocumentHandlingDefault(3); - private static final String[] stringTable = { "single-document", + private static final String[] stringTable = { "single-document", "separate-documents-uncollated-copies", "separate-documents-collated-copies", "single-document-new-sheet" }; - - private static final MultipleDocumentHandlingDefault[] enumValueTable = + + private static final MultipleDocumentHandlingDefault[] enumValueTable = { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES, SEPARATE_DOCUMENTS_COLLATED_COPIES, SINGLE_DOCUMENT_NEW_SHEET}; - + /** * Constructs a <code>MultipleDocumentHandlingDefault</code> object. - * + * * @param value the enum value */ protected MultipleDocumentHandlingDefault(int value) @@ -102,7 +102,7 @@ public final class MultipleDocumentHandlingDefault extends EnumSyntax * * @return The class <code>MultipleDocumentHandlingDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return MultipleDocumentHandlingDefault.class; } @@ -116,7 +116,7 @@ public final class MultipleDocumentHandlingDefault extends EnumSyntax { return "multiple-document-handling-default"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -137,16 +137,16 @@ public final class MultipleDocumentHandlingDefault extends EnumSyntax { 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() + public Attribute getAssociatedAttribute() { - return IppUtilities.getEnumAttribute("multiple-document-handling", + 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 index 6689f2d1c98..8e2d076d5fb 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java @@ -1,4 +1,4 @@ -/* NumberUpDefault.java -- +/* NumberUpDefault.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,13 +46,13 @@ import javax.print.attribute.standard.NumberUp; /** * NumberUpDefault attribute provides the default value of * the numper up attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class NumberUpDefault extends IntegerSyntax implements DefaultValueAttribute { - + /** * Creates a <code>NumberUpDefault</code> object. * @@ -63,13 +63,13 @@ public final class NumberUpDefault extends IntegerSyntax { super(value); } - + /** * Tests if the given object is equal to this object. * * @param obj the object to test * - * @return <code>true</code> if both objects are equal, + * @return <code>true</code> if both objects are equal, * <code>false</code> otherwise. */ public boolean equals(Object obj) @@ -85,7 +85,7 @@ public final class NumberUpDefault extends IntegerSyntax * * @return The class <code>NumberUpDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return NumberUpDefault.class; } @@ -99,15 +99,15 @@ public final class NumberUpDefault extends IntegerSyntax { return "number-up-default"; } - + /** * Returns the equally enum of the standard attribute class * of this DefaultValuesAttribute enum. * <p>May return null if no value exists in JPS API.</p> - * + * * @return The enum of the standard attribute class. */ - public Attribute getAssociatedAttribute() + 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 index 14d26555984..4563ec525c6 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java @@ -45,27 +45,27 @@ import javax.print.attribute.EnumSyntax; /** - * The <code>OrientationRequestedDefault</code> attribute provides + * The <code>OrientationRequestedDefault</code> attribute provides * the default value for the job attribute orientation-requested. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class OrientationRequestedDefault extends EnumSyntax implements DefaultValueAttribute { - + /** Orientation as portrait. */ public static final OrientationRequestedDefault PORTRAIT = new OrientationRequestedDefault(3); - + /** Orientation as landscape. */ public static final OrientationRequestedDefault LANDSCAPE = new OrientationRequestedDefault(4); - + /** Orientation as reversed landscape. */ public static final OrientationRequestedDefault REVERSE_LANDSCAPE = new OrientationRequestedDefault(5); - + /** Orientation as reversed portrait. */ public static final OrientationRequestedDefault REVERSE_PORTRAIT = new OrientationRequestedDefault(6); @@ -74,14 +74,14 @@ public final class OrientationRequestedDefault extends EnumSyntax private static final String[] stringTable = { "portrait", "landscape", "reverse-landscape", "reverse-portrait" }; - - private static final OrientationRequestedDefault[] - enumValueTable = { PORTRAIT, LANDSCAPE, + + private static final OrientationRequestedDefault[] + enumValueTable = { PORTRAIT, LANDSCAPE, REVERSE_LANDSCAPE, REVERSE_PORTRAIT }; - + /** * Constructs a <code>OrientationRequestedDefault</code> object. - * + * * @param value the value */ protected OrientationRequestedDefault(int value) @@ -94,7 +94,7 @@ public final class OrientationRequestedDefault extends EnumSyntax * * @return The class <code>OrientationRequestedDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return OrientationRequestedDefault.class; } @@ -108,7 +108,7 @@ public final class OrientationRequestedDefault extends EnumSyntax { return "orientation-requested-default"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -129,7 +129,7 @@ public final class OrientationRequestedDefault extends EnumSyntax { return enumValueTable; } - + /** * Returns the lowest used value by the enumerations of this class. * . @@ -139,16 +139,16 @@ public final class OrientationRequestedDefault extends EnumSyntax { 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() + public Attribute getAssociatedAttribute() { - return IppUtilities.getEnumAttribute("orientation-requested", + 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 index 707d11de0cd..7b123eeb431 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java @@ -47,7 +47,7 @@ import javax.print.attribute.EnumSyntax; /** * <code>PrintQualityDefault</code> provides the * default value for the print-quality attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class PrintQualityDefault extends EnumSyntax @@ -55,20 +55,20 @@ public final class PrintQualityDefault extends EnumSyntax { /** Draft quality of the printer. */ public static final PrintQualityDefault DRAFT = new PrintQualityDefault(3); - + /** Normal quality of the printer. */ public static final PrintQualityDefault NORMAL = new PrintQualityDefault(4); - + /** High quality of the printer. */ public static final PrintQualityDefault HIGH = new PrintQualityDefault(5); private static final String[] stringTable = { "draft", "normal", "high" }; - + private static final PrintQualityDefault[] enumValueTable = { DRAFT, NORMAL, HIGH }; - + /** * Constructs a <code>PrintQualityDefault</code> object. - * + * * @param value the value of the enum */ protected PrintQualityDefault(int value) @@ -81,7 +81,7 @@ public final class PrintQualityDefault extends EnumSyntax * * @return The class <code>PrintQualityDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrintQualityDefault.class; } @@ -95,7 +95,7 @@ public final class PrintQualityDefault extends EnumSyntax { return "print-quality-default"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -116,7 +116,7 @@ public final class PrintQualityDefault extends EnumSyntax { return enumValueTable; } - + /** * Returns the lowest used value by the enumerations of this class. * . @@ -126,14 +126,14 @@ public final class PrintQualityDefault extends EnumSyntax { 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() + 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 index baa00c6e9c7..2c84b99bae6 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java @@ -45,15 +45,15 @@ import javax.print.attribute.standard.PrinterResolution; /** - * The <code>PrinterResolutionDefault</code> attribute provides + * The <code>PrinterResolutionDefault</code> attribute provides * the default value for the job attribute printer-resolution. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class PrinterResolutionDefault extends ResolutionSyntax implements DefaultValueAttribute { - + /** * Creates a <code>ResolutionSyntax</code> object with the given arguments. * @@ -68,20 +68,20 @@ public final class PrinterResolutionDefault extends ResolutionSyntax { super(crossFeedResolution, feedResolution, units); } - + /** * Tests if the given object is equal to this object. * * @param obj the object to test * - * @return <code>true</code> if both objects are equal, + * @return <code>true</code> if both objects are equal, * <code>false</code> otherwise. */ public boolean equals(Object obj) { if(! (obj instanceof PrinterResolutionDefault)) return false; - + return super.equals(obj); } @@ -90,7 +90,7 @@ public final class PrinterResolutionDefault extends ResolutionSyntax * * @return The class <code>PrinterResolutionDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterResolutionDefault.class; } @@ -104,16 +104,16 @@ public final class PrinterResolutionDefault extends ResolutionSyntax { 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() + public Attribute getAssociatedAttribute() { - return new PrinterResolution(getCrossFeedResolutionDphi(), + 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 index 3c5b0cb864c..a50560ae974 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java @@ -47,45 +47,45 @@ import javax.print.attribute.EnumSyntax; /** * <code>SidesDefault</code> provides the * default for the sides attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class SidesDefault extends EnumSyntax implements DefaultValueAttribute { - + /** Specifies that each page should be printed on one sheet. */ public static final SidesDefault ONE_SIDED = new SidesDefault(0); - - /** - * Specifies that two following pages should be printed on the + + /** + * 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 = + public static final SidesDefault TWO_SIDED_LONG_EDGE = new SidesDefault(1); - - /** - * Specifies that two following pages should be printed on the + + /** + * 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 = + 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", + 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, + + private static final SidesDefault[] enumValueTable = { ONE_SIDED, + TWO_SIDED_LONG_EDGE, TWO_SIDED_SHORT_EDGE }; - - + + /** * Creates a <code>SidesDefault</code> object. * @@ -101,7 +101,7 @@ public final class SidesDefault extends EnumSyntax * * @return The class <code>SidesDefault</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return SidesDefault.class; } @@ -115,7 +115,7 @@ public final class SidesDefault extends EnumSyntax { return "sides-default"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -136,14 +136,14 @@ public final class SidesDefault extends EnumSyntax { 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() + 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 index 057db9bf6a9..4fe2ce0d556 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java @@ -46,24 +46,24 @@ import javax.print.attribute.Attribute; * AttributesCharset attribute as described in RFC 2911 chapter * 3.1.4 Character Set and Natural Language Operation Attributes. * <p> - * This operation attribute identifies the charset used by any text + * This operation attribute identifies the charset used by any text * and name attribute supplied by the client in the request. This * charset must be used by the printer object in the response.<br> * All clients and IPP objects must support the 'utf-8' charset. * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class AttributesCharset extends CharsetSyntax +public final class AttributesCharset extends CharsetSyntax implements Attribute { - + /** Defines a default UTF-8 charset instance */ public static final AttributesCharset UTF8 = new AttributesCharset("utf-8"); /** * Creates a <code>AttributesCharset</code> object. - * + * * @param value the charset string value. */ public AttributesCharset(String value) @@ -76,7 +76,7 @@ public final class AttributesCharset extends CharsetSyntax * * @return The class <code>AttributesCharset</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return AttributesCharset.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java index 8a41711ac8b..151cec43922 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java @@ -1,4 +1,4 @@ -/* AttributesNaturalLanguage.java -- +/* AttributesNaturalLanguage.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,23 +49,23 @@ import javax.print.attribute.Attribute; * <p> * This operation attribute identifies the natural language used * by any text and name attribute supplied by the client in the request. - * The printer object should use this natural language for the response + * The printer object should use this natural language for the response * to this request. * </p> - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class AttributesNaturalLanguage extends NaturalLanguageSyntax +public final class AttributesNaturalLanguage extends NaturalLanguageSyntax implements Attribute { - + /** Defines the default language EN */ - public static final AttributesNaturalLanguage EN = + public static final AttributesNaturalLanguage EN = new AttributesNaturalLanguage("en"); /** * Creates a <code>AttributesNaturalLanguage</code> object. - * + * * @param value the language string value. */ public AttributesNaturalLanguage(String value) @@ -78,7 +78,7 @@ public final class AttributesNaturalLanguage extends NaturalLanguageSyntax * * @return The class <code>AttributesNaturalLanguage</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return AttributesNaturalLanguage.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java index 29f47b7fa95..5b83344a922 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java @@ -1,4 +1,4 @@ -/* JobDetailedStatusMessages.java -- +/* JobDetailedStatusMessages.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,10 +46,10 @@ import javax.print.attribute.TextSyntax; /** * JobDetailedStatusMessages provides additional detailed and * technical job informations. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class JobDetailedStatusMessages +public final class JobDetailedStatusMessages extends TextSyntax implements Attribute { @@ -73,7 +73,7 @@ public final class JobDetailedStatusMessages * * @return The class <code>JobDetailedStatusMessages</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobDetailedStatusMessages.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java index 46083bed7dc..c3fff057c6f 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java @@ -1,4 +1,4 @@ -/* JobDocumentAccessErrors.java -- +/* JobDocumentAccessErrors.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,10 +47,10 @@ 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 +public final class JobDocumentAccessErrors extends TextSyntax implements Attribute { @@ -74,7 +74,7 @@ public final class JobDocumentAccessErrors * * @return The class <code>JobDocumentAccessErrors</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobDocumentAccessErrors.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java index f1d85fa50ba..78c866723e5 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java @@ -1,4 +1,4 @@ -/* JobId.java -- +/* JobId.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,7 +44,7 @@ import javax.print.attribute.IntegerSyntax; /** * The <code>JobId</code> attribute contains the ID of a * print job created or currently being processed. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class JobId extends IntegerSyntax implements Attribute @@ -59,7 +59,7 @@ public final class JobId extends IntegerSyntax implements Attribute public JobId(int value) { super(value); - + if (value < 1) throw new IllegalArgumentException("job-id may not be less than 1"); } @@ -69,7 +69,7 @@ public final class JobId extends IntegerSyntax implements Attribute * * @return The class <code>JobId</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobId.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java index a2fe322a887..569400f403a 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java @@ -1,4 +1,4 @@ -/* JobMoreInfo.java -- +/* JobMoreInfo.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,7 +47,7 @@ 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 @@ -69,7 +69,7 @@ public final class JobMoreInfo extends URISyntax implements Attribute * * @return The class <code>JobMoreInfo</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobMoreInfo.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java index dce552020f2..1375a241985 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java @@ -1,4 +1,4 @@ -/* JobPrinterUri.java -- +/* JobPrinterUri.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,7 +47,7 @@ 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 @@ -69,7 +69,7 @@ public final class JobPrinterUri extends URISyntax implements Attribute * * @return The class <code>JobPrinterUri</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobPrinterUri.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java index 0cf652307b6..d65126621a3 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java @@ -1,4 +1,4 @@ -/* JobStateMessage.java -- +/* JobStateMessage.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,10 +46,10 @@ 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 +public final class JobStateMessage extends TextSyntax implements Attribute { @@ -73,7 +73,7 @@ public final class JobStateMessage * * @return The class <code>JobStateMessage</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobStateMessage.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java index fa7e3f7b5a5..4b545b956b1 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java @@ -1,4 +1,4 @@ -/* JobUri.java -- +/* JobUri.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,7 +47,7 @@ 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 @@ -69,7 +69,7 @@ public final class JobUri extends URISyntax implements Attribute * * @return The class <code>JobUri</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobUri.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java index 7c87545880c..42430377c35 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java @@ -1,4 +1,4 @@ -/* CharsetConfigured.java -- +/* CharsetConfigured.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,16 +46,16 @@ 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 +public final class CharsetConfigured extends CharsetSyntax implements Attribute { /** * Creates a <code>CharsetConfigured</code> object. - * + * * @param value the charset string value. */ public CharsetConfigured(String value) @@ -68,7 +68,7 @@ public final class CharsetConfigured extends CharsetSyntax * * @return The class <code>CharsetConfigured</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return CharsetConfigured.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java index e9abab464f1..9a5e01e1d96 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java @@ -1,4 +1,4 @@ -/* DocumentFormat.java -- +/* DocumentFormat.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,21 +41,22 @@ package gnu.javax.print.ipp.attribute.printer; import java.util.Locale; import javax.print.DocFlavor; +import javax.print.attribute.Attribute; import javax.print.attribute.SupportedValuesAttribute; import javax.print.attribute.TextSyntax; /** * <code>DocumentFormatSupported</code> specifies the supported document * formats of a printer. Printer are supplying a set of this attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class DocumentFormat extends TextSyntax +public final class DocumentFormat extends TextSyntax implements SupportedValuesAttribute { /** - * Creates a <code>DocumentFormat</code> object with the + * Creates a <code>DocumentFormat</code> object with the * given value and locale. * * @param value the value for this syntax @@ -68,12 +69,12 @@ public final class DocumentFormat extends TextSyntax { 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. */ @@ -83,7 +84,7 @@ public final class DocumentFormat extends TextSyntax String mimetype = flavor.getMediaType() + "/" + flavor.getMediaSubtype(); if (charset != null) mimetype += "; charset=" + charset; - + return new DocumentFormat(mimetype, null); } @@ -92,7 +93,7 @@ public final class DocumentFormat extends TextSyntax * * @return The class <code>DocumentFormat</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return DocumentFormat.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java index 8e54e05658a..bb00b8891f7 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java @@ -1,4 +1,4 @@ -/* MultipleOperationTimeOut.java -- +/* MultipleOperationTimeOut.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,10 +46,10 @@ import javax.print.attribute.IntegerSyntax; * 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 +public final class MultipleOperationTimeOut extends IntegerSyntax implements Attribute { @@ -68,7 +68,7 @@ public final class MultipleOperationTimeOut extends IntegerSyntax * * @return The class <code>MultipleOperationTimeOut</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return MultipleOperationTimeOut.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java index 8032c3aa7f3..8dc05fe58d3 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java @@ -1,4 +1,4 @@ -/* NaturalLanguageConfigured.java -- +/* NaturalLanguageConfigured.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,19 +43,19 @@ import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax; import javax.print.attribute.Attribute; /** - * NaturalLanguageConfigured attribute as described in RFC 2911 + * 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 +public final class NaturalLanguageConfigured extends NaturalLanguageSyntax implements Attribute { /** * Creates a <code>NaturalLanguageConfigured</code> object. - * + * * @param value the charset string value. */ public NaturalLanguageConfigured(String value) @@ -68,7 +68,7 @@ public final class NaturalLanguageConfigured extends NaturalLanguageSyntax * * @return The class <code>NaturalLanguageConfigured</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return NaturalLanguageConfigured.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java index fe64ab0f778..361916773a4 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java @@ -1,4 +1,4 @@ -/* PrinterCurrentTime.java -- +/* PrinterCurrentTime.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ 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; @@ -48,10 +49,10 @@ import javax.print.attribute.PrintServiceAttribute; * 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 +public final class PrinterCurrentTime extends DateTimeSyntax implements PrintServiceAttribute { @@ -72,7 +73,7 @@ public final class PrinterCurrentTime extends DateTimeSyntax * * @param obj the object to test * - * @return <code>true</code> if both objects are equal, + * @return <code>true</code> if both objects are equal, * <code>false</code> otherwise. */ public boolean equals(Object obj) @@ -82,13 +83,13 @@ public final class PrinterCurrentTime extends DateTimeSyntax return super.equals(obj); } - + /** * Returns category of this class. * * @return The class <code>PrinterCurrentTime</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterCurrentTime.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java index 8a70edf349c..28a2f448570 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java @@ -1,4 +1,4 @@ -/* PrinterDriverInstaller.java -- +/* PrinterDriverInstaller.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,10 +47,10 @@ 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 +public final class PrinterDriverInstaller extends URISyntax implements Attribute { @@ -70,7 +70,7 @@ public final class PrinterDriverInstaller extends URISyntax * * @return The class <code>PrinterDriverInstaller</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterDriverInstaller.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java index da463c4c9fb..07c458889ff 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java @@ -1,4 +1,4 @@ -/* PrinterStateMessage.java -- +/* PrinterStateMessage.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ 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; @@ -48,15 +49,15 @@ import javax.print.attribute.TextSyntax; * 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 +public final class PrinterStateMessage extends TextSyntax implements PrintServiceAttribute { /** - * Creates a <code>PrinterStateMessage</code> object with the + * Creates a <code>PrinterStateMessage</code> object with the * given value and locale. * * @param value the value for this syntax @@ -75,7 +76,7 @@ public final class PrinterStateMessage extends TextSyntax * * @return The class <code>PrinterStateMessage</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterStateMessage.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java index 7f9b1113ff6..7bec92ed302 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java @@ -1,4 +1,4 @@ -/* PrinterUpTime.java -- +/* PrinterUpTime.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,12 +44,12 @@ 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 + * 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 +public final class PrinterUpTime extends IntegerSyntax implements Attribute { @@ -68,7 +68,7 @@ public final class PrinterUpTime extends IntegerSyntax * * @return The class <code>PrinterUpTime</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterUpTime.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java index 75804b5a46b..22b484ef8dc 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java @@ -1,4 +1,4 @@ -/* CharsetSupported.java -- +/* CharsetSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,23 +40,24 @@ 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 + * 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 +public final class CharsetSupported extends CharsetSyntax implements SupportedValuesAttribute { /** * Creates a <code>CharsetSupported</code> object. - * + * * @param value the charset string value. */ public CharsetSupported(String value) @@ -69,7 +70,7 @@ public final class CharsetSupported extends CharsetSyntax * * @return The class <code>CharsetSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return CharsetSupported.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java index 648167a938d..768091cb29b 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java @@ -42,6 +42,7 @@ 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; @@ -50,34 +51,34 @@ import javax.print.attribute.standard.Compression; /** * <code>CompressionSupported</code> provides the values which are * supported for the compression attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class CompressionSupported extends EnumSyntax implements SupportedValuesAttribute { - + /** The print data is not compressed. */ public static final CompressionSupported NONE = new CompressionSupported(0); - + /** The print data is ZIP compressed. */ public static final CompressionSupported DEFLATE = new CompressionSupported(1); - + /** The print data is GNU Zip compressed. */ public static final CompressionSupported GZIP = new CompressionSupported(2); - + /** The print data is UNIX compressed. */ public static final CompressionSupported COMPRESS = new CompressionSupported(3); - - private static final String[] stringTable = { "none", "deflate", + + private static final String[] stringTable = { "none", "deflate", "gzip", "compress" }; - - private static final CompressionSupported[] enumValueTable = { NONE, DEFLATE, + + private static final CompressionSupported[] enumValueTable = { NONE, DEFLATE, GZIP, COMPRESS }; /** * Constructs a <code>CompressionSupported</code> object. - * + * * @param value the enum value */ protected CompressionSupported(int value) @@ -90,7 +91,7 @@ public final class CompressionSupported extends EnumSyntax * * @return The class <code>CompressionSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return CompressionSupported.class; } @@ -104,7 +105,7 @@ public final class CompressionSupported extends EnumSyntax { return "compression-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -125,38 +126,36 @@ public final class CompressionSupported extends EnumSyntax { 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() + 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) + public static Compression[] + getAssociatedAttributeArray(Set<Attribute> set) { - CompressionSupported tmp; - Compression[] result = new Compression[set.size()]; - Iterator it = set.iterator(); + Compression[] result = new Compression[set.size()]; int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (CompressionSupported) it.next(); - result[j] = tmp.getAssociatedAttribute(); + 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 index 6bd63dcfc72..03449fa4f56 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java @@ -1,4 +1,4 @@ -/* DocumentFormatSupported.java -- +/* DocumentFormatSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,21 +40,22 @@ package gnu.javax.print.ipp.attribute.supported; import java.util.Locale; +import javax.print.attribute.Attribute; import javax.print.attribute.SupportedValuesAttribute; import javax.print.attribute.TextSyntax; /** * <code>DocumentFormatSupported</code> specifies the supported document * formats of a printer. Printer are supplying a set of this attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class DocumentFormatSupported extends TextSyntax +public final class DocumentFormatSupported extends TextSyntax implements SupportedValuesAttribute { /** - * Creates a <code>DocumentFormatSupported</code> object with the + * Creates a <code>DocumentFormatSupported</code> object with the * given value and locale. * * @param value the value for this syntax @@ -73,7 +74,7 @@ public final class DocumentFormatSupported extends TextSyntax * * @return The class <code>DocumentFormatSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return DocumentFormatSupported.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java index 9f9c635d3fe..f271fa71b88 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java @@ -43,6 +43,7 @@ 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; @@ -51,7 +52,7 @@ import javax.print.attribute.standard.Finishings; /** * The <code>FinishingsSupported</code> attribute provides the supported * values for finishings of a job. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class FinishingsSupported extends EnumSyntax @@ -60,122 +61,122 @@ public final class FinishingsSupported extends EnumSyntax /** 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. + * Bind the document(s) with one or more staples (wire stitches) + * along the middle fold. */ - public static final FinishingsSupported SADDLE_STITCH = + public static final FinishingsSupported SADDLE_STITCH = new FinishingsSupported(8); - + /** - * Bind the document(s) with one or more staples (wire stitches) - * along one edge. + * Bind the document(s) with one or more staples (wire stitches) + * along one edge. */ - public static final FinishingsSupported EDGE_STITCH = + public static final FinishingsSupported EDGE_STITCH = new FinishingsSupported(9); - - /** - * Bind the document(s) with one or more staples in the top left - * corner. + + /** + * Bind the document(s) with one or more staples in the top left + * corner. */ - public static final FinishingsSupported STAPLE_TOP_LEFT = + public static final FinishingsSupported STAPLE_TOP_LEFT = new FinishingsSupported(20); - - /** - * Bind the document(s) with one or more staples in the bottom - * left corner. + + /** + * Bind the document(s) with one or more staples in the bottom + * left corner. */ - public static final FinishingsSupported STAPLE_BOTTOM_LEFT = + 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 = + 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 = + public static final FinishingsSupported STAPLE_BOTTOM_RIGHT = new FinishingsSupported(23); - + /** - * Bind the document(s) with one or more staples (wire stitches) + * Bind the document(s) with one or more staples (wire stitches) * along the left edge. */ - public static final FinishingsSupported EDGE_STITCH_LEFT = + public static final FinishingsSupported EDGE_STITCH_LEFT = new FinishingsSupported(24); - + /** - * Bind the document(s) with one or more staples (wire stitches) along + * Bind the document(s) with one or more staples (wire stitches) along * the top edge. */ - public static final FinishingsSupported EDGE_STITCH_TOP = + public static final FinishingsSupported EDGE_STITCH_TOP = new FinishingsSupported(25); - + /** - * Bind the document(s) with one or more staples (wire stitches) along + * Bind the document(s) with one or more staples (wire stitches) along * the right edge. */ - public static final FinishingsSupported EDGE_STITCH_RIGHT = + 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. + * the bottom edge. */ - public static final FinishingsSupported EDGE_STITCH_BOTTOM = + public static final FinishingsSupported EDGE_STITCH_BOTTOM = new FinishingsSupported(27); - + /** - * Bind the document(s) with two staples (wire stitches) along the + * Bind the document(s) with two staples (wire stitches) along the * left edge assuming a portrait document. */ - public static final FinishingsSupported STAPLE_DUAL_LEFT = + public static final FinishingsSupported STAPLE_DUAL_LEFT = new FinishingsSupported(28); - + /** - * Bind the document(s) with two staples (wire stitches) along the + * Bind the document(s) with two staples (wire stitches) along the * top edge assuming a portrait document. */ - public static final FinishingsSupported STAPLE_DUAL_TOP = + public static final FinishingsSupported STAPLE_DUAL_TOP = new FinishingsSupported(29); - + /** - * Bind the document(s) with two staples (wire stitches) along the + * Bind the document(s) with two staples (wire stitches) along the * right edge assuming a portrait document. */ - public static final FinishingsSupported STAPLE_DUAL_RIGHT = + public static final FinishingsSupported STAPLE_DUAL_RIGHT = new FinishingsSupported(30); - + /** - * Bind the document(s) with two staples (wire stitches) along the + * Bind the document(s) with two staples (wire stitches) along the * bottom edge assuming a portrait document. */ - public static final FinishingsSupported STAPLE_DUAL_BOTTOM = + public static final FinishingsSupported STAPLE_DUAL_BOTTOM = new FinishingsSupported(31); - private static final String[] stringTable = { "none", "staple", null, + 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-left", + "staple-top-right", "staple-bottom-right", "edge-stitch-left", "edge-stitch-top", @@ -185,14 +186,14 @@ public final class FinishingsSupported extends EnumSyntax "staple-dual-top", "staple-dual-right", "staple-dual-bottom" }; - - private static final FinishingsSupported[] enumValueTable = { NONE, STAPLE, - null, COVER, BIND, + + private static final FinishingsSupported[] enumValueTable = { NONE, STAPLE, + null, COVER, BIND, SADDLE_STITCH, - EDGE_STITCH, null, - null, null, null, - null, null, null, - null, null, null, + EDGE_STITCH, null, + null, null, null, + null, null, null, + null, null, null, STAPLE_TOP_LEFT, STAPLE_BOTTOM_LEFT, STAPLE_TOP_RIGHT, @@ -205,10 +206,10 @@ public final class FinishingsSupported extends EnumSyntax STAPLE_DUAL_TOP, STAPLE_DUAL_RIGHT, STAPLE_DUAL_BOTTOM }; - + /** * Constructs a <code>FinishingsSupported</code> object. - * + * * @param value the value */ protected FinishingsSupported(int value) @@ -221,7 +222,7 @@ public final class FinishingsSupported extends EnumSyntax * * @return the class <code>FinishingsSupported</code> itself */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return FinishingsSupported.class; } @@ -235,7 +236,7 @@ public final class FinishingsSupported extends EnumSyntax { return "finishings-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -266,38 +267,36 @@ public final class FinishingsSupported extends EnumSyntax { 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() + 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) + public static Finishings[] + getAssociatedAttributeArray(Set<Attribute> set) { - FinishingsSupported tmp; - Finishings[] result = new Finishings[set.size()]; - Iterator it = set.iterator(); + Finishings[] result = new Finishings[set.size()]; int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (FinishingsSupported) it.next(); - result[j] = tmp.getAssociatedAttribute(); + 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 index 1dbb2939fc5..df1d330076c 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java @@ -1,4 +1,4 @@ -/* GeneratedNaturalLanguageSupported.java -- +/* GeneratedNaturalLanguageSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,24 +40,25 @@ 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 + * 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 + * 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 +public final class GeneratedNaturalLanguageSupported + extends NaturalLanguageSyntax implements SupportedValuesAttribute { /** * Creates a <code>GeneratedNaturalLanguageSupported</code> object. - * + * * @param value the charset string value. */ public GeneratedNaturalLanguageSupported(String value) @@ -70,7 +71,7 @@ public final class GeneratedNaturalLanguageSupported * * @return The class <code>GeneratedNaturalLanguageSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return GeneratedNaturalLanguageSupported.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java index 06365e6d11c..072d7499a5e 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java @@ -1,4 +1,4 @@ -/* IppVersionsSupported.java -- +/* IppVersionsSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,7 @@ 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; @@ -45,31 +46,31 @@ 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 +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 = + public static final IppVersionsSupported V_1_0 = new IppVersionsSupported(0); - + /** IPP version 1.1 */ - public static final IppVersionsSupported V_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, + + private static final IppVersionsSupported[] enumValueTable = { V_1_0, V_1_1 }; /** * Constructs a <code>IppVersionsSupported</code> object. - * + * * @param value the enum value */ public IppVersionsSupported(int value) @@ -78,11 +79,11 @@ public final class IppVersionsSupported extends EnumSyntax } /** - * Returns category of this class. + * Returns the category of this class. * * @return The class <code>IppVersionsSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return IppVersionsSupported.class; } @@ -96,7 +97,7 @@ public final class IppVersionsSupported extends EnumSyntax { return "ipp-versions-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java index a15d0095f73..2add4a0cd55 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java @@ -1,4 +1,4 @@ -/* JobHoldUntilSupported.java -- +/* JobHoldUntilSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,63 +40,64 @@ 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 +public final class JobHoldUntilSupported extends TextSyntax implements SupportedValuesAttribute { - - // a keyword/name based attribute in IPP + + // 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 = + public static final JobHoldUntilSupported NO_HOLD = new JobHoldUntilSupported("no-hold", null); - + /** Job should be hold indefinitely. */ - public static final JobHoldUntilSupported INDEFINITE = + public static final JobHoldUntilSupported INDEFINITE = new JobHoldUntilSupported("indefinite", null); - + /** Job should be processed during the day. */ - public static final JobHoldUntilSupported DAY_TIME = + public static final JobHoldUntilSupported DAY_TIME = new JobHoldUntilSupported("day-time", null); - + /** Job should be processed in the evening. */ - public static final JobHoldUntilSupported EVENING = + public static final JobHoldUntilSupported EVENING = new JobHoldUntilSupported("evening", null); - + /** Job should be processed during night. */ - public static final JobHoldUntilSupported NIGHT = + public static final JobHoldUntilSupported NIGHT = new JobHoldUntilSupported("night", null); - + /** Job should be processed during the weekend. */ - public static final JobHoldUntilSupported WEEKEND = + public static final JobHoldUntilSupported WEEKEND = new JobHoldUntilSupported("weekend", null); - - /** - * Job should be processed as second-shift - * (after close of business). + + /** + * Job should be processed as second-shift + * (after close of business). */ - public static final JobHoldUntilSupported SECOND_SHIFT = + public static final JobHoldUntilSupported SECOND_SHIFT = new JobHoldUntilSupported("second-shift", null); - - /** - * Job should be processed as third-shift - * (after midnight). + + /** + * Job should be processed as third-shift + * (after midnight). */ - public static final JobHoldUntilSupported THIRD_SHIFT = - new JobHoldUntilSupported("third-shift", null); + public static final JobHoldUntilSupported THIRD_SHIFT = + new JobHoldUntilSupported("third-shift", null); /** - * Creates a <code>JobHoldUntilSupported</code> object with the + * Creates a <code>JobHoldUntilSupported</code> object with the * given value and locale. * * @param value the value for this syntax @@ -115,7 +116,7 @@ public final class JobHoldUntilSupported extends TextSyntax * * @return The class <code>JobHoldUntilSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobHoldUntilSupported.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java index 4051e24200c..aeb86ff1052 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java @@ -1,4 +1,4 @@ -/* JobSheetsSupported.java -- +/* JobSheetsSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,26 +53,26 @@ 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 +public final class JobSheetsSupported extends TextSyntax implements SupportedValuesAttribute { - //a keyword/name based attribute in IPP + //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 = + public static final JobSheetsDefault NONE = new JobSheetsDefault("none", Locale.getDefault()); - + /** A job sheet is the default */ - public static final JobSheetsDefault STANDARD = + public static final JobSheetsDefault STANDARD = new JobSheetsDefault("standard", Locale.getDefault()); - + /** - * Creates a <code>JobSheetsSupported</code> object with the + * Creates a <code>JobSheetsSupported</code> object with the * given value and locale. * * @param value the value for this syntax @@ -85,13 +85,13 @@ public final class JobSheetsSupported extends TextSyntax { super(value, locale); } - + /** * Returns category of this class. * * @return The class <code>JobSheetsSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return JobSheetsSupported.class; } @@ -105,46 +105,44 @@ public final class JobSheetsSupported extends TextSyntax { return "job-sheets-supported"; } - + /** * Returns the equally enum of the standard attribute class * of this SupportedValuesAttribute enum. * <p>May return null if no value exists in JPS API.</p> - * + * * @return The enum of the standard attribute class. */ - public JobSheets getAssociatedAttribute() + 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) + public static JobSheets[] + getAssociatedAttributeArray(Set<Attribute> set) { - JobSheetsSupported tmp; - ArrayList result = new ArrayList(); - Iterator it = set.iterator(); + ArrayList<JobSheets> result = new ArrayList<JobSheets>(); int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (JobSheetsSupported) it.next(); - Attribute att = tmp.getAssociatedAttribute(); + JobSheets att = ((JobSheetsSupported) tmp).getAssociatedAttribute(); if (att != null) result.add(att); j++; - } - return (JobSheets[]) result.toArray(new JobSheets[result.size()]); + } + 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 index 3f10c06b5f7..2684ebbecd5 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java @@ -1,4 +1,4 @@ -/* MediaSupported.java -- +/* MediaSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,6 +45,7 @@ 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; @@ -52,15 +53,15 @@ 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 +public final class MediaSupported extends TextSyntax implements SupportedValuesAttribute { /** - * Creates a <code>MediaSupported</code> object with the + * Creates a <code>MediaSupported</code> object with the * given value and locale. * * @param value the value for this syntax @@ -79,7 +80,7 @@ public final class MediaSupported extends TextSyntax * * @return The class <code>MediaSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return MediaSupported.class; } @@ -93,26 +94,23 @@ public final class MediaSupported extends TextSyntax { 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) + public static Media[] getAssociatedAttributeArray(Set<Attribute> set) { - MediaSupported tmp; Media tmp2; - ArrayList result = new ArrayList(); - Iterator it = set.iterator(); - while (it.hasNext()) + ArrayList<Media> result = new ArrayList<Media>(); + for (Attribute tmp : set) { - tmp = (MediaSupported) it.next(); tmp2 = (Media) IppUtilities.getEnumAttribute("media", tmp.toString()); if (tmp2 != null) result.add(tmp2); - } - return (Media[]) result.toArray(new Media[result.size()]); + } + 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 index 891a99faedb..73e5921f1cd 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java @@ -42,6 +42,7 @@ 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; @@ -50,49 +51,49 @@ import javax.print.attribute.standard.MultipleDocumentHandling; /** * <code>MultipleDocumentHandlingSupported</code> provides the * supported values for the MultipleDocumentHandling attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class MultipleDocumentHandlingSupported extends EnumSyntax implements SupportedValuesAttribute { - + //a keyword based attribute in IPP - int values just starting at 0 - - /** - * Supports only multiple documents treated as a single document. This + + /** + * 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. + * with a new sheet. */ public static final MultipleDocumentHandlingSupported SINGLE_DOCUMENT_NEW_SHEET = new MultipleDocumentHandlingSupported(3); - private static final String[] stringTable = { "single-document", + private static final String[] stringTable = { "single-document", "separate-documents-uncollated-copies", "separate-documents-collated-copies", "single-document-new-sheet" }; - - private static final MultipleDocumentHandlingSupported[] enumValueTable = + + private static final MultipleDocumentHandlingSupported[] enumValueTable = { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES, SEPARATE_DOCUMENTS_COLLATED_COPIES, SINGLE_DOCUMENT_NEW_SHEET}; - + /** * Constructs a <code>MultipleDocumentHandlingSupported</code> object. - * + * * @param value the enum value */ protected MultipleDocumentHandlingSupported(int value) @@ -105,7 +106,7 @@ public final class MultipleDocumentHandlingSupported extends EnumSyntax * * @return The class <code>MultipleDocumentHandlingSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return MultipleDocumentHandlingSupported.class; } @@ -119,7 +120,7 @@ public final class MultipleDocumentHandlingSupported extends EnumSyntax { return "multiple-document-handling-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -140,38 +141,36 @@ public final class MultipleDocumentHandlingSupported extends EnumSyntax { 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() + 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) + public static MultipleDocumentHandling[] + getAssociatedAttributeArray(Set<Attribute> set) { - MultipleDocumentHandlingSupported tmp; - MultipleDocumentHandling[] result = new MultipleDocumentHandling[set.size()]; - Iterator it = set.iterator(); + MultipleDocumentHandling[] result = new MultipleDocumentHandling[set.size()]; int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (MultipleDocumentHandlingSupported) it.next(); - result[j] = tmp.getAssociatedAttribute(); + 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 index 387e6b5131d..1b299845622 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java @@ -1,4 +1,4 @@ -/* MultipleDocumentJobsSupported.java -- +/* MultipleDocumentJobsSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,35 +38,36 @@ exception statement from your version. */ package gnu.javax.print.ipp.attribute.supported; +import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; import javax.print.attribute.SupportedValuesAttribute; /** * <code>MultipleDocumentJobsSupported</code> specifies if a printer * supported multiple documents in one job. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public class MultipleDocumentJobsSupported extends EnumSyntax +public class MultipleDocumentJobsSupported extends EnumSyntax implements SupportedValuesAttribute { - + /** Multiple documents per job are not supported. */ - public static final MultipleDocumentJobsSupported NOT_SUPPORTED = + public static final MultipleDocumentJobsSupported NOT_SUPPORTED = new MultipleDocumentJobsSupported(0); - + /** Multiple documents per job are supported. */ - public static final MultipleDocumentJobsSupported SUPPORTED = + public static final MultipleDocumentJobsSupported SUPPORTED = new MultipleDocumentJobsSupported(1); private static final String[] stringTable = { "not-supported", "supported" }; - - private static final MultipleDocumentJobsSupported[] enumValueTable = + + private static final MultipleDocumentJobsSupported[] enumValueTable = { NOT_SUPPORTED, SUPPORTED }; - + /** * Constructs a <code>MultipleDocumentJobsSupported</code> object. - * + * * @param value the enum value */ protected MultipleDocumentJobsSupported(int value) @@ -79,7 +80,7 @@ public class MultipleDocumentJobsSupported extends EnumSyntax * * @return The class <code>MultipleDocumentJobsSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return MultipleDocumentJobsSupported.class; } @@ -93,7 +94,7 @@ public class MultipleDocumentJobsSupported extends EnumSyntax { return "multiple-document-jobs-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java index 81e2e34cd05..a059c89a50b 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java @@ -1,4 +1,4 @@ -/* OperationsSupported.java -- +/* OperationsSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,7 @@ 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; @@ -45,12 +46,12 @@ import javax.print.attribute.SupportedValuesAttribute; * <code>OperationsSupported</code> specifies the enums of the operations * supported by a given printer or job object. The attribute is further * specified in RFC 2911 section 4.4.15. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ -public final class OperationsSupported extends EnumSyntax +public final class OperationsSupported extends EnumSyntax implements SupportedValuesAttribute -{ +{ /* * Value Operation Name ----------------- ------------------------------------- @@ -76,104 +77,104 @@ public final class OperationsSupported extends EnumSyntax 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 = + public static final OperationsSupported PRINT_JOB = new OperationsSupported(0x02); - + /** Operation to print a document from an URI */ - public static final OperationsSupported PRINT_URI = + public static final OperationsSupported PRINT_URI = new OperationsSupported(0x03); - + /** Operation to validate a job before submission. */ - public static final OperationsSupported VALIDATE_JOB = + public static final OperationsSupported VALIDATE_JOB = new OperationsSupported(0x04); - - /** - * Operation to create an initial job for use with multiple document per job. + + /** + * Operation to create an initial job for use with multiple document per job. */ - public static final OperationsSupported CREATE_JOB = + public static final OperationsSupported CREATE_JOB = new OperationsSupported(0x05); - - /** - * Operation to send a document to a multidoc job created via CREATE_JOB + + /** + * Operation to send a document to a multidoc job created via CREATE_JOB */ - public static final OperationsSupported SEND_DOCUMENT = + 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. + + /** + * 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 = + 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 = + 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 = + public static final OperationsSupported GET_JOB_ATTRIBUTES = new OperationsSupported(0x09); - + /** Operation to pause a printer. */ - public static final OperationsSupported PAUSE_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 = + public static final OperationsSupported GET_JOBS = new OperationsSupported(0x0A); - + /** Operation to get the attributes of a printer. */ - public static final OperationsSupported GET_PRINTER_ATTRIBUTES = + 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 = + 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 = + 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 = + public static final OperationsSupported RESTART_JOB = new OperationsSupported(0x0E); - + /** Not yet an operation - reserved for futher use. */ - public static final OperationsSupported RESERVED = + public static final OperationsSupported RESERVED = new OperationsSupported(0x0F); - + /** Operation to resume a printer. */ - public static final OperationsSupported RESUME_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 = + public static final OperationsSupported PURGE_JOBS = new OperationsSupported(0x12); - private static final String[] stringTable = { "print-job", "print-uri", + private static final String[] stringTable = { "print-job", "print-uri", "validate-job", "create-job", - "send-document", "send-uri", + "send-document", "send-uri", "cancel-job", "get-job-attributes", - "pause-printer", "get-jobs", + "pause-printer", "get-jobs", "get-printer-attributes", "hold-job", "release-job", "restart-job", "reserved", "resume-printer", "purge-job"}; - - private static final OperationsSupported[] enumValueTable = + + private static final OperationsSupported[] enumValueTable = { PRINT_JOB, PRINT_URI, VALIDATE_JOB, CREATE_JOB, SEND_DOCUMENT, SEND_URI, CANCEL_JOB, GET_JOB_ATTRIBUTES, PAUSE_PRINTER, GET_JOBS, GET_PRINTER_ATTRIBUTES, HOLD_JOB, RELEASE_JOB, RESTART_JOB, RESERVED, RESUME_PRINTER, PURGE_JOBS}; - - + + /** * Constructs a <code>OperationsSupported</code> object. - * + * * @param value the enum value */ protected OperationsSupported(int value) @@ -186,7 +187,7 @@ public final class OperationsSupported extends EnumSyntax * * @return The class <code>OperationsSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return OperationsSupported.class; } @@ -200,7 +201,7 @@ public final class OperationsSupported extends EnumSyntax { return "operations-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -226,5 +227,5 @@ public final class OperationsSupported extends EnumSyntax 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 index 528c758ac70..4b87c53a528 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java @@ -42,33 +42,34 @@ import gnu.javax.print.ipp.IppUtilities; import java.util.Iterator; import java.util.Set; +import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; import javax.print.attribute.SupportedValuesAttribute; import javax.print.attribute.standard.OrientationRequested; /** - * The <code>OrientationRequestedSupported</code> attribute provides + * The <code>OrientationRequestedSupported</code> attribute provides * the supported values for the job attribute orientation-requested. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class OrientationRequestedSupported extends EnumSyntax implements SupportedValuesAttribute { - + /** Orientation as portrait. */ public static final OrientationRequestedSupported PORTRAIT = new OrientationRequestedSupported(3); - + /** Orientation as landscape. */ public static final OrientationRequestedSupported LANDSCAPE = new OrientationRequestedSupported(4); - + /** Orientation as reversed landscape. */ public static final OrientationRequestedSupported REVERSE_LANDSCAPE = new OrientationRequestedSupported(5); - + /** Orientation as reversed portrait. */ public static final OrientationRequestedSupported REVERSE_PORTRAIT = new OrientationRequestedSupported(6); @@ -77,14 +78,14 @@ public final class OrientationRequestedSupported extends EnumSyntax private static final String[] stringTable = { "portrait", "landscape", "reverse-landscape", "reverse-portrait" }; - - private static final OrientationRequestedSupported[] - enumValueTable = { PORTRAIT, LANDSCAPE, + + private static final OrientationRequestedSupported[] + enumValueTable = { PORTRAIT, LANDSCAPE, REVERSE_LANDSCAPE, REVERSE_PORTRAIT }; - + /** * Constructs a <code>OrientationRequestedSupported</code> object. - * + * * @param value the value */ protected OrientationRequestedSupported(int value) @@ -97,7 +98,7 @@ public final class OrientationRequestedSupported extends EnumSyntax * * @return The class <code>OrientationRequestedSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return OrientationRequestedSupported.class; } @@ -111,7 +112,7 @@ public final class OrientationRequestedSupported extends EnumSyntax { return "orientation-requested-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -132,7 +133,7 @@ public final class OrientationRequestedSupported extends EnumSyntax { return enumValueTable; } - + /** * Returns the lowest used value by the enumerations of this class. * . @@ -142,38 +143,36 @@ public final class OrientationRequestedSupported extends EnumSyntax { 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() + 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) + public static OrientationRequested[] + getAssociatedAttributeArray(Set<Attribute> set) { - OrientationRequestedSupported tmp; - OrientationRequested[] result = new OrientationRequested[set.size()]; - Iterator it = set.iterator(); + OrientationRequested[] result = new OrientationRequested[set.size()]; int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (OrientationRequestedSupported) it.next(); - result[j] = tmp.getAssociatedAttribute(); + 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 index d39a37fd708..c58f76748b3 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java @@ -37,36 +37,36 @@ exception statement from your version. */ package gnu.javax.print.ipp.attribute.supported; +import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; import javax.print.attribute.SupportedValuesAttribute; - /** * <code>PageRangesSupported</code> is a boolean typed * attribute indicating (as EnumSyntax) if page ranges * are supported. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class PageRangesSupported extends EnumSyntax implements SupportedValuesAttribute { /** Page ranges are not supported. */ - public static final PageRangesSupported NOT_SUPPORTED = + public static final PageRangesSupported NOT_SUPPORTED = new PageRangesSupported(0); - + /** Page ranges are supported. */ - public static final PageRangesSupported SUPPORTED = + public static final PageRangesSupported SUPPORTED = new PageRangesSupported(1); private static final String[] stringTable = { "not-supported", "supported" }; - + private static final PageRangesSupported[] enumValueTable = { NOT_SUPPORTED, SUPPORTED }; - + /** * Constructs a <code>PageRangesSupported</code> object. - * + * * @param value the enum value */ protected PageRangesSupported(int value) @@ -79,7 +79,7 @@ public final class PageRangesSupported extends EnumSyntax * * @return The class <code>PageRangesSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PageRangesSupported.class; } @@ -93,7 +93,7 @@ public final class PageRangesSupported extends EnumSyntax { return "page-ranges-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java index b0f7e86735b..25cbf9f0bea 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java @@ -42,6 +42,7 @@ 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; @@ -50,33 +51,33 @@ import javax.print.attribute.standard.PrintQuality; /** * <code>PrintQualitySupported</code> provides the * supported values for the print-quality attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class PrintQualitySupported extends EnumSyntax implements SupportedValuesAttribute { /** Draft quality of the printer. */ - public static final PrintQualitySupported DRAFT = + public static final PrintQualitySupported DRAFT = new PrintQualitySupported(3); - + /** Normal quality of the printer. */ - public static final PrintQualitySupported NORMAL = + public static final PrintQualitySupported NORMAL = new PrintQualitySupported(4); - + /** High quality of the printer. */ - public static final PrintQualitySupported HIGH = + public static final PrintQualitySupported HIGH = new PrintQualitySupported(5); private static final String[] stringTable = { "draft", "normal", "high" }; - - private static final PrintQualitySupported[] enumValueTable = { DRAFT, - NORMAL, + + private static final PrintQualitySupported[] enumValueTable = { DRAFT, + NORMAL, HIGH }; - + /** * Constructs a <code>PrintQualitySupported</code> object. - * + * * @param value the value of the enum */ protected PrintQualitySupported(int value) @@ -89,7 +90,7 @@ public final class PrintQualitySupported extends EnumSyntax * * @return The class <code>PrintQualitySupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrintQualitySupported.class; } @@ -103,7 +104,7 @@ public final class PrintQualitySupported extends EnumSyntax { return "print-quality-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. @@ -124,7 +125,7 @@ public final class PrintQualitySupported extends EnumSyntax { return enumValueTable; } - + /** * Returns the lowest used value by the enumerations of this class. * . @@ -134,38 +135,35 @@ public final class PrintQualitySupported extends EnumSyntax { 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() + 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) + public static PrintQuality[] getAssociatedAttributeArray(Set<Attribute> set) { - PrintQualitySupported tmp; - PrintQuality[] result = new PrintQuality[set.size()]; - Iterator it = set.iterator(); + PrintQuality[] result = new PrintQuality[set.size()]; int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (PrintQualitySupported) it.next(); - result[j] = tmp.getAssociatedAttribute(); + 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 index e3266c4221e..eb50aaac530 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java @@ -40,23 +40,24 @@ package gnu.javax.print.ipp.attribute.supported; import java.util.Iterator; import java.util.Set; +import javax.print.attribute.Attribute; import javax.print.attribute.ResolutionSyntax; import javax.print.attribute.SupportedValuesAttribute; import javax.print.attribute.standard.PrinterResolution; /** - * The <code>PrinterResolutionSupported</code> attribute provides + * The <code>PrinterResolutionSupported</code> attribute provides * the supported values for the job attribute printer-resolution. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class PrinterResolutionSupported extends ResolutionSyntax implements SupportedValuesAttribute { - + /** - * Creates a <code>PrinterResolutionSupported</code> object with the + * Creates a <code>PrinterResolutionSupported</code> object with the * given arguments. * * @param crossFeedResolution the cross feed resolution @@ -65,25 +66,25 @@ public final class PrinterResolutionSupported extends ResolutionSyntax * * @exception IllegalArgumentException if preconditions fail */ - public PrinterResolutionSupported(int crossFeedResolution, + public PrinterResolutionSupported(int crossFeedResolution, int feedResolution, int units) { super(crossFeedResolution, feedResolution, units); } - + /** * Tests if the given object is equal to this object. * * @param obj the object to test * - * @return <code>true</code> if both objects are equal, + * @return <code>true</code> if both objects are equal, * <code>false</code> otherwise. */ public boolean equals(Object obj) { if(! (obj instanceof PrinterResolutionSupported)) return false; - + return super.equals(obj); } @@ -92,7 +93,7 @@ public final class PrinterResolutionSupported extends ResolutionSyntax * * @return The class <code>PrinterResolutionSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterResolutionSupported.class; } @@ -106,38 +107,36 @@ public final class PrinterResolutionSupported extends ResolutionSyntax { 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() + public PrinterResolution getAssociatedAttribute() { - return new PrinterResolution(getCrossFeedResolutionDphi(), + 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) + public static PrinterResolution[] + getAssociatedAttributeArray(Set<Attribute> set) { - PrinterResolutionSupported tmp; - PrinterResolution[] result = new PrinterResolution[set.size()]; - Iterator it = set.iterator(); + PrinterResolution[] result = new PrinterResolution[set.size()]; int j = 0; - while (it.hasNext()) + for (Attribute tmp : set) { - tmp = (PrinterResolutionSupported) it.next(); - result[j] = tmp.getAssociatedAttribute(); + 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 index ce3e2a7d6c4..0eed39c6c2a 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java @@ -1,4 +1,4 @@ -/* PrinterUriSupported.java -- +/* PrinterUriSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ 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; @@ -47,10 +48,10 @@ 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 +public final class PrinterUriSupported extends URISyntax implements SupportedValuesAttribute { @@ -70,7 +71,7 @@ public final class PrinterUriSupported extends URISyntax * * @return The class <code>PrinterUriSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return PrinterUriSupported.class; } diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java index 5110e95934b..eff82c143c5 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java @@ -37,6 +37,7 @@ 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; @@ -44,45 +45,45 @@ import javax.print.attribute.SupportedValuesAttribute; /** * <code>SidesSupported</code> provides the * supported values for the sides attribute. - * + * * @author Wolfgang Baer (WBaer@gmx.de) */ public final class SidesSupported extends EnumSyntax implements SupportedValuesAttribute { - + /** Specifies that each page should be printed on one sheet. */ public static final SidesSupported ONE_SIDED = new SidesSupported(0); - - /** - * Specifies that two following pages should be printed on the + + /** + * 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 = + public static final SidesSupported TWO_SIDED_LONG_EDGE = new SidesSupported(1); - - /** - * Specifies that two following pages should be printed on the + + /** + * 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 = + 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", + 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, + + private static final SidesSupported[] + enumValueTable = { ONE_SIDED, TWO_SIDED_LONG_EDGE, TWO_SIDED_SHORT_EDGE }; - - + + /** * Creates a <code>SidesSupported</code> object. * @@ -98,7 +99,7 @@ public final class SidesSupported extends EnumSyntax * * @return The class <code>SidesSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return SidesSupported.class; } @@ -112,7 +113,7 @@ public final class SidesSupported extends EnumSyntax { return "sides-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java index 8deac7a2f63..dc1a29f5cc3 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java @@ -1,4 +1,4 @@ -/* UriAuthenticationSupported.java -- +/* UriAuthenticationSupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,58 +38,59 @@ 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 + * 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 +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 = + 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 = + public static final UriAuthenticationSupported REQUESTING_USER_NAME = new UriAuthenticationSupported(1); - + /** Supports HTTP basic authentication (RFC 2617) */ - public static final UriAuthenticationSupported BASIC = + public static final UriAuthenticationSupported BASIC = new UriAuthenticationSupported(2); - + /** Supports HTTP digest authentication (RFC 2617) */ - public static final UriAuthenticationSupported DIGEST = + public static final UriAuthenticationSupported DIGEST = new UriAuthenticationSupported(3); - + /** Supports authentication through a client provided certificate */ - public static final UriAuthenticationSupported CERTIFICATE = + public static final UriAuthenticationSupported CERTIFICATE = new UriAuthenticationSupported(4); - - private static final String[] stringTable = { "none", - "requesting-user-name", - "basic", "digest", + + private static final String[] stringTable = { "none", + "requesting-user-name", + "basic", "digest", "certificate" }; - - private static final UriAuthenticationSupported[] enumValueTable = + + private static final UriAuthenticationSupported[] enumValueTable = { NONE, REQUESTING_USER_NAME, BASIC, DIGEST, CERTIFICATE }; /** * Constructs a <code>UriAuthenticationSupported</code> object. - * + * * @param value the enum value */ public UriAuthenticationSupported(int value) @@ -102,7 +103,7 @@ public final class UriAuthenticationSupported extends EnumSyntax * * @return The class <code>UriAuthenticationSupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return UriAuthenticationSupported.class; } @@ -116,7 +117,7 @@ public final class UriAuthenticationSupported extends EnumSyntax { return "uri-authentication-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java index 1d995184d2d..03396978f65 100644 --- a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java +++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java @@ -1,4 +1,4 @@ -/* UriSecuritySupported.java -- +/* UriSecuritySupported.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,7 @@ 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; @@ -46,35 +47,35 @@ import javax.print.attribute.SupportedValuesAttribute; * 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 +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 = + public static final UriSecuritySupported NONE = new UriSecuritySupported(0); - + /** The URI has SSL3 communication */ - public static final UriSecuritySupported SSL3 = + public static final UriSecuritySupported SSL3 = new UriSecuritySupported(1); - + /** The URI has TLS (RFC 2246) communication */ - public static final UriSecuritySupported TLS = + public static final UriSecuritySupported TLS = new UriSecuritySupported(2); - + private static final String[] stringTable = { "none", "ssl3", "tls" }; - - private static final UriSecuritySupported[] enumValueTable = { NONE, + + private static final UriSecuritySupported[] enumValueTable = { NONE, SSL3, TLS }; /** * Constructs a <code>UriSecuritySupported</code> object. - * + * * @param value the enum value */ public UriSecuritySupported(int value) @@ -87,7 +88,7 @@ public final class UriSecuritySupported extends EnumSyntax * * @return The class <code>UriSecuritySupported</code> itself. */ - public Class getCategory() + public Class<? extends Attribute> getCategory() { return UriSecuritySupported.class; } @@ -101,7 +102,7 @@ public final class UriSecuritySupported extends EnumSyntax { return "uri-security-supported"; } - + /** * Returns a table with the enumeration values represented as strings * for this object. diff --git a/libjava/classpath/gnu/javax/swing/text/html/css/Selector.java b/libjava/classpath/gnu/javax/swing/text/html/css/Selector.java index 6e182a53623..06d515c620f 100644 --- a/libjava/classpath/gnu/javax/swing/text/html/css/Selector.java +++ b/libjava/classpath/gnu/javax/swing/text/html/css/Selector.java @@ -38,6 +38,9 @@ exception statement from your version. */ package gnu.javax.swing.text.html.css; +import gnu.java.lang.CPStringBuilder; + +import java.util.List; import java.util.Map; import java.util.StringTokenizer; @@ -97,7 +100,7 @@ public class Selector * @return <code>true</code> when this selector matches the element path, * <code>false</code> otherwise */ - public boolean matches(String[] tags, Map[] attributes) + public boolean matches(String[] tags, List<Map<String,String>> attributes) { // TODO: This implements class, id and descendent matching. These are // the most commonly used selector matchers in CSS together with HTML. @@ -118,11 +121,11 @@ public class Selector boolean tagMatch = false; for (; tagIndex < numTags && tagMatch == false; tagIndex++) { - Object pathClass = attributes[tagIndex].get("class"); + Object pathClass = attributes.get(tagIndex).get("class"); // Try pseudo class too. - Object pseudoClass = attributes[tagIndex].get("_pseudo"); - Object dynClass = attributes[tagIndex].get("_dynamic"); - Object pathId = attributes[tagIndex].get("id"); + Object pseudoClass = attributes.get(tagIndex).get("_pseudo"); + Object dynClass = attributes.get(tagIndex).get("_dynamic"); + Object pathId = attributes.get(tagIndex).get("id"); String tag = elements[j]; String clazz = classes[j]; String id = ids[j]; @@ -167,7 +170,7 @@ public class Selector */ public String toString() { - StringBuilder b = new StringBuilder(); + CPStringBuilder b = new CPStringBuilder(); for (int i = selector.length - 1; i >= 0; i--) { b.append(selector[i]); |