Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.print.ipp
Class IppPrintService  view IppPrintService download IppPrintService.java

java.lang.Object
  extended bygnu.javax.print.ipp.IppPrintService
All Implemented Interfaces:
javax.print.PrintService
Direct Known Subclasses:
IppMultiDocPrintService

public class IppPrintService
extends java.lang.Object
implements javax.print.PrintService

Implementation of the PrintService interface for IPP based printers.


Field Summary
private  java.util.List flavors
          The list of supported document flavors.
static javax.print.attribute.standard.JobName JOB_NAME
          job-name defaults to "Java Printing".
(package private) static java.util.logging.Logger logger
          Logger for tracing - enable by passing -Dgnu.classpath.debug.components=ipp to the vm.
private  java.lang.String name
          The name of this print service.
private  java.lang.String passwd
          The password of the user.
private  java.util.Map printerAttr
          A Map with sets of attributes.
private  javax.print.attribute.standard.PrinterURI printerUri
          The standard printer URI.
private  java.util.ArrayList printerUris
          The list of all supported printer URIs.
private  java.util.HashSet printServiceAttributeListener
          The set of listeners.
static javax.print.attribute.standard.RequestingUserName REQUESTING_USER_NAME
          requesting-user-name defaults to the executing user.
private  java.lang.String user
          The username.
 
Constructor Summary
IppPrintService(java.net.URI uri, java.lang.String username, java.lang.String password)
          Creates a IppPrintService object.
 
Method Summary
 void addPrintServiceAttributeListener(javax.print.event.PrintServiceAttributeListener listener)
          Registers a print service attribute listener to this print service.
 javax.print.DocPrintJob createPrintJob()
          We always return a implementation implementing CancelablePrintJob.
 javax.print.attribute.PrintServiceAttribute getAttribute(java.lang.Class category)
          Returns the value of the single specified attribute.
 javax.print.attribute.PrintServiceAttributeSet getAttributes()
          Returns the attributes describing this print service.
 java.lang.Object getDefaultAttributeValue(java.lang.Class category)
          Determines and returns the default value for a given attribute category of this print service.
 java.lang.String getName()
          We return the value of PrinterName here.
private  java.util.Map getPrinterAttributes()
          Fetches all printer attributes from the IPP printer.
private  java.util.Set getPrinterAttributeSet(java.lang.Class attributeClass)
          Extracts the set of attribute values for a given attribute category from the printer attributes map.
private  javax.print.attribute.Attribute getPrinterDefaultAttribute(java.lang.Class attributeClass)
          Extracts the default attribute value for the given default attribute category from the printer attributes map.
 javax.print.attribute.standard.PrinterURI getPrinterURI()
          Returns the printer-uri of this print service.
 javax.print.ServiceUIFactory getServiceUIFactory()
          We currently provide no factories - just returns null.
 java.lang.Class[] getSupportedAttributeCategories()
          Returns all supported attribute categories.
 java.lang.Object getSupportedAttributeValues(java.lang.Class category, javax.print.DocFlavor flavor, javax.print.attribute.AttributeSet attributes)
          Implemented by a GetPrinterAttributes request.
 javax.print.DocFlavor[] getSupportedDocFlavors()
          Determines and returns an array of all supported document flavors which can be used to supply print data to this print service.
 javax.print.attribute.AttributeSet getUnsupportedAttributes(javax.print.DocFlavor flavor, javax.print.attribute.AttributeSet attributes)
          This is done by a validate-job operation and actually implemented in this generic IPP reference implementation.
protected  java.lang.Object handleSupportedAttributeValuesResponse(IppResponse response, java.lang.Class category)
          Called to handle the supported attribute values response for the given category.
 boolean isAttributeCategorySupported(java.lang.Class category)
          Determines a given attribute category is supported by this print service implementation.
 boolean isAttributeValueSupported(javax.print.attribute.Attribute attrval, javax.print.DocFlavor flavor, javax.print.attribute.AttributeSet attributes)
          Determines if a given attribute value is supported when creating a print job for this print service.
 boolean isDocFlavorSupported(javax.print.DocFlavor flavor)
          Determines if a given document flavor is supported or not.
private  void processResponse()
          Processes the response, sorts and splits the attributes.
 void removePrintServiceAttributeListener(javax.print.event.PrintServiceAttributeListener listener)
          De-registers a print service attribute listener from this print service.
 java.lang.String toString()
          Returns "IppPrinter: " + getName()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.print.PrintService
equals, hashCode
 

Field Detail

printerAttr

private java.util.Map printerAttr
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.


printServiceAttributeListener

private java.util.HashSet printServiceAttributeListener
The set of listeners.


user

private transient java.lang.String user
The username.


passwd

private transient java.lang.String passwd
The password of the user.


name

private java.lang.String name
The name of this print service.


flavors

private java.util.List flavors
The list of supported document flavors.


printerUri

private javax.print.attribute.standard.PrinterURI printerUri
The standard printer URI.


printerUris

private java.util.ArrayList printerUris
The list of all supported printer URIs.


logger

static final java.util.logging.Logger logger
Logger for tracing - enable by passing -Dgnu.classpath.debug.components=ipp to the vm.


REQUESTING_USER_NAME

public static final javax.print.attribute.standard.RequestingUserName REQUESTING_USER_NAME
requesting-user-name defaults to the executing user.


JOB_NAME

public static final javax.print.attribute.standard.JobName JOB_NAME
job-name defaults to "Java Printing".

Constructor Detail

IppPrintService

public IppPrintService(java.net.URI uri,
                       java.lang.String username,
                       java.lang.String password)
                throws IppException
Creates a IppPrintService object.

Method Detail

