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

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

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

Message.getSubject介绍

[英]Returns the default subject of the message, or null if the subject has not been set. The subject is a short description of message contents.

The default subject of a message is the subject that corresponds to the message's language. (see #getLanguage()) or if no language is set to the applications default language (see Packet#getDefaultLanguage()).
[中]返回消息的默认主题,如果未设置主题,则返回null。主题是对消息内容的简短描述。
消息的默认主题是与消息语言对应的主题。(请参阅#getLanguage())或如果没有将任何语言设置为应用程序默认语言(请参阅数据包#getDefaultLanguage())。

代码示例

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

@Override
protected boolean acceptSpecific(Message message) {
  // Accept only messages which have a subject set
  return message.getSubject() != null;
}

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

assertEquals(defaultLanguage, message.getSubject());
assertTrue(message.getSubjectLanguages().isEmpty());
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
assertNull(message.getSubject(otherLanguage));
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(otherLanguage, message.getSubject());
assertTrue(message.getSubjectLanguages().isEmpty());
assertEquals(otherLanguage, message.getSubject(otherLanguage));
assertNull(message.getSubject(defaultLanguage));
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(defaultLanguage, message.getSubject());
assertTrue(message.getSubjectLanguages().isEmpty());
assertEquals(defaultLanguage, message.getSubject(null));
assertNull(message.getSubject(otherLanguage));
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
assertNull(message.getSubject(otherLanguage));
assertNull(message.getSubject());
assertFalse(message.getSubjectLanguages().isEmpty());
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
assertEquals(otherLanguage, message.getSubject(otherLanguage));
assertNull(message.getSubject(defaultLanguage));
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertNull(message.getSubject());

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

.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
assertEquals(otherLanguage, message.getSubject(otherLanguage));
assertEquals(2, message.getSubjects().size());
assertEquals(1, message.getSubjectLanguages().size());
        .parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
assertEquals(1, message.getSubjects().size());
assertEquals(0, message.getSubjectLanguages().size());
        .parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(otherLanguage, message.getSubject());
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
assertEquals(2, message.getSubjects().size());
assertEquals(1, message.getSubjectLanguages().size());

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

/**
 * Returns the default subject of the message, or null if the subject has not been set.
 * The subject is a short description of message contents.
 * <p>
 * The default subject of a message is the subject that corresponds to the message's language.
 * (see {@link #getLanguage()}) or if no language is set to the applications default
 * language (see {@link Stanza#getDefaultLanguage()}).
 *
 * @return the subject of the message.
 */
public String getSubject() {
  return getSubject(null);
}

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

@Override
  public boolean accept(Stanza packet) {
    Message msg = (Message) packet;
    return subject.equals(msg.getSubject());
  }
});

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

@Override
  public void processStanza(Stanza packet) {
    final Message msg = (Message) packet;
    final EntityFullJid from = msg.getFrom().asEntityFullJidIfPossible();
    // Update the room subject
    subject = msg.getSubject();
    asyncButOrdered.performAsyncButOrdered(MultiUserChat.this, new Runnable() {
      @Override
      public void run() {
        // Fire event for subject updated listeners
        for (SubjectUpdatedListener listener : subjectUpdatedListeners) {
          listener.subjectUpdated(msg.getSubject(), from);
        }
      }
    });
  }
};

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

