EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.main]

COVERAGE SUMMARY FOR SOURCE FILE [IdentityHolderImpl.java]

nameclass, %method, %block, %line, %
IdentityHolderImpl.java100% (3/3)100% (11/11)87%  (112/129)86%  (24/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IdentityHolderImpl100% (1/1)100% (7/7)80%  (66/83)82%  (18/22)
setIdentity (Account): void 100% (1/1)48%  (16/33)60%  (6/10)
IdentityHolderImpl (Log, Channel, Channel): void 100% (1/1)100% (25/25)100% (7/7)
access$000 (IdentityHolderImpl): Account 100% (1/1)100% (3/3)100% (1/1)
access$002 (IdentityHolderImpl, Account): Account 100% (1/1)100% (5/5)100% (1/1)
access$100 (IdentityHolderImpl): Channel 100% (1/1)100% (3/3)100% (1/1)
getId (): int 100% (1/1)100% (4/4)100% (1/1)
getIdentity (): Account 100% (1/1)100% (10/10)100% (3/3)
     
class IdentityHolderImpl$1100% (1/1)100% (2/2)100% (26/26)100% (2/2)
IdentityHolderImpl$1 (IdentityHolderImpl): void 100% (1/1)100% (6/6)100% (1/1)
passEvent (Event): boolean 100% (1/1)100% (20/20)100% (1/1)
     
class IdentityHolderImpl$2100% (1/1)100% (2/2)100% (20/20)100% (4/4)
IdentityHolderImpl$2 (IdentityHolderImpl): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (14/14)100% (3/3)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveboard.main;
16 
17import org.apache.commons.logging.Log;
18 
19import net.sourceforge.hiveboard.Account;
20import net.sourceforge.hiveboard.Event;
21import net.sourceforge.hiveboard.EventType;
22import net.sourceforge.hiveboard.event.EventsPriorities;
23import net.sourceforge.hiveboard.event.PersistentDeferredConsumer;
24import net.sourceforge.hiveevents.Channel;
25import net.sourceforge.hiveevents.Filter;
26 
27public class IdentityHolderImpl implements IdentityHolder
28{
29        public IdentityHolderImpl(        Log                                        logger, 
30                                                                Channel<Event>                eventsChannel, 
31                                                                Channel<Account>        identityChannel)
32        {
33                _logger = logger;
34                _identityChannel = identityChannel;
35                int priority = EventsPriorities.IDENTITY_UPDATE;
36                Filter<Event> filter = new Filter<Event>()
37                {
38                        public boolean        passEvent(Event event)
39                        {
40                                return (        (event.getType() == EventType.EVT_MODIFY_ACCOUNT)
41                                                &&        (_identity != null)
42                                                &&        (_identity.getId() == event.getAccount().getId()));
43                        }
44                };
45                eventsChannel.registerPushConsumer(priority, filter, new PersistentDeferredConsumer()
46                {
47                        @Override protected void pushEvent(Event event)
48                        {
49                                _identity = event.getAccount();
50                                _identityChannel.push(_identity);
51                        }
52                });
53        }
54        
55        public Account        getIdentity()
56        {
57                if (_identity == null)
58                {
59                        _logger.warn("getIdentity() [_identity == null]");
60                }
61                return _identity;
62        }
63        
64        public int                getId()
65        {
66                return getIdentity().getId();
67        }
68        
69        public void                setIdentity(Account account)
70        {
71                if (_identity == null)
72                {
73                        _identity = account;
74                        _identityChannel.push(_identity);
75                }
76                else
77                {
78                        _logger.warn("setIdentity() [_identity != null]");
79                }
80                if (_identity == null)
81                {
82                        _logger.warn("setIdentity() [_identity == null]");
83                        _identity = new Account();
84                        _identity.setId(-1);
85                }
86        }
87 
88        private final Log                                _logger;
89        private final Channel<Account>        _identityChannel;
90        private Account                                        _identity;
91}

[all classes][net.sourceforge.hiveboard.main]
EMMA 2.0.5312 (C) Vladimir Roubtsov