## com.bbn.openmap
Class MapHandlerChild

    java.lang.Object
      com.bbn.openmap.MapHandlerChild

All Implemented Interfaces:
  java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener, LightMapHandlerChild

Direct Known Subclasses:
  OMComponent, PropertyHandler

public class MapHandlerChild
extends java.lang.Object
implements java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, LightMapHandlerChild

MapHandlerChild shows you all the methods you need to add to an object for it be a good member of the MapHandler. The MapHandler is actually a BeanContext object, which is simply a container for a bunch of objects that may be interested in other objects. If you are using this object as a model to figure out what methods to add to other objects, there are a couple of things to notice. First, java.awt.Components already have a PropertyChangeSupport object in it, so you don't need to implement the methods that deal with property changes. For javax.swing.JComponents, they have VetoablePropertySupport build in, but that object doesn't handle certain methods needed by the BeanContextChild, most notably the (add/remove)VetoableChangeListener() methods with a specific property as an argument.

When you design a MapHandlerChild, you should make it comfortable running without references to objects it depends on. It should wait patiently for the other objects to be added to the MapHandler, and then do the work itself to hook up. It should also listen for those objects to be removed from the MapHandler, disengage gracefully, and wait patiently until it finds something else to hook up to.

An object does not have to be a MapHandlerChild to be added to the MapHandler, but it does need to be one to be able to use it. If you use the findAndInit(Iterator) method to look for objects, you'll find it is called on two different conditions. It's called when this MapHandlerChild is added to the MapHandler, and it then receives a list of all the objects currently contained in the MapHandler. It is also called when other objects are added to the MapHandler. The list then contains objects that have just been added. The findAndInit(Object) method has been added to allow subclassed objects to call super.findAndInit(Object) to let the super classes handles the objects they care about.

When objects are removed from the BeanContext, the childrenRemoved() method is called with a list of objects being removed. Likewise, the findAndUndo(Object) method has been added for the benefit of subclasses.

Field Summary
`protected java.beans.beancontext.BeanContextChildSupport` `beanContextChildSupport` BeanContextChildSupport object provides helper functions for BeanContextChild interface.

Constructor Summary
`MapHandlerChild()`

Method Summary
`void` `addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)` Method for BeanContextChild interface.
`void` `addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)` Method for BeanContextChild interface.
`void` `childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)` BeanContextMembershipListener method.
`void` `childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)` BeanContextMembershipListener method.
`void` `findAndInit(java.util.Iterator it)` This is the method that your object can use to find other objects within the MapHandler (BeanContext).
`void` `findAndInit(java.lang.Object obj)` The findAndInit method has been made non-abstract, because it now calls this method for every object that is in the iterator it receives.
`void` `findAndUndo(java.lang.Object obj)` The childrenRemoved has been changed to go through its iterator to call this method with every object.
`void` `firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)` Method for BeanContextChild interface.
`void` `fireVetoableChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)` Report a vetoable property update to any registered listeners.
`java.beans.beancontext.BeanContext` `getBeanContext()` Method for BeanContextChild interface.
`void` `removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)` Method for BeanContextChild interface.
`void` `removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)` Method for BeanContextChild interface.
`void` `setBeanContext(java.beans.beancontext.BeanContext in_bc)` Method for BeanContextChild interface.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### beanContextChildSupport

    protected java.beans.beancontext.BeanContextChildSupport beanContextChildSupport

  BeanContextChildSupport object provides helper functions for BeanContextChild interface.

Constructor Detail

### MapHandlerChild

    public MapHandlerChild()

Method Detail

### findAndInit

    public void findAndInit(java.util.Iterator it)

  This is the method that your object can use to find other objects within the MapHandler (BeanContext). This method gets called when the object gets added to the MapHandler, or when another object gets added to the MapHandler after the object is a member.

  Parameters:
    `it` - Iterator to use to go through a list of objects. Find the ones you need, and hook yourself up.

