HostedRoom.java

  1. /**
  2.  *
  3.  * Copyright 2003-2007 Jive Software.
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.muc;

  18. import org.jivesoftware.smack.util.Objects;

  19. import org.jivesoftware.smackx.disco.packet.DiscoverItems;

  20. import org.jxmpp.jid.EntityBareJid;

  21. /**
  22.  * Hosted rooms by a chat service may be discovered if they are configured to appear in the room
  23.  * directory . The information that may be discovered is the XMPP address of the room and the room
  24.  * name. The address of the room may be used for obtaining more detailed information
  25.  * {@link org.jivesoftware.smackx.muc.MultiUserChatManager#getRoomInfo(org.jxmpp.jid.EntityBareJid)}
  26.  * or could be used for joining the room
  27.  * {@link org.jivesoftware.smackx.muc.MultiUserChatManager#getMultiUserChat(org.jxmpp.jid.EntityBareJid)}
  28.  * and {@link org.jivesoftware.smackx.muc.MultiUserChat#join(org.jxmpp.jid.parts.Resourcepart)}.
  29.  *
  30.  * @author Gaston Dombiak
  31.  */
  32. public class HostedRoom {

  33.     private final EntityBareJid jid;

  34.     private final String name;

  35.     public HostedRoom(DiscoverItems.Item item) {
  36.         jid = Objects.requireNonNull(item.getEntityID().asEntityBareJidIfPossible(),
  37.                         "The discovered item must be an entity bare JID");
  38.         name = item.getName();
  39.     }

  40.     /**
  41.      * Returns the XMPP address of the hosted room by the chat service. This address may be used
  42.      * when creating a <code>MultiUserChat</code> when joining a room.
  43.      *
  44.      * @return the XMPP address of the hosted room by the chat service.
  45.      */
  46.     public EntityBareJid getJid() {
  47.         return jid;
  48.     }

  49.     /**
  50.      * Returns the name of the room.
  51.      *
  52.      * @return the name of the room.
  53.      */
  54.     public String getName() {
  55.         return name;
  56.     }
  57. }