javax.print
Class PrintServiceLookup

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.print.PrintServiceLookup

public abstract class PrintServiceLookup
extends Object sample code for java.lang.Object definition code for java.lang.Object

Implementations of this class provide lookup services for print services (typically equivalent to printers) of a particular type.

Multiple implementations may be installed concurrently. All implementations must be able to describe the located printers as instances of a PrintService. Typically implementations of this service class are located automatically in JAR files (see the SPI JAR file specification). These classes must be instantiable using a default constructor. Alternatively applications may explicitly register instances at runtime.

Applications use only the static methods of this abstract class. The instance methods are implemented by a service provider in a subclass and the unification of the results from all installed lookup classes are reported by the static methods of this class when called by the application.

A PrintServiceLookup implementor is recommended to check for the SecurityManager.checkPrintJobAccess() to deny access to untrusted code. Following this recommended policy means that untrusted code may not be able to locate any print services. Downloaded applets are the most common example of untrusted code.

This check is made on a per lookup service basis to allow flexibility in the policy to reflect the needs of different lookup services.

Services which are registered by registerService(PrintService) will not be included in lookup results if a security manager is installed and its checkPrintJobAccess() method denies access.


Constructor Summary
PrintServiceLookup sample code for javax.print.PrintServiceLookup.PrintServiceLookup() definition code for javax.print.PrintServiceLookup.PrintServiceLookup() ()
           
 
Method Summary
abstract  PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService getDefaultPrintService sample code for javax.print.PrintServiceLookup.getDefaultPrintService() definition code for javax.print.PrintServiceLookup.getDefaultPrintService() ()
          Not called directly by applications.
abstract  MultiDocPrintService sample code for javax.print.MultiDocPrintService definition code for javax.print.MultiDocPrintService [] getMultiDocPrintServices sample code for javax.print.PrintServiceLookup.getMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.getMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet) (DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor [] flavors, AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
          Not called directly by applications.
abstract  PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService [] getPrintServices sample code for javax.print.PrintServiceLookup.getPrintServices() definition code for javax.print.PrintServiceLookup.getPrintServices() ()
          Not called directly by applications.
abstract  PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService [] getPrintServices sample code for javax.print.PrintServiceLookup.getPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.getPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet) (DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor  flavor, AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
          Locates services that can be positively confirmed to support the combination of attributes and DocFlavors specified.
static PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService lookupDefaultPrintService sample code for javax.print.PrintServiceLookup.lookupDefaultPrintService() definition code for javax.print.PrintServiceLookup.lookupDefaultPrintService() ()
          Locates the default print service for this environment.
static MultiDocPrintService sample code for javax.print.MultiDocPrintService definition code for javax.print.MultiDocPrintService [] lookupMultiDocPrintServices sample code for javax.print.PrintServiceLookup.lookupMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.lookupMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet) (DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor [] flavors, AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
          Locates MultiDoc print Services capable of printing MultiDocs containing all the specified doc flavors.
static PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService [] lookupPrintServices sample code for javax.print.PrintServiceLookup.lookupPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.lookupPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet) (DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor  flavor, AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
          Locates print services capable of printing the specified DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor .
static boolean registerService sample code for javax.print.PrintServiceLookup.registerService(javax.print.PrintService) definition code for javax.print.PrintServiceLookup.registerService(javax.print.PrintService) (PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService  service)
          Allows an application to directly register an instance of a class which implements a print service.
static boolean registerServiceProvider sample code for javax.print.PrintServiceLookup.registerServiceProvider(javax.print.PrintServiceLookup) definition code for javax.print.PrintServiceLookup.registerServiceProvider(javax.print.PrintServiceLookup) (PrintServiceLookup sample code for javax.print.PrintServiceLookup definition code for javax.print.PrintServiceLookup  sp)
          Allows an application to explicitly register a class that implements lookup services.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

PrintServiceLookup sample code for javax.print.PrintServiceLookup() definition code for javax.print.PrintServiceLookup()

public PrintServiceLookup()
Method Detail

lookupPrintServices sample code for javax.print.PrintServiceLookup.lookupPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.lookupPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet)

public static final PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService [] lookupPrintServices(DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor  flavor,
                                                       AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
Locates print services capable of printing the specified DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor .

Parameters:
flavor - the flavor to print. If null, this constraint is not used.
attributes - attributes that the print service must support. If null this constraint is not used.
Returns:
array of matching PrintService objects representing print services that support the specified flavor attributes. If no services match, the array is zero-length.

lookupMultiDocPrintServices sample code for javax.print.PrintServiceLookup.lookupMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.lookupMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet)

