Package rocks.xmpp.extensions.data.model

Examples of rocks.xmpp.extensions.data.model.DataForm$Item


                "  </field>\n" +
                "  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>\n" +
                "  </field>\n" +
                "</x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().size(), 3);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getLabel(), "Personal Information");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getText().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(0).getVar(), "name.first");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(1).getVar(), "name.last");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(2).getVar(), "email");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(3).getVar(), "jid");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(4).getVar(), "background");
    }
View Full Code Here


                "      <fieldref var='reasoning'/>\n" +
                "    </section>\n" +
                "  </page>\n" +
                "</x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().size(), 3);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getLabel(), "Personal Information");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().size(), 2);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(0).getFieldReferences().get(0).getVar(), "name.first");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(0).getFieldReferences().get(1).getVar(), "name.last");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(1).getFieldReferences().get(0).getVar(), "email");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(1).getFieldReferences().get(1).getVar(), "jid");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(0).getVar(), "background");
    }
View Full Code Here

                "    </section>\n" +
                "    <reportedref var='background'/>\n" +
                "  </page>\n" +
                "</x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getReportedReference().getVar(), "background");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getReportedReference().getVar(), "name.first");
    }
View Full Code Here

     *
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#requestvoice">7.13 Requesting Voice</a>
     */
    public void requestVoice() {
        Message message = new Message(roomJid);
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
        RequestVoiceForm requestVoiceForm = new RequestVoiceForm(dataForm);
        requestVoiceForm.setRole(Role.PARTICIPANT);
        message.getExtensions().add(dataForm);
        xmppSession.send(message);
    }
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#createroom-instant">10.1.2 Creating an Instant Room</a>
     */
    public void createRoom() throws XmppException {
        enter(nick);
        xmppSession.query(new IQ(roomJid, IQ.Type.SET, new MucOwner(new DataForm(DataForm.Type.SUBMIT))));
    }
View Full Code Here

                "             var='invitelist'>\n" +
                "        <desc>Tell all your friends about your new bot!</desc>\n" +
                "      </field>\n" +
                "    </x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getType(), DataForm.Type.FORM);
        Assert.assertEquals(dataForm.getTitle(), "Bot Configuration");
        Assert.assertEquals(dataForm.getInstructions().get(0), "Fill out this form to configure your new bot!");

        Assert.assertEquals(dataForm.getFields().size(), 12);
        Assert.assertEquals(dataForm.getFields().get(0).getValues().get(0), "jabber:bot");
        Assert.assertEquals(dataForm.getFields().get(0).getType(), DataForm.Field.Type.HIDDEN);
        Assert.assertEquals(dataForm.getFields().get(0).getVar(), "FORM_TYPE");

        Assert.assertEquals(dataForm.getFields().get(1).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(1).getValues().get(0), "Section 1: Bot Info");

        Assert.assertEquals(dataForm.getFields().get(2).getType(), DataForm.Field.Type.TEXT_SINGLE);
        Assert.assertEquals(dataForm.getFields().get(2).getVar(), "botname");
        Assert.assertEquals(dataForm.getFields().get(2).getLabel(), "The name of your bot");

        Assert.assertEquals(dataForm.getFields().get(3).getType(), DataForm.Field.Type.TEXT_MULTI);
        Assert.assertEquals(dataForm.getFields().get(3).getVar(), "description");
        Assert.assertEquals(dataForm.getFields().get(3).getLabel(), "Helpful description of your bot");

        Assert.assertEquals(dataForm.getFields().get(4).getType(), DataForm.Field.Type.BOOLEAN);
        Assert.assertEquals(dataForm.getFields().get(4).getVar(), "public");
        Assert.assertEquals(dataForm.getFields().get(4).getLabel(), "Public bot?");

        Assert.assertEquals(dataForm.getFields().get(5).getType(), DataForm.Field.Type.TEXT_PRIVATE);
        Assert.assertEquals(dataForm.getFields().get(5).getVar(), "password");
        Assert.assertEquals(dataForm.getFields().get(5).getLabel(), "Password for special access");

        Assert.assertEquals(dataForm.getFields().get(6).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(6).getValues().get(0), "Section 2: Features");

        Assert.assertEquals(dataForm.getFields().get(7).getType(), DataForm.Field.Type.LIST_MULTI);
        Assert.assertEquals(dataForm.getFields().get(7).getVar(), "features");
        Assert.assertEquals(dataForm.getFields().get(7).getLabel(), "What features will the bot support?");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().size(), 5);
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(0).getLabel(), "Contests");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(0).getValue(), "contests");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(1).getLabel(), "News");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(1).getValue(), "news");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(2).getLabel(), "Polls");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(2).getValue(), "polls");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(3).getLabel(), "Reminders");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(3).getValue(), "reminders");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(4).getLabel(), "Search");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(4).getValue(), "search");
        Assert.assertEquals(dataForm.getFields().get(7).getValues().get(0), "news");
        Assert.assertEquals(dataForm.getFields().get(7).getValues().get(1), "search");

        Assert.assertEquals(dataForm.getFields().get(8).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(8).getValues().get(0), "Section 3: Subscriber List");

        Assert.assertEquals(dataForm.getFields().get(9).getType(), DataForm.Field.Type.LIST_SINGLE);
        Assert.assertEquals(dataForm.getFields().get(9).getVar(), "maxsubs");
        Assert.assertEquals(dataForm.getFields().get(9).getLabel(), "Maximum number of subscribers");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().size(), 6);
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(0).getLabel(), "10");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(0).getValue(), "10");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(1).getLabel(), "20");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(1).getValue(), "20");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(2).getLabel(), "30");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(2).getValue(), "30");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(3).getLabel(), "50");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(3).getValue(), "50");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(4).getLabel(), "100");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(4).getValue(), "100");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(5).getLabel(), "None");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(5).getValue(), "none");
        Assert.assertEquals(dataForm.getFields().get(9).getValues().get(0), "20");

        Assert.assertEquals(dataForm.getFields().get(10).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(10).getValues().get(0), "Section 4: Invitations");

        Assert.assertEquals(dataForm.getFields().get(11).getType(), DataForm.Field.Type.JID_MULTI);
        Assert.assertEquals(dataForm.getFields().get(11).getVar(), "invitelist");
        Assert.assertEquals(dataForm.getFields().get(11).getLabel(), "People to invite");

        Assert.assertNotNull(dataForm.findField("FORM_TYPE"));
    }
