BookmarkedConference.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.bookmarks;

  18. import org.jxmpp.jid.EntityBareJid;
  19. import org.jxmpp.jid.parts.Resourcepart;

  20. /**
  21.  * Represents a Conference Room bookmarked on the server using XEP-0048 Bookmark Storage XEP.
  22.  *
  23.  * @author Derek DeMoro
  24.  */
  25. public class BookmarkedConference implements SharedBookmark {

  26.     private String name;
  27.     private boolean autoJoin;
  28.     private final EntityBareJid jid;

  29.     private Resourcepart nickname;
  30.     private String password;
  31.     private boolean isShared;

  32.     protected BookmarkedConference(EntityBareJid jid) {
  33.         this.jid = jid;
  34.     }

  35.     protected BookmarkedConference(String name, EntityBareJid jid, boolean autoJoin, Resourcepart nickname,
  36.             String password) {
  37.         this.name = name;
  38.         this.jid = jid;
  39.         this.autoJoin = autoJoin;
  40.         this.nickname = nickname;
  41.         this.password = password;
  42.     }


  43.     /**
  44.      * Returns the display label representing the Conference room.
  45.      *
  46.      * @return the name of the conference room.
  47.      */
  48.     public String getName() {
  49.         return name;
  50.     }

  51.     protected void setName(String name) {
  52.         this.name = name;
  53.     }

  54.     /**
  55.      * Returns true if this conference room should be auto-joined on startup.
  56.      *
  57.      * @return true if room should be joined on startup, otherwise false.
  58.      */
  59.     public boolean isAutoJoin() {
  60.         return autoJoin;
  61.     }

  62.     protected void setAutoJoin(boolean autoJoin) {
  63.         this.autoJoin = autoJoin;
  64.     }

  65.     /**
  66.      * Returns the full JID of this conference room. (ex.dev@conference.jivesoftware.com)
  67.      *
  68.      * @return the full JID of  this conference room.
  69.      */
  70.     public EntityBareJid getJid() {
  71.         return jid;
  72.     }

  73.     /**
  74.      * Returns the nickname to use when joining this conference room. This is an optional
  75.      * value and may return null.
  76.      *
  77.      * @return the nickname to use when joining, null may be returned.
  78.      */
  79.     public Resourcepart getNickname() {
  80.         return nickname;
  81.     }

  82.     protected void setNickname(Resourcepart nickname) {
  83.         this.nickname = nickname;
  84.     }

  85.     /**
  86.      * Returns the password to use when joining this conference room. This is an optional
  87.      * value and may return null.
  88.      *
  89.      * @return the password to use when joining this conference room, null may be returned.
  90.      */
  91.     public String getPassword() {
  92.         return password;
  93.     }

  94.     protected void setPassword(String password) {
  95.         this.password = password;
  96.     }

  97.     @Override
  98.     public boolean equals(Object obj) {
  99.         if (obj == null || !(obj instanceof BookmarkedConference)) {
  100.             return false;
  101.         }
  102.         BookmarkedConference conference = (BookmarkedConference) obj;
  103.         return conference.getJid().equals(jid);
  104.     }

  105.     @Override
  106.     public int hashCode() {
  107.         return getJid().hashCode();
  108.     }

  109.     protected void setShared(boolean isShared) {
  110.         this.isShared = isShared;
  111.     }

  112.     @Override
  113.     public boolean isShared() {
  114.         return isShared;
  115.     }
  116. }