JavaTM Platform
Standard Ed. 6

javax.print.attribute.standard
类 PrinterStateReasons

java.lang.Object
  继承者 java.util.AbstractMap<K,V>
      继承者 java.util.HashMap<PrinterStateReason,Severity>
          继承者 javax.print.attribute.standard.PrinterStateReasons
所有已实现的接口:
Serializable, Cloneable, Map< PrinterStateReason, Severity>, Attribute, PrintServiceAttribute

public final class PrinterStateReasons
     
extends HashMap< PrinterStateReason, Severity>
implements PrintServiceAttribute

PrinterStateReasons 类是打印属性类,它是一组枚举值集合,提供了有关打印机当前状态的附加信息,即扩充了打印机 PrinterState 属性值的信息。

PrinterStateReason 的实例不会直接出现在 Print Service 的属性集中。而 PrinterStateReasons 属性则会出现在 Print Service 的属性集中。PrinterStateReasons 属性包括零、一个或多个与 Print Service 的状态相关的 PrinterStateReason 对象,并且每个 PrinterStateReason 对象都与 REPORT(不太严重)、WARNING 或 ERROR(最严重)的 Severity 级别相关联。当相应的条件变成了打印机的真实条件时,打印机将把 PrinterStateReason 对象添加到 Print Service 的 PrinterStateReasons 属性中,而当相应的条件变成虚假条件时,无论 Print Service 的总体 PrinterState 是否也已更改,打印机都将再次移除 PrinterStateReason 对象。

类 PrinterStateReasons 从类 java.util.HashMap 中继承了其实现。映射中的每一项都包括映射到 Severity 对象(值)的 PrinterStateReason 对象(键):

与大部分一旦构造就不可改变的打印属性不同,类 PrinterStateReasons 设计为可变的;您可以将 PrinterStateReason 对象添加到现有的 PrinterStateReasons 对象中,并可将它们移除。不过,与类 java.util.HashMap 一样,类 PrinterStateReasons 具有 bot 多线程安全性。如果 PrinterStateReasons 对象将由多线程使用,则一定要同步其操作(例如,使用从类 java.util.Collections 中获取的已同步映射视图)。

IPP 兼容性:字符串值由每个 PrinterStateReason 对象和相关的 Severity 对象的 toString() 方法返回,它们之间用连字号 ("-") 连接,该值提供了 IPP 关键字值。由 getName() 返回的类别名称提供了 IPP 属性名称。

另请参见:
序列化表格

嵌套类摘要
 
从类 java.util.AbstractMap 继承的嵌套类/接口
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
构造方法摘要
PrinterStateReasons()
          构造一个新的空 PrinterStateReasons 属性;底层哈希映射具有默认的初始容量和加载因子。
PrinterStateReasons(int initialCapacity)
          构造一个新的空 PrinterStateReasons 属性;底层哈希映射具有给定的初始容量和默认的加载因子。
PrinterStateReasons(int initialCapacity, float loadFactor)
          构造一个新的空 PrinterStateReasons 属性;底层哈希映射具有给定的初始容量和加载因子。
PrinterStateReasons(Map<PrinterStateReason,Severity> map)
          构造一个新的 PrinterStateReasons 属性,它包括与给定映射相同的 PrinterStateReasonSeverity 映射关系。
 
方法摘要
 Class<? extends Attribute> getCategory()
          获取将用作此打印属性值的“类别”的打印属性类。
 String getName()
          获取类别的名称,此属性值是该类别的一个实例。
 Set<PrinterStateReason> printerStateReasonSet(Severity severity)
          在此 PrinterStateReasons 中,获得在给定的严重性级别每个 PrinterStateReasons 属性的不可修改的视图集。
 Severity put(PrinterStateReason reason, Severity severity)
          根据给定的严重性级别,将给定的打印机状态原因添加到此 PrinterStateReasons 属性中。
 
从类 java.util.HashMap 继承的方法
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values
 
从类 java.util.AbstractMap 继承的方法
equals, hashCode, toString
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, wait, wait, wait
 
