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; 020 021import org.jivesoftware.smackx.disco.packet.DiscoverItems; 022 023import org.jxmpp.jid.EntityBareJid; 024 025/** 026 * Hosted rooms by a chat service may be discovered if they are configured to appear in the room 027 * directory . The information that may be discovered is the XMPP address of the room and the room 028 * name. The address of the room may be used for obtaining more detailed information 029 * {@link org.jivesoftware.smackx.muc.MultiUserChatManager#getRoomInfo(org.jxmpp.jid.EntityBareJid)} 030 * or could be used for joining the room 031 * {@link org.jivesoftware.smackx.muc.MultiUserChatManager#getMultiUserChat(org.jxmpp.jid.EntityBareJid)} 032 * and {@link org.jivesoftware.smackx.muc.MultiUserChat#join(org.jxmpp.jid.parts.Resourcepart)}. 033 * 034 * @author Gaston Dombiak 035 */ 036public class HostedRoom { 037 038 private final EntityBareJid jid; 039 040 private final String name; 041 042 public HostedRoom(DiscoverItems.Item item) { 043 jid = Objects.requireNonNull(item.getEntityID().asEntityBareJidIfPossible(), 044 "The discovered item must be an entity bare JID"); 045 name = item.getName(); 046 } 047 048 /** 049 * Returns the XMPP address of the hosted room by the chat service. This address may be used 050 * when creating a <code>MultiUserChat</code> when joining a room. 051 * 052 * @return the XMPP address of the hosted room by the chat service. 053 */ 054 public EntityBareJid getJid() { 055 return jid; 056 } 057 058 /** 059 * Returns the name of the room. 060 * 061 * @return the name of the room. 062 */ 063 public String getName() { 064 return name; 065 } 066}