xref: /unit/src/java/nginx/unit/HeaderNamesEnumeration.java (revision 977:4f9268f27b57)
1 package nginx.unit;
2 
3 import java.lang.String;
4 import java.util.Enumeration;
5 import java.util.NoSuchElementException;
6 
7 public class HeaderNamesEnumeration implements Enumeration<String> {
8 
9     private long headers_ptr;
10     private long size;
11     private long pos = 0;
12 
HeaderNamesEnumeration(long _headers_ptr, long _size)13     public HeaderNamesEnumeration(long _headers_ptr, long _size) {
14         headers_ptr = _headers_ptr;
15         size = _size;
16     }
17 
18     @Override
hasMoreElements()19     public boolean hasMoreElements()
20     {
21         if (pos >= size) {
22             return false;
23         }
24 
25         pos = nextElementPos(headers_ptr, size, pos);
26         return pos < size;
27     }
28 
nextElementPos(long headers_ptr, long size, long pos)29     static private native long nextElementPos(long headers_ptr, long size, long pos);
30 
31     @Override
nextElement()32     public String nextElement()
33     {
34         if (pos >= size) {
35             throw new NoSuchElementException();
36         }
37 
38         return nextElement(headers_ptr, size, pos++);
39     }
40 
nextElement(long headers_ptr, long size, long pos)41     static private native String nextElement(long headers_ptr, long size, long pos);
42 }
43