@Override
    public void read(JmeImporter im) throws IOException {
        InputCapsule ic = im.getCapsule(this);
        type = ic.readByte("type", (byte) 0);
        switch (type) {
            case TYPE_INTEGER:
                value = ic.readInt("intVal", 0);
                break;
            case TYPE_FLOAT:
                value = ic.readFloat("floatVal", 0f);
                break;
            case TYPE_BOOLEAN:
                value = ic.readBoolean("boolVal", false);
                break;
            case TYPE_STRING:
                value = ic.readString("strVal", null);
                break;
            case TYPE_LONG:
                value = ic.readLong("longVal", 0l);
                break;
            case TYPE_SAVABLE:
                value = ic.readSavable("savableVal", null);
                break;
            case TYPE_LIST:
                value = this.readList(ic, "0");
                break;
            case TYPE_MAP:
                Map<Object, Object> map = new HashMap<>();
                List<?> keys = this.readList(ic, "0");
                List<?> values = this.readList(ic, "1");
                for (int i = 0; i < keys.size(); ++i) {
                    map.put(keys.get(i), values.get(i));
                }
                value = map;
                break;
            case TYPE_ARRAY:
                value = this.readList(ic, "0").toArray();
                break;
            case TYPE_DOUBLE:
                value = ic.readDouble("doubleVal", 0.);
                break;
            case TYPE_SHORT:
                value = ic.readShort("shortVal", (short)0);
                break;
            case TYPE_BYTE:
                value = ic.readByte("byteVal", (byte)0);
                break;
            default:
                throw new UnsupportedOperationException("Unknown type of stored data: " + type);
        }
    }
Creates a new <code>UserData</code> with the given
type and value.

@param type
           Type of data, should be between 0 and 8.
@param value
           Value of the data
jme3-core/src/main/java/com/jme3/scene/UserData.java