001/**
002 *
003 * Copyright 2003-2007 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.muc;
018
019import org.jivesoftware.smack.util.Objects;
020import org.jivesoftware.smackx.disco.packet.DiscoverItems;
021import org.jxmpp.jid.EntityBareJid;
022
023/**
024 * Hosted rooms by a chat service may be discovered if they are configured to appear in the room
025 * directory . The information that may be discovered is the XMPP address of the room and the room
026 * name. The address of the room may be used for obtaining more detailed information
027 * {@link org.jivesoftware.smackx.muc.MultiUserChatManager#getRoomInfo(org.jxmpp.jid.EntityBareJid)}
028 * or could be used for joining the room
029 * {@link org.jivesoftware.smackx.muc.MultiUserChatManager#getMultiUserChat(org.jxmpp.jid.EntityBareJid)}
030 * and {@link org.jivesoftware.smackx.muc.MultiUserChat#join(org.jxmpp.jid.parts.Resourcepart)}.
031 *
032 * @author Gaston Dombiak
033 */
034public class HostedRoom {
035
036    private final EntityBareJid jid;
037
038    private final String name;
039
040    public HostedRoom(DiscoverItems.Item item) {
041        jid = Objects.requireNonNull(item.getEntityID().asEntityBareJidIfPossible(),
042                        "The discovered item must be an entity bare JID");
043        name = item.getName();
044    }
045
046    /**
047     * Returns the XMPP address of the hosted room by the chat service. This address may be used
048     * when creating a <code>MultiUserChat</code> when joining a room.
049     *
050     * @return the XMPP address of the hosted room by the chat service.
051     */
052    public EntityBareJid getJid() {
053        return jid;
054    }
055
056    /**
057     * Returns the name of the room.
058     *
059     * @return the name of the room.
060     */
061    public String getName() {
062        return name;
063    }
064}