org.jivesoftware.smack.packet.Message.removeBody()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.jivesoftware.smack.packet.Message.removeBody()方法的一些代码示例,展示了Message.removeBody()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.removeBody()方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:removeBody

Message.removeBody介绍

[英]Removes the body with the given language from the message.
[中]从消息中删除具有给定语言的正文。

代码示例

代码示例来源:origin: igniterealtime/Smack

/**
 * Sets the body of the message. The body is the main message contents.
 *
 * @param body the body of the message.
 */
public void setBody(String body) {
  if (body == null) {
    removeBody(""); // use empty string because #removeBody(null) is ambiguous
    return;
  }
  addBody(null, body);
}

代码示例来源:origin: igniterealtime/Smack

/**
 * Adds a body with a corresponding language.
 *
 * @param language the language of the body being added.
 * @param body the body being added to the message.
 * @return the new {@link org.jivesoftware.smack.packet.Message.Body}
 * @throws NullPointerException if the body is null, a null pointer exception is thrown
 * @since 3.0.2
 */
public Body addBody(String language, String body) {
  language = determineLanguage(language);
  removeBody(language);
  Body messageBody = new Body(language, body);
  addExtension(messageBody);
  return messageBody;
}

代码示例来源:origin: igniterealtime/Smack

@Test
public void removeMessageBodyTest() {
  Message message = getNewMessage();
  message.setBody("test");
  assertTrue(message.getBodies().size() == 1);
  message.setBody(null);
  assertTrue(message.getBodies().size() == 0);
  assertFalse(message.removeBody("sp"));
  Message.Body body = message.addBody("es", "test");
  assertTrue(message.getBodies().size() == 1);
  message.removeBody(body);
  assertTrue(message.getBodies().size() == 0);
}

代码示例来源:origin: tiandawu/IotXmpp

/**
 * Sets the body of the message. The body is the main message contents.
 *
 * @param body the body of the message.
 */
public void setBody(String body) {
  if (body == null) {
    removeBody(""); // use empty string because #removeBody(null) is ambiguous
    return;
  }
  addBody(null, body);
}

代码示例来源:origin: org.igniterealtime.smack/smack

/**
 * Sets the body of the message. The body is the main message contents.
 *
 * @param body the body of the message.
 */
public void setBody(String body) {
  if (body == null) {
    removeBody(""); // use empty string because #removeBody(null) is ambiguous
    return;
  }
  addBody(null, body);
}

代码示例来源:origin: org.igniterealtime.smack/smack-core

/**
 * Sets the body of the message. The body is the main message contents.
 *
 * @param body the body of the message.
 */
public void setBody(String body) {
  if (body == null) {
    removeBody(""); // use empty string because #removeBody(null) is ambiguous
    return;
  }
  addBody(null, body);
}

代码示例来源:origin: org.littleshoot/smack-xmpp-3-2-2

/**
 * Sets the body of the message. The body is the main message contents.
 *
 * @param body the body of the message.
 */
public void setBody(String body) {
  if (body == null) {
    removeBody(""); // use empty string because #removeBody(null) is ambiguous
    return;
  }
  addBody(null, body);
}

代码示例来源:origin: org.igniterealtime.smack/smack-core

/**
 * Adds a body with a corresponding language.
 *
 * @param language the language of the body being added.
 * @param body the body being added to the message.
 * @return the new {@link org.jivesoftware.smack.packet.Message.Body}
 * @throws NullPointerException if the body is null, a null pointer exception is thrown
 * @since 3.0.2
 */
public Body addBody(String language, String body) {
  language = determineLanguage(language);
  removeBody(language);
  Body messageBody = new Body(language, body);
  addExtension(messageBody);
  return messageBody;
}

相关文章