src/main/java/org/nustaq/serialization/minbin/MBOut.java
public void writeArray(Object primitiveArray, int start, int len) {
        byte type = MinBin.ARRAY_MASK;
        Class<?> componentType = primitiveArray.getClass().getComponentType();
        if (componentType == boolean.class)    type |= MinBin.INT_8;
        else if (componentType == byte.class)  type |= MinBin.INT_8;
        else if (componentType == short.class) type |= MinBin.INT_16;
        else if (componentType == char.class)  type |= MinBin.INT_16 | MinBin.UNSIGN_MASK;
        else if (componentType == int.class)   type |= MinBin.INT_32;
        else if (componentType == long.class)  type |= MinBin.INT_64;
        else throw new RuntimeException("unsupported type " + componentType.getName());
        writeOut(type);
        writeIntPacked(len);
        switch (type) {
            case MinBin.INT_8|MinBin.ARRAY_MASK: {
                if ( componentType == boolean.class ) {
                    boolean[] arr = (boolean[]) primitiveArray;
                    for (int i = start; i < start + len; i++) {
                        writeRawInt(type, arr[i] ? 1 : 0);
                    }
                } else {
                    byte[] arr = (byte[]) primitiveArray;
                    for (int i = start; i < start + len; i++) {
                        writeRawInt(type, arr[i]);
                    }
                }
            }
            break;
            case MinBin.CHAR|MinBin.ARRAY_MASK: {
                char[] charArr = (char[]) primitiveArray;
                for (int i = start; i < start + len; i++) {
                    writeRawInt(type, charArr[i]);
                }
            }
            break;
            case MinBin.INT_32|MinBin.ARRAY_MASK: {
                int[] arr = (int[]) primitiveArray;
                for (int i = start; i < start + len; i++) {
                    writeRawInt(type, arr[i]);
                }
            }
            break;
            case MinBin.INT_64|MinBin.ARRAY_MASK: {
                long[] arr = (long[]) primitiveArray;
                for (int i = start; i < start + len; i++) {
                    writeRawInt(type, arr[i]);
                }
            }
            break;
            default: {
                for (int i = start; i < start + len; i++) {
                    if (componentType == boolean.class)
                        writeRawInt(type, Array.getBoolean(primitiveArray, i) ? 1 : 0);
                    else
                        writeRawInt(type, Array.getLong(primitiveArray, i));
                }
            }
        }
    }
public void writeArray(Object primitiveArray, int start, int len) {
        byte type = MinBin.ARRAY_MASK;
        Class<?> componentType = primitiveArray.getClass().getComponentType();
        if (componentType == boolean.class)    type |= MinBin.INT_8;
        else if (componentType == byte.class)  type |= MinBin.INT_8;
        else if (componentType == short.class) type |= MinBin.INT_16;
        else if (componentType == char.class)  type |= MinBin.INT_16 | MinBin.UNSIGN_MASK;
        else if (componentType == int.class)   type |= MinBin.INT_32;
        else if (componentType == long.class)  type |= MinBin.INT_64;
        else throw new RuntimeException("unsupported type " + componentType.getName());
        writeOut(type);
        writeIntPacked(len);
        switch (type) {
            case MinBin.INT_8|MinBin.ARRAY_MASK: {
                if ( componentType == boolean.class ) {
                    boolean[] arr = (boolean[]) primitiveArray;
                    for (int i = start; i < start + len; i++) {
                        writeRawInt(type, arr[i] ? 1 : 0);
                    }
                } else {
                    byte[] arr = (byte[]) primitiveArray;
                    for (int i = start; i < start + len; i++) {
                        writeRawInt(type, arr[i]);
                    }
                }
            }
            break;
            case MinBin.CHAR|MinBin.ARRAY_MASK: {
                char[] charArr = (char[]) primitiveArray;
                for (int i = start; i < start + len; i++) {
                    writeRawInt(type, charArr[i]);
                }
            }
            break;
            case MinBin.INT_32|MinBin.ARRAY_MASK: {
                int[] arr = (int[]) primitiveArray;
                for (int i = start; i < start + len; i++) {
                    writeRawInt(type, arr[i]);
                }
            }
            break;
            case MinBin.INT_64|MinBin.ARRAY_MASK: {
                long[] arr = (long[]) primitiveArray;
                for (int i = start; i < start + len; i++) {
                    writeRawInt(type, arr[i]);
                }
            }
            break;
            default: {
                for (int i = start; i < start + len; i++) {
                    if (componentType == boolean.class)
                        writeRawInt(type, Array.getBoolean(primitiveArray, i) ? 1 : 0);
                    else
                        writeRawInt(type, Array.getLong(primitiveArray, i));
                }
            }
        }
    }
public void writeArray ( Object primitiveArray , int start , int len ) { byte type = MinBin . ARRAY_MASK ; Class < ? > componentType = primitiveArray . getClass ( ) . getComponentType ( ) ; if ( componentType == boolean . class ) type |= MinBin . INT_8 ; else if ( componentType == byte . class ) type |= MinBin . INT_8 ; else if ( componentType == short . class ) type |= MinBin . INT_16 ; else if ( componentType == char . class ) type |= MinBin . INT_16 | MinBin . UNSIGN_MASK ; else if ( componentType == int . class ) type |= MinBin . INT_32 ; else if ( componentType == long . class ) type |= MinBin . INT_64 ; else throw new RuntimeException ( "unsupported type " + componentType . getName ( ) ) ; writeOut ( type ) ; writeIntPacked ( len ) ; switch ( type ) { case MinBin . INT_8 | MinBin . ARRAY_MASK : { if ( componentType == boolean . class ) { boolean [ ] arr = ( boolean [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ? 1 : 0 ) ; } } else { byte [ ] arr = ( byte [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ) ; } } } break ; case MinBin . CHAR | MinBin . ARRAY_MASK : { char [ ] charArr = ( char [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , charArr [ i ] ) ; } } break ; case MinBin . INT_32 | MinBin . ARRAY_MASK : { int [ ] arr = ( int [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ) ; } } break ; case MinBin . INT_64 | MinBin . ARRAY_MASK : { long [ ] arr = ( long [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ) ; } } break ; default : { for ( int i = start ; i < start + len ; i ++ ) { if ( componentType == boolean . class ) writeRawInt ( type , Array . getBoolean ( primitiveArray , i ) ? 1 : 0 ) ; else writeRawInt ( type , Array . getLong ( primitiveArray , i ) ) ; } } } }
write primitive array + header. no floating point or object array allowed. Just int based types
@param primitiveArray
@param start
@param len
write primitive array + header . no floating point or object array allowed . Just int based types