Java Doc for PrintService.java in  » 6.0-JDK-Core » print » javax » print » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » print » javax.print 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.print.PrintService

All known Subclasses:   javax.print.StreamPrintService,
PrintService
public interface PrintService (Code)
Interface 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) { 
 }
 }
 




Method Summary
public  voidaddPrintServiceAttributeListener(PrintServiceAttributeListener listener)
     Registers a listener for events on this PrintService.
public  DocPrintJobcreatePrintJob()
     Creates and returns a PrintJob capable of handling data from any of the supported document flavors.
public  booleanequals(Object obj)
     Determines if two services are referring to the same underlying service.
public  TgetAttribute(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 minimise overhead.
Parameters:
  category - the category of a PrintServiceAttribute supportedby this service - may not be null.
public  PrintServiceAttributeSetgetAttributes()
     Obtains this print service's set of printer description attributes giving this Print Service's status.
public  ObjectgetDefaultAttributeValue(Class<? extends Attribute> category)
     Determines this print service's default printing attribute value in the given category.
public  StringgetName()
     Returns a String name for this print service which may be used by applications to request a particular print service.
public  ServiceUIFactorygetServiceUIFactory()
     Returns 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. A printing attribute category is designated by a Class that implements interface javax.print.attribute.Attribute Attribute .
public  ObjectgetSupportedAttributeValues(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.
public  DocFlavor[]getSupportedDocFlavors()
     Determines the print data formats a client can specify when setting up a job for this PrintService.
public  AttributeSetgetUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)
     Identifies the attributes that are unsupported for a print request in the context of a particular DocFlavor. This method is useful for validating a potential print job and identifying the specific attributes which cannot be supported. It is important to supply only a supported DocFlavor or an IllegalArgumentException will be thrown.
public  inthashCode()
     This method should be implemented consistently with equals(Object).
public  booleanisAttributeCategorySupported(Class<? extends Attribute> category)
     Determines whether a client can specify the given printing attribute category when setting up a job for this print service.
public  booleanisAttributeValueSupported(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.
public  booleanisDocFlavorSupported(DocFlavor flavor)
     Determines if this print service supports a specific DocFlavor.
public  voidremovePrintServiceAttributeListener(PrintServiceAttributeListener listener)
     Removes the print-service listener from this print service.



Method Detail
addPrintServiceAttributeListener
public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener)(Code)
Registers a listener for events on this PrintService.
Parameters:
  listener - a PrintServiceAttributeListener, whichmonitors the status of a print service
See Also:   PrintService.removePrintServiceAttributeListener



createPrintJob
public DocPrintJob createPrintJob()(Code)
Creates and returns a PrintJob capable of handling data from any of the supported document flavors. a DocPrintJob object



equals
public boolean equals(Object obj)(Code)
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 true only if the service objects being compared may be used interchangeably by the client. Services are free to return the same object reference to an underlying service if that, but clients must not depend on equality of reference.
Parameters:
  obj - the reference object with which to compare. true if this service is the same as the obj argument,false otherwise.




getAttribute
public T getAttribute(Class<T> category)(Code)
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 minimise overhead.
Parameters:
  category - the category of a PrintServiceAttribute supportedby this service - may not be null. the value of the supported attribute or null if theattribute is not supported by this service.
exception:
  NullPointerException - if the category is null.
exception:
  IllegalArgumentException - (unchecked exception) if category is not a Class that implements interface javax.print.attribute.PrintServiceAttribute PrintServiceAttribute.



getAttributes
public PrintServiceAttributeSet getAttributes()(Code)
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 getAttributes() method call: that is, the returned attribute set's contents will not be updated if this print service's attribute set's contents change in the future. To detect changes in attribute values, call getAttributes() again and compare the new attribute set to the previous attribute set; alternatively, register a listener for print service events. Unmodifiable snapshot of this Print Service's attribute set.May be empty, but not null.



getDefaultAttributeValue
public Object getDefaultAttributeValue(Class<? extends Attribute> category)(Code)
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 javax.print.attribute.Attribute Attribute . If a client sets up a print job and does not specify any attribute value in the given category, this Print Service will use the default attribute value instead.

Some attributes may not be supported in a particular context (ie for a particular DocFlavor). Use one of the methods that include a DocFlavor to validate the request before submitting it, such as getSupportedAttributeValues(..).

Not all attributes have a default value. For example the service will not have a defaultvalue for RequestingUser i.e. a null return for a supported category means there is no service default value for that category. Use the isAttributeCategorySupported(Class) method to distinguish these cases.
Parameters:
  category - Printing attribute category for which the defaultattribute value is requested. It must be a java.lang.Class Class that implements interface javax.print.attribute.Attribute Attribute. Default attribute value for category, 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 valuefor this attribute.
exception:
  NullPointerException - (unchecked exception) Thrown if category is null.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if category is not a java.lang.Class Class that implements interface javax.print.attribute.Attribute Attribute.




getName
public String getName()(Code)
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 javax.print.attribute.standard.PrinterName PrinterName attribute. name of the service.



getServiceUIFactory
public ServiceUIFactory getServiceUIFactory()(Code)
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 null. Print Services which do provide UI but want to be supported in an environment with no UI support should ensure that the factory is not initialised unless the application calls this method to obtain the factory. See ServiceUIFactory for more information. null or a factory for UI components.



getSupportedAttributeCategories
public Class[] getSupportedAttributeCategories()(Code)
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 Class that implements interface javax.print.attribute.Attribute Attribute . This method returns just the attribute categories that are supported; it does not return the particular attribute values that are supported.

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 DocFlavor). Use one of the methods that include a DocFlavor to validate the request before submitting it, such as getSupportedAttributeValues(..). Array of printing attribute categories that the client canspecify as a doc-level or job-level attribute in a Print Request. Each element in the array is a java.lang.Class Class that implements interface javax.print.attribute.Attribute Attribute.The array is empty if no categories are supported.