从接口 java.util.Map 继承的方法
equals, hashCode
 

构造方法详细信息

PrinterStateReasons

public PrinterStateReasons()
构造一个新的空 PrinterStateReasons 属性;底层哈希映射具有默认的初始容量和加载因子。


PrinterStateReasons

public PrinterStateReasons(int initialCapacity)
构造一个新的空 PrinterStateReasons 属性;底层哈希映射具有给定的初始容量和默认的加载因子。

参数:
initialCapacity - 初始容量。
抛出:
IllegalArgumentException - 如果初始容量小于零。

PrinterStateReasons

public PrinterStateReasons(int initialCapacity,
                           float loadFactor)
构造一个新的空 PrinterStateReasons 属性;底层哈希映射具有给定的初始容量和加载因子。

参数:
initialCapacity - 初始容量。
loadFactor - 加载因子。
抛出:
IllegalArgumentException - 如果初始容量小于零。

PrinterStateReasons

public PrinterStateReasons(Map<PrinterStateReason,Severity> map)
构造一个新的 PrinterStateReasons 属性,它包括与给定映射相同的 PrinterStateReasonSeverity 映射关系。底层哈希映射的初始容量和加载因子与在超类构造方法 HashMap(Map) 中指定的相同。

参数:
map - 要复制的映射。
抛出:
NullPointerException - (未经检查的异常)如果 map 为 null,或者 map 中的任何键或值为 null。
ClassCastException - (未经检查的异常)如果 map 中的任何键不是类 PrinterStateReason 的一个实例,或者 map 中的任何值不是类 Severity 一个实例。
方法详细信息

put

public Severity put(PrinterStateReason reason,
                    Severity severity)
根据给定的严重性级别,将给定的打印机状态原因添加到此 PrinterStateReasons 属性中。如果此 PrinterStateReasons 属性以前包含了给定打印机状态原因的映射关系,则取代原来的值。

指定者:
接口 Map<PrinterStateReason,Severity> 中的 put
覆盖:
HashMap<PrinterStateReason,Severity> 中的 put
参数:
reason - 打印机状态原因。这必须是类 PrinterStateReason 的一个实例。
severity - 打印机状态原因的严重性。这必须是类 Severity 的一个实例。
返回:
以前与给定打印机状态原因相关联的严重性,如果给定的打印机状态原因不存在,则返回 null
抛出:
NullPointerException - (未经检查的异常)如果 reason 为 null,或者 severity 为 null。
ClassCastException - (未经检查的异常)如果 reason 不是类 PrinterStateReason 的一个实例,或者 severity 不是类 Severity 的一个实例。
从以下版本开始:
1.5

getCategory

public final Class<? extends Attribute> getCategory()
获取将用作此打印属性值的“类别”的打印属性类。

对于类 PrinterStateReasons,该类别就是类 PrinterStateReasons 本身。

指定者:
接口 Attribute 中的 getCategory
返回:
打印属性类(类别),这是类 java.lang.Class 的一个实例。

getName

public final String getName()
获取类别的名称,此属性值是该类别的一个实例。

对于类 PrinterStateReasons,类别名称是 "printer-state-reasons"

指定者:
接口 Attribute 中的 getName
返回:
属性类别名称。

printerStateReasonSet

public Set<PrinterStateReason> printerStateReasonSet(Severity severity)
在此 PrinterStateReasons 中,获得在给定的严重性级别每个 PrinterStateReasons 属性的不可修改的视图集。该视图集中的每个元素都是一个 PrinterStateReason 对象。视图集中仅有的元素是映射到给定严重性值的 PrinterStateReason 对象。该视图集受此 PrinterStateReasons 属性支持,因此,对此 PrinterStateReasons 属性的更改会在视图集中反映出来。该视图集不支持元素插入或移除。视图集的迭代器不支持元素移除。

参数:
severity - 严重性级别。
返回:
在给定 Severity 级别每个 PrinterStateReason 属性的视图集。
抛出:
NullPointerException - (未经检查的异常)如果 severity 为 null。

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策