public final class SimpleDoc extends Object implements Doc
Doc实现。
它可以处理DocFlavor类中定义为静态变量的所有当前定义的“预定义”文档。
特别地,该类实现Doc规范的某些必需语义如下:
如果打印数据是流,或打印作业以数据流的形式请求数据,则SimpleDoc不会监视数据传输完成或作业终止后是否正确关闭流。 客户可能更喜欢使用提供自己的文档实现来添加监听器来监视作业完成并验证诸如流的资源被释放(即关闭)。
| Constructor and Description |
|---|
SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes)
构造一个
SimpleDoc具有指定打印数据,doc的风味和文档属性集。
|
| Modifier and Type | Method and Description |
|---|---|
DocAttributeSet |
getAttributes()
获取此文档对象的打印属性集。
|
DocFlavor |
getDocFlavor()
确定此文档对象将提供其打印数据的文档风格。
|
Object |
getPrintData()
以与支持的文档风格相对应的格式获取包含此文档对象的打印数据的打印数据表示对象。
|
Reader |
getReaderForText()
获取从该文档中提取字符打印数据的读取器。
|
InputStream |
getStreamForBytes()
获取从该文档中提取字节打印数据的输入流。
|
public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes)
SimpleDoc具有指定打印数据,doc的风味和文档属性集。
printData - 打印数据对象
flavor -
DocFlavor对象
attributes - a
DocAttributeSet ,可以是
null
IllegalArgumentException - 如果
flavor或
printData为
null ,或
printData不对应于指定的文档风格 - 例如,数据不是指定为DocFlavor中的
DocFlavor 。
public DocFlavor getDocFlavor()
getDocFlavor在界面
Doc
public DocAttributeSet getAttributes()
getAttributes在界面
Doc
public Object getPrintData() throws IOException
Doc复制
getPrintData()方法返回名称由getDocFlavor().getRepresentationClassName()给出的表示类的实例,返回值可以从类Object转换为该表示类。
getPrintData在界面
Doc
IOException - 如果表示类是流,并在构建流时出现I / O错误,则抛出。
public Reader getReaderForText() throws IOException
Doc实现需要在支持此方法如果DocFlavor具有以下打印数据表示形式类之一,并返回null否则:
char[] java.lang.String java.io.Reader Reader ,用于从打印数据表示对象读取打印数据作为字符流。
然而,如果打印数据表示对象本身是一个Reader则打印数据表示对象只需返回。
getReaderForText在界面
Doc
Reader用于读取此文档中的打印数据字符。
如果由于本文档不符合上述条件而无法提供读者,则返回null 。
IOException - 创建阅读器时是否有I / O错误。
public InputStream getStreamForBytes() throws IOException
DocFlavor具有以下打印数据表示类之一,则需要Doc实现来支持此方法;
否则该方法返回null :
byte[] java.io.InputStream getStreamForBytes在界面
Doc
InputStream用于读取此文档中的打印数据字节。
如果由于此文档不符合上述条件而无法提供输入流,则返回null 。
IOException - 创建输入流时是否有I / O错误。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.