protected HashMap<String, ArrayList<String>> CollectSingleTableData( UserData data, String struct) { LinkedHashSet<String> s; List<String> tmp; MetaType mt = data.getUserDataType(); s = new LinkedHashSet<String>(data.getUserData().keySet()); HashMap<String, ArrayList<String>> tableVales = new HashMap<String, ArrayList<String>>(); tmp = new ArrayList<String>(); /* strip [] from userdata */ for (String key : s) { String newKey = mt.removeIndicesFromStruct(key, struct); tmp.add(newKey); if (tableVales.containsKey(newKey)) { ArrayList<String> tmpVal = tableVales.get(newKey); tmpVal.add(data.getUserData().get(key)); tableVales.put(newKey, tmpVal); } else { ArrayList<String> tmpVal = new ArrayList<String>(); tmpVal.add(data.getUserData().get(key)); tableVales.put(newKey, tmpVal); } } return tableVales; }
public boolean setData(Sample sample, String colName, int index) { UserData data; boolean result = true; if (sample != null) { data = sample.getMessage().getUserData(); int rowCount = this.getRowCount(); if (data == null) { return false; } HashMap<String, ArrayList<String>> tableData = CollectSingleTableData(data, colName); for (int i = 0; i < rowCount; i++) { String fName = (String) this.getValueAt(i, 1); if (index >= 0) { if (fName.startsWith(colName)) { String tmp = fName.substring(colName.length()); fName = colName + "[" + index + "]" + tmp; } } if (tableData.containsKey(fName)) { ArrayList<String> colVals = tableData.get(fName); if (index >= 0) { this.setValueAt(colVals.get(index), i, 2); } else { this.setValueAt(colVals.toString(), i, 2); } } else if (tableData.containsKey(colName)) { ArrayList<String> colVals = tableData.get(colName); if (index >= 0) { this.setValueAt(colVals.get(index), i, 2); } else { this.setValueAt(colVals.toString(), i, 2); } } else { LinkedHashSet<String> s = new LinkedHashSet<String>(data.getUserData().keySet()); String value = null; for (String key : s) { if (key.startsWith(fName)) { if (value != null) { value = value + "," + data.getUserData().get(key); } else { value = data.getUserData().get(key); } } } if (value == null) { LinkedHashSet<String> td = new LinkedHashSet<String>(tableData.keySet()); for (String key : td) { if (key.startsWith(fName)) { if (value != null) { value = value + "," + tableData.get(key).toString(); } else { value = tableData.get(key).toString(); } } } } this.setValueAt(value, i, 2); } } ud = data; } return result; }