Java Code Examples for org.jivesoftware.smackx.xdata.FormField#getValues()
The following examples show how to use
org.jivesoftware.smackx.xdata.FormField#getValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MucConfigFormManager.java From Smack with Apache License 2.0 | 6 votes |
/** * Create a new MUC config form manager. * <p> * Note that the answerForm needs to be filled out with the defaults. * </p> * * @param multiUserChat the MUC for this configuration form. * @throws InterruptedException if the calling thread was interrupted. * @throws NotConnectedException if the XMPP connection is not connected. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. */ MucConfigFormManager(MultiUserChat multiUserChat) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { this.multiUserChat = multiUserChat; // Set the answer form Form configForm = multiUserChat.getConfigurationForm(); this.answerForm = configForm.getFillableForm(); // Set the local variables according to the fields found in the answer form FormField roomOwnersFormField = answerForm.getDataForm().getField(MUC_ROOMCONFIG_ROOMOWNERS); if (roomOwnersFormField != null) { // Set 'owners' to the currently configured owners List<? extends CharSequence> ownerStrings = roomOwnersFormField.getValues(); owners = new ArrayList<>(ownerStrings.size()); JidUtil.jidsFrom(ownerStrings, owners, null); } else { // roomowners not supported, this should barely be the case owners = null; } }
Example 2
Source File: FileTransferNegotiator.java From Smack with Apache License 2.0 | 6 votes |
private StreamNegotiator getOutgoingNegotiator(final FormField field) throws NoAcceptableTransferMechanisms { boolean isByteStream = false; boolean isIBB = false; for (CharSequence variable : field.getValues()) { String variableString = variable.toString(); if (variableString.equals(Bytestream.NAMESPACE) && !IBB_ONLY) { isByteStream = true; } else if (variableString.equals(DataPacketExtension.NAMESPACE)) { isIBB = true; } } if (!isByteStream && !isIBB) { throw new FileTransferException.NoAcceptableTransferMechanisms(); } if (isByteStream) { return byteStreamTransferManager; } else { return inbandTransferManager; } }
Example 3
Source File: ConferenceUtils.java From Spark with Apache License 2.0 | 6 votes |
/** * 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; }
Example 4
Source File: FormReader.java From Smack with Apache License 2.0 | 5 votes |
default List<? extends CharSequence> readValues(String fieldName) { FormField formField = getField(fieldName); if (formField == null) { return Collections.emptyList(); } return formField.getValues(); }