Add Registration functionality and tidy up
[WeStealzYourDataz.git] / src / uk / ac / ntu / n0521366 / wsyd / libs / message / MessageMember.java
1 /*
2  * The MIT License
3  *
4  * Copyright 2015 TJ <hacker@iam.tj>.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 package uk.ac.ntu.n0521366.wsyd.libs.message;
25
26 import uk.ac.ntu.n0521366.wsyd.libs.WSYD_Member;
27
28 /**
29  * A specialised message containing a WSYD_Member.
30  * 
31  * @author TJ <hacker@iam.tj>
32  */
33 public class MessageMember extends MessageAbstract {
34
35     public static enum STATE {UNREGISTERED, REGISTERED};
36     private static final String _type = "WSYD_Member";
37     
38     private WSYD_Member _member;
39     private STATE _registered;
40     private String _status;
41     
42     public static String getType() {
43         return _type;
44     }
45
46     @Override
47     public String getMessageType() {
48         return _type;
49     }
50     
51     public MessageMember(WSYD_Member member, STATE registered, String status) {
52         _member = member;
53         _registered = registered;
54         _status = status;
55     }
56     
57     public MessageMember(WSYD_Member member) {
58         this(member, STATE.UNREGISTERED, null);
59     }
60     
61     public MessageMember() {
62         this(null, STATE.UNREGISTERED, null);
63     }
64     
65     /**
66      * Get the Member contained in this message.
67      * 
68      * @return 
69      */
70     public WSYD_Member getMember() {
71         return _member;
72     }
73         
74     /**
75      * Current registration state of the member record contained in this message.
76      * 
77      * @return
78      */
79     public STATE getRegistered() {
80         return _registered;
81     }
82
83     /**
84      * Update the registration state of the member record contained in this message.
85      * 
86      * @param registered 
87      */
88     public void setRegistered(STATE registered) {
89         _registered = registered;
90     }
91     
92     /**
93      * Get registration status message.
94      * 
95      * @return 
96      */
97     public String getStatus() {
98         return _status;
99     }
100     
101     /**
102      * Set registration status message.
103      * 
104      * ServerSocial may set this with text describing why a registration failed.
105      * @param status 
106      */
107     public void setStatus(String status) {
108         _status = status;
109     }
110 }