Java Doc for NamingEnumeration.java in  » 6.0-JDK-Core » naming » javax » naming » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » naming » javax.naming 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.naming.NamingEnumeration

NamingEnumeration
public interface NamingEnumeration extends Enumeration<T>(Code)
This interface is for enumerating lists returned by methods in the javax.naming and javax.naming.directory packages. It extends Enumeration to allow as exceptions to be thrown during the enumeration.

When a method such as list(), listBindings(), or search() returns a NamingEnumeration, any exceptions encountered are reserved until all results have been returned. At the end of the enumeration, the exception is thrown (by hasMore());

For example, if the list() is returning only a partial answer, the corresponding exception would be PartialResultException. list() would first return a NamingEnumeration. When the last of the results has been returned by the NamingEnumeration's next(), invoking hasMore() would result in PartialResultException being thrown.

In another example, if a search() method was invoked with a specified size limit of 'n'. If the answer consists of more than 'n' results, search() would first return a NamingEnumeration. When the n'th result has been returned by invoking next() on the NamingEnumeration, a SizeLimitExceedException would then thrown when hasMore() is invoked.

Note that if the program uses hasMoreElements() and nextElement() instead to iterate through the NamingEnumeration, because these methods cannot throw exceptions, no exception will be thrown. Instead, in the previous example, after the n'th result has been returned by nextElement(), invoking hasMoreElements() would return false.

Note also that NoSuchElementException is thrown if the program invokes next() or nextElement() when there are no elements left in the enumeration. The program can always avoid this exception by using hasMore() and hasMoreElements() to check whether the end of the enumeration has been reached.

If an exception is thrown during an enumeration, the enumeration becomes invalid. Subsequent invocation of any method on that enumeration will yield undefined results.
author:
   Rosanna Lee
author:
   Scott Seligman
version:
   1.15 07/05/05
See Also:   Context.list
See Also:   Context.listBindings
See Also:   javax.naming.directory.DirContext.search
See Also:   javax.naming.directory.Attributes.getAll
See Also:   javax.naming.directory.Attributes.getIDs
See Also:   javax.naming.directory.Attribute.getAll
since:
   1.3





Method Summary
public  voidclose()
     Closes this enumeration. After this method has been invoked on this enumeration, the enumeration becomes invalid and subsequent invocation of any of its methods will yield undefined results. This method is intended for aborting an enumeration to free up resources. If an enumeration proceeds to the end--that is, until hasMoreElements() or hasMore() returns false-- resources will be freed up automatically and there is no need to explicitly call close().

This method indicates to the service provider that it is free to release resources associated with the enumeration, and can notify servers to cancel any outstanding requests.

public  booleanhasMore()
     Determines whether there are any more elements in the enumeration. This method allows naming exceptions encountered while determining whether there are more elements to be caught and handled by the application. true if there is more in the enumeration ; false otherwise.
exception:
  NamingException - If a naming exception is encountered while attemptingto determine whether there is another elementin the enumeration.
public  Tnext()
     Retrieves the next element in the enumeration. This method allows naming exceptions encountered while retrieving the next element to be caught and handled by the application.



Method Detail
close
public void close() throws NamingException(Code)
Closes this enumeration. After this method has been invoked on this enumeration, the enumeration becomes invalid and subsequent invocation of any of its methods will yield undefined results. This method is intended for aborting an enumeration to free up resources. If an enumeration proceeds to the end--that is, until hasMoreElements() or hasMore() returns false-- resources will be freed up automatically and there is no need to explicitly call close().

This method indicates to the service provider that it is free to release resources associated with the enumeration, and can notify servers to cancel any outstanding requests. The close() method is a hint to implementations for managing their resources. Implementations are encouraged to use appropriate algorithms to manage their resources when client omits the close() calls.
exception:
  NamingException - If a naming exception is encounteredwhile closing the enumeration.
since:
   1.3




hasMore
public boolean hasMore() throws NamingException(Code)
Determines whether there are any more elements in the enumeration. This method allows naming exceptions encountered while determining whether there are more elements to be caught and handled by the application. true if there is more in the enumeration ; false otherwise.
exception:
  NamingException - If a naming exception is encountered while attemptingto determine whether there is another elementin the enumeration. See NamingExceptionand its subclasses for the possible naming exceptions.
See Also:   java.util.Enumeration.hasMoreElements



next
public T next() throws NamingException(Code)
Retrieves the next element in the enumeration. This method allows naming exceptions encountered while retrieving the next element to be caught and handled by the application.

Note that next() can also throw the runtime exception NoSuchElementException to indicate that the caller is attempting to enumerate beyond the end of the enumeration. This is different from a NamingException, which indicates that there was a problem in obtaining the next element, for example, due to a referral or server unavailability, etc. The possibly null element in the enumeration.null is only valid for enumerations that can returnnull (e.g. Attribute.getAll() returns an enumeration ofattribute values, and an attribute value can be null).
exception:
  NamingException - If a naming exception is encountered while attemptingto retrieve the next element. See NamingExceptionand its subclasses for the possible naming exceptions.
exception:
  java.util.NoSuchElementException - If attempting to get the next element when none is available.
See Also:   java.util.Enumeration.nextElement




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.