JavaTM 2 Platform
Standard Ed. 6

javax.print.attribute
类 AttributeSetUtilities

java.lang.Object
  继承者 javax.print.attribute.AttributeSetUtilities

public final class AttributeSetUtilities
extends Object

类 AttributeSetUtilities 为操作 AttributeSets 提供静态方法。

AttributeSet S不可修改的视图 U 为客户机提供对 S 的“只读”访问。U 上的查询操作“遍历”S;因此,S 中的更改会反映在 U 中。但是,任何修改 U 的尝试都会导致 UnmodifiableSetException。如果属性集对象 S 是可序列化的,则不可修改的视图对象 U 将是可序列化的。

属性集 S同步视图 V 为客户机提供对 S 的同步(多线程安全)访问。V 的每个操作使用 V 本身作为锁定对象进行同步,然后只调用 S 的相应操作。为了相互保证独占访问,通过 V 完成对 S 的所有访问非常重要。如果属性集对象 S 是可序列化的,则同步视图对象 V 将是可序列化的。

如 javax.print 的包描述中提及的那样,方法的 null 引用参数是不正确的,除非在该方法中将该参数明确记录为具有有意义的解释。与之相反的用法是不正确的编码,可能立即或在稍后某一时间导致运行时异常。IllegalArgumentException 和 NullPointerException 是针对这种情况的典型的、可接受的运行时异常的示例。


方法摘要
static AttributeSet synchronizedView(AttributeSet attributeSet)
          创建给定属性集的同步视图。
static DocAttributeSet synchronizedView(DocAttributeSet attributeSet)
          创建一个给定文档属性集的同步视图。
static PrintJobAttributeSet synchronizedView(PrintJobAttributeSet attributeSet)
          创建一个给定打印作业属性集的同步视图。
static PrintRequestAttributeSet synchronizedView(PrintRequestAttributeSet attributeSet)
          创建一个给定打印请求属性集的同步视图。
static PrintServiceAttributeSet synchronizedView(PrintServiceAttributeSet attributeSet)
          创建一个给定打印服务属性集的同步视图。
static AttributeSet unmodifiableView(AttributeSet attributeSet)
          创建给定属性集的不可修改的视图。
static DocAttributeSet unmodifiableView(DocAttributeSet attributeSet)
          创建一个给定文档属性集的不可修改的视图。
static PrintJobAttributeSet unmodifiableView(PrintJobAttributeSet attributeSet)
          创建一个给定打印作业属性集的不可修改的视图。
static PrintRequestAttributeSet unmodifiableView(PrintRequestAttributeSet attributeSet)
          创建一个给定打印请求属性集的不可修改的视图。
static PrintServiceAttributeSet unmodifiableView(PrintServiceAttributeSet attributeSet)
          创建一个给定打印服务属性集的不可修改的视图。
static Class<?> verifyAttributeCategory(Object object, Class<?> interfaceName)
          验证给定的对象是否为实现给定接口(假定为接口 Attribute 或其子接口)的 Class
static Attribute verifyAttributeValue(Object object, Class<?> interfaceName)
          验证给定的对象是否为给定接口(假定为接口 Attribute 或其子接口)的一个实例。
static void verifyCategoryForValue(Class<?> category, Attribute attribute)
          验证给定的属性类别对象是否等于给定属性值对象的类别。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

unmodifiableView

public static AttributeSet unmodifiableView(AttributeSet attributeSet)
创建给定属性集的不可修改的视图。

参数:
attributeSet - 底层属性集。
返回:
attributeSet 的不可修改的视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

unmodifiableView

public static DocAttributeSet unmodifiableView(DocAttributeSet attributeSet)
创建一个给定文档属性集的不可修改的视图。

参数:
attributeSet - 底层文档属性集。
返回:
attributeSet 的不可修改的视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

unmodifiableView

public static PrintRequestAttributeSet unmodifiableView(PrintRequestAttributeSet attributeSet)
创建一个给定打印请求属性集的不可修改的视图。

