public interface PrintService
例子:
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) {
}
}
Modifier and Type | Method and Description |
---|---|
void |
addPrintServiceAttributeListener(PrintServiceAttributeListener listener)
注册一个在打字的事件监听器。
|
DocPrintJob |
createPrintJob()
创建并返回一个能够处理从任何支持的文档数据PRINTJOB口味。
|
boolean |
equals(Object obj)
确定两个服务是否指同一个基础服务。
|
<T extends PrintServiceAttribute> |
getAttribute(类<T> category)
获取单个指定的服务属性的值。
|
PrintServiceAttributeSet |
getAttributes()
获取此打印服务的打印机描述属性的设置,使此打印服务的状态。
|
Object |
getDefaultAttributeValue(类<? extends Attribute> category)
确定在给定类别中的该打印服务的默认打印属性值。
|
String |
getName()
返回用于请求特定打印服务的应用程序使用的打印服务的字符串名称。
|
ServiceUIFactory |
getServiceUIFactory()
返回一个允许用户在不同角色中与服务交互的用户界面组件的工厂。
|
类<?>[] |
getSupportedAttributeCategories()
确定在为该打印服务设置一个作业时,客户机可以指定的打印属性类别。
|
Object |
getSupportedAttributeValues(类<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes)
确定在为该打印服务设置一个作业时,客户端可以在指定类别中指定的打印属性值。
|
DocFlavor[] |
getSupportedDocFlavors()
确定打印数据格式,客户可以指定当建立这个
PrintService 工作。
|
AttributeSet |
getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)
确定了在特定的语境docflavor打印请求是不支持的属性。
|
int |
hashCode()
应使用此方法始终与
equals(Object) 。
|
boolean |
isAttributeCategorySupported(类<? extends Attribute> category)
确定是否在为该打印服务设置一个作业时,客户端是否可以指定给定的打印属性类别。
|
boolean |
isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes)
确定在设置此打印服务的作业时,客户端是否可以指定给定的打印属性值。
|
boolean |
isDocFlavorSupported(DocFlavor flavor)
确定这是否打印服务支持一个特定的
DocFlavor 。
|
void |
removePrintServiceAttributeListener(PrintServiceAttributeListener listener)
从该打印服务中删除打印服务侦听器。
|
String getName()
PrinterName
属性相同。
DocPrintJob createPrintJob()
void addPrintServiceAttributeListener(PrintServiceAttributeListener listener)
listener
- printserviceattributelistener,监测打印服务的状态
removePrintServiceAttributeListener(javax.print.event.PrintServiceAttributeListener)
void removePrintServiceAttributeListener(PrintServiceAttributeListener listener)
PrintService
事件感兴趣。
listener
- printserviceattributelistener对象
addPrintServiceAttributeListener(javax.print.event.PrintServiceAttributeListener)
PrintServiceAttributeSet getAttributes()
getAttributes()
方法调用的时间:即返回的属性集的内容将不被更新,如果将来改变这种打印服务的属性集的内容。检测属性值的变化,又称
getAttributes()
比较集前面的属性设置新的属性;另外,登记一个打印服务的事件监听器。
<T extends PrintServiceAttribute> T getAttribute(类<T> category)
category
-一个printserviceattribute这个服务支持类不得空。
NullPointerException
-如果类别是空的。
IllegalArgumentException
-(unchecked例外)如果
category
不是
类
实现接口
PrintServiceAttribute
。
DocFlavor[] getSupportedDocFlavors()
PrintService
工作。打印数据格式由一个“博士味指定”(类
DocFlavor
)组成的一个MIME类型加上打印数据表示的类。
请注意,一些文档的味道可能不被支持与所有属性相结合。使用getUnsupportedAttributes(..)
验证特定的组合。
boolean isDocFlavorSupported(DocFlavor flavor)
DocFlavor
。这是一个确定的
DocFlavor
会对
getSupportedDocFlavors()
结果成员方便的方法。
请注意,一些文档的味道可能不被支持与所有属性相结合。使用getUnsupportedAttributes(..)
验证特定的组合。
flavor
-支持
DocFlavor
to查询。
true
如果打印服务支持指定的
DocFlavor
;
false
否则。
NullPointerException
-(unchecked异常)如果
flavor
空抛。
类<?>[] getSupportedAttributeCategories()
类
实现指定接口
Attribute
。此方法返回的属性类别所支持的;它不返回特定的属性价值观所支持。
此方法返回此打印服务支持的所有可能的作业的所有打印属性类别。某些类别可能不在特定情况下的支持(即一个特定的DocFlavor
)。使用的方法包括DocFlavor
之前提交验证请求,如getSupportedAttributeValues(..)
。
boolean isAttributeCategorySupported(类<? extends Attribute> category)
类
实现指定接口
Attribute
。这个方法告诉属性是否类别支持;它不能告诉是否一个特定的属性价值支持。
某些类别可能不在特定情况下的支持(即一个特定的DocFlavor
)。使用的方法包括DocFlavor
之前提交验证请求,如getSupportedAttributeValues(..)
。
这是一个确定的类别会对getSupportedAttributeCategories()
结果成员方便的方法。
category
打印属性分类测试。它必须是一个
类
实现接口
Attribute
。
true
如果打印服务支持指定医生水平或工作水平
category
属性在打印要求;
false
如果不行。
NullPointerException
-(unchecked异常)如果
category
空抛。
IllegalArgumentException
-(unchecked例外)如果
category
不是
类
实现接口
Attribute
扔。
Object getDefaultAttributeValue(类<? extends Attribute> category)
Attribute
实例。如果一个客户机设置了一个打印作业,并且不在指定的类别中指定任何属性值,则此打印服务将使用默认属性值代替。
有些属性可能不在特定情况下的支持(即一个特定的DocFlavor
)。使用的方法包括DocFlavor
之前提交验证请求,如getSupportedAttributeValues(..)
。
并不是所有的属性都有一个默认值。例如,服务不会有RequestingUser
即支持的类空返回值,意味着有没有分类服务的默认值。使用isAttributeCategorySupported(Class)
方法区分这些情况。
category
打印属性类的默认属性值的要求。它必须是一个
类
实现接口
Attribute
。
category
默认属性值为空,或者如果这个打印服务不支持指定的医生水平或工作水平
category
属性在打印请求,或服务不具有此属性的默认值。
NullPointerException
-(unchecked异常)如果
category
空抛。
IllegalArgumentException
-(unchecked例外)如果
category
不是
类
实现接口
Attribute
扔。
Object getSupportedAttributeValues(类<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes)
Attribute
实例。
如果flavor
无效attributes
是null或空设置,此方法返回所有的打印属性值这个打印服务支持任何可能的工作。如果flavor
是无效的或attributes
不是空集,此方法返回只是打印属性值,与给定的DOC的风味和/或组属性兼容。那是一个空的返回值可能表明指定此属性与指定的docflavor不相容。如果DocFlavor不为空,它必须是一个味道的打字时会被支持,其他。
如果attributes
参数包含的类别为category
参数相同的属性,服务必须忽略该属性在attributeset。
DocAttribute
s是在Doc
指定必须包含在这套精确表示上下文。
此方法返回一个对象,因为不同的打印属性类别表示支持的属性值以不同的方式显示。在包装印刷javax.print.attribute.standard
每个属性的文档介绍了如何每个属性表明其支持的值。指示支持的可能方式包括:
getCategory(Class)
返回一个数组。category
打印属性分类测试。它必须是一个
类
实现接口
Attribute
。
flavor
文档风味的一个工作,或者为空。
attributes
-设置一个打印作业属性(工作级别的属性和文件级属性),或空。
category
,或null如果打印服务不支持指定的医生水平或工作水平
category
属性在打印请求。
NullPointerException
-(unchecked异常)如果
category
空抛。
IllegalArgumentException
-(unchecked例外)如果
category
不是
类
实现接口
Attribute
抛出,或
DocFlavor
是不被支持的服务。
boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes)
Attribute
实例。
如果flavor
无效attributes
是null或空设置,这个方法告诉这是否打印服务支持给医生一些可能的组合印刷的属性值和属性集。如果flavor
是无效的或attributes
不是空集,这个方法告诉这是否打印服务支持给定的打印属性值与给定的DOC的风味和/或组属性组合。
如果DocFlavor不为空,它必须是一个味道的打字时会被支持,其他。
DocAttribute
s是在Doc
指定必须包含在这套精确表示上下文。
这是一个确定的值会对getSupportedAttributeValues(...)
结果成员方便的方法。
attrval
打印属性值来测试。
flavor
文档风味的一个工作,或者为空。
attributes
-设置一个打印作业属性(工作级别的属性和文件级属性),或空。
attrval
为DOC级别或职位级别属性在打印请求真,假如果不行。
NullPointerException
-(unchecked异常)如果
attrval
是空的。
IllegalArgumentException
如果味道不支持这个打字。
AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)
DocAttribute
s是在Doc
指定必须包含在这套精确表示上下文。
如果返回值为非零,在返回的集合的所有属性都不支持这个docflavor。返回的集合不区分由不支持的属性值所支持的属性类别。
然后支持的打印请求就可以从原来的属性集,去除所有不支持的属性创建的,除了不支持的情况下,docflavor。
如果任何属性都是不支持的,因为他们是在与其他属性的冲突,那么它是在服务的自由裁量权选择的属性(S)被确定为冲突的原因。
使用isDocFlavorSupported()
验证docflavor支撑在调用此方法之前。
flavor
文档味道测试,或空
attributes
-设置一个打印作业属性(工作级别的属性和文件级属性),或空。
IllegalArgumentException
-如果
flavor
不支持这个打字。
ServiceUIFactory getServiceUIFactory()
ServiceUIFactory
。
boolean equals(Object obj)
客户应该调用此方法来确定是否两个服务是指同一个基本服务。
服务必须实现这个方法,只有在比较服务对象可以互换使用的客户端返回true。服务是免费返回相同的对象引用到一个基本的服务,如果该,但客户不能依靠平等的参考。
equals
方法重写,继承类
Object
obj
-参考对象的比较。
Object.hashCode()
,
HashMap
int hashCode()
equals(Object)
。
hashCode
方法重写,继承类
Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
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.