gnu.javax.print.ipp

Class IppPrintService

Implemented Interfaces:
PrintService
Known Direct Subclasses:
IppMultiDocPrintService

public class IppPrintService
extends Object
implements PrintService

Implementation of the PrintService interface for IPP based printers.

Field Summary

static JobName
JOB_NAME
job-name defaults to "Java Printing".
static RequestingUserName
REQUESTING_USER_NAME
requesting-user-name defaults to the executing user.

Constructor Summary

IppPrintService(URI uri, String username, String password)
Creates a IppPrintService object.

Method Summary

void
addPrintServiceAttributeListener(PrintServiceAttributeListener listener)
DocPrintJob
createPrintJob()
We always return a implementation implementing CancelablePrintJob.
extends PrintServiceAttribute> T getAttribute(Class category)
PrintServiceAttributeSet
getAttributes()
Object
getDefaultAttributeValue(Attribute> category)
String
getName()
We return the value of PrinterName here.
PrinterURI
getPrinterURI()
Returns the printer-uri of this print service.
ServiceUIFactory
getServiceUIFactory()
We currently provide no factories - just returns null.
Class[]
getSupportedAttributeCategories()
Object
getSupportedAttributeValues(Attribute> category, DocFlavor flavor, AttributeSet attributes)
Implemented by a GetPrinterAttributes request.
DocFlavor[]
getSupportedDocFlavors()
AttributeSet
getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)
This is done by a validate-job operation and actually implemented in this generic IPP reference implementation.
protected Object
handleSupportedAttributeValuesResponse(IppResponse response, Attribute> category)
Called to handle the supported attribute values response for the given category.
boolean
isAttributeCategorySupported(Attribute> category)
boolean
isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes)
boolean
isDocFlavorSupported(DocFlavor flavor)
void
removePrintServiceAttributeListener(PrintServiceAttributeListener listener)
String
toString()
Returns "IppPrinter: " + getName()

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

JOB_NAME

public static final JobName JOB_NAME
job-name defaults to "Java Printing".

REQUESTING_USER_NAME

public static final RequestingUserName REQUESTING_USER_NAME
requesting-user-name defaults to the executing user.

Constructor Details

IppPrintService

public IppPrintService(URI uri,
                       String username,
                       String password)
            throws IppException
Creates a IppPrintService object.
Parameters:
uri - the URI of the IPP printer.
username - the user of this print service.
password - the password of the user.
Throws:
IppException - if an error during connection occurs.

Method Details

addPrintServiceAttributeListener

public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener)
Specified by:
addPrintServiceAttributeListener in interface PrintService

createPrintJob

public DocPrintJob createPrintJob()
We always return a implementation implementing CancelablePrintJob.
Specified by:
createPrintJob in interface PrintService

extends PrintServiceAttribute> T getAttribute

public extends PrintServiceAttribute> T getAttribute(Class category)
Specified by:
extends PrintServiceAttribute> T getAttribute in interface PrintService
See Also:
javax.print.PrintService.getAttribute(java.lang.Class)

getAttributes

public PrintServiceAttributeSet getAttributes()
Specified by:
getAttributes in interface PrintService

getDefaultAttributeValue

public Object getDefaultAttributeValue(Attribute> category)
Specified by:
getDefaultAttributeValue in interface PrintService
See Also:
javax.print.PrintService.getDefaultAttributeValue(java.lang.Class)

getName

public String getName()
We return the value of PrinterName here.
Specified by:
getName in interface PrintService

getPrinterURI

public PrinterURI getPrinterURI()
Returns the printer-uri of this print service.
Returns:
The printer-uri attribute.

getServiceUIFactory

public ServiceUIFactory getServiceUIFactory()
We currently provide no factories - just returns null.
Specified by:
getServiceUIFactory in interface PrintService

getSupportedAttributeCategories

public Class[] getSupportedAttributeCategories()
Specified by:
getSupportedAttributeCategories in interface PrintService

getSupportedAttributeValues

public Object getSupportedAttributeValues(Attribute> category,
                                          DocFlavor flavor,
                                          AttributeSet attributes)
Implemented by a GetPrinterAttributes request. Subclasses providing supported attribute values totally different may override this methods. Subclass only in need of handling the response differently may override the method handleSupportedAttributeValuesResponse(IppResponse, Class) only.
Specified by:
getSupportedAttributeValues in interface PrintService
See Also:
PrintService.getSupportedAttributeValues(Class, DocFlavor, AttributeSet), handleSupportedAttributeValuesResponse(IppResponse, Class)

getSupportedDocFlavors

public DocFlavor[] getSupportedDocFlavors()
Specified by:
getSupportedDocFlavors in interface PrintService

getUnsupportedAttributes

public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
                                             AttributeSet attributes)
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.
Specified by:
getUnsupportedAttributes in interface PrintService

handleSupportedAttributeValuesResponse

protected Object handleSupportedAttributeValuesResponse(IppResponse response,
                                                        Attribute> 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.
Parameters:
response - the response of the GetPrinterAttributes IPP request
category - the category for which the supported values are requested
Returns:
A object indicating the supported values for the given attribute category, or null if this print service doesn't support the given attribute category at all.
See Also:
getSupportedAttributeValues(Class, DocFlavor, AttributeSet)

isAttributeCategorySupported

public boolean isAttributeCategorySupported(Attribute> category)
Specified by:
isAttributeCategorySupported in interface PrintService
See Also:
PrintService.isAttributeCategorySupported(Class)

isAttributeValueSupported

public boolean isAttributeValueSupported(Attribute attrval,
                                         DocFlavor flavor,
                                         AttributeSet attributes)
Specified by:
isAttributeValueSupported in interface PrintService

isDocFlavorSupported

public boolean isDocFlavorSupported(DocFlavor flavor)
Specified by:
isDocFlavorSupported in interface PrintService

removePrintServiceAttributeListener

public void removePrintServiceAttributeListener(PrintServiceAttributeListener listener)
Specified by:
removePrintServiceAttributeListener in interface PrintService

toString

public String toString()
Returns "IppPrinter: " + getName()
Overrides:
toString in interface Object
Returns:
The string representation.

IppPrintService.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.