/** * 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(); }
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder buf = new XmlStringBuilder(this); // Add attributes buf.optAttribute("label", getLabel()); buf.optAttribute("var", getVariable()); buf.optAttribute("type", getType()); buf.rightAngleBracket(); // Add elements buf.optElement("desc", getDescription()); buf.condEmptyElement(isRequired(), "required"); // Loop through all the values and append them to the string buffer for (CharSequence value : getValues()) { buf.element("value", value); } // Loop through all the values and append them to the string buffer for (Option option : getOptions()) { buf.append(option.toXML(null)); } buf.optElement(validateElement); buf.closeElement(this); return buf; }
assertEquals("Event Name", nameField.getLabel());
/** * Retrieve the date (in yyyyMMdd) format of the time the room was created. * * @param roomJID the jid of the room. * @return the formatted date. * @throws Exception throws an exception if we are unable to retrieve the date. */ public static String getCreationDate(EntityBareJid roomJID) throws Exception { ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection()); final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); DiscoverInfo infoResult = discoManager.discoverInfo(roomJID); DataForm dataForm = infoResult.getExtension("x", "jabber:x:data"); if (dataForm == null) { return "Not available"; } String creationDate = ""; for ( final FormField field : dataForm.getFields() ) { String label = field.getLabel(); if (label != null && "Creation date".equalsIgnoreCase(label)) { for ( CharSequence value : field.getValues() ) { creationDate = value.toString(); Date date = dateFormatter.parse(creationDate); creationDate = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.MEDIUM).format(date); } } } return creationDate; }
JLabel label = new JLabel(formfield.getLabel()); FormField.Type type = formfield.getType();
String label = field.getLabel(); FormField.Type type = field.getType();
String label = field.getLabel(); FormField.Type type = field.getType();