Top Description Inners Constructors Methods
javax.print

public abstract Class PrintServiceLookup

extends Object
Class Inheritance
Known Direct Subclasses
sun.print.PrintServiceLookupProvider
Imports
java.util.ArrayList, .Iterator, .ServiceConfigurationError, .ServiceLoader, javax.print.attribute.AttributeSet, sun.awt.AppContext

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
PrintServiceLookup.Services

Contains a lists of services.

Constructor Summary

AccessConstructor and Description
protected
PrintServiceLookup()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
private static ArrayList<PrintServiceLookup>

Returns:

all lookup services for this environment
getAllLookupServices
()

Returns all lookup services for this environment.

public abstract PrintService

Returns:

the default PrintService for this lookup service. If there is no default, returns null.
getDefaultPrintService
()

Not called directly by applications.

private static ArrayList<PrintServiceLookup>

Returns:

the list of lookup services
getListOfLookupServices
()

Returns the list of lookup services.

public abstract MultiDocPrintService[]

Returns:

array of matching PrintServices. If no services match, the array is zero-length.
getMultiDocPrintServices
(DocFlavor[]
of documents required. If null or empty it is ignored.
flavors
,
AttributeSet
required to be supported. If null this constraint is not used.
attributes
)

Not called directly by applications.

private static ArrayList<MultiDocPrintService>

Returns:

list of matching MultiDocPrintService objects. If no services match, the empty list is returned.
getMultiDocServices
(DocFlavor[]
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.
flavors
,
AttributeSet
attributes that the print service must support. If null this constraint is not used.
attributes
)

Locates MultiDoc print Services capable of printing MultiDocs containing all the specified doc flavors.

public abstract PrintService[]

Returns:

array of matching PrintServices. If no services match, the array is zero-length.
getPrintServices
(DocFlavor
of document required. If null it is ignored.
flavor
,
AttributeSet
required to be supported. If null this constraint is not used.
attributes
)

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

public abstract PrintService[]

Returns:

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

Not called directly by applications.

private static ArrayList<PrintService>

Returns:

the list of registered services
getRegisteredServices
()

Returns the list of registered services.

private static ArrayList<PrintService>

Returns:

list of matching PrintService objects representing print services that support the specified flavor attributes. If no services match, the empty list is returned.
getServices
(DocFlavor
the flavor to print. If null, this constraint is not used.
flavor
,
AttributeSet
attributes that the print service must support. If null this constraint is not used.
attributes
)

Locates print services capable of printing the specified DocFlavor.

private static PrintServiceLookup.Services

Returns:

the services
getServicesForContext
()

Returns the services from the current appcontext.

private static ArrayList<PrintServiceLookup>

Returns:

the list of lookup services
initListOfLookupServices
()

Initialize the list of lookup services.

private static ArrayList<PrintService>

Returns:

the list of registered services
initRegisteredServices
()

Initialize the list of registered services.

public static final PrintService

Returns:

the default PrintService
lookupDefaultPrintService
()

Locates the default print service for this environment.

public static final MultiDocPrintService[]

Returns:

array of matching MultiDocPrintService objects. If no services match, the array is zero-length.
lookupMultiDocPrintServices
(DocFlavor[]
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.
flavors
,
AttributeSet
attributes that the print service must support. If null this constraint is not used.
attributes
)

Locates MultiDoc print Services capable of printing MultiDocs containing all the specified doc flavors.

public static final PrintService[]

Returns:

array of matching PrintService objects representing print services that support the specified flavor attributes. If no services match, the array is zero-length.
lookupPrintServices
(DocFlavor
the flavor to print. If null, this constraint is not used.
flavor
,
AttributeSet
attributes that the print service must support. If null this constraint is not used.
attributes
)

Locates print services capable of printing the specified DocFlavor.

public static boolean

Returns:

true if the service is newly registered; false otherwise
registerService
(PrintService
an implementation of a print service
service
)

Allows an application to directly register an instance of a class which implements a print service.

public static boolean

Returns:

true if the new lookup service is newly registered; false otherwise
registerServiceProvider
(PrintServiceLookup
an implementation of a lookup service
sp
)

Allows an application to explicitly register a class that implements lookup services.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PrintServiceLookupback to summary
protected PrintServiceLookup()

Constructor for subclasses to call.

Method Detail

getAllLookupServicesback to summary
private static ArrayList<PrintServiceLookup> getAllLookupServices()

Returns all lookup services for this environment.

Returns:ArrayList<PrintServiceLookup>

all lookup services for this environment

Annotations
@SuppressWarnings:removal
getDefaultPrintServiceback to summary
public abstract PrintService getDefaultPrintService()

Not called directly by applications. Implemented by a service provider, and called by the print lookup service.

