当前位置: 首页>>代码示例>>Java>>正文


Java FormField类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.FormField的典型用法代码示例。如果您正苦于以下问题:Java FormField类的具体用法?Java FormField怎么用?Java FormField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormField类属于org.jivesoftware.smackx包,在下文中一共展示了FormField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
protected void setUp() throws Exception {
    //SmackConfiguration.DEBUG = false;
    super.setUp();
    room = "[email protected]" + getMUCDomain();
    try {
        // User1 creates the room
        muc = new MultiUserChat(getConnection(0), room);
        muc.create("testbot");

        // User1 sends an empty room configuration form which indicates that we want
        // an instant room
        Form form = new Form(Form.TYPE_SUBMIT);
        FormField field = new FormField("muc#roomconfig_whois");
        field.setType("list-single");
        form.addField(field);
        form.setAnswer("muc#roomconfig_whois", Arrays.asList("moderators"));
        muc.sendConfigurationForm(form);
    }
    catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:MultiUserChatTest.java

示例2: testSubscribeConfigRequired

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
public void testSubscribeConfigRequired() throws Exception
{
	ConfigureForm form = new ConfigureForm(FormType.submit);
	form.setAccessModel(AccessModel.open);
	
	// Openfire specific field - nothing in the spec yet
	FormField required = new FormField("pubsub#subscription_required");
	required.setType(FormField.TYPE_BOOLEAN);
	form.addField(required);
	form.setAnswer("pubsub#subscription_required", true);
	LeafNode node = (LeafNode)getManager().createNode("Pubnode" + System.currentTimeMillis(), form);

	Subscription sub = node.subscribe(getJid());
	
	assertEquals(getJid(), sub.getJid());
	assertNotNull(sub.getId());
	assertEquals(node.getId(), sub.getNode());
	assertEquals(true, sub.isConfigRequired());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:20,代码来源:SubscriberUseCases.java

示例3: createNode

import org.jivesoftware.smackx.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
 * @exception XMPPException
 */
public Node createNode(String name, Form config)
	throws XMPPException
{
	PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
	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().next().equals(NodeType.leaf.toString());
	}

	// Errors will cause exceptions in getReply, so it only returns
	// on success.
	sendPubsubPacket(con, to, Type.SET, request);
	Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
	newNode.setTo(to);
	nodeMap.put(newNode.getId(), newNode);
	
	return newNode;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:36,代码来源:PubSubManager.java

示例4: parseOption

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
private FormField.Option parseOption(XmlPullParser parser) throws Exception {
    boolean done = false;
    FormField.Option option = null;
    String label = parser.getAttributeValue("", "label");
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("value")) {
                option = new FormField.Option(label, parser.nextText());                     
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("option")) {
                done = true;
            }
        }
    }
    return option;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:19,代码来源:DataFormProvider.java

示例5: getItemsToSearch

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
private String getItemsToSearch() {
    StringBuilder buf = new StringBuilder();

    if (form == null) {
        form = Form.getFormFrom(this);
    }

    if (form == null) {
        return "";
    }

    Iterator<FormField> fields = form.getFields();
    while (fields.hasNext()) {
        FormField field = fields.next();
        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:CJC-ivotten,项目名称:androidPN-client.,代码行数:24,代码来源:SimpleUserSearch.java

示例6: 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;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:29,代码来源:StreamNegotiator.java

示例7: RoomInfo

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
RoomInfo(DiscoverInfo info) {
    super();
    this.room = info.getFrom();
    // Get the information based on the discovered features
    this.membersOnly = info.containsFeature("muc_membersonly");
    this.moderated = info.containsFeature("muc_moderated");
    this.nonanonymous = info.containsFeature("muc_nonanonymous");
    this.passwordProtected = info.containsFeature("muc_passwordprotected");
    this.persistent = info.containsFeature("muc_persistent");
    // Get the information based on the discovered extended information
    Form form = Form.getFormFrom(info);
    if (form != null) {
        FormField descField = form.getField("muc#roominfo_description");
        this.description = ( descField == null || !(descField.getValues().hasNext()) )? "" : descField.getValues().next();

        FormField subjField = form.getField("muc#roominfo_subject");
        this.subject = ( subjField == null || !(subjField.getValues().hasNext()) ) ? "" : subjField.getValues().next();

        FormField occCountField = form.getField("muc#roominfo_occupants");
        this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
                .next());
    }
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:24,代码来源:RoomInfo.java

示例8: parseItem

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
private DataForm.Item parseItem(XmlPullParser parser) throws Exception {
    boolean done = false;
    List<FormField> fields = new ArrayList<FormField>();
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("field")) { 
                fields.add(parseField(parser));
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("item")) {
                done = true;
            }
        }
    }
    return new DataForm.Item(fields);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:18,代码来源:DataFormProvider.java

