模块 java.desktop

类 BeanContextSupport

java.lang.Object
java.beans.beancontext.BeanContextChildSupport
java.beans.beancontext.BeanContextSupport
所有已实现的接口:
BeanContext , BeanContextChild , BeanContextServiceRevokedListener , BeanContextServicesListener , DesignMode , PropertyChangeListener , VetoableChangeListener , Visibility , Serializable , Iterable , Collection , EventListener
已知子类:
BeanContextServicesSupport

public class BeanContextSupport extends BeanContextChildSupport implements BeanContext , Serializable , PropertyChangeListener , VetoableChangeListener
这个帮助器类提供了 java.beans.beancontext.BeanContext 接口的实用程序实现。

由于此类直接实现了 BeanContext 接口,因此该类可以并且旨在通过子类化此实现或通过从另一个类的实例临时委托来使用。

自从:
1.2
参见:
  • 字段详细信息

    • children

      protected transient HashMap <Object ,BeanContextSupport.BCSChild > children
      所有对 protected HashMap children 字段的访问都应在该对象上同步。
    • bcmListeners

      protected transient ArrayList <BeanContextMembershipListener > bcmListeners
      所有对 protected ArrayList bcmListeners 字段的访问都应在该对象上同步。
    • locale

      protected Locale  locale
      此 BeanContext 的当前locale。
    • okToUseGui

      protected boolean okToUseGui
      boolean 指示此实例现在是否可以呈现 GUI。
    • designTime

      protected boolean designTime
      boolean 指示此对象当前是否处于设计时模式。
  • 构造方法详细信息

    • BeanContextSupport

      public BeanContextSupport(BeanContext  peer, Locale  lcle, boolean dTime, boolean visible)
      构造一个 BeanContextSupport 实例
      参数:
      peer - 我们正在为其提供实现的对等点 BeanContext,或者如果此对象是它自己的对等点,则为 null
      lcle - 此 BeanContext 的当前locale。如果 lclenull,则默认区域设置分配给 BeanContext 实例。
      dTime - 初始状态,true 如果处于设计模式,false 如果是运行时。
      visible - 初始可见性。
      参见:
    • BeanContextSupport

      public BeanContextSupport(BeanContext  peer, Locale  lcle, boolean dtime)
      使用指定的locale和设计模式创建实例。
      参数:
      peer - 我们正在为其提供实现的对等点 BeanContext,或者如果此对象是它自己的对等点,则为 null
      lcle - 此 BeanContext 的当前locale。如果 lclenull,则默认区域设置分配给 BeanContext 实例。
      dtime - 初始状态,true 如果处于设计模式,false 如果是运行时。
      参见:
    • BeanContextSupport

      public BeanContextSupport(BeanContext  peer, Locale  lcle)
      使用指定locale创建实例
      参数:
      peer - 我们为其提供实现的对等 BeanContext,或者 null 如果此对象是它自己的对等
      lcle - 此 BeanContext 的当前locale。如果 lclenull,则默认区域设置分配给 BeanContext 实例。
      参见:
    • BeanContextSupport

      public BeanContextSupport(BeanContext  peer)
      使用默认locale创建实例
      参数:
      peer - 我们正在为其提供实现的对等点 BeanContext,或者如果此对象是它自己的对等点,则为 null
    • BeanContextSupport

      public BeanContextSupport()
      创建一个不是另一个对象的委托的实例
  • 方法详情

    • getBeanContextPeer

      public BeanContext  getBeanContextPeer()
      获取此对象为其提供实现的 BeanContext 实例。
      返回:
      BeanContext 实例
    • instantiateChild

      public Object  instantiateChild(String  beanName) throws IOException , ClassNotFoundException

      instantiateChild 方法是 BeanContext 中的一个便利挂钩,用于简化将嵌套的 Bean 实例化为 BeanContext 的任务。

      beanName 参数的语义由 java.beans.Beans.instantiate 定义。

      指定者:
      instantiateChild 在接口 BeanContext
      参数:
      beanName - 要在此 BeanContext 中实例化的 Bean 的名称
      返回:
      新对象
      抛出:
      IOException - 如果在反序列化 bean 时出现 I/O 错误
      ClassNotFoundException - 如果找不到由 beanName 参数标识的类
    • size

      public int size()
      获取当前嵌套在此 BeanContext 中的子项数。
      指定者:
      size 在接口 Collection
      返回:
      儿童人数
    • isEmpty

      public boolean isEmpty()
      报告此 BeanContext 是否为空。当 BeanContext 包含零个嵌套子项时,它被认为是空的。
      指定者:
      isEmpty 在接口 Collection
      返回:
      如果没有子级
    • contains

      public boolean contains(Object  o)
      确定指定对象当前是否是此 BeanContext 的子对象。
      指定者:
      contains 在接口 Collection
      参数:
      o - 有问题的对象
      返回:
      如果这个对象是一个子级
    • containsKey

      public boolean containsKey(Object  o)
      确定指定对象当前是否是此 BeanContext 的子对象。
      参数:
      o - 有问题的对象
      返回:
      如果这个对象是一个子级
    • iterator

      public Iterator <Object > iterator()
      获取当前嵌套在此 BeanContext 中的所有 JavaBean 或 BeanContext 实例。
      指定者:
      iterator 在接口 Collection
      指定者:
      iterator 在接口 Iterable
      返回:
      嵌套子项的 Iterator
    • toArray

      public Object [] toArray()
      获取当前嵌套在此 BeanContext 中的所有 JavaBean 或 BeanContext 实例。
      指定者:
      toArray 在接口 Collection
      返回:
      一个数组,其 运行时组件类型Object,包含此集合中的所有元素
    • toArray

      public Object [] toArray(Object [] arry)
      获取一个数组,其中包含此 BeanContext 的所有子项,这些子项与 arry 中包含的类型相匹配。
      指定者:
      toArray 在接口 Collection
      参数:
      arry - 感兴趣的对象类型数组。
      返回:
      一个子元素的数组
    • createBCSChild

      protected BeanContextSupport.BCSChild  createBCSChild(Object  targetChild, Object  peer)

      子类可以重写此方法以插入自己的 Child 子类,而不必重写 add() 或其他将子类添加到集合的 Collection 方法。

      参数:
      targetChild - 子代创建子代
      peer - peer 如果 tragetChild 和 peer 通过 BeanContextProxy 的实现相关
      返回:
      Child 的特定于子类型的子类,没有重写集合方法
    • add

      public boolean add(Object  targetChild)
      在这个 BeanContext 中添加/嵌套一个孩子。

      作为 java.beans.Beans.instantiate() 的副作用调用。如果子对象对于添加无效,则此方法抛出 IllegalStateException。

      指定者:
      add 在接口 Collection
      参数:
      targetChild - 嵌套在这个 BeanContext 中的子对象
      返回:
      如果成功添加了子级,则为真。
      参见:
    • remove

      public boolean remove(Object  targetChild)
      从此 BeanContext 中移除一个子项。如果子对象不用于添加,则此方法抛出 IllegalStateException。
      指定者:
      remove 在接口 Collection
      参数:
      targetChild - 要删除的子对象
      返回:
      true 如果一个元素作为这个调用的结果被移除
      参见:
    • remove

      protected boolean remove(Object  targetChild, boolean callChildSetBC)
      当因意外的 setBeanContextremove() 调用导致删除时使用内部删除。
      参数:
      targetChild - 要删除的 JavaBean、BeanContext 或对象
      callChildSetBC - 用于表示应该通知孩子它不再嵌套在这个 BeanContext 中。
      返回:
      在被删除之前是否存在
    • containsAll

      public boolean containsAll(Collection  c)
      测试指定 Collection 中的所有对象是否都是此 BeanContext 的子对象。
      指定者:
      containsAll 在接口 Collection
      参数:
      c - 指定的 Collection
      返回:
      true 如果集合中的所有对象都是此 BeanContext 的子对象,否则为 false。
      参见:
    • addAll

      public boolean addAll(Collection  c)
      将集合添加到子集(不支持)实现必须在层次结构锁和“子”保护字段上同步
      指定者:
      addAll 在接口 Collection
      参数:
      c - 包含要添加到此集合的元素的集合
      返回:
      此实现无条件抛出 UnsupportedOperationException
      抛出:
      UnsupportedOperationException - 此实现无条件抛出
      参见:
    • removeAll

      public boolean removeAll(Collection  c)
      删除所有指定的子项(不支持)实现必须在层次结构锁和“子项”保护字段上同步
      指定者:
      removeAll 在接口 Collection
      参数:
      c - 包含要从此集合中删除的元素的集合
      返回:
      此实现无条件抛出 UnsupportedOperationException
      抛出:
      UnsupportedOperationException - 此实现无条件抛出
      参见:
    • retainAll

      public boolean retainAll(Collection  c)
      仅保留指定的子项(不支持)实现必须在层次锁和“子项”保护字段上同步
      指定者:
      retainAll 在接口 Collection
      参数:
      c - 包含要保留在此集合中的元素的集合
      返回:
      此实现无条件抛出 UnsupportedOperationException
      抛出:
      UnsupportedOperationException - 此实现无条件抛出
      参见:
    • clear

      public void clear()
      清除子(不支持)实现必须在层次锁和“子”保护字段上同步
      指定者:
      clear 在接口 Collection
      抛出:
      UnsupportedOperationException - 此实现无条件抛出
    • addBeanContextMembershipListener

      public void addBeanContextMembershipListener(BeanContextMembershipListener  bcml)
      添加一个 BeanContextMembershipListener
      指定者:
      addBeanContextMembershipListener 在接口 BeanContext
      参数:
      bcml - 要添加的 BeanContextMembershipListener
      抛出:
      NullPointerException - 如果参数为空
    • removeBeanContextMembershipListener

      public void removeBeanContextMembershipListener(BeanContextMembershipListener  bcml)
      删除 BeanContextMembershipListener
      指定者:
      removeBeanContextMembershipListener 在接口 BeanContext
      参数:
      bcml - 要删除的 BeanContextMembershipListener
      抛出:
      NullPointerException - 如果参数为空
    • getResourceAsStream

      public InputStream  getResourceAsStream(String  name, BeanContextChild  bcc)
      从接口 BeanContext 复制的描述
      类似于 java.lang.ClassLoader.getResourceAsStream() ,此方法允许 BeanContext 实现在子 Component 和底层 ClassLoader 之间插入行为。
      指定者:
      getResourceAsStream 在接口 BeanContext
      参数:
      name - 所请求资源的名称。
      bcc - 发出请求的子对象。
      返回:
      请求的资源作为 InputStream
      抛出:
      NullPointerException - 如果参数为空
    • getResource

      public URL  getResource(String  name, BeanContextChild  bcc)
      从接口 BeanContext 复制的描述
      类似于 java.lang.ClassLoader.getResource(),此方法允许 BeanContext 实现在子 Component 和底层 ClassLoader 之间插入行为。
      指定者:
      getResource 在接口 BeanContext
      参数:
      name - 所请求资源的名称。
      bcc - 发出请求的子对象。
      返回:
      请求的资源作为 InputStream
    • setDesignTime

      public void setDesignTime(boolean dTime)
      为此 BeanContext 设置新的设计时间值。
      指定者:
      setDesignTime 在接口 DesignMode
      参数:
      dTime - 新的 designTime 值
      参见:
    • isDesignTime

      public boolean isDesignTime()
      报告此对象当前是否处于设计时模式。
      指定者:
      isDesignTime 在接口 DesignMode
      返回:
      true 如果处于设计时模式,false 如果不是
    • setLocale

      public void setLocale(Locale  newLocale) throws PropertyVetoException
      设置此 BeanContext 的locale。
      参数:
      newLocale - 新locale。如果 newLocale 是 null ,则此方法调用将无效。
      抛出:
      PropertyVetoException - 如果新值被拒绝
    • getLocale

      public Locale  getLocale()
      获取此 BeanContext 的locale。
      返回:
      BeanContext 的当前locale
    • needsGui

      public boolean needsGui()

      通常从环境中调用此方法以确定实现者是否“需要”GUI。

      此处使用的算法测试 BeanContextPeer 及其当前子项以确定它们是否是容器、组件,或者它们是否实现了可见性并返回 needsGui() == true。

      指定者:
      needsGui 在接口 Visibility
      返回:
      true 如果实现者需要 GUI
    • dontUseGui

      public void dontUseGui()
      通知此实例它可能不再呈现 GUI。
      指定者:
      dontUseGui 在接口 Visibility
    • okToUseGui

      public void okToUseGui()
      通知此实例它现在可以呈现 GUI
      指定者:
      okToUseGui 在接口 Visibility
    • avoidingGui

      public boolean avoidingGui()
      用于确定 BeanContext 孩子是否正在避免使用其 GUI。
      指定者:
      avoidingGui 在接口 Visibility
      返回:
      此实例是否避免使用其 GUI?
      参见:
    • isSerializing

      public boolean isSerializing()
      这个BeanContext是在连载中吗?
      返回:
      如果这个 BeanContext 当前正在被序列化
    • bcsChildren

      protected Iterator <BeanContextSupport.BCSChild > bcsChildren()
      返回此 BeanContext 的所有子项的迭代器。
      返回:
      所有当前 BCSChild 值的迭代器
    • bcsPreSerializationHook

      protected void bcsPreSerializationHook(ObjectOutputStream  oos) throws IOException
      在 defaultWriteObject() 之后但在当前可序列化子对象的序列化之前由 writeObject 调用。子类可以重写此方法,以在该超类序列化子类之前对其状态执行自定义序列化。但是,子类不应使用此方法来替换它们自己的 writeObject() 实现(如果有)。
      参数:
      oos - 在序列化期间使用的 ObjectOutputStream
      抛出:
      IOException - 如果序列化失败
    • bcsPreDeserializationHook

      protected void bcsPreDeserializationHook(ObjectInputStream  ois) throws IOException , ClassNotFoundException
      在 defaultReadObject() 之后但在反序列化任何子对象之前由 readObject 调用。子类可以重写此方法,以在该超类反序列化子类之前对其状态执行自定义反序列化。但是,子类不应使用此方法来替换它们自己的 readObject() 实现(如果有)。
      参数:
      ois - 在反序列化期间使用的 ObjectInputStream
      抛出:
      IOException - 如果反序列化失败
      ClassNotFoundException - 如果找不到需要的类
    • childDeserializedHook

      protected void childDeserializedHook(Object  child, BeanContextSupport.BCSChild  bcsc)
      由带有新反序列化的子对象和 BCSChild 的 readObject 调用。
      参数:
      child - 新反序列化的孩子
      bcsc - 新反序列化的 BCSChild
    • serialize

      protected final void serialize(ObjectOutputStream  oos, Collection <?> coll) throws IOException
      由 writeObject 用于序列化 Collection。
      参数:
      oos - 在序列化期间使用的 ObjectOutputStream
      coll - 要序列化的 Collection
      抛出:
      IOException - 如果序列化失败
    • deserialize

      protected final void deserialize(ObjectInputStream  ois, Collection  coll) throws IOException , ClassNotFoundException
      readObject 使用它来反序列化一个集合。
      参数:
      ois - 要使用的 ObjectInputStream
      coll - Collection
      抛出:
      IOException - 如果反序列化失败
      ClassNotFoundException - 如果找不到需要的类
    • writeChildren

      public final void writeChildren(ObjectOutputStream  oos) throws IOException
      用于序列化此 BeanContext 的所有子项。
      参数:
      oos - 在序列化期间使用的 ObjectOutputStream
      抛出:
      IOException - 如果序列化失败
    • readChildren

      public final void readChildren(ObjectInputStream  ois) throws IOException , ClassNotFoundException
      当此类的实例用作 BeanContext 协议(及其子协议)实现的委托时,在反序列化期间存在“先有鸡还是先有蛋”的问题
      参数:
      ois - 要使用的 ObjectInputStream
      抛出:
      IOException - 如果反序列化失败
      ClassNotFoundException - 如果找不到需要的类
    • vetoableChange

      public void vetoableChange(PropertyChangeEvent  pce) throws PropertyVetoException
      子类可能会封装以监视否决子属性的更改。
      指定者:
      vetoableChange 在接口 VetoableChangeListener
      参数:
      pce - 一个 PropertyChangeEvent 对象,描述事件源和已更改的属性。
      抛出:
      PropertyVetoException - 如果接收者希望回滚属性更改。
    • propertyChange

      public void propertyChange(PropertyChangeEvent  pce)
      子类可以封装以监视子属性的更改。
      指定者:
      propertyChange 在接口 PropertyChangeListener
      参数:
      pce - 描述事件源和已更改属性的 PropertyChangeEvent 对象。
    • validatePendingAdd

      protected boolean validatePendingAdd(Object  targetChild)

      此类的子类可以重写或封装此方法,以添加BeanContext 的验证行为,以便在将子对象添加到 BeanContext 之前立即对其进行检查。

      参数:
      targetChild - 子代创建子代
      返回:
      当且仅当可以将子级添加到此 BeanContext 时为真,否则为假。
    • validatePendingRemove

      protected boolean validatePendingRemove(Object  targetChild)

      此类的子类可以重写或封装此方法,以添加 BeanContext 的验证行为,以在子对象从 BeanContext 中删除之前立即检查它们。

      参数:
      targetChild - 子代创建子代
      返回:
      当且仅当可以从此 BeanContext 中删除子级时为真,否则为假。
    • childJustAddedHook

      protected void childJustAddedHook(Object  child, BeanContextSupport.BCSChild  bcsc)
      子类可以重写此方法以在添加子项之后和事件通知发生之前简单地扩展 add() 语义。该方法与子同步调用。
      参数:
      child - 孩子
      bcsc - BCSChild
    • childJustRemovedHook

      protected void childJustRemovedHook(Object  child, BeanContextSupport.BCSChild  bcsc)
      子类可以重写此方法以在子项被移除之后和事件通知发生之前简单地扩展 remove() 语义。该方法与子同步调用。
      参数:
      child - 孩子
      bcsc - BCSChild
    • getChildVisibility

      protected static final Visibility  getChildVisibility(Object  child)
      获取与指定子项关联的 Component(如果有)。
      参数:
      child - 指定的孩子
      返回:
      与指定子项关联的组件(如果有)。
    • getChildSerializable

      protected static final Serializable  getChildSerializable(Object  child)
      获取与指定 Child 关联的 Serializable(如果有)
      参数:
      child - 指定的孩子
      返回:
      与指定 Child 关联的 Serializable(如果有)
    • getChildPropertyChangeListener

      protected static final PropertyChangeListener  getChildPropertyChangeListener(Object  child)
      获取指定子项的 PropertyChangeListener(如果有)
      参数:
      child - 指定的孩子
      返回:
      指定子项的 PropertyChangeListener(如果有)
    • getChildVetoableChangeListener

      protected static final VetoableChangeListener  getChildVetoableChangeListener(Object  child)
      获取指定子项的 VetoableChangeListener(如果有)
      参数:
      child - 指定的孩子
      返回:
      指定子项的 VetoableChangeListener(如果有)
    • getChildBeanContextMembershipListener

      protected static final BeanContextMembershipListener  getChildBeanContextMembershipListener(Object  child)
      获取指定子项的 BeanContextMembershipListener(如果有)
      参数:
      child - 指定的孩子
      返回:
      指定子级的 BeanContextMembershipListener(如果有)
    • getChildBeanContextChild

      protected static final BeanContextChild  getChildBeanContextChild(Object  child)
      获取指定子项的 BeanContextChild(如果有)
      参数:
      child - 指定的孩子
      返回:
      指定子项的 BeanContextChild(如果有)
      抛出:
      IllegalArgumentException - 如果 child 实现了 BeanContextChild 和 BeanContextProxy
    • fireChildrenAdded

      protected final void fireChildrenAdded(BeanContextMembershipEvent  bcme)
      在 BeanContextMembershipListener 接口上触发 BeanContextshipEvent
      参数:
      bcme - 要触发的事件
    • fireChildrenRemoved

      protected final void fireChildrenRemoved(BeanContextMembershipEvent  bcme)
      在 BeanContextMembershipListener 接口上触发 BeanContextshipEvent
      参数:
      bcme - 要触发的事件
    • initialize

      protected void initialize()
      从构造方法和 readObject 调用的受保护方法来初始化 BeanContextSupport 实例的瞬态。此类使用此方法来实例化用于监视子级上的 PropertyChange 和 VetoableChange 事件的内部类监听。子类可以封装此方法以添加自己的初始化行为
    • copyChildren

      protected final Object [] copyChildren()
      获取此 BeanContext 的子项的副本。
      返回:
      当前嵌套子项的副本
    • classEquals

      protected static final boolean classEquals(Class <?> first, Class <?> second)
      测试两个类对象或它们的名称是否相等。
      参数:
      first - 第一个对象
      second - 第二个对象
      返回:
      如果相等则为真,否则为假