/** * Parses the first value of this form field as XEP-0082 date/time format and returns a date instance or {@code null}. * * @return a Date instance representing the date/time information of the first value of this field. * @throws ParseException if parsing fails. * @since 4.3.0 */ public Date getFirstValueAsDate() throws ParseException { String valueString = getFirstValue(); if (valueString == null) { return null; } return XmppDateTime.parseXEP0082Date(valueString); }
private String getFieldValue(SubscribeOptionFields field) { FormField formField = getField(field.getFieldName()); return formField.getFirstValue(); }
private String getFieldValue(ConfigureNodeFields field) { FormField formField = getField(field.getFieldName()); return formField.getFirstValue(); }
/** * Returns the number of offline messages for the user of the connection. * * @return the number of offline messages for the user of the connection. * @throws XMPPErrorException If the user is not allowed to make this request or the server does * not support offline message retrieval. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getFirstValue(); return Integer.parseInt(value); } return 0; }
if (descField != null && !descField.getValues().isEmpty()) { description = descField.getFirstValue(); subject = subjField.getFirstValue(); occupantsCount = Integer.parseInt(occCountField.getFirstValue()); maxhistoryfetch = Integer.parseInt(maxhistoryfetchField.getFirstValue()); lang = langField.getFirstValue(); ldapgroup = ldapgroupField.getFirstValue(); String firstValue = subjectmodField.getFirstValue(); subjectmod = ("true".equals(firstValue) || "1".equals(firstValue)); String urlString = urlField.getFirstValue(); try { logs = new URL(urlString); pubsub = pubsubField.getFirstValue();
private static UploadService uploadServiceFrom(DiscoverInfo discoverInfo) { assert (containsHttpFileUploadNamespace(discoverInfo)); UploadService.Version version; if (discoverInfo.containsFeature(NAMESPACE)) { version = Version.v0_3; } else if (discoverInfo.containsFeature(NAMESPACE_0_2)) { version = Version.v0_2; } else { throw new AssertionError(); } DomainBareJid address = discoverInfo.getFrom().asDomainBareJid(); DataForm dataForm = DataForm.from(discoverInfo); if (dataForm == null) { return new UploadService(address, version); } FormField field = dataForm.getField("max-file-size"); if (field == null) { return new UploadService(address, version); } String maxFileSizeValue = field.getFirstValue(); if (maxFileSizeValue == null) { // This is likely an implementation error of the upload component, because the max-file-size form field is // there but has no value set. return new UploadService(address, version); } Long maxFileSize = Long.valueOf(maxFileSizeValue); return new UploadService(address, version, maxFileSize); }
private static UploadService uploadServiceFrom(DiscoverInfo discoverInfo) { assert (containsHttpFileUploadNamespace(discoverInfo)); UploadService.Version version; if (discoverInfo.containsFeature(NAMESPACE)) { version = Version.v0_3; } else if (discoverInfo.containsFeature(NAMESPACE_0_2)) { version = Version.v0_2; } else { throw new AssertionError(); } DomainBareJid address = discoverInfo.getFrom().asDomainBareJid(); DataForm dataForm = DataForm.from(discoverInfo); if (dataForm == null) { return new UploadService(address, version); } FormField field = dataForm.getField("max-file-size"); if (field == null) { return new UploadService(address, version); } String maxFileSizeValue = field.getFirstValue(); if (maxFileSizeValue == null) { // This is likely an implementation error of the upload component, because the max-file-size form field is // there but has no value set. return new UploadService(address, version); } Long maxFileSize = Long.valueOf(maxFileSizeValue); return new UploadService(address, version, maxFileSize); }