public static final MultiDocPrintService sample code for javax.print.MultiDocPrintService definition code for javax.print.MultiDocPrintService [] lookupMultiDocPrintServices(DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor [] flavors,
                                                                       AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
Locates MultiDoc print Services capable of printing MultiDocs containing all the specified doc flavors.

This method is useful to help locate a service that can print a MultiDoc in which the elements may be different flavors. An application could perform this itself by multiple lookups on each DocFlavor in turn and collating the results, but the lookup service may be able to do this more efficiently.

Parameters:
flavors - the flavors to print. If null or empty this constraint is not used. Otherwise return only multidoc print services that can print all specified doc flavors.
attributes - attributes that the print service must support. If null this constraint is not used.
Returns:
array of matching MultiDocPrintService sample code for javax.print.MultiDocPrintService definition code for javax.print.MultiDocPrintService objects. If no services match, the array is zero-length.

lookupDefaultPrintService sample code for javax.print.PrintServiceLookup.lookupDefaultPrintService() definition code for javax.print.PrintServiceLookup.lookupDefaultPrintService()

public static final PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService  lookupDefaultPrintService()
Locates the default print service for this environment. This may return null. If multiple lookup services each specify a default, the chosen service is not precisely defined, but a platform native service, rather than an installed service, is usually returned as the default. If there is no clearly identifiable platform native default print service, the default is the first to be located in an implementation-dependent manner.

This may include making use of any preferences API that is available as part of the Java or native platform. This algorithm may be overridden by a user setting the property javax.print.defaultPrinter. A service specified must be discovered to be valid and currently available to be returned as the default.

Returns:
the default PrintService.

registerServiceProvider sample code for javax.print.PrintServiceLookup.registerServiceProvider(javax.print.PrintServiceLookup) definition code for javax.print.PrintServiceLookup.registerServiceProvider(javax.print.PrintServiceLookup)

public static boolean registerServiceProvider(PrintServiceLookup sample code for javax.print.PrintServiceLookup definition code for javax.print.PrintServiceLookup  sp)
Allows an application to explicitly register a class that implements lookup services. The registration will not persist across VM invocations. This is useful if an application needs to make a new service available that is not part of the installation. If the lookup service is already registered, or cannot be registered, the method returns false.

Parameters:
sp - an implementation of a lookup service.
Returns:
true if the new lookup service is newly registered; false otherwise.

registerService sample code for javax.print.PrintServiceLookup.registerService(javax.print.PrintService) definition code for javax.print.PrintServiceLookup.registerService(javax.print.PrintService)

public static boolean registerService(PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService  service)
Allows an application to directly register an instance of a class which implements a print service. The lookup operations for this service will be performed by the PrintServiceLookup class using the attribute values and classes reported by the service. This may be less efficient than a lookup service tuned for that service. Therefore registering a PrintServiceLookup instance instead is recommended. The method returns true if this service is not previously registered and is now successfully registered. This method should not be called with StreamPrintService instances. They will always fail to register and the method will return false.

Parameters:
service - an implementation of a print service.
Returns:
true if the service is newly registered; false otherwise.

getPrintServices sample code for javax.print.PrintServiceLookup.getPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.getPrintServices(javax.print.DocFlavor, javax.print.attribute.AttributeSet)

public abstract PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService [] getPrintServices(DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor  flavor,
                                                AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
Locates services that can be positively confirmed to support the combination of attributes and DocFlavors specified. This method is not called directly by applications.

Implemented by a service provider, used by the static methods of this class.

The results should be the same as obtaining all the PrintServices and querying each one individually on its support for the specified attributes and flavors, but the process can be more efficient by taking advantage of the capabilities of lookup services for the print services.

Parameters:
flavor - of document required. If null it is ignored.
attributes - required to be supported. If null this constraint is not used.
Returns:
array of matching PrintServices. If no services match, the array is zero-length.

getPrintServices sample code for javax.print.PrintServiceLookup.getPrintServices() definition code for javax.print.PrintServiceLookup.getPrintServices()

public abstract PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService [] getPrintServices()
Not called directly by applications. Implemented by a service provider, used by the static methods of this class.

Returns:
array of all PrintServices known to this lookup service class. If none are found, the array is zero-length.

getMultiDocPrintServices sample code for javax.print.PrintServiceLookup.getMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet) definition code for javax.print.PrintServiceLookup.getMultiDocPrintServices(javax.print.DocFlavor[], javax.print.attribute.AttributeSet)

public abstract MultiDocPrintService sample code for javax.print.MultiDocPrintService definition code for javax.print.MultiDocPrintService [] getMultiDocPrintServices(DocFlavor sample code for javax.print.DocFlavor definition code for javax.print.DocFlavor [] flavors,
                                                                AttributeSet sample code for javax.print.attribute.AttributeSet definition code for javax.print.attribute.AttributeSet  attributes)
Not called directly by applications.

Implemented by a service provider, used by the static methods of this class.

Locates MultiDoc print services which can be positively confirmed to support the combination of attributes and DocFlavors specified.

Parameters:
flavors - of documents required. If null or empty it is ignored.
attributes - required to be supported. If null this constraint is not used.
Returns:
array of matching PrintServices. If no services match, the array is zero-length.

getDefaultPrintService sample code for javax.print.PrintServiceLookup.getDefaultPrintService() definition code for javax.print.PrintServiceLookup.getDefaultPrintService()

public abstract PrintService sample code for javax.print.PrintService definition code for javax.print.PrintService  getDefaultPrintService()
Not called directly by applications. Implemented by a service provider, and called by the print lookup service

Returns:
the default PrintService for this lookup service. If there is no default, returns null.