atg.naming
Class NameContextImpl

java.lang.Object
  extended by atg.naming.NameContextImpl
All Implemented Interfaces:
NameContext, NameContextBindingEventSource, NameContextBindingListener, NameContextElement, java.util.EventListener

public class NameContextImpl
extends java.lang.Object
implements NameContext, NameContextBindingEventSource

This is a straightforward implementation of NameContext. This also implements NameContextBindingEventSource, meaning that it notifies listeners whenever a binding or removal occurs.

In this implementation, the absolute name of a child is formed by taking the parent's absolute name, adding a '/', and appending the child's name. This behavior can be changed by overriding getAbsoluteElementName().

This implementation attempts to avoid creating any objects if the Context is not used to store elements - if no elements or listeners are added, then no Dictionaries or Vectors will be created.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
NameContextImpl()
          Constructs a new NameContextImpl
 
Method Summary
 void addNameContextBindingListener(NameContextBindingListener pListener)
          Adds the specified listener to the list of listeners that will be notified whenever an element is bound into or unbound from this NameContext.
 java.lang.Object getElement(java.lang.String pName)
          Returns the element bound to the specified name.
 java.lang.String getName()
          Returns the name by which this element is know within its enclosing NameContext.
 NameContext getNameContext()
          Returns the NameContext into which this element has been bound, or null if the element is not bound in a NameContext.
 NameContextBindingListener[] getNameContextBindingListeners()
          Returns property NameContextBindingListeners
 NameContext getRoot()
          Searches up the tree until it finds the root NameContext
 boolean isElementBound(java.lang.String pName)
          Returns true if the name has and element bound to it, false if not.
 java.util.Enumeration listElementNames()
          Returns the list of element names as an Enumeration
 java.util.Enumeration listElements()
          Returns the list of bound elements as an Enumeration
 void nameContextElementBound(NameContextBindingEvent pEvent)
          This is called to notify this context that it is being bound into a NameContext.
 void nameContextElementUnbound(NameContextBindingEvent pEvent)
          This is called to notify this context that it is being unbound from a NameContext.
 void putElement(java.lang.String pName, java.lang.Object pElement)
          Binds the specified element to the specified name.
 void removeElement(java.lang.String pName)
          Removes the binding for the specified name.
 void removeNameContextBindingListener(NameContextBindingListener pListener)
          Removes the specified listener from the list of listeners that will be notified whenever an element is bound into or unbound from this NameContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

NameContextImpl

public NameContextImpl()
Constructs a new NameContextImpl

Method Detail

getNameContextBindingListeners

public NameContextBindingListener[] getNameContextBindingListeners()
Returns property NameContextBindingListeners


getRoot

public NameContext getRoot()
Searches up the tree until it finds the root NameContext


getElement

public java.lang.Object getElement(java.lang.String pName)
Returns the element bound to the specified name.

Specified by:
getElement in interface NameContext

putElement

public void putElement(java.lang.String pName,
                       java.lang.Object pElement)
Binds the specified element to the specified name.

Specified by:
putElement in interface NameContext

removeElement

public void removeElement(java.lang.String pName)
Removes the binding for the specified name.

Specified by:
removeElement in interface NameContext

isElementBound

public boolean isElementBound(java.lang.String pName)
Returns true if the name has and element bound to it, false if not.

Specified by:
isElementBound in interface NameContext

listElementNames

public java.util.Enumeration listElementNames()
Returns the list of element names as an Enumeration

Specified by:
listElementNames in interface NameContext

listElements

public java.util.Enumeration listElements()
Returns the list of bound elements as an Enumeration

Specified by:
listElements in interface NameContext

addNameContextBindingListener

public void addNameContextBindingListener(NameContextBindingListener pListener)
Adds the specified listener to the list of listeners that will be notified whenever an element is bound into or unbound from this NameContext.

Specified by:
addNameContextBindingListener in interface NameContextBindingEventSource

removeNameContextBindingListener

public void removeNameContextBindingListener(NameContextBindingListener pListener)
Removes the specified listener from the list of listeners that will be notified whenever an element is bound into or unbound from this NameContext.

Specified by:
removeNameContextBindingListener in interface NameContextBindingEventSource

nameContextElementBound

public void nameContextElementBound(NameContextBindingEvent pEvent)
This is called to notify this context that it is being bound into a NameContext.

Specified by:
nameContextElementBound in interface NameContextBindingListener

nameContextElementUnbound

public void nameContextElementUnbound(NameContextBindingEvent pEvent)
This is called to notify this context that it is being unbound from a NameContext.

Specified by:
nameContextElementUnbound in interface NameContextBindingListener

getNameContext

public NameContext getNameContext()
Returns the NameContext into which this element has been bound, or null if the element is not bound in a NameContext.

Specified by:
getNameContext in interface NameContextElement

getName

public java.lang.String getName()
Returns the name by which this element is know within its enclosing NameContext.

Specified by:
getName in interface NameContextElement