aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-savable/src/main
diff options
context:
space:
mode:
authorneothemachine <[email protected]>2012-12-05 17:03:16 +0100
committerneothemachine <[email protected]>2012-12-05 17:03:16 +0100
commit9dd02f103042cb8a196f8a3ed2278da443e345bf (patch)
tree422449f0c62ff9518316ce5d4219bb2b12f0ed15 /ardor3d-savable/src/main
parent2b26b12fd794de0f03a064a10024a3d9f5583756 (diff)
move all files from trunk to root folder
Diffstat (limited to 'ardor3d-savable/src/main')
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dExporter.java36
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dImporter.java55
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/ByteUtils.java419
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/CapsuleUtils.java54
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/InputCapsule.java144
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/OutputCapsule.java145
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/ReadListener.java17
-rw-r--r--ardor3d-savable/src/main/java/com/ardor3d/util/export/Savable.java21
8 files changed, 891 insertions, 0 deletions
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dExporter.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dExporter.java
new file mode 100644
index 0000000..495bf6f
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dExporter.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface Ardor3dExporter {
+
+ /**
+ * Save a Savable object to the given stream.
+ *
+ * @param savable
+ * @param os
+ * @throws IOException
+ */
+ void save(Savable savable, OutputStream os) throws IOException;
+
+ /**
+ * Save a Savable object to the given file.
+ *
+ * @param savable
+ * @param file
+ * @throws IOException
+ */
+ void save(Savable savable, File file) throws IOException;
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dImporter.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dImporter.java
new file mode 100644
index 0000000..12a4277
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/Ardor3dImporter.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+public interface Ardor3dImporter {
+
+ /**
+ * Load a Savable object from the given stream.
+ *
+ * @param is
+ * @return the savable object.
+ * @throws IOException
+ */
+ Savable load(InputStream is) throws IOException;
+
+ /**
+ * Load a Savable object from the given URL.
+ *
+ * @param url
+ * @return the savable object.
+ * @throws IOException
+ */
+ Savable load(URL url) throws IOException;
+
+ /**
+ * Load a Savable object from the given file.
+ *
+ * @param file
+ * @return the savable object.
+ * @throws IOException
+ */
+ Savable load(File file) throws IOException;
+
+ /**
+ * Load a Savable object from the given byte array, starting at the first index.
+ *
+ * @param data
+ * @return the savable object.
+ * @throws IOException
+ */
+ Savable load(byte[] data) throws IOException;
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/ByteUtils.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/ByteUtils.java
new file mode 100644
index 0000000..1c32f12
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/ByteUtils.java
@@ -0,0 +1,419 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * <code>ByteUtils</code> is a helper class for converting numeric primitives to and from byte representations.
+ */
+public abstract class ByteUtils {
+
+ /**
+ * Takes an InputStream and returns the complete byte content of it
+ *
+ * @param inputStream
+ * The input stream to read from
+ * @return The byte array containing the data from the input stream
+ * @throws java.io.IOException
+ * thrown if there is a problem reading from the input stream provided
+ */
+ public static byte[] getByteContent(final InputStream inputStream) throws IOException {
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(16 * 1024);
+ final byte[] buffer = new byte[1024];
+ int byteCount = -1;
+ byte[] data = null;
+
+ // Read the byte content into the output stream first
+ while ((byteCount = inputStream.read(buffer)) > 0) {
+ outputStream.write(buffer, 0, byteCount);
+ }
+
+ // Set data with byte content from stream
+ data = outputStream.toByteArray();
+
+ // Release resources
+ outputStream.close();
+
+ return data;
+ }
+
+ // ********** byte <> short METHODS **********
+
+ /**
+ * Writes a short out to an OutputStream.
+ *
+ * @param outputStream
+ * The OutputStream the short will be written to
+ * @param value
+ * The short to write
+ * @throws IOException
+ * Thrown if there is a problem writing to the OutputStream
+ */
+ public static void writeShort(final OutputStream outputStream, final short value) throws IOException {
+ final byte[] byteArray = convertToBytes(value);
+
+ outputStream.write(byteArray);
+
+ return;
+ }
+
+ public static byte[] convertToBytes(final short value) {
+ final byte[] byteArray = new byte[2];
+
+ byteArray[0] = (byte) (value >> 8);
+ byteArray[1] = (byte) value;
+ return byteArray;
+ }
+
+ /**
+ * Read in a short from an InputStream
+ *
+ * @param inputStream
+ * The InputStream used to read the short
+ * @return A short, which is the next 2 bytes converted from the InputStream
+ * @throws IOException
+ * Thrown if there is a problem reading from the InputStream
+ */
+ public static short readShort(final InputStream inputStream) throws IOException {
+ final byte[] byteArray = new byte[2];
+
+ // Read in the next 2 bytes
+ inputStream.read(byteArray);
+
+ final short number = convertShortFromBytes(byteArray);
+
+ return number;
+ }
+
+ public static short convertShortFromBytes(final byte[] byteArray) {
+ return convertShortFromBytes(byteArray, 0);
+ }
+
+ public static short convertShortFromBytes(final byte[] byteArray, final int offset) {
+ // Convert it to a short
+ final short number = (short) ((byteArray[offset + 1] & 0xFF) + ((byteArray[offset + 0] & 0xFF) << 8));
+ return number;
+ }
+
+ // ********** byte <> int METHODS **********
+
+ /**
+ * Writes an integer out to an OutputStream.
+ *
+ * @param outputStream
+ * The OutputStream the integer will be written to
+ * @param integer
+ * The integer to write
+ * @throws IOException
+ * Thrown if there is a problem writing to the OutputStream
+ */
+ public static void writeInt(final OutputStream outputStream, final int integer) throws IOException {
+ final byte[] byteArray = convertToBytes(integer);
+
+ outputStream.write(byteArray);
+
+ return;
+ }
+
+ public static byte[] convertToBytes(final int integer) {
+ final byte[] byteArray = new byte[4];
+
+ byteArray[0] = (byte) (integer >> 24);
+ byteArray[1] = (byte) (integer >> 16);
+ byteArray[2] = (byte) (integer >> 8);
+ byteArray[3] = (byte) integer;
+ return byteArray;
+ }
+
+ /**
+ * Read in an integer from an InputStream
+ *
+ * @param inputStream
+ * The InputStream used to read the integer
+ * @return An int, which is the next 4 bytes converted from the InputStream
+ * @throws IOException
+ * Thrown if there is a problem reading from the InputStream
+ */
+ public static int readInt(final InputStream inputStream) throws IOException {
+ final byte[] byteArray = new byte[4];
+
+ // Read in the next 4 bytes
+ inputStream.read(byteArray);
+
+ final int number = convertIntFromBytes(byteArray);
+
+ return number;
+ }
+
+ public static int convertIntFromBytes(final byte[] byteArray) {
+ return convertIntFromBytes(byteArray, 0);
+ }
+
+ public static int convertIntFromBytes(final byte[] byteArray, final int offset) {
+ // Convert it to an int
+ final int number = ((byteArray[offset] & 0xFF) << 24) + ((byteArray[offset + 1] & 0xFF) << 16)
+ + ((byteArray[offset + 2] & 0xFF) << 8) + (byteArray[offset + 3] & 0xFF);
+ return number;
+ }
+
+ // ********** byte <> long METHODS **********
+
+ /**
+ * Writes a long out to an OutputStream.
+ *
+ * @param outputStream
+ * The OutputStream the long will be written to
+ * @param value
+ * The long to write
+ * @throws IOException
+ * Thrown if there is a problem writing to the OutputStream
+ */
+ public static void writeLong(final OutputStream outputStream, final long value) throws IOException {
+ final byte[] byteArray = convertToBytes(value);
+
+ outputStream.write(byteArray);
+
+ return;
+ }
+
+ public static byte[] convertToBytes(long n) {
+ final byte[] bytes = new byte[8];
+
+ bytes[7] = (byte) (n);
+ n >>>= 8;
+ bytes[6] = (byte) (n);
+ n >>>= 8;
+ bytes[5] = (byte) (n);
+ n >>>= 8;
+ bytes[4] = (byte) (n);
+ n >>>= 8;
+ bytes[3] = (byte) (n);
+ n >>>= 8;
+ bytes[2] = (byte) (n);
+ n >>>= 8;
+ bytes[1] = (byte) (n);
+ n >>>= 8;
+ bytes[0] = (byte) (n);
+
+ return bytes;
+ }
+
+ /**
+ * Read in a long from an InputStream
+ *
+ * @param inputStream
+ * The InputStream used to read the long
+ * @return A long, which is the next 8 bytes converted from the InputStream
+ * @throws IOException
+ * Thrown if there is a problem reading from the InputStream
+ */
+ public static long readLong(final InputStream inputStream) throws IOException {
+ final byte[] byteArray = new byte[8];
+
+ // Read in the next 8 bytes
+ inputStream.read(byteArray);
+
+ final long number = convertLongFromBytes(byteArray);
+
+ return number;
+ }
+
+ public static long convertLongFromBytes(final byte[] bytes) {
+ return convertLongFromBytes(bytes, 0);
+ }
+
+ public static long convertLongFromBytes(final byte[] bytes, final int offset) {
+ // Convert it to an long
+ return ((((long) bytes[offset + 7]) & 0xFF) + ((((long) bytes[offset + 6]) & 0xFF) << 8)
+ + ((((long) bytes[offset + 5]) & 0xFF) << 16) + ((((long) bytes[offset + 4]) & 0xFF) << 24)
+ + ((((long) bytes[offset + 3]) & 0xFF) << 32) + ((((long) bytes[offset + 2]) & 0xFF) << 40)
+ + ((((long) bytes[offset + 1]) & 0xFF) << 48) + ((((long) bytes[offset + 0]) & 0xFF) << 56));
+ }
+
+ // ********** byte <> double METHODS **********
+
+ /**
+ * Writes a double out to an OutputStream.
+ *
+ * @param outputStream
+ * The OutputStream the double will be written to
+ * @param value
+ * The double to write
+ * @throws IOException
+ * Thrown if there is a problem writing to the OutputStream
+ */
+ public static void writeDouble(final OutputStream outputStream, final double value) throws IOException {
+ final byte[] byteArray = convertToBytes(value);
+
+ outputStream.write(byteArray);
+
+ return;
+ }
+
+ public static byte[] convertToBytes(final double n) {
+ final long bits = Double.doubleToLongBits(n);
+ return convertToBytes(bits);
+ }
+
+ /**
+ * Read in a double from an InputStream
+ *
+ * @param inputStream
+ * The InputStream used to read the double
+ * @return A double, which is the next 8 bytes converted from the InputStream
+ * @throws IOException
+ * Thrown if there is a problem reading from the InputStream
+ */
+ public static double readDouble(final InputStream inputStream) throws IOException {
+ final byte[] byteArray = new byte[8];
+
+ // Read in the next 8 bytes
+ inputStream.read(byteArray);
+
+ final double number = convertDoubleFromBytes(byteArray);
+
+ return number;
+ }
+
+ public static double convertDoubleFromBytes(final byte[] bytes) {
+ return convertDoubleFromBytes(bytes, 0);
+ }
+
+ public static double convertDoubleFromBytes(final byte[] bytes, final int offset) {
+ // Convert it to a double
+ final long bits = convertLongFromBytes(bytes, offset);
+ return Double.longBitsToDouble(bits);
+ }
+
+ // ********** byte <> float METHODS **********
+
+ /**
+ * Writes an float out to an OutputStream.
+ *
+ * @param outputStream
+ * The OutputStream the float will be written to
+ * @param fVal
+ * The float to write
+ * @throws IOException
+ * Thrown if there is a problem writing to the OutputStream
+ */
+ public static void writeFloat(final OutputStream outputStream, final float fVal) throws IOException {
+ final byte[] byteArray = convertToBytes(fVal);
+
+ outputStream.write(byteArray);
+
+ return;
+ }
+
+ public static byte[] convertToBytes(final float f) {
+ final int temp = Float.floatToIntBits(f);
+ return convertToBytes(temp);
+ }
+
+ /**
+ * Read in a float from an InputStream
+ *
+ * @param inputStream
+ * The InputStream used to read the float
+ * @return A float, which is the next 4 bytes converted from the InputStream
+ * @throws IOException
+ * Thrown if there is a problem reading from the InputStream
+ */
+ public static float readFloat(final InputStream inputStream) throws IOException {
+ final byte[] byteArray = new byte[4];
+
+ // Read in the next 4 bytes
+ inputStream.read(byteArray);
+
+ final float number = convertFloatFromBytes(byteArray);
+
+ return number;
+ }
+
+ public static float convertFloatFromBytes(final byte[] byteArray) {
+ return convertFloatFromBytes(byteArray, 0);
+ }
+
+ public static float convertFloatFromBytes(final byte[] byteArray, final int offset) {
+ // Convert it to an int
+ final int number = convertIntFromBytes(byteArray, offset);
+ return Float.intBitsToFloat(number);
+ }
+
+ // ********** byte <> boolean METHODS **********
+
+ /**
+ * Writes a boolean out to an OutputStream.
+ *
+ * @param outputStream
+ * The OutputStream the boolean will be written to
+ * @param bVal
+ * The boolean to write
+ * @throws IOException
+ * Thrown if there is a problem writing to the OutputStream
+ */
+ public static void writeBoolean(final OutputStream outputStream, final boolean bVal) throws IOException {
+ final byte[] byteArray = convertToBytes(bVal);
+
+ outputStream.write(byteArray);
+
+ return;
+ }
+
+ public static byte[] convertToBytes(final boolean b) {
+ final byte[] rVal = new byte[1];
+ rVal[0] = b ? (byte) 1 : (byte) 0;
+ return rVal;
+ }
+
+ /**
+ * Read in a boolean from an InputStream
+ *
+ * @param inputStream
+ * The InputStream used to read the boolean
+ * @return A boolean, which is the next byte converted from the InputStream (iow, byte != 0)
+ * @throws IOException
+ * Thrown if there is a problem reading from the InputStream
+ */
+ public static boolean readBoolean(final InputStream inputStream) throws IOException {
+ final byte[] byteArray = new byte[1];
+
+ // Read in the next byte
+ inputStream.read(byteArray);
+
+ return convertBooleanFromBytes(byteArray);
+ }
+
+ public static boolean convertBooleanFromBytes(final byte[] byteArray) {
+ return convertBooleanFromBytes(byteArray, 0);
+ }
+
+ public static boolean convertBooleanFromBytes(final byte[] byteArray, final int offset) {
+ return byteArray[offset] != 0;
+ }
+
+ public static byte[] rightAlignBytes(final byte[] bytes, final int width) {
+ if (bytes.length != width) {
+ final byte[] rVal = new byte[width];
+ for (int x = width - bytes.length; x < width; x++) {
+ rVal[x] = bytes[x - (width - bytes.length)];
+ }
+ return rVal;
+ }
+
+ return bytes;
+ }
+
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/CapsuleUtils.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/CapsuleUtils.java
new file mode 100644
index 0000000..1d3cc35
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/CapsuleUtils.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.lang.reflect.Array;
+
+public final class CapsuleUtils {
+
+ private CapsuleUtils() {}
+
+ /**
+ * Convert an object array to a Savable array for easier use during export.
+ *
+ * @param values
+ * our object array, should be of a class type that implements Savable.
+ * @return the array as Savable.
+ */
+ public static Savable[] asSavableArray(final Object[] values) {
+ final Savable[] rVal = new Savable[values.length];
+ for (int i = 0; i < values.length; i++) {
+ rVal[i] = (Savable) values[i];
+ }
+ return rVal;
+ }
+
+ /**
+ * Converts from a Savable array to a particular class type for import operations.
+ *
+ * @param <T>
+ * The class type to convert to.
+ * @param array
+ * our Savable array to convert.
+ * @param clazz
+ * the class type value.
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T[] asArray(final Savable[] array, final Class<T> clazz) {
+ final T[] values = (T[]) Array.newInstance(clazz, array.length);
+ for (int i = 0; i < array.length; i++) {
+ values[i] = (T) array[i];
+ }
+ return values;
+ }
+
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/InputCapsule.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/InputCapsule.java
new file mode 100644
index 0000000..8dd51b1
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/InputCapsule.java
@@ -0,0 +1,144 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
+import java.util.BitSet;
+import java.util.List;
+import java.util.Map;
+
+public interface InputCapsule {
+
+ // byte primitive
+
+ public byte readByte(String name, byte defVal) throws IOException;
+
+ public byte[] readByteArray(String name, byte[] defVal) throws IOException;
+
+ public byte[][] readByteArray2D(String name, byte[][] defVal) throws IOException;
+
+ // int primitive
+
+ public int readInt(String name, int defVal) throws IOException;
+
+ public int[] readIntArray(String name, int[] defVal) throws IOException;
+
+ public int[][] readIntArray2D(String name, int[][] defVal) throws IOException;
+
+ // float primitive
+
+ public float readFloat(String name, float defVal) throws IOException;
+
+ public float[] readFloatArray(String name, float[] defVal) throws IOException;
+
+ public float[][] readFloatArray2D(String name, float[][] defVal) throws IOException;
+
+ // double primitive
+
+ public double readDouble(String name, double defVal) throws IOException;
+
+ public double[] readDoubleArray(String name, double[] defVal) throws IOException;
+
+ public double[][] readDoubleArray2D(String name, double[][] defVal) throws IOException;
+
+ // long primitive
+
+ public long readLong(String name, long defVal) throws IOException;
+
+ public long[] readLongArray(String name, long[] defVal) throws IOException;
+
+ public long[][] readLongArray2D(String name, long[][] defVal) throws IOException;
+
+ // short primitive
+
+ public short readShort(String name, short defVal) throws IOException;
+
+ public short[] readShortArray(String name, short[] defVal) throws IOException;
+
+ public short[][] readShortArray2D(String name, short[][] defVal) throws IOException;
+
+ // boolean primitive
+
+ public boolean readBoolean(String name, boolean defVal) throws IOException;
+
+ public boolean[] readBooleanArray(String name, boolean[] defVal) throws IOException;
+
+ public boolean[][] readBooleanArray2D(String name, boolean[][] defVal) throws IOException;
+
+ // String
+
+ public String readString(String name, String defVal) throws IOException;
+
+ public String[] readStringArray(String name, String[] defVal) throws IOException;
+
+ public String[][] readStringArray2D(String name, String[][] defVal) throws IOException;
+
+ // BitSet
+
+ public BitSet readBitSet(String name, BitSet defVal) throws IOException;
+
+ // BinarySavable
+
+ public Savable readSavable(String name, Savable defVal) throws IOException;
+
+ public Savable[] readSavableArray(String name, Savable[] defVal) throws IOException;
+
+ public Savable[][] readSavableArray2D(String name, Savable[][] defVal) throws IOException;
+
+ // Lists
+
+ public <E extends Savable> List<E> readSavableList(String name, List<E> defVal) throws IOException;
+
+ public <E extends Savable> List<E>[] readSavableListArray(String name, List<E>[] defVal) throws IOException;
+
+ public <E extends Savable> List<E>[][] readSavableListArray2D(String name, List<E>[][] defVal) throws IOException;
+
+ public List<FloatBuffer> readFloatBufferList(String name, List<FloatBuffer> defVal) throws IOException;
+
+ public List<ByteBuffer> readByteBufferList(String name, List<ByteBuffer> defVal) throws IOException;
+
+ // Maps
+
+ public <K extends Savable, V extends Savable> Map<K, V> readSavableMap(String name, Map<K, V> defVal)
+ throws IOException;
+
+ public <V extends Savable> Map<String, V> readStringSavableMap(String name, Map<String, V> defVal)
+ throws IOException;
+
+ // NIO BUFFERS
+ // float buffer
+
+ public FloatBuffer readFloatBuffer(String name, FloatBuffer defVal) throws IOException;
+
+ // int buffer
+
+ public IntBuffer readIntBuffer(String name, IntBuffer defVal) throws IOException;
+
+ // byte buffer
+
+ public ByteBuffer readByteBuffer(String name, ByteBuffer defVal) throws IOException;
+
+ // short buffer
+
+ public ShortBuffer readShortBuffer(String name, ShortBuffer defVal) throws IOException;
+
+ // enums
+
+ public <T extends Enum<T>> T readEnum(String name, Class<T> enumType, T defVal) throws IOException;
+
+ public <T extends Enum<T>> T[] readEnumArray(final String name, final Class<T> enumType, final T[] defVal)
+ throws IOException;
+
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/OutputCapsule.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/OutputCapsule.java
new file mode 100644
index 0000000..226bc40
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/OutputCapsule.java
@@ -0,0 +1,145 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
+import java.util.BitSet;
+import java.util.List;
+import java.util.Map;
+
+public interface OutputCapsule {
+
+ // byte primitive
+
+ public void write(byte value, String name, byte defVal) throws IOException;
+
+ public void write(byte[] value, String name, byte[] defVal) throws IOException;
+
+ public void write(byte[][] value, String name, byte[][] defVal) throws IOException;
+
+ // int primitive
+
+ public void write(int value, String name, int defVal) throws IOException;
+
+ public void write(int[] value, String name, int[] defVal) throws IOException;
+
+ public void write(int[][] value, String name, int[][] defVal) throws IOException;
+
+ // float primitive
+
+ public void write(float value, String name, float defVal) throws IOException;
+
+ public void write(float[] value, String name, float[] defVal) throws IOException;
+
+ public void write(float[][] value, String name, float[][] defVal) throws IOException;
+
+ // double primitive
+
+ public void write(double value, String name, double defVal) throws IOException;
+
+ public void write(double[] value, String name, double[] defVal) throws IOException;
+
+ public void write(double[][] value, String name, double[][] defVal) throws IOException;
+
+ // long primitive
+
+ public void write(long value, String name, long defVal) throws IOException;
+
+ public void write(long[] value, String name, long[] defVal) throws IOException;
+
+ public void write(long[][] value, String name, long[][] defVal) throws IOException;
+
+ // short primitive
+
+ public void write(short value, String name, short defVal) throws IOException;
+
+ public void write(short[] value, String name, short[] defVal) throws IOException;
+
+ public void write(short[][] value, String name, short[][] defVal) throws IOException;
+
+ // boolean primitive
+
+ public void write(boolean value, String name, boolean defVal) throws IOException;
+
+ public void write(boolean[] value, String name, boolean[] defVal) throws IOException;
+
+ public void write(boolean[][] value, String name, boolean[][] defVal) throws IOException;
+
+ // String
+
+ public void write(String value, String name, String defVal) throws IOException;
+
+ public void write(String[] value, String name, String[] defVal) throws IOException;
+
+ public void write(String[][] value, String name, String[][] defVal) throws IOException;
+
+ // BitSet
+
+ public void write(BitSet value, String name, BitSet defVal) throws IOException;
+
+ // BinarySavable
+
+ public void write(Savable object, String name, Savable defVal) throws IOException;
+
+ public void write(Savable[] objects, String name, Savable[] defVal) throws IOException;
+
+ public void write(Savable[][] objects, String name, Savable[][] defVal) throws IOException;
+
+ // Lists
+
+ public void writeSavableList(List<? extends Savable> array, String name, List<? extends Savable> defVal)
+ throws IOException;
+
+ public void writeSavableListArray(List<? extends Savable>[] array, String name, List<? extends Savable>[] defVal)
+ throws IOException;
+
+ public void writeSavableListArray2D(List<? extends Savable>[][] array, String name,
+ List<? extends Savable>[][] defVal) throws IOException;
+
+ public void writeFloatBufferList(List<FloatBuffer> array, String name, List<FloatBuffer> defVal) throws IOException;
+
+ public void writeByteBufferList(List<ByteBuffer> array, String name, List<ByteBuffer> defVal) throws IOException;
+
+ // Maps
+
+ public void writeSavableMap(Map<? extends Savable, ? extends Savable> map, String name,
+ Map<? extends Savable, ? extends Savable> defVal) throws IOException;
+
+ public void writeStringSavableMap(Map<String, ? extends Savable> map, String name,
+ Map<String, ? extends Savable> defVal) throws IOException;
+
+ // NIO BUFFERS
+ // float buffer
+
+ public void write(FloatBuffer value, String name, FloatBuffer defVal) throws IOException;
+
+ // int buffer
+
+ public void write(IntBuffer value, String name, IntBuffer defVal) throws IOException;
+
+ // byte buffer
+
+ public void write(ByteBuffer value, String name, ByteBuffer defVal) throws IOException;
+
+ // short buffer
+
+ public void write(ShortBuffer value, String name, ShortBuffer defVal) throws IOException;
+
+ // enums
+
+ public void write(Enum<?> value, String name, Enum<?> defVal) throws IOException;
+
+ public void write(Enum<?>[] value, String name) throws IOException;
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/ReadListener.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/ReadListener.java
new file mode 100644
index 0000000..ec9b724
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/ReadListener.java
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+public interface ReadListener {
+
+ public void readBytes(int bytes);
+
+}
diff --git a/ardor3d-savable/src/main/java/com/ardor3d/util/export/Savable.java b/ardor3d-savable/src/main/java/com/ardor3d/util/export/Savable.java
new file mode 100644
index 0000000..d021554
--- /dev/null
+++ b/ardor3d-savable/src/main/java/com/ardor3d/util/export/Savable.java
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util.export;
+
+import java.io.IOException;
+
+public interface Savable {
+ void write(OutputCapsule capsule) throws IOException;
+
+ void read(InputCapsule capsule) throws IOException;
+
+ Class<?> getClassTag();
+}