getSupportedAttributeValues
public Object getSupportedAttributeValues(Class<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes)(Code)
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 javax.print.attribute.Attribute Attribute .

If flavor is null and attributes is null or is an empty set, this method returns all the printing attribute values this Print Service supports for any possible job. If flavor is not null or attributes is not an empty set, this method returns just the printing attribute values that are compatible with the given doc flavor and/or set of attributes. That is, a null return value may indicate that specifying this attribute is incompatible with the specified DocFlavor. Also if DocFlavor is not null it must be a flavor supported by this PrintService, else IllegalArgumentException will be thrown.

If the attributes parameter contains an Attribute whose category is the same as the category parameter, the service must ignore this attribute in the AttributeSet.

DocAttributes which are to be specified on the Doc must be included in this set to accurately represent the context.

This method returns an Object because different printing attribute categories indicate the supported attribute values in different ways. The documentation for each printing attribute in package javax.print.attribute.standard javax.print.attribute.standard describes how each attribute indicates its supported values. Possible ways of indicating support include:

  • Return a single instance of the attribute category to indicate that any value is legal -- used, for example, by an attribute whose value is an arbitrary text string. (The value of the returned attribute object is irrelevant.)
  • Return an array of one or more instances of the attribute category, containing the legal values -- used, for example, by an attribute with a list of enumerated values. The type of the array is an array of the specified attribute category type as returned by its getCategory(Class).
  • Return a single object (of some class other than the attribute category) that indicates bounds on the legal values -- used, for example, by an integer-valued attribute that must lie within a certain range.


Parameters:
  category - Printing attribute category to test. It must be ajava.lang.Class Class that implements interface javax.print.attribute.Attribute Attribute.
Parameters:
  flavor - Doc flavor for a supposed job, or null.
Parameters:
  attributes - Set of printing attributes for a supposed job(both job-level attributes and document-level attributes), or null. Object indicating supported values for category,or null if this Print Service does not support specifying a doc-level or job-level attribute in category in a Print Request.
exception:
  NullPointerException - (unchecked exception) Thrown if category is null.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if category is not a java.lang.Class Class that implements interface javax.print.attribute.Attribute Attribute, orDocFlavor is not supported by this service.




getSupportedDocFlavors
public DocFlavor[] getSupportedDocFlavors()(Code)
Determines the print data formats a client can specify when setting up a job for this PrintService. A print data format is designated by a "doc flavor" (class javax.print.DocFlavor DocFlavor ) consisting of a MIME type plus a print data representation class.

Note that some doc flavors may not be supported in combination with all attributes. Use getUnsupportedAttributes(..) to validate specific combinations. Array of supported doc flavors, should have at leastone element.




