JavaTM 2 Platform
Standard Ed. 6

javax.print
类 StreamPrintServiceFactory

java.lang.Object
  继承者 javax.print.StreamPrintServiceFactory

public abstract class StreamPrintServiceFactory
extends Object

StreamPrintServiceFactoryStreamPrintService 实例的工厂,StreamPrintService 可以 mime 类型所描述的特定文档格式向输出流中打印数据。典型的输出文档格式为 Postscript(TM)。

此类由服务实现,并通过服从 SPI JAR File specification 的实现查找。

应用程序可调用 lookupStreamPrintServiceFactories(DocFlavor, String) 方法来查找此类的实例。

应用程序可使用从工厂获得的 StreamPrintService 来代替表示物理打印机设备的 PrintService


构造方法摘要
StreamPrintServiceFactory()
           
 
方法摘要
abstract  String getOutputFormat()
          查询该工厂,了解从此工厂获得的打印机所发出的文档的格式。
abstract  StreamPrintService getPrintService(OutputStream out)
          返回可打印到指定输出流的 StreamPrintService
abstract  DocFlavor[] getSupportedDocFlavors()
          查询该工厂,了解从此工厂所获得打印机可接受的 doc flavor。
static StreamPrintServiceFactory[] lookupStreamPrintServiceFactories(DocFlavor flavor, String outputMimeType)
          查找 PrintService 的工厂,PrintJob 可使用它来输出数据流,数据格式由 flavor 指定。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

StreamPrintServiceFactory

public StreamPrintServiceFactory()
方法详细信息

lookupStreamPrintServiceFactories

public static StreamPrintServiceFactory[] lookupStreamPrintServiceFactories(DocFlavor flavor,
                                                                            String outputMimeType)
查找 PrintService 的工厂,PrintJob 可使用它来输出数据流,数据格式由 flavor 指定。例如,doc flavor 是用户希望创建的文档类型,不是打印前的文档 flavor。

虽然在 StreamPrintService 的查找中使用 null 是可接受的值,但是通常要搜索所需的特定格式,如 Postscript(TM)。

参数:
flavor - 输入文档的类型 - null 意味着匹配所有类型。
outputMimeType - 表示所需的输出格式,用于标识适合的流打印机工厂。null 值意味着匹配所有格式。
返回:
用于 StreamPrintService 实例的匹配工厂,如果无法找到适合的工厂,则返回一个空工厂。

getOutputFormat

public abstract String getOutputFormat()
查询该工厂,了解从此工厂获得的打印机所发出的文档的格式。

返回:
以 mime 类型描述的输出格式。

getSupportedDocFlavors

public abstract DocFlavor[] getSupportedDocFlavors()
查询该工厂,了解从此工厂所获得打印机可接受的 doc flavor。

返回:
受支持的 doc flavor 的数组。

getPrintService

public abstract StreamPrintService getPrintService(OutputStream out)
返回可打印到指定输出流的 StreamPrintService。由应用程序创建并管理该输出流。应用程序负责关闭该流,并确保不再使用此打印机。从打印机创建的所有 PrintJob 完成前,应用程序不应关闭此流。提前关闭此流可能生成 PrinterException 和一个指示作业失败的事件。

尽管可以重用连接到物理打印机的 PrintService,但不能重用连接到流的 StreamPrintService。从 DocPrintJobprint 方法返回前,打印系统可使用 dispose 方法处置底层的 StreamPrintService,这样该打印系统就知道此打印机不再是可使用的。这等效于从此转至脱机状态的物理打印机。应用程序可以提供一个 null 打印流来创建可查询的服务。为这种流创建一个 PrintJob 是无效的。在构造时分配资源的实现应该检查该流,并且仅在该流不为 null 时才分配资源。

参数:
out - 已生成输出的目标流。
返回:
一个 PrintService,它将生成由此工厂所支持的 DocFlavor 所指定的格式。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only