Affiliate.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.smackx.muc.packet.MUCItem;

  19. import org.jxmpp.jid.Jid;
  20. import org.jxmpp.jid.parts.Resourcepart;

  21. /**
  22.  * Represents an affiliation of a user to a given room. The affiliate's information will always have
  23.  * the bare jid of the real user and its affiliation. If the affiliate is an occupant of the room
  24.  * then we will also have information about the role and nickname of the user in the room.
  25.  *
  26.  * @author Gaston Dombiak
  27.  */
  28. public class Affiliate {
  29.     // Fields that must have a value
  30.     private final Jid jid;
  31.     private final MUCAffiliation affiliation;

  32.     // Fields that may have a value
  33.     private final MUCRole role;
  34.     private final Resourcepart nick;

  35.     Affiliate(MUCItem item) {
  36.         this.jid = item.getJid();
  37.         this.affiliation = item.getAffiliation();
  38.         this.role = item.getRole();
  39.         this.nick = item.getNick();
  40.     }

  41.     /**
  42.      * Returns the bare JID of the affiliated user. This information will always be available.
  43.      *
  44.      * @return the bare JID of the affiliated user.
  45.      */
  46.     public Jid getJid() {
  47.         return jid;
  48.     }

  49.     /**
  50.      * Returns the affiliation of the affiliated user. Possible affiliations are: "owner", "admin",
  51.      * "member", "outcast". This information will always be available.
  52.      *
  53.      * @return the affiliation of the affiliated user.
  54.      */
  55.     public MUCAffiliation getAffiliation() {
  56.         return affiliation;
  57.     }

  58.     /**
  59.      * Returns the current role of the affiliated user if the user is currently in the room.
  60.      * If the user is not present in the room then the answer will be 'none'.
  61.      *
  62.      * @return the current role of the affiliated user in the room or null if the user is not in
  63.      *         the room.
  64.      */
  65.     public MUCRole getRole() {
  66.         return role;
  67.     }

  68.     /**
  69.      * Returns the current nickname of the affiliated user if the user is currently in the room.
  70.      * If the user is not present in the room then the answer will be null.
  71.      *
  72.      * @return the current nickname of the affiliated user in the room or null if the user is not in
  73.      *         the room.
  74.      */
  75.     public Resourcepart getNick() {
  76.         return nick;
  77.     }
  78. }