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