模块 java.desktop

类 AttributeSetUtilities

java.lang.Object
javax.print.attribute.AttributeSetUtilities

public final class AttributeSetUtilities extends Object
AttributeSetUtilities 提供用于操作 AttributeSets 的静态方法。
  • 创建属性集的不可修改和同步视图的方法。
  • 对构建接口 AttributeSet 的实现有用的操作
一个不可修改的视图 U一个AttributeSetS为客户端提供“只读”访问权限S.查询操作U“通读”到S;因此,变化S反映在U.然而,任何试图修改U, 结果为 UnmodifiableSetException 。不可修改的视图对象U如果属性集对象将是可序列化的S是可序列化的。

A 同步视图 V一个属性集S为客户端提供同步(多线程安全)访问S.的每个操作V使用同步V本身作为锁定对象,然后仅调用相应的操作S.为了保证互斥访问,至关重要的是所有访问S是通过V.同步视图对象V如果属性集对象将是可序列化的S是可序列化的。

javax.print 的包描述中所述,方法的 null 引用参数是不正确的,除非在方法上明确记录为具有有意义的解释。相反的用法是不正确的编码,可能会立即或稍后导致运行时异常。 IllegalArgumentExceptionNullPointerException 是此类情况下典型且可接受的运行时异常的示例。

  • 方法详情

    • unmodifiableView

      public static AttributeSet  unmodifiableView(AttributeSet  attributeSet)
      创建给定属性集的不可修改视图。
      参数:
      attributeSet - 基础属性集
      返回:
      attributeSet 不可修改的视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • unmodifiableView

      public static DocAttributeSet  unmodifiableView(DocAttributeSet  attributeSet)
      创建给定文档属性集的不可修改视图。
      参数:
      attributeSet - 底层文档属性集
      返回:
      attributeSet 不可修改的视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • unmodifiableView

      public static PrintRequestAttributeSet  unmodifiableView(PrintRequestAttributeSet  attributeSet)
      创建给定打印请求属性集的不可修改视图。
      参数:
      attributeSet - 底层打印请求属性集
      返回:
      attributeSet 不可修改的视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • unmodifiableView

      public static PrintJobAttributeSet  unmodifiableView(PrintJobAttributeSet  attributeSet)
      创建给定打印作业属性集的不可修改视图。
      参数:
      attributeSet - 底层打印作业属性集
      返回:
      attributeSet 不可修改的视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • unmodifiableView

      public static PrintServiceAttributeSet  unmodifiableView(PrintServiceAttributeSet  attributeSet)
      创建给定打印服务属性集的不可修改视图。
      参数:
      attributeSet - 底层打印服务属性集
      返回:
      attributeSet 不可修改的视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • synchronizedView

      public static AttributeSet  synchronizedView(AttributeSet  attributeSet)
      创建给定属性集的同步视图。
      参数:
      attributeSet - 基础属性集
      返回:
      attributeSet 的同步视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • synchronizedView

      public static DocAttributeSet  synchronizedView(DocAttributeSet  attributeSet)
      创建给定文档属性集的同步视图。
      参数:
      attributeSet - 底层文档属性集
      返回:
      attributeSet 的同步视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • synchronizedView

      public static PrintRequestAttributeSet  synchronizedView(PrintRequestAttributeSet  attributeSet)
      创建给定打印请求属性集的同步视图。
      参数:
      attributeSet - 底层打印请求属性集
      返回:
      attributeSet 的同步视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • synchronizedView

      public static PrintJobAttributeSet  synchronizedView(PrintJobAttributeSet  attributeSet)
      创建给定打印作业属性集的同步视图。
      参数:
      attributeSet - 底层打印作业属性集
      返回:
      attributeSet 的同步视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • synchronizedView

      public static PrintServiceAttributeSet  synchronizedView(PrintServiceAttributeSet  attributeSet)
      创建给定打印服务属性集的同步视图。
      参数:
      attributeSet - 底层打印服务属性集
      返回:
      attributeSet 的同步视图
      抛出:
      NullPointerException - 如果 attributeSetnull
    • verifyAttributeCategory

      public static Class <?> verifyAttributeCategory(Object  object, Class <?> interfaceName)
      验证给定对象是实现给定接口的Class ,假定为接口Attribute 或其子接口。
      参数:
      object - Object 测试
      interfaceName - 对象必须实现的接口
      返回:
      如果 object 是实现 interfaceNameClass ,则 object 向下转换为类型 Class ;否则抛出异常
      抛出:
      NullPointerException - 如果 objectnull
      ClassCastException - 如果 object 不是实现 interfaceNameClass
    • verifyAttributeValue

      public static Attribute  verifyAttributeValue(Object  object, Class <?> interfaceName)
      验证给定对象是给定接口的实例,假定为接口 Attribute 或其子接口。
      参数:
      object - Object 测试
      interfaceName - 对象必须是其实例的接口
      返回:
      如果 objectinterfaceName 的实例,则 object 向下转换为类型 Attribute ;否则抛出异常
      抛出:
      NullPointerException - 如果 objectnull
      ClassCastException - 如果 object 不是 interfaceName 的实例
    • verifyCategoryForValue

      public static void verifyCategoryForValue(Class <?> category, Attribute  attribute)
      验证给定的属性类别对象是否等于给定的属性值对象的类别。如果是这样,此方法返回不执行任何操作。如果不是,此方法将抛出异常。
      参数:
      category - 要测试的属性类别
      attribute - 要测试的属性值
      抛出:
      NullPointerException - 如果 categoryattributenull
      IllegalArgumentException - 如果 category 不等于 attribute 的类别