diff --git a/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java b/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java index f4b580f148..1d91ca903b 100644 --- a/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java +++ b/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java @@ -704,17 +704,7 @@ public ByteBuffer readByteBuffer(String name, ByteBuffer defVal) throws IOExcept return defVal; } - int position = 0; - String positionString = XMLUtils.getAttribute(importer.getFormatVersion(), element, XMLExporter.ATTRIBUTE_POSITION); - if (!positionString.isEmpty()) { - try { - position = Integer.parseInt(positionString); - } catch (NumberFormatException nfe) { - throw new IOException(nfe); - } - } - - return (ByteBuffer) BufferUtils.createByteBuffer(array.length).put(array).position(position); + return (ByteBuffer) BufferUtils.createByteBuffer(array.length).put(array).rewind(); } @Override @@ -727,17 +717,7 @@ public ShortBuffer readShortBuffer(String name, ShortBuffer defVal) throws IOExc return defVal; } - int position = 0; - String positionString = XMLUtils.getAttribute(importer.getFormatVersion(), element, XMLExporter.ATTRIBUTE_POSITION); - if (!positionString.isEmpty()) { - try { - position = Integer.parseInt(positionString); - } catch (NumberFormatException nfe) { - throw new IOException(nfe); - } - } - - return (ShortBuffer) BufferUtils.createShortBuffer(array.length).put(array).position(position); + return (ShortBuffer) BufferUtils.createShortBuffer(array.length).put(array).rewind(); } @Override @@ -750,17 +730,7 @@ public IntBuffer readIntBuffer(String name, IntBuffer defVal) throws IOException return defVal; } - int position = 0; - String positionString = XMLUtils.getAttribute(importer.getFormatVersion(), element, XMLExporter.ATTRIBUTE_POSITION); - if (!positionString.isEmpty()) { - try { - position = Integer.parseInt(positionString); - } catch (NumberFormatException nfe) { - throw new IOException(nfe); - } - } - - return (IntBuffer) BufferUtils.createIntBuffer(array.length).put(array).position(position); + return (IntBuffer) BufferUtils.createIntBuffer(array.length).put(array).rewind(); } @Override @@ -773,17 +743,7 @@ public FloatBuffer readFloatBuffer(String name, FloatBuffer defVal) throws IOExc return defVal; } - int position = 0; - String positionString = XMLUtils.getAttribute(importer.getFormatVersion(), element, XMLExporter.ATTRIBUTE_POSITION); - if (!positionString.isEmpty()) { - try { - position = Integer.parseInt(positionString); - } catch (NumberFormatException nfe) { - throw new IOException(nfe); - } - } - - return (FloatBuffer) BufferUtils.createFloatBuffer(array.length).put(array).position(position); + return (FloatBuffer) BufferUtils.createFloatBuffer(array.length).put(array).rewind(); } @Override diff --git a/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMOutputCapsule.java b/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMOutputCapsule.java index a9fc483725..2c6ca4fce8 100644 --- a/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMOutputCapsule.java +++ b/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMOutputCapsule.java @@ -90,7 +90,7 @@ private Element appendElement(String name) { // helper function to reduce duplicate code. uses reflection to write an array of any primitive type. // also has optional position argument for writing buffers. - private void writePrimitiveArrayHelper(Object value, String name, int position) throws IOException { + private void writePrimitiveArrayHelper(Object value, String name) throws IOException { StringBuilder sb = new StringBuilder(); for(int i = 0; i < Array.getLength(value); i++) { @@ -104,9 +104,7 @@ private void writePrimitiveArrayHelper(Object value, String name, int position) appendElement(name); XMLUtils.setAttribute(currentElement, XMLExporter.ATTRIBUTE_SIZE, String.valueOf(Array.getLength(value))); XMLUtils.setAttribute(currentElement, XMLExporter.ATTRIBUTE_DATA, sb.toString()); - if (position >= 0) { - XMLUtils.setAttribute(currentElement, XMLExporter.ATTRIBUTE_POSITION, String.valueOf(position)); - } + currentElement = (Element) currentElement.getParentNode(); } @@ -124,7 +122,7 @@ private void writePrimitiveArray2DHelper(Object[] value, String name) throws IOE String childName = childNamePrefix + i; if (value[i] != null) { - writePrimitiveArrayHelper(value[i], childName, -1); + writePrimitiveArrayHelper(value[i], childName); } else { // empty tag appendElement(childName); @@ -145,7 +143,7 @@ public void write(byte value, String name, byte defVal) throws IOException { @Override public void write(byte[] value, String name, byte[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -166,7 +164,7 @@ public void write(short value, String name, short defVal) throws IOException { @Override public void write(short[] value, String name, short[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -187,7 +185,7 @@ public void write(int value, String name, int defVal) throws IOException { @Override public void write(int[] value, String name, int[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -208,7 +206,7 @@ public void write(long value, String name, long defVal) throws IOException { @Override public void write(long[] value, String name, long[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -229,7 +227,7 @@ public void write(float value, String name, float defVal) throws IOException { @Override public void write(float[] value, String name, float[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -250,7 +248,7 @@ public void write(double value, String name, double defVal) throws IOException { @Override public void write(double[] value, String name, double[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -271,7 +269,7 @@ public void write(boolean value, String name, boolean defVal) throws IOException @Override public void write(boolean[] value, String name, boolean[] defVal) throws IOException { if (!Arrays.equals(value, defVal)) { - writePrimitiveArrayHelper(value, name, -1); + writePrimitiveArrayHelper(value, name); } } @@ -478,7 +476,7 @@ public void write(ByteBuffer value, String name, ByteBuffer defVal) throws IOExc value.get(array); value.position(position); - writePrimitiveArrayHelper(array, name, value.position()); + writePrimitiveArrayHelper(array, name); } @Override @@ -493,7 +491,7 @@ public void write(ShortBuffer value, String name, ShortBuffer defVal) throws IOE value.get(array); value.position(position); - writePrimitiveArrayHelper(array, name, value.position()); + writePrimitiveArrayHelper(array, name); } @Override @@ -508,7 +506,7 @@ public void write(IntBuffer value, String name, IntBuffer defVal) throws IOExcep value.get(array); value.position(position); - writePrimitiveArrayHelper(array, name, value.position()); + writePrimitiveArrayHelper(array, name); } @Override @@ -523,7 +521,7 @@ public void write(FloatBuffer value, String name, FloatBuffer defVal) throws IOE value.get(array); value.position(position); - writePrimitiveArrayHelper(array, name, value.position()); + writePrimitiveArrayHelper(array, name); } @Override diff --git a/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java b/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java index 2c565f8498..bc4ef918b0 100644 --- a/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java +++ b/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java @@ -62,7 +62,6 @@ public class XMLExporter implements JmeExporter { public static final String ELEMENT_VALUE = "Value"; public static final String ATTRIBUTE_SIZE = "size"; public static final String ATTRIBUTE_DATA = "data"; - public static final String ATTRIBUTE_POSITION = "position"; // for buffers only public static final String ATTRIBUTE_CLASS = "class"; public static final String ATTRIBUTE_REFERENCE_ID = "reference_ID"; public static final String ATTRIBUTE_REFERENCE = "ref";