getUnsupportedAttributes
public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)(Code)
Identifies the attributes that are unsupported for a print request in the context of a particular DocFlavor. This method is useful for validating a potential print job and identifying the specific attributes which cannot be supported. It is important to supply only a supported DocFlavor or an IllegalArgumentException will be thrown. If the return value from this method is null, all attributes are supported.

DocAttributes which are to be specified on the Doc must be included in this set to accurately represent the context.

If the return value is non-null, all attributes in the returned set are unsupported with this DocFlavor. The returned set does not distinguish attribute categories that are unsupported from unsupported attribute values.

A supported print request can then be created by removing all unsupported attributes from the original attribute set, except in the case that the DocFlavor is unsupported.

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 isDocFlavorSupported() to verify that a DocFlavor is supported before calling this method.
Parameters:
  flavor - Doc flavor to test, or null
Parameters:
  attributes - Set of printing attributes for a supposed job(both job-level attributes and document-level attributes), or null. null if this Print Service supports the print requestspecification, else the unsupported attributes.
exception:
  IllegalArgumentException - ifflavor isnot supported by this PrintService.




hashCode
public int hashCode()(Code)
This method should be implemented consistently with equals(Object). hash code of this object.



isAttributeCategorySupported
public boolean isAttributeCategorySupported(Class<? extends Attribute> category)(Code)
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 Class that implements interface javax.print.attribute.Attribute Attribute . This method tells whether the attribute category is supported; it does not tell whether a particular attribute value is supported.

Some categories may not be supported in a particular context (ie for a particular DocFlavor). Use one of the methods which include a DocFlavor to validate the request before submitting it, such as getSupportedAttributeValues(..).

This is a convenience method to determine if the category would be a member of the result of getSupportedAttributeCategories().
Parameters:
  category - Printing attribute category to test. It must be aClass that implements interface javax.print.attribute.Attribute Attribute. true if this print service supportsspecifying a doc-level orjob-level attribute in category in a Print Request; false if it doesn't.
exception:
  NullPointerException - (unchecked exception) Thrown if category is null.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if category is not a Class that implements interface javax.print.attribute.Attribute Attribute.




isAttributeValueSupported
public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes)(Code)
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 javax.print.attribute.Attribute Attribute .

If flavor is null and attributes is null or is an empty set, this method tells whether this Print Service supports the given printing attribute value for some possible combination of doc flavor and set of attributes. If flavor is not null or attributes is not an empty set, this method tells whether this Print Service supports the given printing attribute value in combination with the given doc flavor and/or set of attributes.

Also if DocFlavor is not null it must be a flavor supported by this PrintService, else IllegalArgumentException will be thrown.

DocAttributes which are to be specified on the Doc must be included in this set to accurately represent the context.

This is a convenience method to determine if the value would be a member of the result of getSupportedAttributeValues(...).
Parameters:
  attrval - Printing attribute value to test.
Parameters:
  flavor - Doc flavor for a supposed job, or null.
Parameters:
  attributes - Set of printing attributes for a supposed job(both job-level attributes and document-level attributes), or null. True if this Print Service supports specifyingattrval as a doc-level or job-level attribute in a Print Request, false if it doesn't.
exception:
  NullPointerException - (unchecked exception) if attrval is null.
exception:
  IllegalArgumentException - if flavor is not supported bythis PrintService.




isDocFlavorSupported
public boolean isDocFlavorSupported(DocFlavor flavor)(Code)
Determines if this print service supports a specific DocFlavor. This is a convenience method to determine if the DocFlavor would be a member of the result of getSupportedDocFlavors().

Note that some doc flavors may not be supported in combination with all attributes. Use getUnsupportedAttributes(..) to validate specific combinations.
Parameters:
  flavor - the DocFlavorto query for support. true if this print service supports thespecified DocFlavor; false otherwise.
exception:
  NullPointerException - (unchecked exception) Thrown if flavor is null.




removePrintServiceAttributeListener
public void removePrintServiceAttributeListener(PrintServiceAttributeListener listener)(Code)
Removes the print-service listener from this print service. This means the listener is no longer interested in PrintService events.
Parameters:
  listener - a PrintServiceAttributeListener object
See Also:   PrintService.addPrintServiceAttributeListener



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.