PrintService is the factory for a DocPrintJob. A
PrintService describes the capabilities of a printer and can be
queried regarding a printer's supported attributes.
Example:
DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
PrintService[] pservices =
PrintServiceLookup.lookupPrintServices(flavor, aset);
if (pservices.length > 0) {
DocPrintJob pj = pservices[0].createPrintJob();
try {
FileInputStream fis = new FileInputStream("test.ps");
Doc doc = new SimpleDoc(fis, flavor, null);
pj.print(doc, aset);
} catch (FileNotFoundException fe) {
} catch (PrintException e) {
}
}
| Modifier and Type | Method and Description |
|---|---|
| public void | addPrintServiceAttributeListener(PrintServiceAttributeListener
a PrintServiceAttributeListener, which monitors the
status of a print service listener)Registers a listener for events on this |
| public DocPrintJob | Returns: aDocPrintJob objectCreates and returns a |
| public boolean | |
| public < the type of the specified service attribute T extends PrintServiceAttribute> T | Returns: the value of the supported attribute ornull if the
attribute is not supported by this servicethe category of a category)PrintServiceAttribute
supported by this service - may not be nullGets the value of the single specified service attribute. |
| public PrintServiceAttributeSet | Returns: unmodifiable snapshot of this Print Service's attribute set. May be empty, but notnull.Obtains this print service's set of printer description attributes giving this Print Service's status. |
| public Object | Returns: default attribute value forcategory, or null if
this Print Service does not support specifying a doc-level or
job-level attribute in category in a Print Request, or
the service does not have a default value for this attributeDetermines this print service's default printing attribute value in the given category. |
| public String | Returns: name of the serviceReturns a string name for this print service which may be used by applications to request a particular print service. |
| public ServiceUIFactory | Returns: null or a factory for UI componentsReturns a factory for UI components which allow users to interact with the service in various roles. |
| public Class | getSupportedAttributeCategories()
Determines the printing attribute categories a client can specify when setting up a job for this print service. |
| public Object | Returns: object indicating supported values forcategory, or
null if this Print Service does not support specifying a
doc-level or job-level attribute in category in a Print
Requestdoc flavor for a supposed job, or flavor, AttributeSet nullset of printing attributes for a supposed job (both
job-level attributes and document-level attributes), or
attributes)nullDetermines the printing attribute values a client can specify in the given category when setting up a job for this print service. |
| public DocFlavor[] | Returns: array of supported doc flavors, should have at least one elementDetermines the print data formats a client can specify when setting up a
job for this |
| public AttributeSet | Returns: null if this Print Service supports the print request
specification, else the unsupported attributesdoc flavor to test, or flavor, AttributeSet nullset of printing attributes for a supposed job (both
job-level attributes and document-level attributes), or
attributes)nullIdentifies the attributes that are unsupported for a print request in the
context of a particular |
| public int | Returns: hash code of this objectThis method should be implemented consistently with
|
| public boolean | Returns: true if this print service supports specifying a
doc-level or job-level attribute in category in a Print
Request; false if it doesn'tprinting attribute category to test. It must be a
category)Class that implements interface
Attribute.Determines whether a client can specify the given printing attribute category when setting up a job for this print service. |
| public boolean | Returns: true if this Print Service supports specifying
attrval as a doc-level or job-level attribute in a Print
Request, false if it doesn'tprinting attribute value to test attrval, DocFlavor doc flavor for a supposed job, or flavor, AttributeSet nullset of printing attributes for a supposed job (both
job-level attributes and document-level attributes), or
attributes)nullDetermines whether a client can specify the given printing attribute value when setting up a job for this Print Service. |
| public boolean | Returns: true if this print service supports the specified
DocFlavor; false otherwisethe flavor)DocFlavor to query for supportDetermines if this print service supports a specific |
| public void | removePrintServiceAttributeListener(PrintServiceAttributeListener
a listener)PrintServiceAttributeListener objectRemoves the print-service listener from this print service. |
| addPrintServiceAttributeListener | back to summary |
|---|---|
| public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener) Registers a listener for events on this
| |
| createPrintJob | back to summary |
|---|---|
| public DocPrintJob createPrintJob() Creates and returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Determines if two services are referring to the same underlying service. Objects encapsulating a print service may not exhibit equality of reference even though they refer to the same underlying service. Clients should call this method to determine if two services are referring to the same underlying service.
Services must implement this method and return
| |
| getAttribute | back to summary |
|---|---|
| public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) Gets the value of the single specified service attribute. This may be useful to clients which only need the value of one attribute and want to minimize overhead.
| |
| getAttributes | back to summary |
|---|---|
| public PrintServiceAttributeSet getAttributes() Obtains this print service's set of printer description attributes giving
this Print Service's status. The returned attribute set object is
unmodifiable. The returned attribute set object is a "snapshot" of this
Print Service's attribute set at the time of the
| |
| getDefaultAttributeValue | back to summary |
|---|---|
| public Object getDefaultAttributeValue(Class<? extends Attribute> category) Determines this print service's default printing attribute value in the
given category. A printing attribute value is an instance of a class that
implements interface
Some attributes may not be supported in a particular context (ie for a
particular
Not all attributes have a default value. For example the service will not
have a default value for
| |
| getName | back to summary |
|---|---|
| public String getName() Returns a string name for this print service which may be used by
applications to request a particular print service. In a suitable
context, such as a name service, this name must be unique. In some
environments this unique name may be the same as the user friendly
printer name defined as the
| |
| getServiceUIFactory | back to summary |
|---|---|
| public ServiceUIFactory getServiceUIFactory() Returns a factory for UI components which allow users to interact with
the service in various roles. Services which do not provide any UI should
return
| |
| getSupportedAttributeCategories | back to summary |
|---|---|
| public Class Determines the printing attribute categories a client can specify when
setting up a job for this print service. A printing attribute category is
designated by a
This method returns all the printing attribute categories this print
service supports for any possible job. Some categories may not be
supported in a particular context (ie for a particular
| |
| getSupportedAttributeValues | back to summary |
|---|---|
| public Object getSupportedAttributeValues(Class<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes) Determines the printing attribute values a client can specify in the
given category when setting up a job for this print service. A printing
attribute value is an instance of a class that implements interface
If
If the
This method returns an
| |
| getSupportedDocFlavors | back to summary |
|---|---|
| public DocFlavor[] getSupportedDocFlavors() Determines the print data formats a client can specify when setting up a
job for this
Note that some doc flavors may not be supported in combination with all
attributes. Use
| |
| getUnsupportedAttributes | back to summary |
|---|---|
| public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes) Identifies the attributes that are unsupported for a print request in the
context of a particular
If the return value is
A supported print request can then be created by removing all unsupported
attributes from the original attribute set, except in the case that the
If any attributes are unsupported only because they are in conflict with other attributes then it is at the discretion of the service to select the attribute(s) to be identified as the cause of the conflict.
Use
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() This method should be implemented consistently with
| |
| isAttributeCategorySupported | back to summary |
|---|---|
| public boolean isAttributeCategorySupported(Class<? extends Attribute> category) Determines whether a client can specify the given printing attribute
category when setting up a job for this print service. A printing
attribute category is designated by a
Some categories may not be supported in a particular context (ie for a
particular
This is a convenience method to determine if the category would be a
member of the result of
| |
| isAttributeValueSupported | back to summary |
|---|---|
| public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes) Determines whether a client can specify the given printing attribute
value when setting up a job for this Print Service. A printing attribute
value is an instance of a class that implements interface
If
Also if
This is a convenience method to determine if the value would be a member
of the result of
| |
| isDocFlavorSupported | back to summary |
|---|---|
| public boolean isDocFlavorSupported(DocFlavor flavor) Determines if this print service supports a specific
Note that some doc flavors may not be supported in combination with all
attributes. Use
| |
| removePrintServiceAttributeListener | back to summary |
|---|---|
| public void removePrintServiceAttributeListener(PrintServiceAttributeListener listener) Removes the print-service listener from this print service. This means
the listener is no longer interested in
| |