Java Platform 1.2
Beta 4

Interface org.omg.CosNaming.BindingIterator

All Known Implementing Classes:
_BindingIteratorImplBase

public abstract interface BindingIterator
extends Object
Provides methods that allow a client to iterate through a list of bindings in a naming context.

A BindingIterator object is obtained by using the NamingContext method list. If there are more bindings in a naming context than are requested, the method list assigns a new BindingIterator object to the value field of the object supplied as a parameter. The new iterator is attached to the rest of the list in the naming context, and the BindingIterator interface provides the methods next_one and next_n to interate through the list.

The following usage example illustrates using the method list to get an iterator, printing out the first ten bindings in the naming context, and then using the iterator to go through the remainder of the bindings to print them out. In this code fragment, nc is an instance of org.omg.CosNaming.NamingContext. Also, this code fragment assumes that nc contains more than 10 bindings.

 BindingListHolder myBLH = new BindingListHolder();
 BindingIteratorHolder myBIH = new BindingIteratorHolder();
 BindingHolder myBindingHolder = new BindingHolder();
 int bindingsRequested = 10;
 // get an array of the first 10 bindings and an iterator for the
 // rest of the bindings in the list
 nc.list(bindingsRequested, myBLH, myBIH);
 Binding [] myBindingList = myBLH.value;
 BindingIterator myBindingIterator = myBIH.value:
 // print out the bindings in the array myBindingList
 for (int i= 0; i < bindingsRequested; i++) {
     System.out.print("Binding number " + (i + 1) + " is ");
     System.out.println(myBindingList[i]);
 }
 // print out the rest of the list using myBindingIterator
 boolean more = true;
 while (more) {
     boolean successful = myBindingIterator.next_one(myBindingHolder);
     if (! successful) {
         more = false;
     }
     else {
         System.out.print("Binding number " + (bindingsRequested++) + " is ");
         System.out.println(myBindingHolder.value);
    }
 } 
 myBIH.destroy(); // to avoid creating garbage for the name server
 

See Also:
NamingContext.list

Method Summary
 void destroy()
          Destroys this binding iterator.
 boolean next_n(int how_many, BindingListHolder bl)
          Assigns up to the requested number of name/object reference bindings to the value field of the given BindingListHolder object and returns a boolean to indicate success or failure.
 boolean next_one(BindingHolder b)
          Assigns the next name/object reference binding to the value field of the given BindingHolder object and returns a boolean to indicate success or failure.
 
Methods inherited from interface org.omg.CORBA.Object
_create_request , _create_request , _duplicate , _get_domain_managers , _get_implementation , _get_interface , _get_policy , _hash , _is_a , _is_equivalent , _non_existent , _release , _request , _set_policy_override
 

Method Detail

next_one

public boolean next_one(BindingHolder b)
Assigns the next name/object reference binding to the value field of the given BindingHolder object and returns a boolean to indicate success or failure.
Parameters:
b - the BindingHolder object to whose value field the next binding will be assigned
Returns:
true if there is a next binding; false otherwise

next_n

public boolean next_n(int how_many,
                      BindingListHolder bl)
Assigns up to the requested number of name/object reference bindings to the value field of the given BindingListHolder object and returns a boolean to indicate success or failure. This method returns at most the requested number of bindings. If the requested number is larger that the remaining number of bindings in the list, the remaining number of bindings are assigned.
Parameters:
how_many - the maximum number of bindings to assign to the value field of the given BindingListHolder object

bl - the BindingListHolder object to whose value field the bindings will be assigned

Returns:
true if there is one binding or more; false otherwise

destroy

public void destroy()
Destroys this binding iterator. It is important to destroy each binding iterator after it has been used to avoid creating garbage on the name server.

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.