本文整理汇总了Java中org.jivesoftware.smackx.xdata.FormField类的典型用法代码示例。如果您正苦于以下问题:Java FormField类的具体用法?Java FormField怎么用?Java FormField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormField类属于org.jivesoftware.smackx.xdata包,在下文中一共展示了FormField类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createNode
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
* Creates a node with specified configuration.
*
* Note: This is the only way to create a collection node.
*
* @param name The name of the node, which must be unique within the
* pubsub service
* @param config The configuration for the node
* @return The node that was created
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null);
boolean isLeafNode = true;
if (config != null)
{
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
}
// Errors will cause exceptions in getReply, so it only returns
// on success.
sendPubsubPacket(con, request);
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:37,代码来源:PubSubManager.java
示例2: getItemsToSearch
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private String getItemsToSearch() {
StringBuilder buf = new StringBuilder();
if (form == null) {
form = Form.getFormFrom(this);
}
if (form == null) {
return "";
}
for (FormField field : form.getFields()) {
String name = field.getVariable();
String value = getSingleValue(field);
if (value.trim().length() > 0) {
buf.append("<").append(name).append(">").append(value).append("</").append(name).append(">");
}
}
return buf.toString();
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:SimpleUserSearch.java
示例3: createInitiationAccept
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
* Creates the initiation acceptance stanza(/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.
*/
protected static StreamInitiation createInitiationAccept(
StreamInitiation streamInitiationOffer, String[] namespaces)
{
StreamInitiation response = new StreamInitiation();
response.setTo(streamInitiationOffer.getFrom());
response.setFrom(streamInitiationOffer.getTo());
response.setType(IQ.Type.result);
response.setStanzaId(streamInitiationOffer.getStanzaId());
DataForm form = new DataForm(DataForm.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;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:StreamNegotiator.java
示例4: parseItem
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private DataForm.Item parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
List<FormField> fields = new ArrayList<FormField>();
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "field":
fields.add(parseField(parser));
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new DataForm.Item(fields);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:DataFormProvider.java
示例5: parseReported
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private DataForm.ReportedData parseReported(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
List<FormField> fields = new ArrayList<FormField>();
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "field":
fields.add(parseField(parser));
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new DataForm.ReportedData(fields);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:DataFormProvider.java
示例6: parseOption
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private FormField.Option parseOption(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
FormField.Option option = null;
String label = parser.getAttributeValue("", "label");
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "value":
option = new FormField.Option(label, parser.nextText());
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return option;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:DataFormProvider.java
示例7: verifyPacketExtensions
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
*
* @param info
* @return true if the stanza(/packet) extensions is ill-formed
*/
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
List<FormField> foundFormTypes = new LinkedList<FormField>();
for (ExtensionElement pe : info.getExtensions()) {
if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
DataForm df = (DataForm) pe;
for (FormField f : df.getFields()) {
if (f.getVariable().equals("FORM_TYPE")) {
for (FormField fft : foundFormTypes) {
if (f.equals(fft))
return true;
}
foundFormTypes.add(f);
}
}
}
}
return false;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:EntityCapsManager.java
示例8: checkNonMultiConsistency
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
* @param formField
* @param method
*/
protected void checkNonMultiConsistency(FormField formField, String method) {
checkListRangeConsistency(formField);
if (formField.getType() != null) {
switch (formField.getType()) {
case hidden:
case jid_multi:
case list_multi:
case text_multi:
throw new ValidationConsistencyException(String.format(
"Field type '%1$s' is not consistent with validation method '%2$s'.",
formField.getType(), method));
default:
break;
}
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:ValidateElement.java
示例9: validateRoomWithForm
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
@Test
public void validateRoomWithForm() {
DataForm dataForm = new DataForm(DataForm.Type.result);
FormField desc = new FormField("muc#roominfo_description");
desc.addValue("The place for all good witches!");
dataForm.addField(desc);
FormField subject = new FormField("muc#roominfo_subject");
subject.addValue("Spells");
dataForm.addField(subject);
FormField occupants = new FormField("muc#roominfo_occupants");
occupants.addValue("3");
dataForm.addField(occupants);
DiscoverInfo discoInfo = new DiscoverInfo();
discoInfo.addExtension(dataForm);
RoomInfo roomInfo = new RoomInfo(discoInfo);
assertEquals("The place for all good witches!", roomInfo.getDescription());
assertEquals("Spells", roomInfo.getSubject());
assertEquals(3, roomInfo.getOccupantsCount());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:RoomInfoTest.java
示例10: test
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
@Test
public void test() throws XmlPullParserException, IOException, SmackException {
//Build a Form
DataForm df = new DataForm(DataForm.Type.submit);
String instruction = "InstructionTest1";
df.addInstruction(instruction);
FormField field = new FormField("testField1");
df.addField(field);
assertNotNull( df.toXML());
String output = df.toXML().toString();
assertEquals(TEST_OUTPUT_1, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
df = pr.parse(parser);
assertNotNull(df);
assertNotNull(df.getFields());
assertEquals(1 , df.getFields().size() );
assertEquals(1 , df.getInstructions().size());
assertNotNull( df.toXML());
output = df.toXML().toString();
assertEquals(TEST_OUTPUT_1, output);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:DataFormTest.java
示例11: processStanza
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
@Override
public void processStanza(Stanza packet) {
XMPPConnection conn = getConnection();
conn.removeAsyncStanzaListener(this);
IQ iq = (IQ) packet;
if (iq.getType() != IQ.Type.result) {
finish(XMPPError.Condition.internal_server_error);
return;
}
DataForm response = iq.getExtension("x", "jabber:x:data");
if (response == null) {
finish(XMPPError.Condition.internal_server_error);
return;
}
String token = null;
FormField field = response.getField("token");
if (field != null)
token = field.getValues().get(0);
EndpointServer from = Preferences.getEndpointServer(getContext());
finish(token, from != null ? from.toString() : conn.getXMPPServiceDomain().toString());
}
开发者ID:kontalk,项目名称:androidclient,代码行数:26,代码来源:PrivateKeyUploadListener.java
示例12: prepareKeyPacket
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private Stanza prepareKeyPacket() {
String privatekey = Base64.encodeToString(mPrivateKeyData, Base64.NO_WRAP);
Registration iq = new Registration();
iq.setType(IQ.Type.set);
iq.setTo(getConnection().getServiceName());
Form form = new Form(DataForm.Type.submit);
// form type: register#privatekey
FormField type = new FormField("FORM_TYPE");
type.setType(FormField.Type.hidden);
type.addValue("http://kontalk.org/protocol/register#privatekey");
form.addField(type);
// private key
FormField fieldKey = new FormField("privatekey");
fieldKey.setLabel("Private key");
fieldKey.setType(FormField.Type.text_single);
fieldKey.addValue(privatekey);
form.addField(fieldKey);
iq.addExtension(form.getDataFormToSend());
return iq;
}
开发者ID:kontalk,项目名称:androidclient,代码行数:25,代码来源:PrivateKeyUploadListener.java
示例13: createValidationForm
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private Stanza createValidationForm() throws IOException {
Registration iq = new Registration();
iq.setType(IQ.Type.set);
iq.setTo(mConnector.getConnection().getServiceName());
Form form = new Form(DataForm.Type.submit);
FormField type = new FormField("FORM_TYPE");
type.setType(FormField.Type.hidden);
type.addValue("http://kontalk.org/protocol/register#code");
form.addField(type);
if (mValidationCode != null) {
FormField code = new FormField("code");
code.setLabel("Validation code");
code.setType(FormField.Type.text_single);
code.addValue(mValidationCode.toString());
form.addField(code);
}
iq.addExtension(form.getDataFormToSend());
return iq;
}
开发者ID:kontalk,项目名称:androidclient,代码行数:23,代码来源:NumberValidator.java
示例14: createRegistrationForm
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private Packet createRegistrationForm() {
Registration iq = new Registration();
iq.setType(IQ.Type.SET);
iq.setTo(mConnector.getConnection().getServiceName());
Form form = new Form(Form.TYPE_SUBMIT);
FormField type = new FormField("FORM_TYPE");
type.setType(FormField.TYPE_HIDDEN);
type.addValue("jabber:iq:register");
form.addField(type);
FormField phone = new FormField("phone");
phone.setLabel("Phone number");
phone.setType(FormField.TYPE_TEXT_SINGLE);
phone.addValue(mPhone);
form.addField(phone);
iq.addExtension(form.getDataFormToSend());
return iq;
}
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:21,代码来源:NumberValidator.java
示例15: requestVoice
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
* Sends a voice request to the MUC. The room moderators usually need to approve this request.
*
* @throws NotConnectedException
* @see <a href="http://xmpp.org/extensions/xep-0045.html#requestvoice">XEP-45 § 7.13 Requesting
* Voice</a>
* @since 4.1
*/
public void requestVoice() throws NotConnectedException {
DataForm form = new DataForm(DataForm.Type.submit);
FormField formTypeField = new FormField(FormField.FORM_TYPE);
formTypeField.addValue(MUCInitialPresence.NAMESPACE + "#request");
form.addField(formTypeField);
FormField requestVoiceField = new FormField("muc#role");
requestVoiceField.setType(FormField.Type.text_single);
requestVoiceField.setLabel("Requested role");
requestVoiceField.addValue("participant");
form.addField(requestVoiceField);
Message message = new Message(room);
message.addExtension(form);
connection.sendStanza(message);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:23,代码来源:MultiUserChat.java
示例16: setChildrenAssociationPolicy
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
* Sets the policy that determines who may associate children with the node.
*
* @param policy The policy being set
*/
public void setChildrenAssociationPolicy(ChildrenAssociationPolicy policy)
{
addField(ConfigureNodeFields.children_association_policy, FormField.Type.list_single);
List<String> values = new ArrayList<String>(1);
values.add(policy.toString());
setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:ConfigureForm.java
示例17: toString
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
@Override
public String toString()
{
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields())
{
result.append('(');
result.append(formField.getVariable());
result.append(':');
StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues())
{
if (valuesBuilder.length() > 0)
result.append(',');
valuesBuilder.append(value);
}
if (valuesBuilder.length() == 0)
valuesBuilder.append("NOT SET");
result.append(valuesBuilder);
result.append(')');
}
result.append(']');
return result.toString();
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:ConfigureForm.java
示例18: addField
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private void addField(ConfigureNodeFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);
field.setType(type);
addField(field);
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:ConfigureForm.java
示例19: setShowValues
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
/**
* Sets the list of {@link PresenceState} for which an entity wants
* to receive notifications.
*
* @param stateValues The list of states
*/
public void setShowValues(Collection<PresenceState> stateValues)
{
ArrayList<String> values = new ArrayList<String>(stateValues.size());
for (PresenceState state : stateValues)
{
values.add(state.toString());
}
addField(SubscribeOptionFields.show_values, FormField.Type.list_multi);
setAnswer(SubscribeOptionFields.show_values.getFieldName(), values);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:SubscribeForm.java
示例20: addField
import org.jivesoftware.smackx.xdata.FormField; //导入依赖的package包/类
private void addField(SubscribeOptionFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);
field.setType(type);
addField(field);
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:SubscribeForm.java
注:本文中的org.jivesoftware.smackx.xdata.FormField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论