示例9: verifyPacketExtensions

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
/**
 * 
 * @param info
 * @return true if the packet extensions is ill-formed
 */
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
    List<FormField> foundFormTypes = new LinkedList<FormField>();
    for (Iterator<PacketExtension> i = info.getExtensions().iterator(); i.hasNext();) {
        PacketExtension pe = i.next();
        if (pe.getNamespace().equals(Form.NAMESPACE)) {
            DataForm df = (DataForm) pe;
            for (Iterator<FormField> it = df.getFields(); it.hasNext();) {
                FormField f = it.next();
                if (f.getVariable().equals("FORM_TYPE")) {
                    for (FormField fft : foundFormTypes) {
                        if (f.equals(fft))
                            return true;
                    }
                    foundFormTypes.add(f);
                }
            }
        }
    }
    return false;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:26,代码来源:EntityCapsManager.java

示例10: testCreateReservedRoom

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
/**
 * Tests creating a new "Reserved Room".
 */
public void testCreateReservedRoom() {
    MultiUserChat muc = new MultiUserChat(getConnection(0), room);

    try {
        // Create the room
        muc.create("testbot1");

        // Get the the room's configuration form
        Form form = muc.getConfigurationForm();
        assertNotNull("No room configuration form", form);
        // Create a new form to submit based on the original form
        Form submitForm = form.createAnswerForm();
        // Add default answers to the form to submit
        for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
            FormField field = fields.next();
            if (!FormField.TYPE_HIDDEN.equals(field.getType())
                && field.getVariable() != null) {
                // Sets the default value as the answer
                submitForm.setDefaultAnswer(field.getVariable());
            }
        }
        List<String> owners = new ArrayList<String>();
        owners.add(getBareJID(0));
        submitForm.setAnswer("muc#roomconfig_roomowners", owners);

        // Update the new room's configuration
        muc.sendConfigurationForm(submitForm);

        // Destroy the new room
        muc.destroy("The room has almost no activity...", null);

    }
    catch (XMPPException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:41,代码来源:MultiUserChatCreationTest.java

示例11: toString

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
@Override
public String toString()
{
	StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
	
	Iterator<FormField> fields = getFields();
	
	while (fields.hasNext())
	{
		FormField formField = fields.next();
		result.append('(');
		result.append(formField.getVariable());
		result.append(':');
		
		Iterator<String> values = formField.getValues();
		StringBuilder valuesBuilder = new StringBuilder();
			
		while (values.hasNext())
		{
			if (valuesBuilder.length() > 0)
				result.append(',');
			String value = (String)values.next();
			valuesBuilder.append(value);
		}
		
		if (valuesBuilder.length() == 0)
			valuesBuilder.append("NOT SET");
		result.append(valuesBuilder);
		result.append(')');
	}
	result.append(']');
	return result.toString();
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:ConfigureForm.java

示例12: addField

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
private void addField(ConfigureNodeFields nodeField, String type)
{
	String fieldName = nodeField.getFieldName();
	
	if (getField(fieldName) == null)
	{
		FormField field = new FormField(fieldName);
		field.setType(type);
		addField(field);
	}
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:12,代码来源:ConfigureForm.java

示例13: setShowValues

import org.jivesoftware.smackx.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:ice-coffee,项目名称:EIM,代码行数:18,代码来源:SubscribeForm.java

示例14: addField

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
private void addField(SubscribeOptionFields nodeField, String type)
{
	String fieldName = nodeField.getFieldName();
	
	if (getField(fieldName) == null)
	{
		FormField field = new FormField(fieldName);
		field.setType(type);
		addField(field);
	}
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:12,代码来源:SubscribeForm.java

示例15: toXML

import org.jivesoftware.smackx.FormField; //导入依赖的package包/类
public String toXML() {
    StringBuilder buf = new StringBuilder();
    buf.append("<item>");
    // Loop through all the form items and append them to the string buffer
    for (Iterator<FormField> i = getFields(); i.hasNext();) {
        FormField field = i.next();
        buf.append(field.toXML());
    }
    buf.append("</item>");
    return buf.toString();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:12,代码来源:DataForm.java


注:本文中的org.jivesoftware.smackx.FormField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。