### findAndInit

    public void findAndInit(java.lang.Object obj)

  The findAndInit method has been made non-abstract, because it now calls this method for every object that is in the iterator it receives. This lets subclasses call a method on super classes so they can handle their needs as well.

  Specified by:
    `findAndInit` in interface `LightMapHandlerChild`

### childrenAdded

    public void childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)

  BeanContextMembershipListener method. Called when a new object is added to the BeanContext of this object.

  Specified by:
    `childrenAdded` in interface `java.beans.beancontext.BeanContextMembershipListener`

### childrenRemoved

    public void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)

  BeanContextMembershipListener method. Called when a new object is removed from the BeanContext of this object. For the Layer, this method doesn't do anything. If your layer does something with the childrenAdded method, or findAndInit, you should take steps in this method to unhook the layer from the object used in those methods.

  Specified by:
    `childrenRemoved` in interface `java.beans.beancontext.BeanContextMembershipListener`

### findAndUndo

    public void findAndUndo(java.lang.Object obj)

  The childrenRemoved has been changed to go through its iterator to call this method with every object. This lets subclasses call this method on their super class, so it can handle what it needs to with objects it may be interested in.

  Specified by:
    `findAndUndo` in interface `LightMapHandlerChild`

### getBeanContext

    public java.beans.beancontext.BeanContext getBeanContext()

  Method for BeanContextChild interface.

  Specified by:
    `getBeanContext` in interface `java.beans.beancontext.BeanContextChild`

### setBeanContext

    public void setBeanContext(java.beans.beancontext.BeanContext in_bc)
                        throws java.beans.PropertyVetoException

  Method for BeanContextChild interface. Adds this object as a BeanContextMembership listener, set the BeanContext in this objects BeanContextSupport, and receives the initial list of objects currently contained in the BeanContext.

  Specified by:
    `setBeanContext` in interface `java.beans.beancontext.BeanContextChild`
  Throws:
    `java.beans.PropertyVetoException`

### addPropertyChangeListener

    public void addPropertyChangeListener(java.lang.String propertyName,
                                          java.beans.PropertyChangeListener in_pcl)

  Method for BeanContextChild interface. Uses the BeanContextChildSupport to add a listener to this object's property. You don't need this function for objects that extend java.awt.Component.

  Specified by:
    `addPropertyChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### removePropertyChangeListener

    public void removePropertyChangeListener(java.lang.String propertyName,
                                             java.beans.PropertyChangeListener in_pcl)

  Method for BeanContextChild interface. Uses the BeanContextChildSupport to remove a listener to this object's property. You don't need this function for objects that extend java.awt.Component.

  Specified by:
    `removePropertyChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### addVetoableChangeListener

    public void addVetoableChangeListener(java.lang.String propertyName,
                                          java.beans.VetoableChangeListener in_vcl)

  Method for BeanContextChild interface. Uses the BeanContextChildSupport to add a listener to this object's property. This listener wants to have the right to veto a property change.

  Specified by:
    `addVetoableChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### removeVetoableChangeListener

    public void removeVetoableChangeListener(java.lang.String propertyName,
                                             java.beans.VetoableChangeListener in_vcl)

  Method for BeanContextChild interface. Uses the BeanContextChildSupport to remove a listener to this object's property. The listener has the power to veto property changes.

  Specified by:
    `removeVetoableChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### firePropertyChange

    public void firePropertyChange(java.lang.String name,
                                   java.lang.Object oldValue,
                                   java.lang.Object newValue)

  Method for BeanContextChild interface. Uses the BeanContextChildSupport to fire a property change. You don't need this function for objects that extend java.awt.Component.

### fireVetoableChange

    public void fireVetoableChange(java.lang.String name,
                                   java.lang.Object oldValue,
                                   java.lang.Object newValue)
                            throws java.beans.PropertyVetoException

  Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

  No event is fired if old and new are equal and non-null.

  Parameters:
    `name` - The programmatic name of the property that is about to change
    `oldValue` - The old value of the property
    `newValue` - - The new value of the property
  Throws:
    `PropertyVetoException` - if the recipient wishes the property change to be rolled back.

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details