javax.print

Class PrintServiceLookup


public abstract class PrintServiceLookup
extends Object

PrintServiceLookup implementations provide a way to lookup print services based on different constraints.

Implementations are located and loaded automatically through the SPI JAR file specification. Therefore implementation classes must provide a default constructor for instantiation. Furthermore, applications are able to register further instances directly at runtime.

If an SecurityManager is installed implementors should call checkPrintJobAccess() to disable access for untrusted code. This check is to be made in every lookup service implementation for flexibility. Print services registered by applications through registerService(PrintService) are suppressed in the lookup results if a security manager is installed and disallows access.

Constructor Summary

PrintServiceLookup()
Constructs a PrintServiceLookup object.

Method Summary

abstract PrintService
getDefaultPrintService()
Not to be called directly by applications.
abstract MultiDocPrintService[]
getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes)
Not to be called directly by applications.
abstract PrintService[]
getPrintServices()
Not to be called directly by applications.
abstract PrintService[]
getPrintServices(DocFlavor flavor, AttributeSet attributes)
Not to be called directly by applications.
static PrintService
lookupDefaultPrintService()
Searches the default print service in the current environment.
static MultiDocPrintService[]
lookupMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes)
Searches print services capable of multi document printing in all of the given document flavors and supporting the specified printing attributes.
static PrintService[]
lookupPrintServices(DocFlavor flavor, AttributeSet attributes)
Searches print services capable of printing in the given document flavor which supports the specified printing attributes.
static boolean
registerService(PrintService service)
Explicitly registers the provided print service instance.
static boolean
registerServiceProvider(PrintServiceLookup sp)
Explicitly registers the provided print service lookup implementation.

Methods inherited from class java.lang.Object

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

Constructor Details

PrintServiceLookup

public PrintServiceLookup()
Constructs a PrintServiceLookup object.

Method Details

getDefaultPrintService

public abstract PrintService getDefaultPrintService()
Not to be called directly by applications.
Returns:
The default lookup service of the implementing lookup service or null if there is no default one.

getMultiDocPrintServices

public abstract MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
                                                                AttributeSet attributes)
Not to be called directly by applications.
Parameters:
flavors - the document flavors which have to be supported.
attributes - the attributes which have to be supported.
Returns:
The multidoc print services of the implementing lookup service for the given parameters, or an array of length 0 if none is available.

getPrintServices

public abstract PrintService[] getPrintServices()
Not to be called directly by applications.
Returns:
All known print services of the implementing lookup service regardless of supported features, or an array of length 0 if none is available.

getPrintServices

public abstract PrintService[] getPrintServices(DocFlavor flavor,
                                                AttributeSet attributes)
Not to be called directly by applications.
Parameters:
flavor - the document flavor which has to be supported.
attributes - the attributes which have to be supported.
Returns:
The print services of the implementing lookup service for the given parameters, or an array of length 0 if none is available.

lookupDefaultPrintService

public static final PrintService lookupDefaultPrintService()
Searches the default print service in the current environment.

If multiple lookup services are registered and each has a default print service the result is not specified. Usually the default print service of the native platform lookup service is returned.

The GNU classpath implementation will return the CUPS default printing service as the default print service, if available.

The default print service may be overriden by users through the property javax.print.defaultPrinter. A service specified must be found to be returned as the default.

Returns:
The default print service, or null if none found.

lookupMultiDocPrintServices

public static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors,
                                                                       AttributeSet attributes)
Searches print services capable of multi document printing in all of the given document flavors and supporting the specified printing attributes.
Parameters:
flavors - the document flavors to support. If null this constraint is ignored during lookup.
attributes - the printing attributes to support. If null this constraint is ignored during lookup.
Returns:
The resulting available multi document print services, or an array of length 0 if none is found.

lookupPrintServices

public static final PrintService[] lookupPrintServices(DocFlavor flavor,
                                                       AttributeSet attributes)
Searches print services capable of printing in the given document flavor which supports the specified printing attributes.
Parameters:
flavor - the document flavor to support. If null this constraint is ignored during lookup.
attributes - the printing attributes to support. If null this constraint is ignored during lookup.
Returns:
The resulting available print services, or an array of length 0 if none is found.

registerService

public static boolean registerService(PrintService service)
Explicitly registers the provided print service instance.

The registration will silently fail (returning false) if the print service instance is already registered or the registration somehow else fails.

Parameters:
service - the single print service to register.
Returns:
true if registered, false otherwise.

registerServiceProvider

public static boolean registerServiceProvider(PrintServiceLookup sp)
Explicitly registers the provided print service lookup implementation.

The registration will silently fail (returning false) if the lookup service is already registered or the registration somehow else fails.

Parameters:
sp - the print service lookup implementation to register.
Returns:
true if registered, false otherwise.

PrintServiceLookup.java -- Copyright (C) 2004, 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.