summaryrefslogtreecommitdiffstats
blob: d9b60483d2092812a4e83ef2146a068d9f8510f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * Copyright (c) 2012, Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010, Kevin Smith
 * All rights reserved.
 */
package com.isode.stroke.elements;

import com.isode.stroke.jid.JID;

/**
 * Class representing a MUC Occupant
 *
 */
public class MUCOccupant {

    /**
     * MUC Role
     *
     */
    public enum Role {
        Moderator("moderator"),
        Participant("participant"),
        Visitor("visitor"),
        NoRole("none");

        Role(String name) {
            this.nodeName = name;
        }

        public String nodeName;
    };

    /**
     * MUC Affiliation of the user
     *
     */
    public enum Affiliation {
        Owner("owner"), 
        Admin("admin"),
        Member("member"),
        Outcast("outcast"),
        NoAffiliation("none");

        public String nodeName;

        Affiliation(String name) {
            this.nodeName = name;
        }
    };

    /**
     * Create the MUC Occupant object
     * @param nick nick name, not null
     * @param role MUC Role, not null
     * @param affiliation MUC Affiliation, not null
     */
    public MUCOccupant(String nick, Role role, Affiliation affiliation) {
        this.nick_ = nick;
        this.role_ = role;
        this.affiliation_ = affiliation;
    }

    /**
     * Create a copy of the given MUC Occupant
     * @param other object to copy from
     */
    public MUCOccupant(MUCOccupant other) {
        this.nick_ = other.nick_;
        this.role_ = other.role_;
        this.affiliation_ = other.affiliation_;
        this.realJID_ = new JID(other.realJID_ != null ? other.realJID_.toString() : "");
    }

    /**
     * Get the nick name
     * @return nick name, not null
     */
    public String getNick() {
        return nick_;
    }

    /**
     * Get the role
     * @return role, not null
     */
    public Role getRole(){
        return role_;
    }

    /**
     * Get the affiliation of the user
     * @return affiliation , not null
     */
    public Affiliation getAffiliation() {
        return affiliation_;
    }

    /**
     * Get the real Jabber ID of the user
     * @return real Jabber ID, not null if set
     */
    public JID getRealJID(){
        return realJID_;
    }

    /**
     * Set the real Jabber ID
     * @param jid Jabber ID, not null
     */
    public void setRealJID(JID jid) {
        this.realJID_ = jid;
    }

    /**
     * Set the nick name of the user
     * @param nick nick name, not null
     */
    public void setNick(String nick) {
        this.nick_ = nick;
    }

    private String nick_;
    private Role role_;
    private Affiliation affiliation_;
    private JID realJID_;
    /* If you add a field, remember to update the const copy constructor */
}