KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javabb > infra > Online


1 package org.javabb.infra;
2
3 import java.util.Collection JavaDoc;
4 import java.util.HashSet JavaDoc;
5 import java.util.Set JavaDoc;
6
7 /*
8  * Copyright 2004 JavaFree.org
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */

22
23 /**
24  * $Id: Online.java,v 1.8.10.2 2006/04/17 17:47:17 daltoncamargo Exp $
25  * @author Dalton Camargo - <a HREF="mailto:dalton@javabb.org">dalton@javabb.org </a> <br>
26  * @author Ronald Tetsuo Miura
27  */

28 public class Online {
29
30     /**
31      * Controle de "Quem está online"
32      * @return os visitantes online.
33      */

34     public Collection JavaDoc getGuestsOnline() {
35         return ApplicationContext.getContext().getOnlineGuests();
36     }
37
38     /**
39      * Controle de "Quem está online"
40      * @return o total de pessoas online.
41      */

42     public int getTotalUsersOnline() {
43         ApplicationContext ctx = ApplicationContext.getContext();
44         return ctx.getOnlineGuests().size() + ctx.getOnlineRegisteredUsers().size();
45     }
46
47     /**
48      * Controle de "Quem está online"
49      * @return o total de usuários online.
50      */

51     public Collection JavaDoc getUsersOnline() {
52         ApplicationContext ctx = ApplicationContext.getContext();
53
54         Set JavaDoc users = new HashSet JavaDoc(ctx.getOnlineGuests());
55         users.addAll(ctx.getOnlineRegisteredUsers());
56         return users;
57     }
58
59     /**
60      * Quantidade de usuários cadastrados online
61      * @return number
62      */

63     public int getNumberUsersOnline() {
64         ApplicationContext ctx = ApplicationContext.getContext();
65         return ctx.getOnlineGuests().size() + ctx.getOnlineRegisteredUsers().size();
66     }
67
68     /**
69      * Quantidade de visitantes online
70      * @return number
71      */

72     public int getNumberGuestesOnline() {
73         Collection JavaDoc onlineGuests = ApplicationContext.getContext().getOnlineGuests();
74         return onlineGuests.size();
75     }
76 }
77
Popular Tags