java.lang.Object
javax.print.attribute.AttributeSetUtilities
类
AttributeSetUtilities 提供用于操作 AttributeSets 的静态方法。
- 创建属性集的不可修改和同步视图的方法。
- 对构建接口
AttributeSet的实现有用的操作
AttributeSetS为客户端提供“只读”访问权限S.查询操作U“通读”到S;因此,变化S反映在U.然而,任何试图修改U, 结果为 UnmodifiableSetException 。不可修改的视图对象U如果属性集对象将是可序列化的S是可序列化的。
A 同步视图 V一个属性集S为客户端提供同步(多线程安全)访问S.的每个操作V使用同步V本身作为锁定对象,然后仅调用相应的操作S.为了保证互斥访问,至关重要的是所有访问S是通过V.同步视图对象V如果属性集对象将是可序列化的S是可序列化的。
如 javax.print 的包描述中所述,方法的 null 引用参数是不正确的,除非在方法上明确记录为具有有意义的解释。相反的用法是不正确的编码,可能会立即或稍后导致运行时异常。 IllegalArgumentException 和 NullPointerException 是此类情况下典型且可接受的运行时异常的示例。
-
方法总结
修饰符和类型方法描述static AttributeSetsynchronizedView(AttributeSet attributeSet) 创建给定属性集的同步视图。static DocAttributeSetsynchronizedView(DocAttributeSet attributeSet) 创建给定文档属性集的同步视图。static PrintJobAttributeSetsynchronizedView(PrintJobAttributeSet attributeSet) 创建给定打印作业属性集的同步视图。static PrintRequestAttributeSetsynchronizedView(PrintRequestAttributeSet attributeSet) 创建给定打印请求属性集的同步视图。static PrintServiceAttributeSetsynchronizedView(PrintServiceAttributeSet attributeSet) 创建给定打印服务属性集的同步视图。static AttributeSetunmodifiableView(AttributeSet attributeSet) 创建给定属性集的不可修改视图。static DocAttributeSetunmodifiableView(DocAttributeSet attributeSet) 创建给定文档属性集的不可修改视图。static PrintJobAttributeSetunmodifiableView(PrintJobAttributeSet attributeSet) 创建给定打印作业属性集的不可修改视图。static PrintRequestAttributeSetunmodifiableView(PrintRequestAttributeSet attributeSet) 创建给定打印请求属性集的不可修改视图。static PrintServiceAttributeSetunmodifiableView(PrintServiceAttributeSet attributeSet) 创建给定打印服务属性集的不可修改视图。static Class<?>verifyAttributeCategory(Object object, Class<?> interfaceName) static AttributeverifyAttributeValue(Object object, Class<?> interfaceName) 验证给定对象是给定接口的实例,假定为接口Attribute或其子接口。static voidverifyCategoryForValue(Class<?> category, Attribute attribute) 验证给定的属性类别对象是否等于给定的属性值对象的类别。
-
方法详情
-
unmodifiableView
创建给定属性集的不可修改视图。- 参数:
attributeSet- 基础属性集- 返回:
attributeSet不可修改的视图- 抛出:
NullPointerException- 如果attributeSet是null
-
unmodifiableView
创建给定文档属性集的不可修改视图。- 参数:
attributeSet- 底层文档属性集- 返回:
attributeSet不可修改的视图- 抛出:
NullPointerException- 如果attributeSet是null
-
unmodifiableView
创建给定打印请求属性集的不可修改视图。- 参数:
attributeSet- 底层打印请求属性集- 返回:
attributeSet不可修改的视图- 抛出:
NullPointerException- 如果attributeSet是null
-
unmodifiableView
创建给定打印作业属性集的不可修改视图。- 参数:
attributeSet- 底层打印作业属性集- 返回:
attributeSet不可修改的视图- 抛出:
NullPointerException- 如果attributeSet是null
-
unmodifiableView
创建给定打印服务属性集的不可修改视图。- 参数:
attributeSet- 底层打印服务属性集- 返回:
attributeSet不可修改的视图- 抛出:
NullPointerException- 如果attributeSet是null
-
synchronizedView
创建给定属性集的同步视图。- 参数:
attributeSet- 基础属性集- 返回:
attributeSet的同步视图- 抛出:
NullPointerException- 如果attributeSet是null
-
synchronizedView
创建给定文档属性集的同步视图。- 参数:
attributeSet- 底层文档属性集- 返回:
attributeSet的同步视图- 抛出:
NullPointerException- 如果attributeSet是null
-
synchronizedView
创建给定打印请求属性集的同步视图。- 参数:
attributeSet- 底层打印请求属性集- 返回:
attributeSet的同步视图- 抛出:
NullPointerException- 如果attributeSet是null
-
synchronizedView
创建给定打印作业属性集的同步视图。- 参数:
attributeSet- 底层打印作业属性集- 返回:
attributeSet的同步视图- 抛出:
NullPointerException- 如果attributeSet是null
-
synchronizedView
创建给定打印服务属性集的同步视图。- 参数:
attributeSet- 底层打印服务属性集- 返回:
attributeSet的同步视图- 抛出:
NullPointerException- 如果attributeSet是null
-
verifyAttributeCategory
- 参数:
object-Object测试interfaceName- 对象必须实现的接口- 返回:
-
如果
object是实现interfaceName的Class,则object向下转换为类型Class;否则抛出异常 - 抛出:
NullPointerException- 如果object是nullClassCastException- 如果object不是实现interfaceName的Class
-
verifyAttributeValue
验证给定对象是给定接口的实例,假定为接口Attribute或其子接口。- 参数:
object-Object测试interfaceName- 对象必须是其实例的接口- 返回:
-
如果
object是interfaceName的实例,则object向下转换为类型Attribute;否则抛出异常 - 抛出:
NullPointerException- 如果object是nullClassCastException- 如果object不是interfaceName的实例
-
verifyCategoryForValue
验证给定的属性类别对象是否等于给定的属性值对象的类别。如果是这样,此方法返回不执行任何操作。如果不是,此方法将抛出异常。- 参数:
category- 要测试的属性类别attribute- 要测试的属性值- 抛出:
NullPointerException- 如果category或attribute是nullIllegalArgumentException- 如果category不等于attribute的类别
-