本文整理汇总了Java中org.jivesoftware.smackx.xdata.packet.DataForm类的典型用法代码示例。如果您正苦于以下问题:Java DataForm类的具体用法?Java DataForm怎么用?Java DataForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataForm类属于org.jivesoftware.smackx.xdata.packet包,在下文中一共展示了DataForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createNodeToAllowComments
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
public void createNodeToAllowComments(String blogPostId) {
String nodeName = PublishCommentExtension.NODE + "/" + blogPostId;
PubSubManager pubSubManager = PubSubManager.getInstance(XMPPSession.getInstance().getXMPPConnection());
try {
// create node
ConfigureForm configureForm = new ConfigureForm(DataForm.Type.submit);
configureForm.setPublishModel(PublishModel.open);
configureForm.setAccessModel(AccessModel.open);
Node node = pubSubManager.createNode(nodeName, configureForm);
// subscribe to comments
String myJIDString = getUser().toString();
node.subscribe(myJIDString);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
e.printStackTrace();
}
}
开发者ID:esl,项目名称:mangosta-android,代码行数:19,代码来源:XMPPSession.java
示例2: createInitiationAccept
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例3: parseItem
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例4: parseReported
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例5: verifyPacketExtensions
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例6: validateRoomWithForm
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例7: processStanza
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例8: prepareKeyPacket
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例9: createValidationForm
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例10: requestVoice
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的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
示例11: createReturnExtension
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
@Override
protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content)
{
if (content.size() == 0)
return new ConfigurationEvent(attMap.get("node"));
else
return new ConfigurationEvent(attMap.get("node"), new ConfigureForm((DataForm)content.iterator().next()));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:ConfigEventProvider.java
示例12: getReportedDataFrom
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
/**
* Returns a new ReportedData if the stanza(/packet) is used for reporting data and includes an
* extension that matches the elementName and namespace "x","jabber:x:data".
*
* @param packet the stanza(/packet) used for reporting data.
*/
public static ReportedData getReportedDataFrom(Stanza packet) {
// Check if the packet includes the DataForm extension
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {
if (dataForm.getReportedData() != null)
return new ReportedData(dataForm);
}
// Otherwise return null
return null;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:ReportedData.java
示例13: getStreamMethodField
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
private FormField getStreamMethodField(DataForm form) {
for (FormField field : form.getFields()) {
if (field.getVariable().equals(STREAM_DATA_FIELD_NAME)) {
return field;
}
}
return null;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:FileTransferNegotiator.java
示例14: createDefaultInitiationForm
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
private DataForm createDefaultInitiationForm() {
DataForm form = new DataForm(DataForm.Type.form);
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
field.setType(FormField.Type.list_single);
if (!IBB_ONLY) {
field.addOption(new FormField.Option(Bytestream.NAMESPACE));
}
field.addOption(new FormField.Option(DataPacketExtension.NAMESPACE));
form.addField(field);
return form;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:FileTransferNegotiator.java
示例15: getFormFrom
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
/**
* Returns a new ReportedData if the stanza(/packet) is used for gathering data and includes an
* extension that matches the elementName and namespace "x","jabber:x:data".
*
* @param packet the stanza(/packet) used for gathering data.
* @return the data form parsed from the stanza(/packet) or <tt>null</tt> if there was not
* a form in the packet.
*/
public static Form getFormFrom(Stanza packet) {
// Check if the packet includes the DataForm extension
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {
if (dataForm.getReportedData() == null)
return new Form(dataForm);
}
// Otherwise return null
return null;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:19,代码来源:Form.java
示例16: getDataFormToSend
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
/**
* Returns a DataForm that serves to send this Form to the server. If the form is of type
* submit, it may contain fields with no value. These fields will be removed since they only
* exist to assist the user while editing/completing the form in a UI.
*
* @return the wrapped DataForm.
*/
public DataForm getDataFormToSend() {
if (isSubmitType()) {
// Create a new DataForm that contains only the answered fields
DataForm dataFormToSend = new DataForm(getType());
for(FormField field : getFields()) {
if (!field.getValues().isEmpty()) {
dataFormToSend.addField(field);
}
}
return dataFormToSend;
}
return dataForm;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:Form.java
示例17: createAnswerForm
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
/**
* Returns a new Form to submit the completed values. The new Form will include all the fields
* of the original form except for the fields of type FIXED. Only the HIDDEN fields will
* include the same value of the original form. The other fields of the new form MUST be
* completed. If a field remains with no answer when sending the completed form, then it won't
* be included as part of the completed form.<p>
*
* The reason why the fields with variables are included in the new form is to provide a model
* for binding with any UI. This means that the UIs will use the original form (of type
* "form") to learn how to render the form, but the UIs will bind the fields to the form of
* type submit.
*
* @return a Form to submit the completed values.
*/
public Form createAnswerForm() {
if (!isFormType()) {
throw new IllegalStateException("Only forms of type \"form\" could be answered");
}
// Create a new Form
Form form = new Form(DataForm.Type.submit);
for (FormField field : getFields()) {
// Add to the new form any type of field that includes a variable.
// Note: The fields of type FIXED are the only ones that don't specify a variable
if (field.getVariable() != null) {
FormField newField = new FormField(field.getVariable());
newField.setType(field.getType());
form.addField(newField);
// Set the answer ONLY to the hidden fields
if (field.getType() == FormField.Type.hidden) {
// Since a hidden field could have many values we need to collect them
// in a list
List<String> values = new ArrayList<String>();
for (String value : field.getValues()) {
values.add(value);
}
form.setAnswer(field.getVariable(), values);
}
}
}
return form;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:42,代码来源:Form.java
示例18: validateRoomWithEmptyForm
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
@Test
public void validateRoomWithEmptyForm() {
DataForm dataForm = new DataForm(DataForm.Type.result);
DiscoverInfo discoInfo = new DiscoverInfo();
discoInfo.addExtension(dataForm);
RoomInfo roomInfo = new RoomInfo(discoInfo);
assertTrue(roomInfo.getDescription().isEmpty());
assertTrue(roomInfo.getSubject().isEmpty());
assertEquals(-1, roomInfo.getOccupantsCount());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:RoomInfoTest.java
示例19: checkChildrenAssocPolicy
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
@Test
public void checkChildrenAssocPolicy()
{
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:ConfigureFormTest.java
示例20: testLayoutFromFile
import org.jivesoftware.smackx.xdata.packet.DataForm; //导入依赖的package包/类
@Test
public void testLayoutFromFile() throws XmlPullParserException, IOException, SmackException {
DataFormProvider pr = new DataFormProvider();
XmlPullParser parser = PacketParserUtils.newXmppParser();
parser.setInput(new InputStreamReader(this.getClass().getResourceAsStream(TEST_INPUT_1), "UTF-8"));
parser.next();
DataForm form = pr.parse(parser);
assertNotNull( form);
assertEquals(1 , form.getExtensionElements().size());
DataLayout layout = (DataLayout) form.getExtensionElements().get(0);
assertEquals(5 , layout.getPageLayout().size());
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());
Section section = (Section) layout.getPageLayout().get(1);
assertEquals("section Label - & \u00E9 \u00E1 ", section.getLabel());
Text text = (Text)layout.getPageLayout().get(2);
assertEquals("PageText - & \u00E9 \u00E1 ", text.getText());
section = (Section) layout.getPageLayout().get(3);
assertEquals("<html>Number of Persons by<br/> Nationality and Status</html>", section.getLabel());
text = (Text) layout.getPageLayout().get(4);
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
assertNotNull( layout.toXML());
String output = layout.toXML().toString();
assertEquals(TEST_OUTPUT_SPECIAL, output);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:31,代码来源:DataLayoutTest.java
注:本文中的org.jivesoftware.smackx.xdata.packet.DataForm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论