Browse Source

refactoring of load/save processes

lookup-tables
Stephan Richter 5 years ago
parent
commit
500af0a547
  1. 2
      pom.xml
  2. 4
      src/main/java/de/srsoftware/web4rail/BaseClass.java
  3. 169
      src/main/java/de/srsoftware/web4rail/Route.java
  4. 5
      src/main/java/de/srsoftware/web4rail/actions/Action.java
  5. 32
      src/main/java/de/srsoftware/web4rail/actions/ActionList.java
  6. 19
      src/main/java/de/srsoftware/web4rail/actions/ConditionalAction.java
  7. 8
      src/main/java/de/srsoftware/web4rail/actions/DelayedAction.java
  8. 30
      src/main/java/de/srsoftware/web4rail/conditions/ConditionList.java
  9. 23
      src/main/java/de/srsoftware/web4rail/tiles/Contact.java

2
pom.xml

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId> <groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId> <artifactId>web4rail</artifactId>
<version>1.2.10</version> <version>1.2.11</version>
<name>Web4Rail</name> <name>Web4Rail</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<description>Java Model Railway Control</description> <description>Java Model Railway Control</description>

4
src/main/java/de/srsoftware/web4rail/BaseClass.java

@ -352,7 +352,7 @@ public abstract class BaseClass implements Constants{
protected Window properties(List<Fieldset> preForm,FormInput formInputs,List<Fieldset> postForm) { protected Window properties(List<Fieldset> preForm,FormInput formInputs,List<Fieldset> postForm) {
Window win = new Window(getClass().getSimpleName()+"-properties", t("Properties of {} ({})",this.title(),id)); Window win = new Window(getClass().getSimpleName()+"-properties", t("Properties of {}",this.title()));
preForm.forEach(fieldset -> fieldset.addTo(win)); preForm.forEach(fieldset -> fieldset.addTo(win));
@ -372,7 +372,7 @@ public abstract class BaseClass implements Constants{
} }
private String title() { private String title() {
return getClass().getSimpleName(); return toString();
} }
private Map<String,String> props(Map<String,String> additionalProps){ private Map<String,String> props(Map<String,String> additionalProps){

169
src/main/java/de/srsoftware/web4rail/Route.java

@ -53,19 +53,21 @@ public class Route extends BaseClass implements Comparable<Route>{
private static final Logger LOG = LoggerFactory.getLogger(Route.class); private static final Logger LOG = LoggerFactory.getLogger(Route.class);
private static final String ACTIONS = "actions"; private static final String ACTIONS = "actions";
private static final String ACTION_LISTS = "action_lists";
private static final String BRAKE_TIMES = "brake_times"; private static final String BRAKE_TIMES = "brake_times";
private static final String CONDITIONS = "conditions"; private static final String CONDITION_LIST = "condition_list";
private static final String END_DIRECTION = "direction_end"; private static final String END_DIRECTION = "direction_end";
private static final String ROUTES = "routes"; private static final String ROUTES = "routes";
private static final String SETUP_ACTIONS = "setup_actions"; private static final String SETUP_ACTIONS = "setup_actions";
private static final String START_ACTIONS = "start_actions"; private static final String START_ACTIONS = "start_actions";
private static final String START_DIRECTION = "direction_start"; private static final String START_DIRECTION = "direction_start";
private static final String TRIGGER = "trigger";
static final String NAME = "name"; static final String NAME = "name";
static final String PATH = "path"; static final String PATH = "path";
static final String SIGNALS = "signals"; static final String SIGNALS = "signals";
static final String TURNOUTS = "turnouts"; static final String TURNOUTS = "turnouts";
private static final String ROUTE_START = "route_start";
private static final String ROUTE_SETUP = "route_setup";
private static HashMap<Id, String> names = new HashMap<Id, String>(); // maps id to name. needed to keep names during plan.analyze() private static HashMap<Id, String> names = new HashMap<Id, String>(); // maps id to name. needed to keep names during plan.analyze()
@ -144,17 +146,10 @@ public class Route extends BaseClass implements Comparable<Route>{
public Train train; public Train train;
private HashMap<String,ActionList> triggers = new HashMap<String, ActionList>(); private HashMap<String,ActionList> triggers = new HashMap<String, ActionList>();
private HashMap<Turnout,Turnout.State> turnouts; private HashMap<Turnout,Turnout.State> turnouts;
private ActionList setupActions;
private ActionList startActions;
private Block startBlock = null; private Block startBlock = null;
public Direction startDirection; public Direction startDirection;
private HashSet<Contact> triggeredContacts = new HashSet<>(); private HashSet<Contact> triggeredContacts = new HashSet<>();
public Route() {
setupActions = new ActionList(this);
startActions = new ActionList(this);
}
/** /**
* process commands from the client * process commands from the client
* @param params * @param params
@ -253,10 +248,10 @@ public class Route extends BaseClass implements Comparable<Route>{
Tag list = new Tag("ol"); Tag list = new Tag("ol");
Tag setup = new Tag("li").content(t("Setup actions")+NBSP); Tag setup = new Tag("li").content(t("Setup actions")+NBSP);
setupActions.list().addTo(setup).addTo(list); triggers.get(ROUTE_SETUP).list().addTo(setup).addTo(list);
Tag start = new Tag("li").content(t("Start actions")+NBSP); Tag start = new Tag("li").content(t("Start actions")+NBSP);
startActions.list().addTo(start).addTo(list); triggers.get(ROUTE_START).list().addTo(start).addTo(list);
for (Contact c : contacts) { for (Contact c : contacts) {
Tag item = c.link("span", c).addTo(new Tag("li")).content(NBSP); Tag item = c.link("span", c).addTo(new Tag("li")).content(NBSP);
@ -277,7 +272,6 @@ public class Route extends BaseClass implements Comparable<Route>{
conditions.addAll(existingRoute.conditions); conditions.addAll(existingRoute.conditions);
setupActions.addActionsFrom(existingRoute.setupActions);
for (Entry<String, ActionList> entry : triggers.entrySet()) { for (Entry<String, ActionList> entry : triggers.entrySet()) {
String trigger = entry.getKey(); String trigger = entry.getKey();
ActionList existingActionList = existingRoute.triggers.get(trigger); ActionList existingActionList = existingRoute.triggers.get(trigger);
@ -376,8 +370,8 @@ public class Route extends BaseClass implements Comparable<Route>{
add(lastContact.trigger(), new BrakeStop(this)); add(lastContact.trigger(), new BrakeStop(this));
add(lastContact.trigger(), new FinishRoute(this)); add(lastContact.trigger(), new FinishRoute(this));
} }
for (Signal signal : signals) setupActions.add(new SetSignal(this).set(signal).to(Signal.GO)); for (Signal signal : signals) add(ROUTE_SETUP,new SetSignal(this).set(signal).to(Signal.GO));
startActions.add(new SetSpeed(this).to(999)); add(ROUTE_START,new SetSpeed(this).to(999));
return this; return this;
} }
@ -437,7 +431,7 @@ public class Route extends BaseClass implements Comparable<Route>{
} }
public boolean fireSetupActions(Context context) { public boolean fireSetupActions(Context context) {
return setupActions.fire(context); return triggers.get(ROUTE_SETUP).fire(context);
} }
private String generateName() { private String generateName() {
@ -492,21 +486,17 @@ public class Route extends BaseClass implements Comparable<Route>{
json.put(BRAKE_TIMES, brakeTimes); json.put(BRAKE_TIMES, brakeTimes);
if (!conditions.isEmpty()) json.put(CONDITIONS, conditions.jsonArray()); if (!conditions.isEmpty()) {
json.put(CONDITION_LIST, conditions.json());
}
JSONArray jTriggers = new JSONArray(); JSONObject jActions = new JSONObject();
for (Entry<String, ActionList> entry : triggers.entrySet()) { for (Entry<String, ActionList> entry : triggers.entrySet()) {
JSONObject trigger = new JSONObject(); String trigger = entry.getKey();
trigger.put(TRIGGER, entry.getKey()); ActionList lst = entry.getValue();
ActionList actionList = entry.getValue(); jActions.put(trigger,lst.json());
trigger.put(ACTIONS, actionList.jsonArray());
jTriggers.put(trigger);
} }
if (!jTriggers.isEmpty()) json.put(ACTION_LISTS, jTriggers); json.put(ACTIONS, jActions);
if (!setupActions.isEmpty()) json.put(SETUP_ACTIONS, setupActions.json());
if (!startActions.isEmpty()) json.put(START_ACTIONS, startActions.json());
String name = name(); String name = name();
if (isSet(name)) json.put(NAME, name); if (isSet(name)) json.put(NAME, name);
@ -550,10 +540,96 @@ public class Route extends BaseClass implements Comparable<Route>{
if (json.has(SIGNALS)) { if (json.has(SIGNALS)) {
for (Object signalId : json.getJSONArray(SIGNALS)) addSignal((Signal) plan.get(new Id((String) signalId), false)); for (Object signalId : json.getJSONArray(SIGNALS)) addSignal((Signal) plan.get(new Id((String) signalId), false));
} }
if (json.has(ACTION_LISTS)) loadActions(json.getJSONArray(ACTION_LISTS)); if (json.has(ACTIONS)) {
if (json.has(CONDITIONS)) conditions.load(json.getJSONArray(CONDITIONS)).parent(this); loadActions(json.getJSONObject(ACTIONS));
if (json.has(SETUP_ACTIONS)) setupActions.load(json.getJSONArray(SETUP_ACTIONS)).parent(this); }
if (json.has(START_ACTIONS)) startActions.load(json.getJSONArray(START_ACTIONS)).parent(this); if (json.has("action_lists")) { // TODO: this is legacy!
JSONArray jarr = json.getJSONArray("action_lists");
for (Object o : jarr) {
if (o instanceof JSONObject) {
JSONObject jo = (JSONObject) o;
ActionList aList = new ActionList(this);
String trigger = jo.getString("trigger");
JSONArray jActions = jo.getJSONArray(ACTIONS);
for (Object ja : jActions) {
JSONObject jao = (JSONObject) ja;
String type = jao.getString(TYPE);
Action action = Action.create(type, aList);
if (isSet(action)) {
action.load(jao);
aList.add(action);
}
}
triggers.put(trigger, aList);
}
}
}
if (json.has("conditions")) { // TODO: this is legacy!
JSONArray jConditions = json.getJSONArray("conditions");
for (Object o : jConditions) {
if (o instanceof JSONObject) {
JSONObject jo = (JSONObject) o;
String type = jo.getString(TYPE);
Condition condition = Condition.create(type);
if (isSet(condition)) {
condition.load(jo);
conditions.add(condition);
}
}
}
}
if (json.has(CONDITION_LIST)) conditions.load(json.getJSONObject(CONDITION_LIST)).parent(this);
if (json.has(SETUP_ACTIONS)) { // TODO: this is legacy!
Object so = json.get(SETUP_ACTIONS);
if (so instanceof JSONObject) {
JSONObject jo = (JSONObject) so;
ActionList setupActions = new ActionList(this);
setupActions.load(jo).parent(this);
triggers.put(ROUTE_SETUP, setupActions);
}
if (so instanceof JSONArray) {
JSONArray ja = (JSONArray) so;
ActionList setupActions = new ActionList(this);
for (Object o : ja) {
if (o instanceof JSONObject) {
JSONObject jo = (JSONObject) o;
String type = jo.getString(TYPE);
Action action = Action.create(type, setupActions);
if (isSet(action)) {
action.load(jo);
setupActions.add(action);
}
}
}
triggers.put(ROUTE_SETUP, setupActions);
}
}
if (json.has(START_ACTIONS)) { // TODO: this is legacy!
Object so = json.get(START_ACTIONS);
if (so instanceof JSONObject) {
JSONObject jo = (JSONObject) so;
ActionList startActions = new ActionList(this);
startActions.load(jo).parent(this);
triggers.put(ROUTE_START, startActions);
}
if (so instanceof JSONArray) {
JSONArray ja = (JSONArray) so;
ActionList startActions = new ActionList(this);
for (Object o : ja) {
if (o instanceof JSONObject) {
JSONObject jo = (JSONObject) o;
String type = jo.getString(TYPE);
Action action = Action.create(type, startActions);
if (isSet(action)) {
action.load(jo);
startActions.add(action);
}
}
}
triggers.put(ROUTE_START, startActions);
}
}
if (json.has(DISABLED)) disabled = json.getBoolean(DISABLED); if (json.has(DISABLED)) disabled = json.getBoolean(DISABLED);
if (json.has(BRAKE_TIMES)) { if (json.has(BRAKE_TIMES)) {
JSONObject dummy = json.getJSONObject(BRAKE_TIMES); JSONObject dummy = json.getJSONObject(BRAKE_TIMES);
@ -561,15 +637,16 @@ public class Route extends BaseClass implements Comparable<Route>{
} }
return plan.registerRoute(this); return plan.registerRoute(this);
} }
private void loadActions(JSONArray arr) { private void loadActions(JSONObject jsonObject) {
for (int i=0; i<arr.length(); i++) { for (String trigger : jsonObject.keySet()) {
JSONObject json = arr.getJSONObject(i); JSONObject json = jsonObject.getJSONObject(trigger);
String trigger = json.getString(TRIGGER); String type = json.getString(TYPE);
ActionList actionList = new ActionList(this).load(json.getJSONArray(ACTIONS)); ActionList actionList = Action.create(type, this);
actionList.parent(this); if (isNull(actionList)) continue;
actionList.load(json);
triggers.put(trigger, actionList); triggers.put(trigger, actionList);
} }
} }
public static void loadAll(String filename, Plan plan) throws IOException { public static void loadAll(String filename, Plan plan) throws IOException {
@ -578,7 +655,9 @@ public class Route extends BaseClass implements Comparable<Route>{
JSONObject json = new JSONObject(tokener); JSONObject json = new JSONObject(tokener);
JSONArray routes = json.getJSONArray(ROUTES); JSONArray routes = json.getJSONArray(ROUTES);
for (Object o : routes) { for (Object o : routes) {
if (o instanceof JSONObject) new Route().load((JSONObject)o, plan); if (o instanceof JSONObject) {
new Route().load((JSONObject)o, plan);
}
} }
fis.close(); fis.close();
} }
@ -659,8 +738,6 @@ public class Route extends BaseClass implements Comparable<Route>{
ActionList actionList = triggers.remove(key); ActionList actionList = triggers.remove(key);
if (isSet(actionList)) actionList.remove(); if (isSet(actionList)) actionList.remove();
}; };
setupActions.remove();
startActions.remove();
return this; return this;
} }
@ -674,8 +751,6 @@ public class Route extends BaseClass implements Comparable<Route>{
if (child == train) train = null; if (child == train) train = null;
for (ActionList list : triggers.values()) list.removeChild(child); for (ActionList list : triggers.values()) list.removeChild(child);
turnouts.remove(child); turnouts.remove(child);
setupActions.removeChild(child);
startActions.removeChild(child);
if (child == startBlock) startBlock = null; if (child == startBlock) startBlock = null;
triggeredContacts.remove(child); triggeredContacts.remove(child);
} }
@ -771,7 +846,7 @@ public class Route extends BaseClass implements Comparable<Route>{
public boolean train(Train newTrain) { public boolean train(Train newTrain) {
if (isSet(train) && newTrain != train) return false; if (isSet(train) && newTrain != train) return false;
train = newTrain; train = newTrain;
return isSet(train) ? startActions.fire(new Context(this).train(train)) : true; return isSet(train) ? triggers.get(ROUTE_START).fire(new Context(this).train(train)) : true;
} }
public Route unlock() throws IOException { public Route unlock() throws IOException {

5
src/main/java/de/srsoftware/web4rail/actions/Action.java

@ -37,9 +37,10 @@ public abstract class Action extends BaseClass {
return context; return context;
} }
public static Action create(String type,BaseClass parent) { @SuppressWarnings("unchecked")
public static <T extends Action> T create(String type,BaseClass parent) {
try { try {
return (Action) Class.forName(PREFIX+"."+type).getDeclaredConstructor(BaseClass.class).newInstance(parent); return (T) Class.forName(PREFIX+"."+type).getDeclaredConstructor(BaseClass.class).newInstance(parent);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

32
src/main/java/de/srsoftware/web4rail/actions/ActionList.java

@ -22,7 +22,8 @@ import de.srsoftware.web4rail.tags.Input;
public class ActionList extends Action implements Iterable<Action>{ public class ActionList extends Action implements Iterable<Action>{
static final Logger LOG = LoggerFactory.getLogger(ActionList.class); static final Logger LOG = LoggerFactory.getLogger(ActionList.class);
private static final String ACTIONS = "actions";
protected Vector<Action> actions; protected Vector<Action> actions;
public ActionList(BaseClass parent) { public ActionList(BaseClass parent) {
@ -104,14 +105,11 @@ public class ActionList extends Action implements Iterable<Action>{
@Override @Override
public JSONObject json() { public JSONObject json() {
String cls = getClass().getSimpleName(); JSONObject json = super.json();
throw new UnsupportedOperationException(cls+".json() not supported, use "+cls+".jsonArray instead!"); JSONArray jActions = new JSONArray();
} actions.forEach(action -> jActions.put(action.json()));
json.put(ACTIONS,jActions);
public JSONArray jsonArray() { return json;
JSONArray result = new JSONArray();
for (Action action : actions) result.put(action.json());
return result;
} }
public Tag list() { public Tag list() {
@ -136,12 +134,16 @@ public class ActionList extends Action implements Iterable<Action>{
return span; return span;
} }
public ActionList load(JSONArray list) { public Action load(JSONObject json) {
for (Object o : list) { super.load(json);
if (o instanceof JSONObject) { if (json.has(ACTIONS)) {
JSONObject json = (JSONObject) o; JSONArray list = json.getJSONArray(ACTIONS);
Action action = Action.create(json.getString(TYPE),this); for (Object o : list) {
if (action != null) add(action.load(json)); if (o instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) o;
Action action = Action.create(jsonObject.getString(TYPE),this);
if (action != null) add(action.load(jsonObject));
}
} }
} }
return this; return this;

19
src/main/java/de/srsoftware/web4rail/actions/ConditionalAction.java

@ -15,7 +15,6 @@ import de.srsoftware.web4rail.tags.Fieldset;
public class ConditionalAction extends ActionList { public class ConditionalAction extends ActionList {
private static final String CONDITIONS = "conditions"; private static final String CONDITIONS = "conditions";
private static final String ACTIONS = "actions";
private ConditionList conditions = new ConditionList(); private ConditionList conditions = new ConditionList();
public ConditionalAction(BaseClass parent) { public ConditionalAction(BaseClass parent) {
@ -41,24 +40,24 @@ public class ConditionalAction extends ActionList {
JSONArray conditions = new JSONArray(); JSONArray conditions = new JSONArray();
for (Condition condition : this.conditions) conditions.put(condition.json()); for (Condition condition : this.conditions) conditions.put(condition.json());
json.put(CONDITIONS, conditions); json.put(CONDITIONS, conditions);
json.put(ACTIONS, super.jsonArray());
return json; return json;
} }
@Override @Override
public Action load(JSONObject json) { public Action load(JSONObject json) {
super.load(json); super.load(json);
for (Object o : json.getJSONArray(CONDITIONS)) { if (json.has(CONDITIONS)) {
if (o instanceof JSONObject) { for (Object o : json.getJSONArray(CONDITIONS)) {
JSONObject j = (JSONObject) o; if (o instanceof JSONObject) {
Condition condition = Condition.create(j.getString(TYPE)); JSONObject j = (JSONObject) o;
if (isSet(condition)) { Condition condition = Condition.create(j.getString(TYPE));
condition.parent(this); if (isSet(condition)) {
conditions.add(condition.load(j)); condition.parent(this);
conditions.add(condition.load(j));
}
} }
} }
} }
super.load(json.getJSONArray(ACTIONS));
return this; return this;
} }

8
src/main/java/de/srsoftware/web4rail/actions/DelayedAction.java

@ -13,8 +13,6 @@ import de.srsoftware.web4rail.tags.Input;
public class DelayedAction extends ActionList { public class DelayedAction extends ActionList {
private static final String ACTIONS = "actions";
public static final String DELAY = "delay"; public static final String DELAY = "delay";
private static final int DEFAULT_DELAY = 1000; private static final int DEFAULT_DELAY = 1000;
private int delay = DEFAULT_DELAY; private int delay = DEFAULT_DELAY;
@ -45,16 +43,12 @@ public class DelayedAction extends ActionList {
@Override @Override
public JSONObject json() { public JSONObject json() {
JSONObject json = super.json(); return super.json().put(DELAY, delay);
json.put(DELAY, delay);
json.put(ACTIONS, jsonArray());
return json;
} }
public DelayedAction load(JSONObject json) { public DelayedAction load(JSONObject json) {
super.load(json); super.load(json);
delay = json.getInt(DELAY); delay = json.getInt(DELAY);
if (json.has(ACTIONS)) super.load(json.getJSONArray(ACTIONS));
return this; return this;
} }

30
src/main/java/de/srsoftware/web4rail/conditions/ConditionList.java

@ -18,6 +18,7 @@ import de.srsoftware.web4rail.tags.Input;
public class ConditionList extends Condition implements Iterable<Condition>{ public class ConditionList extends Condition implements Iterable<Condition>{
private static final String CONDITIONS = "conditions";
private Vector<Condition> conditions = new Vector<Condition>(); private Vector<Condition> conditions = new Vector<Condition>();
public ConditionList add(Condition condition) { public ConditionList add(Condition condition) {
@ -53,13 +54,10 @@ public class ConditionList extends Condition implements Iterable<Condition>{
@Override @Override
public JSONObject json() { public JSONObject json() {
String cls = getClass().getSimpleName(); JSONObject json = super.json();
throw new UnsupportedOperationException(cls+".json() not supported, use "+cls+".jsonArray instead!"); JSONArray jConditions = new JSONArray();
} conditions.stream().map(Condition::json).forEach(js -> jConditions.put(js));
json.put(CONDITIONS, jConditions);
public JSONArray jsonArray() {
JSONArray json = new JSONArray();
for (Condition condition : conditions) json.put(condition.json());
return json; return json;
} }
@ -89,13 +87,17 @@ public class ConditionList extends Condition implements Iterable<Condition>{
} }
public ConditionList load(JSONArray arr) { @Override
for (int i=0; i<arr.length(); i++) { public Condition load(JSONObject json) {
JSONObject json = arr.getJSONObject(i); super.load(json);
Condition condition = Condition.create(json.getString(TYPE)); if (json.has(CONDITIONS)) {
if (condition != null) { JSONArray jConditions = json.getJSONArray(CONDITIONS);
condition.parent(this); for (Object o : jConditions) {
conditions.add(condition.load(json)); if (o instanceof JSONObject) {
JSONObject jo = (JSONObject) o;
Condition condition = Condition.create(jo.getString(TYPE));
if (isSet(condition)) add(condition.load(jo));
}
} }
} }
return this; return this;

23
src/main/java/de/srsoftware/web4rail/tiles/Contact.java

@ -8,11 +8,13 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import de.srsoftware.tools.Tag; import de.srsoftware.tools.Tag;
import de.srsoftware.web4rail.BaseClass; import de.srsoftware.web4rail.BaseClass;
import de.srsoftware.web4rail.Window; import de.srsoftware.web4rail.Window;
import de.srsoftware.web4rail.actions.Action;
import de.srsoftware.web4rail.actions.ActionList; import de.srsoftware.web4rail.actions.ActionList;
import de.srsoftware.web4rail.tags.Fieldset; import de.srsoftware.web4rail.tags.Fieldset;
import de.srsoftware.web4rail.tags.Input; import de.srsoftware.web4rail.tags.Input;
@ -124,7 +126,26 @@ public class Contact extends Tile{
@Override @Override
public Tile load(JSONObject json) { public Tile load(JSONObject json) {
if (json.has(ADDRESS)) addr(json.getInt(ADDRESS)); if (json.has(ADDRESS)) addr(json.getInt(ADDRESS));
if (json.has(REALM_ACTIONS)) actions.load(json.getJSONArray(REALM_ACTIONS)); if (json.has(REALM_ACTIONS)) {
Object dummy = json.get(REALM_ACTIONS);
if (dummy instanceof JSONArray) {
JSONArray jarr = (JSONArray) dummy;
for (Object o : jarr) {
if (o instanceof JSONObject) {
JSONObject jo = (JSONObject) o;
String type = jo.getString("type");
Action action = Action.create(type, actions);
if (isSet(action)) {
action.load(jo);
actions.add(action);
}
}
}
}
if (dummy instanceof JSONObject) {
actions.load((JSONObject) dummy);
}
}
return super.load(json); return super.load(json);
} }

Loading…
Cancel
Save