Class PrintServiceLookup
 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.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract PrintServiceNot called directly by applications.abstract MultiDocPrintService[]getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) Not called directly by applications.abstract PrintService[]Not called directly by applications.abstract PrintService[]getPrintServices(DocFlavor flavor, AttributeSet attributes) Locates services that can be positively confirmed to support the combination of attributes andDocFlavorsspecified.static final PrintServiceLocates the default print service for this environment.static final MultiDocPrintService[]lookupMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) LocatesMultiDocprintServicescapable of printingMultiDocscontaining all the specified doc flavors.static final PrintService[]lookupPrintServices(DocFlavor flavor, AttributeSet attributes) Locates print services capable of printing the specifiedDocFlavor.static booleanregisterService(PrintService service) Allows an application to directly register an instance of a class which implements a print service.static booleanAllows an application to explicitly register a class that implements lookup services.
- 
Constructor Details- 
PrintServiceLookupprotected PrintServiceLookup()Constructor for subclasses to call.
 
- 
- 
Method Details- 
lookupPrintServicesLocates print services capable of printing the specifiedDocFlavor.- Parameters:
- flavor- the flavor to print. If- null, this constraint is not used.
- attributes- attributes that the print service must support. If- nullthis constraint is not used.
- Returns:
- array of matching PrintServiceobjects representing print services that support the specified flavor attributes. If no services match, the array is zero-length.
 
- 
lookupMultiDocPrintServicespublic static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) LocatesMultiDocprintServicescapable of printingMultiDocscontaining all the specified doc flavors.This method is useful to help locate a service that can print a MultiDocin which the elements may be different flavors. An application could perform this itself by multiple lookups on eachDocFlavorin turn and collating the results, but the lookup service may be able to do this more efficiently.- Parameters:
- flavors- the flavors to print. If- nullor 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- nullthis constraint is not used.
- Returns:
- array of matching MultiDocPrintServiceobjects. If no services match, the array is zero-length.
 
- 
lookupDefaultPrintServiceLocates the default print service for this environment. This may returnnull. 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
 
- 
registerServiceProviderAllows 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 returnsfalse.- Parameters:
- sp- an implementation of a lookup service
- Returns:
- trueif the new lookup service is newly registered;- falseotherwise
 
- 
registerServiceAllows 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 thePrintServiceLookupclass 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 aPrintServiceLookupinstance instead is recommended. The method returnstrueif this service is not previously registered and is now successfully registered. This method should not be called withStreamPrintServiceinstances. They will always fail to register and the method will returnfalse.- Parameters:
- service- an implementation of a print service
- Returns:
- trueif the service is newly registered;- falseotherwise
 
- 
getPrintServicesLocates services that can be positively confirmed to support the combination of attributes andDocFlavorsspecified. 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 PrintServicesand 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- nullit is ignored.
- attributes- required to be supported. If- nullthis constraint is not used.
- Returns:
- array of matching PrintServices. If no services match, the array is zero-length.
 
- 
getPrintServicesNot called directly by applications. Implemented by a service provider, used by the static methods of this class.- Returns:
- array of all PrintServicesknown to this lookup service class. If none are found, the array is zero-length.
 
- 
getMultiDocPrintServicespublic abstract MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) Not called directly by applications.Implemented by a service provider, used by the static methods of this class. Locates MultiDocprint services which can be positively confirmed to support the combination of attributes andDocFlavorsspecified.- Parameters:
- flavors- of documents required. If- nullor empty it is ignored.
- attributes- required to be supported. If- nullthis constraint is not used.
- Returns:
- array of matching PrintServices. If no services match, the array is zero-length.
 
- 
getDefaultPrintServiceNot called directly by applications. Implemented by a service provider, and called by the print lookup service.- Returns:
- the default PrintServicefor this lookup service. If there is no default, returnsnull.
 
 
-