public void read(JMEImporter e) throws IOException { super.read(e); float[] vals = e.getCapsule(this).readFloatArray("vals", null); if (unsavedKeys == null) throw new IOException("Keys not stored"); if (vals == null) throw new IOException("Vals not stored"); if (unsavedKeys.length != vals.length) throw new IOException("Key/Val size mismatch: " + unsavedKeys.length + " vs. " + vals.length); for (int i = 0; i < unsavedKeys.length; i++) put(unsavedKeys[i], vals[i]); }
/** Subclasses must super.write(e)! */ public void write(JMEExporter e) throws IOException { super.write(e); // TODO: Verify that Map.keySet() and Map.values() guarantee parallel // entrySet ordering. float[] nativeArray = new float[size()]; int i = -1; for (float f : values()) nativeArray[++i] = f; e.getCapsule(this).write(nativeArray, "vals", null); }