1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-07-02 08:16:45 +02:00
Smack/extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientInfo.java
Florian Schmaus 1e57f1c659 Activate checkstyle and add missing license headers
Delete also all "All rights reserved" statements, as they are
unnecessary and conflict with checkstyle's header check. Delete unused
imports.
2014-02-17 20:09:55 +01:00

96 lines
3.7 KiB
Java

/**
*
* Copyright 2003-2006 Jive Software.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.address;
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
import java.util.List;
/**
* MultipleRecipientInfo keeps information about the multiple recipients extension included
* in a received packet. Among the information we can find the list of TO and CC addresses.
*
* @author Gaston Dombiak
*/
public class MultipleRecipientInfo {
MultipleAddresses extension;
MultipleRecipientInfo(MultipleAddresses extension) {
this.extension = extension;
}
/**
* Returns the list of {@link org.jivesoftware.smackx.address.packet.MultipleAddresses.Address}
* that were the primary recipients of the packet.
*
* @return list of primary recipients of the packet.
*/
public List<MultipleAddresses.Address> getTOAddresses() {
return extension.getAddressesOfType(MultipleAddresses.TO);
}
/**
* Returns the list of {@link org.jivesoftware.smackx.address.packet.MultipleAddresses.Address}
* that were the secondary recipients of the packet.
*
* @return list of secondary recipients of the packet.
*/
public List<MultipleAddresses.Address> getCCAddresses() {
return extension.getAddressesOfType(MultipleAddresses.CC);
}
/**
* Returns the JID of a MUC room to which responses should be sent or <tt>null</tt> if
* no specific address was provided. When no specific address was provided then the reply
* can be sent to any or all recipients. Otherwise, the user should join the specified room
* and send the reply to the room.
*
* @return the JID of a MUC room to which responses should be sent or <tt>null</tt> if
* no specific address was provided.
*/
public String getReplyRoom() {
List<MultipleAddresses.Address> replyRoom = extension.getAddressesOfType(MultipleAddresses.REPLY_ROOM);
return replyRoom.isEmpty() ? null : ((MultipleAddresses.Address) replyRoom.get(0)).getJid();
}
/**
* Returns true if the received packet should not be replied. Use
* {@link MultipleRecipientManager#reply(org.jivesoftware.smack.Connection, org.jivesoftware.smack.packet.Message, org.jivesoftware.smack.packet.Message)}
* to send replies.
*
* @return true if the received packet should not be replied.
*/
public boolean shouldNotReply() {
return !extension.getAddressesOfType(MultipleAddresses.NO_REPLY).isEmpty();
}
/**
* Returns the address to which all replies are requested to be sent or <tt>null</tt> if
* no specific address was provided. When no specific address was provided then the reply
* can be sent to any or all recipients.
*
* @return the address to which all replies are requested to be sent or <tt>null</tt> if
* no specific address was provided.
*/
public MultipleAddresses.Address getReplyAddress() {
List<MultipleAddresses.Address> replyTo = extension.getAddressesOfType(MultipleAddresses.REPLY_TO);
return replyTo.isEmpty() ? null : (MultipleAddresses.Address) replyTo.get(0);
}
}