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