Merge pull request #24 from thomaskrause/feature/fix-java8

Fix issue with payloads when using Krill on Java 8
diff --git a/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java b/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
index e4eb624..5303876 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
@@ -390,7 +390,7 @@
                 bb.rewind();
 
                 // Split payload at type marker boundaries
-                String[] pls = payloadStr.split("(?=<)|(?<=>)");
+                String[] pls = payloadStr.split("((?=<)|(?<=>))(?!\\A)");
 
                 l = 0; // Bytearray length
 
@@ -404,21 +404,21 @@
                             bb.position(l);
                         };
 
-                        switch (pls[i]) {
+                        switch (pls[i-1]) {
                             case "<b>": // byte
-                                bb.put(Byte.parseByte(pls[i + 1]));
+                                bb.put(Byte.parseByte(pls[i]));
                                 l++;
                                 break;
                             case "<s>": // short
-                                bb.putShort(Short.parseShort(pls[i + 1]));
+                                bb.putShort(Short.parseShort(pls[i]));
                                 l += 2;
                                 break;
                             case "<i>": // integer
-                                bb.putInt(Integer.parseInt(pls[i + 1]));
+                                bb.putInt(Integer.parseInt(pls[i]));
                                 l += 4;
                                 break;
                             case "<l>": // long
-                                bb.putLong(Long.parseLong(pls[i + 1]));
+                                bb.putLong(Long.parseLong(pls[i]));
                                 l += 8;
                                 break;
                         };