FileDocCategorySizeDatePackage
MultiMapNamesEnumeration.javaAPI DocGlassfish v2 API3547Fri May 04 22:33:14 BST 2007org.apache.tomcat.util.collections

MultiMapNamesEnumeration

public final class MultiMapNamesEnumeration extends Object implements Enumeration
Enumerate the distinct header names. Each nextElement() is O(n) ( a comparation is done with all previous elements ). This is less frequesnt than add() - we want to keep add O(1).

Fields Summary
int
pos
int
size
String
next
MultiMap
headers
Constructors Summary
MultiMapNamesEnumeration(MultiMap headers, boolean toString, boolean unique)
Create a new multi-map enumeration.

param
headers the collection to enumerate
param
toString convert each name to string
param
unique return only unique names

	this.headers=headers;
	pos=0;
	size = headers.size();
	findNext();
    
Methods Summary
private voidfindNext()

	next=null;
	for(  ; pos< size; pos++ ) {
	    next=headers.getName( pos ).toString();
	    for( int j=0; j<pos ; j++ ) {
		if( headers.getName( j ).equalsIgnoreCase( next )) {
		    // duplicate.
		    next=null;
		    break;
		}
	    }
	    if( next!=null ) {
		// it's not a duplicate
		break;
	    }
	}
	// next time findNext is called it will try the
	// next element
	pos++;
    
public booleanhasMoreElements()

	return next!=null;
    
public java.lang.ObjectnextElement()

	String current=next;
	findNext();
	return current;