FileDocCategorySizeDatePackage
Room.javaAPI DocApache Struts 2.0.9 Apps2969Mon Jul 23 13:43:26 BST 2007org.apache.struts2.showcase.chat

Room

public class Room extends Object

Fields Summary
private static final int
MAX_CHAT_MESSAGES
private String
name
private String
description
private Date
creationDate
private List
messages
private Map
members
Constructors Summary
public Room(String name, String description)


         
        this.name = name;
        this.description = description;
        this.creationDate = new Date(System.currentTimeMillis());
    
Methods Summary
public voidaddMessage(ChatMessage chatMessage)

        if (messages.size() > MAX_CHAT_MESSAGES) {
            // messages.remove(messages.size() - 1);
            messages.remove(0);
        }
        messages.add(chatMessage);
    
public UserfindMember(java.lang.String name)

        assert(name != null);
        return members.get(name);
    
public java.util.ListgetChatMessages()

        return new ArrayList<ChatMessage>(messages);
    
public java.util.DategetCreationDate()

        return creationDate;
    
public java.lang.StringgetDescription()

        return description;
    
public java.util.ListgetMembers()

        return new ArrayList<User>(members.values());
    
public java.lang.StringgetName()

        return name;
    
public booleanhasMember(java.lang.String name)

        assert(name != null);
        return members.containsKey(name);
    
public voidmemberEnter(User member)

        assert(member != null);
        if (! hasMember(member.getName())) {
            members.put(member.getName(), member);
        }
    
public voidmemberExit(java.lang.String memberName)

        assert(memberName != null);
        assert(memberName.trim().length() > 0);
        members.remove(memberName);