List<String> valueList = new ArrayList<>(); valueList.add(jid); ReportedData.Field field = new ReportedData.Field("jid", valueList); fields.add(field); ReportedData.Field field = new ReportedData.Field(name, valueList); fields.add(field);
/** * Creates a new ReportedData based on the returned dataForm from a search *(namespace "jabber:iq:search"). * * @param dataForm the dataForm returned from a search (namespace "jabber:iq:search"). */ private ReportedData(DataForm dataForm) { // Add the columns to the report based on the reported data fields for (FormField field : dataForm.getReportedData().getFields()) { columns.add(new Column(field.getLabel(), field.getVariable(), field.getType())); } // Add the rows to the report based on the form's items for (Item item : dataForm.getItems()) { List<Field> fieldList = new ArrayList<>(columns.size()); for (FormField field : item.getFields()) { // The field is created with all the values of the data form's field List<CharSequence> values = new ArrayList<>(); values.addAll(field.getValues()); fieldList.add(new Field(field.getVariable(), values)); } rows.add(new Row(fieldList)); } // Set the report's title this.title = dataForm.getTitle(); }
/** * Returns the values of the field whose variable matches the requested variable. * * @param variable the variable to match. * @return the values of the field whose variable matches the requested variable. */ public List<CharSequence> getValues(String variable) { for (Field field : getFields()) { if (variable.equalsIgnoreCase(field.getVariable())) { return field.getValues(); } } return null; }