use of com.jme3.util.IntMap in project jmonkeyengine by jMonkeyEngine.
the class DOMInputCapsule method readIntSavableMap.
public IntMap<? extends Savable> readIntSavableMap(String name, IntMap<? extends Savable> defVal) throws IOException {
IntMap<Savable> ret = null;
Element tempEl;
if (name != null) {
tempEl = findChildElement(currentElem, name);
} else {
tempEl = currentElem;
}
if (tempEl != null) {
ret = new IntMap<Savable>();
NodeList nodes = tempEl.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node n = nodes.item(i);
if (n instanceof Element && n.getNodeName().equals("MapEntry")) {
Element elem = (Element) n;
currentElem = elem;
int key = Integer.parseInt(currentElem.getAttribute("key"));
Savable val = readSavable("Savable", null);
ret.put(key, val);
}
}
} else {
return defVal;
}
currentElem = (Element) tempEl.getParentNode();
return ret;
}
use of com.jme3.util.IntMap in project jmonkeyengine by jMonkeyEngine.
the class DOMOutputCapsule method writeIntSavableMap.
@Override
public void writeIntSavableMap(IntMap<? extends Savable> map, String name, IntMap<? extends Savable> defVal) throws IOException {
if (map == null) {
return;
}
if (map.equals(defVal)) {
return;
}
Element stringMap = appendElement(name);
for (Entry<? extends Savable> entry : map) {
int key = entry.getKey();
Element mapEntry = appendElement("MapEntry");
mapEntry.setAttribute("key", Integer.toString(key));
Savable s = entry.getValue();
write(s, "Savable", null);
currentElement = stringMap;
}
currentElement = (Element) stringMap.getParentNode();
}
Aggregations