diff options
author | Andrei Belov <defan@nginx.com> | 2019-03-01 18:30:09 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2019-03-01 18:30:09 +0300 |
commit | 3c3720cba7154bc168cbd00c74817626bb53e140 (patch) | |
tree | da1500f7c6bd5e90ecf45299b6f4b19a29d521cd /src/java/nginx/unit/HeaderNamesEnumeration.java | |
parent | 315a864c27aa27a48c013c4a1ef67a099ffea894 (diff) | |
parent | df02b03824065389c73213b19736140442cf63bc (diff) | |
download | unit-3c3720cba7154bc168cbd00c74817626bb53e140.tar.gz unit-3c3720cba7154bc168cbd00c74817626bb53e140.tar.bz2 |
Merged with the default branch.
Diffstat (limited to 'src/java/nginx/unit/HeaderNamesEnumeration.java')
-rw-r--r-- | src/java/nginx/unit/HeaderNamesEnumeration.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/java/nginx/unit/HeaderNamesEnumeration.java b/src/java/nginx/unit/HeaderNamesEnumeration.java new file mode 100644 index 00000000..d81b8778 --- /dev/null +++ b/src/java/nginx/unit/HeaderNamesEnumeration.java @@ -0,0 +1,42 @@ +package nginx.unit; + +import java.lang.String; +import java.util.Enumeration; +import java.util.NoSuchElementException; + +public class HeaderNamesEnumeration implements Enumeration<String> { + + private long headers_ptr; + private long size; + private long pos = 0; + + public HeaderNamesEnumeration(long _headers_ptr, long _size) { + headers_ptr = _headers_ptr; + size = _size; + } + + @Override + public boolean hasMoreElements() + { + if (pos >= size) { + return false; + } + + pos = nextElementPos(headers_ptr, size, pos); + return pos < size; + } + + static private native long nextElementPos(long headers_ptr, long size, long pos); + + @Override + public String nextElement() + { + if (pos >= size) { + throw new NoSuchElementException(); + } + + return nextElement(headers_ptr, size, pos++); + } + + static private native String nextElement(long headers_ptr, long size, long pos); +} |