01: package org.claros.chat.controllers;
02:
03: import java.util.HashMap;
04:
05: import org.claros.chat.models.Avatar;
06:
07: public class AvatarController {
08: private static HashMap avatars = new HashMap();
09:
10: /**
11: *
12: * @param user
13: * @param b
14: * @param hash
15: */
16: public static void addAvatar(String user, byte b[], String hash) {
17: if (hash != null && b != null) {
18: Avatar avatar = (Avatar) avatars.get(user);
19: if (avatar == null) {
20: avatars.put(user, new Avatar(user, b, hash));
21: } else {
22: if (!hash.equals(avatar.getHash())) {
23: avatars.put(user, new Avatar(user, b, hash));
24: }
25: }
26: }
27: }
28:
29: public static Avatar getAvatar(String user) {
30: return (Avatar) avatars.get(user);
31: }
32:
33: }
|