本文整理汇总了Java中org.jivesoftware.smackx.FormField.addValue方法的典型用法代码示例。如果您正苦于以下问题:Java FormField.addValue方法的具体用法?Java FormField.addValue怎么用?Java FormField.addValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.FormField
的用法示例。
在下文中一共展示了FormField.addValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInitiationAccept
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
/**
* Creates the initiation acceptance packet to forward to the stream
* initiator.
*
* @param streamInitiationOffer The offer from the stream initiator to connect for a stream.
* @param namespaces The namespace that relates to the accepted means of transfer.
* @return The response to be forwarded to the initiator.
*/
public StreamInitiation createInitiationAccept(
StreamInitiation streamInitiationOffer, String[] namespaces)
{
StreamInitiation response = new StreamInitiation();
response.setTo(streamInitiationOffer.getFrom());
response.setFrom(streamInitiationOffer.getTo());
response.setType(IQ.Type.RESULT);
response.setPacketID(streamInitiationOffer.getPacketID());
DataForm form = new DataForm(Form.TYPE_SUBMIT);
FormField field = new FormField(
FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
for (String namespace : namespaces) {
field.addValue(namespace);
}
form.addField(field);
response.setFeatureNegotiationForm(form);
return response;
}
示例2: parseField
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
private FormField parseField(XmlPullParser parser) throws Exception {
boolean done = false;
FormField formField = new FormField(parser.getAttributeValue("", "var"));
formField.setLabel(parser.getAttributeValue("", "label"));
formField.setType(parser.getAttributeValue("", "type"));
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("desc")) {
formField.setDescription(parser.nextText());
}
else if (parser.getName().equals("value")) {
formField.addValue(parser.nextText());
}
else if (parser.getName().equals("required")) {
formField.setRequired(true);
}
else if (parser.getName().equals("option")) {
formField.addOption(parseOption(parser));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("field")) {
done = true;
}
}
}
return formField;
}