View Full Code Here

     */
    public int requestNumberOfMessages() throws XmppException {
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoDiscovery = serviceDiscoveryManager.discoverInformation(null, OfflineMessage.NAMESPACE);
        if (!infoDiscovery.getExtensions().isEmpty()) {
            DataForm dataForm = infoDiscovery.getExtensions().get(0);
            if (dataForm != null) {
                for (DataForm.Field field : dataForm.getFields()) {
                    if ("number_of_messages".equals(field.getVar())) {
                        String numberOfMessages = field.getValues().get(0);
                        return Integer.parseInt(numberOfMessages);
                    }
                }
View Full Code Here

        IQ iq = unmarshal(xml, IQ.class);
        Search search = iq.getExtension(Search.class);

        Assert.assertNotNull(search);

        DataForm dataForm = search.getAdditionalInformation();
        Assert.assertNotNull(dataForm);
        Assert.assertNotNull(dataForm.getReportedFields());
        Assert.assertEquals(dataForm.getReportedFields().size(), 4);
        Assert.assertEquals(dataForm.getReportedFields().get(0).getVar(), "first");
        Assert.assertEquals(dataForm.getReportedFields().get(0).getLabel(), "Given Name");
        Assert.assertEquals(dataForm.getReportedFields().get(0).getType(), DataForm.Field.Type.TEXT_SINGLE);

        Assert.assertEquals(dataForm.getItems().size(), 2);
        Assert.assertEquals(dataForm.getItems().get(0).getFields().size(), 4);
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(0).getValues().get(0), "Benvolio");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(0).getVar(), "first");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(1).getValues().get(0), "Montague");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(1).getVar(), "last");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(2).getValues().get(0), "benvolio@montague.net");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(2).getVar(), "jid");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(3).getValues().get(0), "male");
        Assert.assertEquals(dataForm.getItems().get(0).getFields().get(3).getVar(), "x-gender");

        Assert.assertEquals(dataForm.getItems().get(1).getFields().size(), 4);
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(0).getValues().get(0), "Romeo");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(0).getVar(), "first");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(1).getValues().get(0), "Montague");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(1).getVar(), "last");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(2).getValues().get(0), "romeo@montague.net");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(2).getVar(), "jid");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(3).getValues().get(0), "male");
        Assert.assertEquals(dataForm.getItems().get(1).getFields().get(3).getVar(), "x-gender");
    }
View Full Code Here

                "  </validate>\n" +
                "  <value>2003-10-06T11:22:00-07:00</value>\n" +
                "</field>" +
                "</x>";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Validation validation = dataForm.getFields().get(0).getValidation();
        Assert.assertNotNull(validation);
        Assert.assertEquals(validation.getDataType(), "xs:dateTime");
        Assert.assertTrue(validation.getValidationMethod() instanceof Validation.ValidationMethod.Basic);
    }
View Full Code Here

                "  <option><value>reminder</value></option>\n" +
                "  <option><value>appointment</value></option>\n" +
                "</field>" +
                "</x>";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Validation validation = dataForm.getFields().get(0).getValidation();
        Assert.assertNotNull(validation);
        Assert.assertEquals(validation.getDataType(), "xs:string");
        Assert.assertTrue(validation.getValidationMethod() instanceof Validation.ValidationMethod.Open);
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.data.model.DataForm$Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.