public FortGameLogArrayItem addData(String paramStr1, String paramStr2) { FortGameLogArrayItem item = new FortGameLogArrayItem(); item.setParamStr1(paramStr1); item.setParamStr2(paramStr2); list.add(item); return item; }
/** 编码 */ @Override public void encode(Data data) { data.writeInt(list.size()); for (FortGameLogArrayItem item : list) { data.writeString(item.getParamStr1()); data.writeString(item.getParamStr2()); } }
@Override public boolean validate() { for (FortGameLogArrayItem item : list) { if (!item.validate()) { return false; } } return true; }
/** 解码 */ @Override public void decode(Data data) { int size = data.getInt(); for (int i = 0; i < size; i++) { FortGameLogArrayItem item = FortGameLogArrayItem.create(); item.setParamStr1(data.getString()); item.setParamStr2(data.getString()); list.add(item); } }
public String toString() { StringBuilder bb = new StringBuilder(); bb.append("["); int i = 0; for (FortGameLogArrayItem item : list) { bb.append("{").append(item.toString()).append("}"); i++; if (i != list.size()) { bb.append(", "); } } bb.append("]"); return bb.toString(); }