- java.lang.Object
-
- javax.print.attribute.AttributeSetUtilities
-
public final class AttributeSetUtilities extends Object
类AttributeSetUtilities提供了用于操作AttributeSets静态方法。- 用于创建属性集的不可修改和同步视图的方法。
- 有助于构建接口
AttributeSet的实现的操作
AttributeSet的不可修改的视图 U向客户端提供对S的 “只读”访问。 对U “通读”到S的查询操作; 因此, S的变化反映在U中 。 但是,任何修改U的尝试都会产生UnmodifiableSetException。 如果属性集对象S是可序列化的,则不可修改的视图对象U将是可序列化的。集合的属性的同步视图 V提供具有同步(多线程安全)访问s的客户。 V的每个操作是用V本身作为锁定对象同步,然后调用仅仅S的相应的操作。 为了保证互斥访问,通过V完成对S的所有访问是至关重要的。 如果属性集对象S是可序列化的,则同步视图对象V将是可序列化的。
如
javax.print的包描述中javax.print,方法的参考参数null是不正确的,除非在方法上明确记录为具有有意义的解释。 相反的用法是不正确的编码,并且可能立即或稍后导致运行时异常。IllegalArgumentException和NullPointerException是此类情况的典型和可接受的运行时异常的示例。
-
-
方法摘要
-
-
-
方法详细信息
-
unmodifiableView
public static AttributeSet unmodifiableView(AttributeSet attributeSet)
创建给定属性集的不可修改视图。- 参数
-
attributeSet- 基础属性集 - 结果
-
attributeSet不可修改的视图 - 异常
-
NullPointerException- 如果attributeSet是null
-
unmodifiableView
public static DocAttributeSet unmodifiableView(DocAttributeSet attributeSet)
创建给定doc属性集的不可修改视图。- 参数
-
attributeSet- 基础doc属性集 - 结果
-
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)
创建给定doc属性集的同步视图。- 参数
-
attributeSet- 基础doc属性集 - 结果
-
同步视图
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 - 异常
-
NullPointerException- 如果attributeSet是null
-
verifyAttributeCategory
public static 类<?> verifyAttributeCategory(Object object, 类<?> interfaceName)
- 参数
-
object-Object进行测试 -
interfaceName- 对象必须实现的接口 - 结果
-
如果
object是类实现interfaceName,object返回垂头丧气键入类; 否则抛出异常 - 异常
-
NullPointerException- 如果object是null -
ClassCastException- 如果object不是类,实现interfaceName
-
verifyAttributeValue
public static Attribute verifyAttributeValue(Object object, 类<?> interfaceName)
验证给定对象是给定接口的实例,假定该接口是接口Attribute或其子接口。- 参数
-
object-Object进行测试 -
interfaceName- 对象必须是实例的接口 - 结果
-
如果
object是object的实例,interfaceNameobject向下转换为类型Attribute; 否则抛出异常 - 异常
-
NullPointerException- 如果object是null -
ClassCastException-如果object不是一个实例interfaceName
-
verifyCategoryForValue
public static void verifyCategoryForValue(类<?> category, Attribute attribute)
验证给定的属性类别对象是否等于给定属性值对象的类别。 如果是这样,此方法无效。 如果不是,则此方法抛出异常。- 参数
-
category- 要测试的属性类别 -
attribute- 要测试的属性值 - 异常
-
NullPointerException- 如果category或attribute是null -
IllegalArgumentException-如果category不等于类别attribute
-
-