getPrinterAttributes

private java.util.Map getPrinterAttributes()
                                    throws IppException
Fetches all printer attributes from the IPP printer.


getPrinterAttributeSet

private java.util.Set getPrinterAttributeSet(java.lang.Class attributeClass)
Extracts the set of attribute values for a given attribute category from the printer attributes map.


getPrinterDefaultAttribute

private javax.print.attribute.Attribute getPrinterDefaultAttribute(java.lang.Class attributeClass)
Extracts the default attribute value for the given default attribute category from the printer attributes map.


processResponse

private void processResponse()
Processes the response, sorts and splits the attributes.


createPrintJob

public javax.print.DocPrintJob createPrintJob()
We always return a implementation implementing CancelablePrintJob.

Specified by:
createPrintJob in interface javax.print.PrintService

getAttribute

public javax.print.attribute.PrintServiceAttribute getAttribute(java.lang.Class category)
Description copied from interface: javax.print.PrintService
Returns the value of the single specified attribute.

Specified by:
getAttribute in interface javax.print.PrintService

getAttributes

public javax.print.attribute.PrintServiceAttributeSet getAttributes()
Description copied from interface: javax.print.PrintService
Returns the attributes describing this print service. The returned attributes set is unmodifiable and represents the current state of the print service. As some print service attributes may change (depends on the print service implementation) a subsequent call to this method may return a different set. To monitor changes a PrintServiceAttributeListener may be registered.

Specified by:
getAttributes in interface javax.print.PrintService

getDefaultAttributeValue

public java.lang.Object getDefaultAttributeValue(java.lang.Class category)
Description copied from interface: javax.print.PrintService
Determines and returns the default value for a given attribute category of this print service.

A return value of null means either that the print service does not support the attribute category or there is no default value available for this category. To distinguish these two case one can test with PrintService.isAttributeCategorySupported(Class)>PrintService.isAttributeCategorySupported(Class) 55 if the category is supported.

Specified by:
getDefaultAttributeValue in interface javax.print.PrintService

getName

public java.lang.String getName()
We return the value of PrinterName here.

Specified by:
getName in interface javax.print.PrintService

getServiceUIFactory

public javax.print.ServiceUIFactory getServiceUIFactory()
We currently provide no factories - just returns null.

Specified by:
getServiceUIFactory in interface javax.print.PrintService

getSupportedAttributeCategories

public java.lang.Class[] getSupportedAttributeCategories()
Description copied from interface: javax.print.PrintService
Returns all supported attribute categories.

Specified by:
getSupportedAttributeCategories in interface javax.print.PrintService

getSupportedAttributeValues

public java.lang.Object getSupportedAttributeValues(java.lang.Class category,
                                                    javax.print.DocFlavor flavor,
                                                    javax.print.attribute.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 javax.print.PrintService

handleSupportedAttributeValuesResponse

protected java.lang.Object handleSupportedAttributeValuesResponse(IppResponse response,
                                                                  java.lang.Class 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.


getSupportedDocFlavors

public javax.print.DocFlavor[] getSupportedDocFlavors()
Description copied from interface: javax.print.PrintService
Determines and returns an array of all supported document flavors which can be used to supply print data to this print service.

The supported attribute categories may differ between the supported document flavors. To test for supported attributes one can use the PrintService.getUnsupportedAttributes(DocFlavor, AttributeSet)>PrintService.getUnsupportedAttributes(DocFlavor, AttributeSet) 55 method with the specific doc flavor and attributes set.

Specified by:
getSupportedDocFlavors in interface javax.print.PrintService

getUnsupportedAttributes

public javax.print.attribute.AttributeSet getUnsupportedAttributes(javax.print.DocFlavor flavor,
                                                                   javax.print.attribute.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 javax.print.PrintService

isAttributeCategorySupported

public boolean isAttributeCategorySupported(java.lang.Class category)
Description copied from interface: javax.print.PrintService
Determines a given attribute category is supported by this print service implementation. This only tests for the category not for any specific values of this category nor in the context of a specific document flavor.

Specified by:
isAttributeCategorySupported in interface javax.print.PrintService

isAttributeValueSupported

public boolean isAttributeValueSupported(javax.print.attribute.Attribute attrval,
                                         javax.print.DocFlavor flavor,
                                         javax.print.attribute.AttributeSet attributes)
Description copied from interface: javax.print.PrintService
Determines if a given attribute value is supported when creating a print job for this print service.

If either the document flavor or the provided attributes are null it is determined if the given attribute value is supported in some combination of the available document flavors and attributes of the print service. Otherwise it is checked for the specific context of the given document flavor/attributes set.

Specified by:
isAttributeValueSupported in interface javax.print.PrintService

isDocFlavorSupported

public boolean isDocFlavorSupported(javax.print.DocFlavor flavor)
Description copied from interface: javax.print.PrintService
Determines if a given document flavor is supported or not.

Specified by:
isDocFlavorSupported in interface javax.print.PrintService

addPrintServiceAttributeListener

public void addPrintServiceAttributeListener(javax.print.event.PrintServiceAttributeListener listener)
Description copied from interface: javax.print.PrintService
Registers a print service attribute listener to this print service.

Specified by:
addPrintServiceAttributeListener in interface javax.print.PrintService

removePrintServiceAttributeListener

public void removePrintServiceAttributeListener(javax.print.event.PrintServiceAttributeListener listener)
Description copied from interface: javax.print.PrintService
De-registers a print service attribute listener from this print service.

Specified by:
removePrintServiceAttributeListener in interface javax.print.PrintService

toString

public java.lang.String toString()
Returns "IppPrinter: " + getName()


getPrinterURI

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