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.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
| Constructor and Description |
|---|
NameContextImpl()
Constructs a new NameContextImpl
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected java.util.Dictionary |
createElementsDictionary()
Create the dictionary used to create elements.
|
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.
|
public NameContextBindingListener[] getNameContextBindingListeners()
public NameContext getRoot()
public java.lang.Object getElement(java.lang.String pName)
getElement in interface NameContextpublic void putElement(java.lang.String pName,
java.lang.Object pElement)
putElement in interface NameContextpublic void removeElement(java.lang.String pName)
removeElement in interface NameContextpublic boolean isElementBound(java.lang.String pName)
isElementBound in interface NameContextpublic java.util.Enumeration listElementNames()
listElementNames in interface NameContextpublic java.util.Enumeration listElements()
listElements in interface NameContextpublic void addNameContextBindingListener(NameContextBindingListener pListener)
addNameContextBindingListener in interface NameContextBindingEventSourcepublic void removeNameContextBindingListener(NameContextBindingListener pListener)
removeNameContextBindingListener in interface NameContextBindingEventSourcepublic void nameContextElementBound(NameContextBindingEvent pEvent)
nameContextElementBound in interface NameContextBindingListenerpublic void nameContextElementUnbound(NameContextBindingEvent pEvent)
nameContextElementUnbound in interface NameContextBindingListenerpublic NameContext getNameContext()
getNameContext in interface NameContextElementpublic java.lang.String getName()
getName in interface NameContextElementprotected java.util.Dictionary createElementsDictionary()