Add Registration functionality and tidy up
[WeStealzYourDataz.git] / src / uk / ac / ntu / n0521366 / wsyd / libs / message / MessageMember.java
diff --git a/src/uk/ac/ntu/n0521366/wsyd/libs/message/MessageMember.java b/src/uk/ac/ntu/n0521366/wsyd/libs/message/MessageMember.java
new file mode 100644 (file)
index 0000000..c04648c
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2015 TJ <hacker@iam.tj>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package uk.ac.ntu.n0521366.wsyd.libs.message;
+
+import uk.ac.ntu.n0521366.wsyd.libs.WSYD_Member;
+
+/**
+ * A specialised message containing a WSYD_Member.
+ * 
+ * @author TJ <hacker@iam.tj>
+ */
+public class MessageMember extends MessageAbstract {
+
+    public static enum STATE {UNREGISTERED, REGISTERED};
+    private static final String _type = "WSYD_Member";
+    
+    private WSYD_Member _member;
+    private STATE _registered;
+    private String _status;
+    
+    public static String getType() {
+        return _type;
+    }
+
+    @Override
+    public String getMessageType() {
+        return _type;
+    }
+    
+    public MessageMember(WSYD_Member member, STATE registered, String status) {
+        _member = member;
+        _registered = registered;
+        _status = status;
+    }
+    
+    public MessageMember(WSYD_Member member) {
+        this(member, STATE.UNREGISTERED, null);
+    }
+    
+    public MessageMember() {
+        this(null, STATE.UNREGISTERED, null);
+    }
+    
+    /**
+     * Get the Member contained in this message.
+     * 
+     * @return 
+     */
+    public WSYD_Member getMember() {
+        return _member;
+    }
+        
+    /**
+     * Current registration state of the member record contained in this message.
+     * 
+     * @return
+     */
+    public STATE getRegistered() {
+        return _registered;
+    }
+
+    /**
+     * Update the registration state of the member record contained in this message.
+     * 
+     * @param registered 
+     */
+    public void setRegistered(STATE registered) {
+        _registered = registered;
+    }
+    
+    /**
+     * Get registration status message.
+     * 
+     * @return 
+     */
+    public String getStatus() {
+        return _status;
+    }
+    
+    /**
+     * Set registration status message.
+     * 
+     * ServerSocial may set this with text describing why a registration failed.
+     * @param status 
+     */
+    public void setStatus(String status) {
+        _status = status;
+    }
+}
\ No newline at end of file