diff --git a/build.gradle b/build.gradle
index a1030983..0ee7fd48 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,7 +2,7 @@ import java.util.zip.ZipFile
apply plugin: 'java'
apply plugin: 'maven'
-version="1.42"
+version="1.5"
jar.baseName='fst'
diff --git a/pom.xml b/pom.xml
index 1028584f..bb45bfaa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
4.0.0
de.ruedigermoeller
fst
- 1.42
+ 1.5
a fast java serialization drop in-replacement + some serialization based utils (Structs, OffHeap Memory)
https://code.google.com/p/fast-serialization/
diff --git a/src/main/java/de/ruedigermoeller/serialization/FSTObjectInput.java b/src/main/java/de/ruedigermoeller/serialization/FSTObjectInput.java
index 1e8adfaa..f98674ba 100644
--- a/src/main/java/de/ruedigermoeller/serialization/FSTObjectInput.java
+++ b/src/main/java/de/ruedigermoeller/serialization/FSTObjectInput.java
@@ -670,6 +670,73 @@ public String readStringAsc() throws IOException {
return new String(ascStringCache,0,0,len);
}
+ /**
+ * utility for fast-cast
+ * @param componentType
+ * @param len
+ * @return
+ */
+ public Object readFPrimitiveArray( Class componentType, int len ) {
+ try {
+ Object array = Array.newInstance(componentType, len);
+ if (componentType == byte.class) {
+ byte[] arr = (byte[]) array;
+ ensureReadAhead(arr.length); // fixme: move this stuff to the stream !
+ read(arr);
+ return arr;
+ } else if (componentType == char.class) {
+ char[] arr = (char[]) array;
+ for (int j = 0; j < len; j++) {
+ arr[j] = readCChar();
+ }
+ return arr;
+ } else if (componentType == short.class) {
+ short[] arr = (short[]) array;
+ ensureReadAhead(arr.length*2);
+ for (int j = 0; j < len; j++) {
+ arr[j] = readFShort();
+ }
+ return arr;
+ } else if (componentType == int.class) {
+ final int[] arr = (int[]) array;
+ readFIntArr(len, arr);
+ return arr;
+ } else if (componentType == float.class) {
+ float[] arr = (float[]) array;
+ ensureReadAhead(arr.length*4);
+ for (int j = 0; j < len; j++) {
+ arr[j] = readFFloat();
+ }
+ return arr;
+ } else if (componentType == double.class) {
+ double[] arr = (double[]) array;
+ ensureReadAhead(arr.length*8);
+ for (int j = 0; j < len; j++) {
+ arr[j] = readFDouble();
+ }
+ return arr;
+ } else if (componentType == long.class) {
+ long[] arr = (long[]) array;
+ ensureReadAhead(arr.length*8);
+ for (int j = 0; j < len; j++) {
+ arr[j] = readFLong();
+ }
+ return arr;
+ } else if (componentType == boolean.class) {
+ boolean[] arr = (boolean[]) array;
+ ensureReadAhead(arr.length);
+ for (int j = 0; j < len; j++) {
+ arr[j] = readBoolean();
+ }
+ return arr;
+ } else {
+ throw new RuntimeException("unexpected primitive type " + componentType);
+ }
+ } catch (IOException e) {
+ throw FSTUtil.rethrow(e); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
protected Object readArray(FSTClazzInfo.FSTFieldInfo referencee) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
Class arrCl = readClass().getClazz();
final int len = readCInt();
diff --git a/src/main/java/de/ruedigermoeller/serialization/FSTObjectOutput.java b/src/main/java/de/ruedigermoeller/serialization/FSTObjectOutput.java
index ab2d24f5..fbe61460 100644
--- a/src/main/java/de/ruedigermoeller/serialization/FSTObjectOutput.java
+++ b/src/main/java/de/ruedigermoeller/serialization/FSTObjectOutput.java
@@ -727,6 +727,10 @@ public void writeCCharArr(char[] arr) throws IOException {
writeCChar(arr[i]);
}
+ public void writeFByteArr(byte[] array) throws IOException {
+ writeFByteArr(array,0,array.length);
+ }
+
/**
* does not write length, just plain bytes
* @param array