com.ca.commons.naming
Class DXNamingEnumeration

java.lang.Object
  |
  +--com.ca.commons.naming.DXNamingEnumeration
All Implemented Interfaces:
java.util.Enumeration, javax.naming.NamingEnumeration

public class DXNamingEnumeration
extends java.lang.Object
implements javax.naming.NamingEnumeration

A simple class that implements NamingEnumeration, used to bundle up search results 'n stuff. Used by not-really-jndi ftns to wrap things nicely for higher level ftns that are expecting NamingEnumerations. as usual, the enumeration can be enumerated using the model:

     while (myEnumeration.hasMoreElements())
          doSomethingWith(myEnumeration.nextElement();
    
in addition, it supports the NamingEnumeration interface equivalent, which (in the future) may also throw a NamingException.
     try
     {
         while (myEnumeration.hasMore())
             doSomethingWith(myEnumeration.next();
     }
     catch (NamingException e) { }
    
As a spot of convenience evil, it implements a sort() ftn as well... (Since it's not a 'dynamic' enumeration as a normal naming enumeration would be, but uses a vector base object), and also allows the enumeration to be dumped out as a vector or a string array :-) .


Constructor Summary
DXNamingEnumeration()
          The constructor does nothing except initialise class variables.
DXNamingEnumeration(java.util.Enumeration ne)
          A quicky to wrap normal enumerations with as well...
DXNamingEnumeration(javax.naming.NamingEnumeration ne)
          The constructor takes another NamingEnumeration and uses it to initialise with.
 
Method Summary
 void add(java.lang.Object o)
          Adds an object to the enumeration.
 void close()
          Included for Naming Enumeration compatibility... does nothing, 'cause DXNamingEnumeration isn't really an enumeration, and has already slurped all the data... :-)
 boolean contains(java.lang.Object test)
          A simple existance test against the core vector list of objects.
 java.util.Vector getVector()
           
 boolean hasMore()
           
 boolean hasMoreElements()
           
 java.lang.Object next()
           
 java.lang.Object nextElement()
           
 void remove(java.lang.Object o)
          Removes an object from the enumeration.
 void reset()
          Enumerations can't usually be re-used.
 int size()
          Not really necessary, this returns the number of elements in the enumeration.
 DXNamingEnumeration sort()
          This method attempts to order the components of the SimpleEnumeration using their intrinsic 'toString()' methods (this may be meaningless for some components).
 java.lang.Object[] toArray()
           
 java.lang.String toString()
           
 java.lang.String[] toStringArray()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DXNamingEnumeration

public DXNamingEnumeration()
The constructor does nothing except initialise class variables.


DXNamingEnumeration

public DXNamingEnumeration(java.util.Enumeration ne)
A quicky to wrap normal enumerations with as well...


DXNamingEnumeration

public DXNamingEnumeration(javax.naming.NamingEnumeration ne)
The constructor takes another NamingEnumeration and uses it to initialise with.

Method Detail

add

public void add(java.lang.Object o)
Adds an object to the enumeration.


remove

public void remove(java.lang.Object o)
Removes an object from the enumeration.


reset

public void reset()
Enumerations can't usually be re-used. Sometimes it would be nice though... this resets the enumeration so you can reread it, which is useful for debugging (i.e. you can print it before use...)


size

public int size()
Not really necessary, this returns the number of elements in the enumeration.

Returns:
number of objects in enumeration

hasMore

public boolean hasMore()
Specified by:
hasMore in interface javax.naming.NamingEnumeration

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Specified by:
next in interface javax.naming.NamingEnumeration
java.util.NoSuchElementException

nextElement

public java.lang.Object nextElement()
                             throws java.util.NoSuchElementException
Specified by:
nextElement in interface java.util.Enumeration
java.util.NoSuchElementException

sort

public DXNamingEnumeration sort()
This method attempts to order the components of the SimpleEnumeration using their intrinsic 'toString()' methods (this may be meaningless for some components).


contains

public boolean contains(java.lang.Object test)
A simple existance test against the core vector list of objects.


close

public void close()
Included for Naming Enumeration compatibility... does nothing, 'cause DXNamingEnumeration isn't really an enumeration, and has already slurped all the data... :-)

Specified by:
close in interface javax.naming.NamingEnumeration

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toArray

public java.lang.Object[] toArray()

toStringArray

public java.lang.String[] toStringArray()

getVector

public java.util.Vector getVector()