FileDocCategorySizeDatePackage
PersistentBindingIterator.javaAPI DocJava SE 5 API4700Fri Aug 26 14:54:26 BST 2005com.sun.corba.se.impl.naming.pcosnaming

PersistentBindingIterator

public class PersistentBindingIterator extends com.sun.corba.se.impl.naming.cosnaming.BindingIteratorImpl
Class TransientBindingIterator implements the abstract methods defined by BindingIteratorImpl, to use with the TransientNamingContext implementation of the NamingContextImpl. The TransientBindingIterator implementation receives a hash table of InternalBindingValues, and uses an Enumeration to iterate over the contents of the hash table.
see
BindingIteratorImpl
see
TransientNamingContext

Fields Summary
private org.omg.PortableServer.POA
biPOA
private int
currentSize
private Hashtable
theHashtable
private Enumeration
theEnumeration
private org.omg.CORBA.ORB
orb
Constructors Summary
public PersistentBindingIterator(org.omg.CORBA.ORB orb, Hashtable aTable, org.omg.PortableServer.POA thePOA)
Constructs a new PersistentBindingIterator object.

param
orb a org.omg.CORBA.ORB object.
param
aTable A hashtable containing InternalBindingValues which is the content of the PersistentNamingContext.
param
java.lang.Exception a Java exception.
exception
Exception a Java exception thrown of the base class cannot initialize.

	super(orb);
	this.orb = orb;
	theHashtable = aTable;
	theEnumeration = this.theHashtable.keys();
	currentSize = this.theHashtable.size();
        biPOA = thePOA;
    
Methods Summary
public final voidDestroy()
Destroys this BindingIterator by disconnecting from the ORB

exception
org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.

        // Remove the object from the Active Object Map.
        try {
            byte[] objectId = biPOA.servant_to_id( this );
            if( objectId != null ) {
                biPOA.deactivate_object( objectId );
            }
        }
        catch( Exception e ) {
            throw new INTERNAL( "Exception in BindingIterator.Destroy " + e );
        }
    
public final booleanNextOne(org.omg.CosNaming.BindingHolder b)
Returns the next binding in the NamingContext. Uses the enumeration object to determine if there are more bindings and if so, returns the next binding from the InternalBindingValue.

param
b The Binding as an out parameter.
return
true if there were more bindings.

	// If there are more elements get the next element
	boolean hasMore = theEnumeration.hasMoreElements();
	if (hasMore) {
            InternalBindingKey theBindingKey =
		 ((InternalBindingKey)theEnumeration.nextElement());
            InternalBindingValue theElement =
		(InternalBindingValue)theHashtable.get( theBindingKey );
	    NameComponent n = new NameComponent( theBindingKey.id, theBindingKey.kind ); 
	    NameComponent[] nlist = new NameComponent[1];
	    nlist[0] = n;
            BindingType theType = theElement.theBindingType;
	    
	    b.value =
	        new Binding( nlist, theType );	
	} else {
	    // Return empty but marshalable binding
	    b.value = new Binding(new NameComponent[0],BindingType.nobject);
	}
	return hasMore;
    
public final intRemainingElements()
Returns the remaining number of elements in the iterator.

return
the remaining number of elements in the iterator.

	return currentSize;