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 */ 017 018package org.jivesoftware.smackx.muc; 019 020import org.jivesoftware.smackx.muc.packet.MUCItem; 021import org.jxmpp.jid.Jid; 022import org.jxmpp.jid.parts.Resourcepart; 023 024/** 025 * Represents an affiliation of a user to a given room. The affiliate's information will always have 026 * the bare jid of the real user and its affiliation. If the affiliate is an occupant of the room 027 * then we will also have information about the role and nickname of the user in the room. 028 * 029 * @author Gaston Dombiak 030 */ 031public class Affiliate { 032 // Fields that must have a value 033 private final Jid jid; 034 private final MUCAffiliation affiliation; 035 036 // Fields that may have a value 037 private final MUCRole role; 038 private final Resourcepart nick; 039 040 Affiliate(MUCItem item) { 041 this.jid = item.getJid(); 042 this.affiliation = item.getAffiliation(); 043 this.role = item.getRole(); 044 this.nick = item.getNick(); 045 } 046 047 /** 048 * Returns the bare JID of the affiliated user. This information will always be available. 049 * 050 * @return the bare JID of the affiliated user. 051 */ 052 public Jid getJid() { 053 return jid; 054 } 055 056 /** 057 * Returns the affiliation of the afffiliated user. Possible affiliations are: "owner", "admin", 058 * "member", "outcast". This information will always be available. 059 * 060 * @return the affiliation of the afffiliated user. 061 */ 062 public MUCAffiliation getAffiliation() { 063 return affiliation; 064 } 065 066 /** 067 * Returns the current role of the affiliated user if the user is currently in the room. 068 * If the user is not present in the room then the answer will be 'none'. 069 * 070 * @return the current role of the affiliated user in the room or null if the user is not in 071 * the room. 072 */ 073 public MUCRole getRole() { 074 return role; 075 } 076 077 /** 078 * Returns the current nickname of the affiliated user if the user is currently in the room. 079 * If the user is not present in the room then the answer will be null. 080 * 081 * @return the current nickname of the affiliated user in the room or null if the user is not in 082 * the room. 083 */ 084 public Resourcepart getNick() { 085 return nick; 086 } 087}