private Bundlable get() { try { String clName = getString( CLASS_NAME ); if (aliases.containsKey( clName )) { clName = aliases.get( clName ); } Class<?> cl = Class.forName( clName ); if (cl != null) { Bundlable object = (Bundlable)cl.newInstance(); object.restoreFromBundle( this ); return object; } else { return null; } } catch (Exception e) { e = null; return null; } }
public void put( String key, Collection<? extends Bundlable> collection ) { JSONArray array = new JSONArray(); for (Bundlable object : collection) { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); array.put( bundle.data ); } try { data.put( key, array ); } catch (JSONException e) { } }
public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { } } }
private Bundlable get() { if (data == null) return null; try { String clName = getString( CLASS_NAME ); if (aliases.containsKey( clName )) { clName = aliases.get( clName ); } Class<?> cl = ClassReflection.forName( clName ); if (cl != null && (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers()))) { Bundlable object = (Bundlable) ClassReflection.newInstance(cl); object.restoreFromBundle( this ); return object; } else { return null; } } catch (ReflectionException e ) { Game.reportException(e); return null; } }
public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { Game.reportException(e); } } }
private Bundlable get() { if (data == null) return null; try { String clName = getString( CLASS_NAME ); if (aliases.containsKey( clName )) { clName = aliases.get( clName ); } Class<?> cl = Class.forName( clName ); if (cl != null && (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers()))) { Bundlable object = (Bundlable)cl.newInstance(); object.restoreFromBundle( this ); return object; } else { return null; } } catch (ClassNotFoundException e ) { Game.reportException(e); return null; } catch (InstantiationException e ) { Game.reportException(e); return null; } catch (IllegalAccessException e ) { Game.reportException(e); return null; } }
public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { Game.reportException(e); } } }
public void put( String key, Collection<? extends Bundlable> collection ) { JSONArray array = new JSONArray(); for (Bundlable object : collection) { //Skip none-static inner classes as they can't be instantiated through bundle restoring //Classes which make use of none-static inner classes must manage instantiation manually if (object != null) { Class cl = object.getClass(); if (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers())) { Bundle bundle = new Bundle(); bundle.put(CLASS_NAME, cl.getName()); object.storeInBundle(bundle); array.put(bundle.data); } } } try { data.put( key, array ); } catch (JSONException e) { Game.reportException(e); } }
public void put( String key, Collection<? extends Bundlable> collection ) { JSONArray array = new JSONArray(); for (Bundlable object : collection) { //Skip none-static inner classes as they can't be instantiated through bundle restoring //Classes which make use of none-static inner classes must manage instantiation manually if (object != null) { Class cl = object.getClass(); if (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers())) { Bundle bundle = new Bundle(); bundle.put(CLASS_NAME, cl.getName()); object.storeInBundle(bundle); array.put(bundle.data); } } } try { data.put( key, array ); } catch (JSONException e) { Game.reportException(e); } }