Returns:PrintService

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

getListOfLookupServicesback to summary
private static ArrayList<PrintServiceLookup> getListOfLookupServices()

Returns the list of lookup services.

Returns:ArrayList<PrintServiceLookup>

the list of lookup services

getMultiDocPrintServicesback to summary
public 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 MultiDoc print services which can be positively confirmed to support the combination of attributes and DocFlavors specified.

Parameters
flavors:DocFlavor[]

of documents required. If null or empty it is ignored.

attributes:AttributeSet

required to be supported. If null this constraint is not used.

Returns:MultiDocPrintService[]

array of matching PrintServices. If no services match, the array is zero-length.

getMultiDocServicesback to summary
private static ArrayList<MultiDocPrintService> getMultiDocServices(DocFlavor[] flavors, AttributeSet attributes)

Locates MultiDoc print Services capable of printing MultiDocs containing all the specified doc flavors.

Parameters
flavors:DocFlavor[]

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:AttributeSet

attributes that the print service must support. If null this constraint is not used.

Returns:ArrayList<MultiDocPrintService>

list of matching MultiDocPrintService objects. If no services match, the empty list is returned.

getPrintServicesback to summary
public abstract PrintService[] getPrintServices(DocFlavor flavor, 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:DocFlavor

of document required. If null it is ignored.

attributes:AttributeSet

required to be supported. If null this constraint is not used.

Returns:PrintService[]

array of matching PrintServices. If no services match, the array is zero-length.

getPrintServicesback to summary
public abstract PrintService[] getPrintServices()

Not called directly by applications. Implemented by a service provider, used by the static methods of this class.

Returns:PrintService[]

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

getRegisteredServicesback to summary
private static ArrayList<PrintService> getRegisteredServices()

Returns the list of registered services.

Returns:ArrayList<PrintService>

the list of registered services

getServicesback to summary
private static ArrayList<PrintService> getServices(DocFlavor flavor, AttributeSet attributes)

Locates print services capable of printing the specified DocFlavor.

Parameters
flavor:DocFlavor

the flavor to print. If null, this constraint is not used.

attributes:AttributeSet

attributes that the print service must support. If null this constraint is not used.

Returns:ArrayList<PrintService>

list of matching PrintService objects representing print services that support the specified flavor attributes. If no services match, the empty list is returned.

getServicesForContextback to summary
private static PrintServiceLookup.Services getServicesForContext()

Returns the services from the current appcontext.

Returns:PrintServiceLookup.Services

the services

initListOfLookupServicesback to summary
private static ArrayList<PrintServiceLookup> initListOfLookupServices()

Initialize the list of lookup services.

Returns:ArrayList<PrintServiceLookup>

the list of lookup services

initRegisteredServicesback to summary
private static ArrayList<PrintService> initRegisteredServices()

Initialize the list of registered services.

Returns:ArrayList<PrintService>

the list of registered services

lookupDefaultPrintServiceback to summary
public static final 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:PrintService

the default PrintService

lookupMultiDocPrintServicesback to summary
public static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors, 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:DocFlavor[]

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:AttributeSet

attributes that the print service must support. If null this constraint is not used.

Returns:MultiDocPrintService[]

array of matching MultiDocPrintService objects. If no services match, the array is zero-length.

lookupPrintServicesback to summary
public static final PrintService[] lookupPrintServices(DocFlavor flavor, AttributeSet attributes)

Locates print services capable of printing the specified DocFlavor.

Parameters
flavor:DocFlavor

the flavor to print. If null, this constraint is not used.

attributes:AttributeSet

attributes that the print service must support. If null this constraint is not used.

Returns:PrintService[]

array of matching PrintService objects representing print services that support the specified flavor attributes. If no services match, the array is zero-length.

registerServiceback to summary
public static boolean registerService(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:PrintService

an implementation of a print service

Returns:boolean

true if the service is newly registered; false otherwise

registerServiceProviderback to summary
public static boolean registerServiceProvider(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:PrintServiceLookup

an implementation of a lookup service

Returns:boolean

true if the new lookup service is newly registered; false otherwise

javax.print back to summary

pack-priv Class PrintServiceLookup.Services

extends Object
Class Inheritance

Contains a lists of services.

Field Summary

Modifier and TypeField and Description
private ArrayList<PrintServiceLookup>
listOfLookupServices

The list of lookup services.

private ArrayList<PrintService>
registeredServices

The list of registered services.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listOfLookupServicesback to summary
private ArrayList<PrintServiceLookup> listOfLookupServices

The list of lookup services.

registeredServicesback to summary
private ArrayList<PrintService> registeredServices

The list of registered services.

Constructor Detail

Servicesback to summary
pack-priv Services()