参数:
attributeSet - 底层打印请求属性集。
返回:
attributeSet 的不可修改的视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

unmodifiableView

public static PrintJobAttributeSet unmodifiableView(PrintJobAttributeSet attributeSet)
创建一个给定打印作业属性集的不可修改的视图。

参数:
attributeSet - 底层打印作业属性集。
返回:
attributeSet 的不可修改的视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

unmodifiableView

public static PrintServiceAttributeSet unmodifiableView(PrintServiceAttributeSet attributeSet)
创建一个给定打印服务属性集的不可修改的视图。

参数:
attributeSet - 底层打印服务属性集。
返回:
attributeSet 的不可修改的视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

synchronizedView

public static AttributeSet synchronizedView(AttributeSet attributeSet)
创建给定属性集的同步视图。

参数:
attributeSet - 底层属性集。
返回:
attributeSet 的同步视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

synchronizedView

public static DocAttributeSet synchronizedView(DocAttributeSet attributeSet)
创建一个给定文档属性集的同步视图。

参数:
attributeSet - 底层文档属性集。
返回:
attributeSet 的同步视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

synchronizedView

public static PrintRequestAttributeSet synchronizedView(PrintRequestAttributeSet attributeSet)
创建一个给定打印请求属性集的同步视图。

参数:
attributeSet - 底层打印请求属性集。
返回:
attributeSet 的同步视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

synchronizedView

public static PrintJobAttributeSet synchronizedView(PrintJobAttributeSet attributeSet)
创建一个给定打印作业属性集的同步视图。

参数:
attributeSet - 底层打印作业属性集。
返回:
attributeSet 的同步视图。
抛出:
NullPointerException - 如果 attributeSet 为 null,则抛出该异常。

synchronizedView

public static PrintServiceAttributeSet synchronizedView(PrintServiceAttributeSet attributeSet)
创建一个给定打印服务属性集的同步视图。

参数:
attributeSet - 底层打印服务属性集。
返回:
attributeSet 的同步视图。

verifyAttributeCategory

public static Class<?> verifyAttributeCategory(Object object,
                                               Class<?> interfaceName)
验证给定的对象是否为实现给定接口(假定为接口 Attribute 或其子接口)的 Class

参数:
object - 要测试的对象。
interfaceName - 该对象必须实现的接口。
返回:
如果 object 是实现 interfaceNameClass,则返回的 object 向下转型到类型 Class;否则抛出一个异常。
抛出:
NullPointerException - (未经检查的异常)如果 object 为 null,则抛出该异常。
ClassCastException - (未经检查的异常)如果 object 不是实现 interfaceNameClass,则抛出该异常。

verifyAttributeValue

public static Attribute verifyAttributeValue(Object object,
                                             Class<?> interfaceName)
验证给定的对象是否为给定接口(假定为接口 Attribute 或其子接口)的一个实例。

参数:
object - 要测试的对象。
interfaceName - 其对象必须是实例的接口的名称。
返回:
如果 objectinterfaceName 的一个实例,则返回的 object 向下转型到类型 Attribute;否则抛出一个异常。
抛出:
NullPointerException - (未经检查的异常)如果 object 为 null,则抛出该异常。
ClassCastException - (未经检查的异常)如果 object 不是 interfaceName 的一个实例,则抛出该异常。

verifyCategoryForValue

public static void verifyCategoryForValue(Class<?> category,
                                          Attribute attribute)
验证给定的属性类别对象是否等于给定属性值对象的类别。如果等于,则此方法只返回而不执行任何操作。如果不等于,则此方法抛出一个异常。

参数:
category - 要测试的属性类别。
attribute - 要测试的属性值。
抛出:
NullPointerException - (未经检查的异常)如果 category 为 null,或者如果 attribute 为 null,则抛出该异常。
IllegalArgumentException - (未经检查的异常)如果 category 不等于 attribute 的类别,则抛出该异常。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

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