1 package org.claros.chat.controllers; 2 3 import java.util.HashMap ; 4 5 import org.claros.chat.models.Avatar; 6 7 public class AvatarController { 8 private static HashMap avatars = new HashMap (); 9 10 11 17 public static void addAvatar(String user, byte b[], String hash) { 18 if (hash != null && b != null) { 19 Avatar avatar = (Avatar)avatars.get(user); 20 if (avatar == null) { 21 avatars.put(user, new Avatar(user, b, hash)); 22 } else { 23 if (!hash.equals(avatar.getHash())) { 24 avatars.put(user, new Avatar(user, b, hash)); 25 } 26 } 27 } 28 } 29 30 31 public static Avatar getAvatar(String user) { 32 return (Avatar)avatars.get(user); 33 } 34 35 } 36 | Popular Tags |