@Test
public void setMessageSubjectTest() throws IOException, SAXException {
  final String messageSubject = "This is a test of the emergency broadcast system.";
  StringBuilder controlBuilder = new StringBuilder();
  controlBuilder.append("<message>")
      .append("<subject>")
      .append(messageSubject)
      .append("</subject>")
      .append("</message>");
  String control = controlBuilder.toString();
  Message message = getNewMessage();
  message.setSubject(messageSubject);
  assertEquals(messageSubject, message.getSubject());
  assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

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

String subject = parseElementText(parser);
if (message.getSubject(xmlLangSubject) == null) {
  message.addSubject(xmlLangSubject, subject);

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

assertEquals("Subjects are different", msg.getSubject(), msg2.getSubject());
assertEquals("Bodies are different", msg.getBody(), msg2.getBody());
assertEquals(

代码示例来源:origin: spring-projects/spring-integration

@Override
protected Map<String, Object> extractStandardHeaders(Message source) {
  Map<String, Object> headers = new HashMap<>();
  Jid from = source.getFrom();
  if (from != null) {
    headers.put(XmppHeaders.FROM, from.toString());
  }
  String subject = source.getSubject();
  if (StringUtils.hasText(subject)) {
    headers.put(XmppHeaders.SUBJECT, subject);
  }
  String thread = source.getThread();
  if (StringUtils.hasText(thread)) {
    headers.put(XmppHeaders.THREAD, thread);
  }
  Jid to = source.getTo();
  if (to != null) {
    headers.put(XmppHeaders.TO, to.toString());
  }
  Message.Type type = source.getType();
  if (type != null) {
    headers.put(XmppHeaders.TYPE, type);
  }
  return headers;
}

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

public boolean accept(Packet packet) {
    Message msg = (Message) packet;
    return msg.getSubject() != null;
  }
};

代码示例来源:origin: org.mobicents.resources/mobicents-slee-ra-xmpp-library

public boolean accept(Packet packet) {
    Message msg = (Message) packet;
    return msg.getSubject() != null;
  }
});

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

public boolean accept(Packet packet) {
    Message msg = (Message) packet;
    return msg.getSubject() != null;
  }
};

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

public boolean accept(Packet packet) {
    Message msg = (Message) packet;
    return subject.equals(msg.getSubject());
  }
});

代码示例来源:origin: org.mobicents.resources/mobicents-slee-ra-xmpp-library

public boolean accept(Packet packet) {
    Message msg = (Message) packet;
    return subject.equals(msg.getSubject());
  }
});

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

public void processPacket(Packet packet) {
    Message msg = (Message) packet;
    // Update the room subject
    subject = msg.getSubject();
    // Fire event for subject updated listeners
    fireSubjectUpdatedListeners(
      msg.getSubject(),
      msg.getFrom());
  }
};

代码示例来源:origin: org.mobicents.resources/mobicents-slee-ra-xmpp-library

public void processPacket(Packet packet) {
    Message msg = (Message) packet;
    // Update the room subject
    subject = msg.getSubject();
    // Fire event for subject updated listeners
    fireSubjectUpdatedListeners(
      msg.getSubject(),
      msg.getFrom());
    
  }
};

代码示例来源:origin: spring-projects/spring-integration

assertNull(target.getTo());
assertNull(target.getFrom());
assertNull(target.getSubject());
assertEquals(Message.Type.normal, target.getType());

代码示例来源:origin: spring-projects/spring-integration

@Test
public void fromHeadersStandardOutbound() {
  DefaultXmppHeaderMapper mapper = new DefaultXmppHeaderMapper();
  Map<String, Object> headerMap = new HashMap<>();
  headerMap.put("userDefined1", "foo");
  headerMap.put("userDefined2", "bar");
  headerMap.put(XmppHeaders.THREAD, "test.thread");
  headerMap.put(XmppHeaders.TO, "test.to");
  headerMap.put(XmppHeaders.FROM, "test.from");
  headerMap.put(XmppHeaders.SUBJECT, "test.subject");
  headerMap.put(XmppHeaders.TYPE, "headline");
  MessageHeaders headers = new MessageHeaders(headerMap);
  Message target = new Message();
  mapper.fromHeadersToRequest(headers, target);
  // "standard" XMPP headers
  assertEquals("test.thread", target.getThread());
  assertEquals("test.to", target.getTo().toString());
  assertEquals("test.from", target.getFrom().toString());
  assertEquals("test.subject", target.getSubject());
  assertEquals(Message.Type.headline, target.getType());
  // user-defined headers not included by default
  assertNull(JivePropertiesManager.getProperty(target, "userDefined1"));
  assertNull(JivePropertiesManager.getProperty(target, "userDefined2"));
  // transient headers should not be copied
  assertNull(JivePropertiesManager.getProperty(target, "id"));
  assertNull(JivePropertiesManager.getProperty(target, "timestamp"));
}

代码示例来源:origin: org.mule.transports/mule-transport-xmpp

private void addXmppMessageProperties(Message message, Map<String, Object> properties)
  {
    properties.put(XmppConnector.XMPP_SUBJECT, message.getSubject());
    properties.put(XmppConnector.XMPP_THREAD, message.getThread());
  }
}

相关文章