package th.co.ais.ssbsrfc.instance; import java.util.ArrayList; import th.co.ais.ssbsrfc.message.MessageParser; import th.co.ais.ssbsrfc.utils.Global; import ec02.data.E01Data; import ec02.utils.AppLog; public class E01Ins { private ArrayList message; private ArrayList atomic; public E01Ins() { } public E01Ins(String strJson) { try { ListE01Data listIns = (ListE01Data) MessageParser.fromJson(strJson, ListE01Data.class); for(E01Data ins : listIns.getListE01Data()) { String command = ins.getCmdName(); String resultcode = ins.getResultCode(); String description = ins.getDescription(); boolean isAtomic = ins.isAtomic(); E01Message e01Msg = null; if(isAtomic) { String name = ins.getAtomicName(); long value = ins.getAtomicValue(); if(this.message == null) { this.atomic = new ArrayList(); } e01Msg = new E01Message(command, resultcode, description, name, value); this.atomic.add(e01Msg); } else { String id = ins.getId(); String objecttype = ins.getKeyObject() == null ? null : ins.getKeyObject().getObjectType(); String key0 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey0(); String key1 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey1(); String key2 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey2(); String key3 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey3(); String key4 = ins.getKeyObject() == null ? null : ins.getKeyObject().getKey4(); E01MessageData data = new E01MessageData(ins.getData()); if(this.message == null) { this.message = new ArrayList(); } e01Msg = new E01Message(command, resultcode, description, id, objecttype, key0, key1, key2, key3, key4, data); this.message.add(e01Msg); } } // this.description = ins.getDescription(); } catch (Exception e) { AppLog.e("## EXCEPTION :" + e.getMessage()); } } @Override public String toString() { return Global.unescapePrintString(MessageParser.toJson(this)); } public ArrayList getMessage() { return message; } public void setMessage(ArrayList message) { this.message = message; } public ArrayList getAtomic() { return atomic; } public void setAtomic(ArrayList atomic) { this.atomic = atomic; } }