EMMA Coverage Report (generated Sat Apr 14 15:01:05 EDT 2012)
[all classes][org.deduced.viewer.web.server]

COVERAGE SUMMARY FOR SOURCE FILE [PropertyCollectionIndex.java]

nameclass, %method, %block, %line, %
PropertyCollectionIndex.java100% (1/1)100% (4/4)100% (39/39)100% (12/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PropertyCollectionIndex100% (1/1)100% (4/4)100% (39/39)100% (12/12)
PropertyCollectionIndex (): void 100% (1/1)100% (8/8)100% (3/3)
addAllListeners (PropertyCollection): void 100% (1/1)100% (13/13)100% (4/4)
getCollection (Object): PropertyCollection 100% (1/1)100% (6/6)100% (1/1)
removeAllListeners (PropertyCollection): void 100% (1/1)100% (12/12)100% (4/4)

1/**
2 *    Copyright 2005-2011 Steve McDuff d-duff@users.sourceforge.net
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.deduced.viewer.web.server;
17 
18import java.util.HashMap;
19import java.util.Map;
20 
21import org.deduced.AbstractPropertyCollection;
22import org.deduced.PropertyCollection;
23import org.deduced.RecursiveModelListener;
24 
25/**
26 * PropertyCollectionIndex is used to monitor an object tree and index all the
27 * property collection it contains to find them for future reference.
28 * 
29 * @author Steve McDuff
30 * 
31 */
32public class PropertyCollectionIndex extends RecursiveModelListener
33{
34 
35        /**
36         * index of the property collections where the key is the unique ID of the
37         * collection.
38         */
39        private Map<Object, PropertyCollection<?, ?>> index =
40                new HashMap<Object, PropertyCollection<?, ?>>();
41 
42        /**
43         * PropertyCollectionIndex constructor
44         */
45        public PropertyCollectionIndex()
46        {
47 
48        }
49 
50        /**
51         * get a Collection based on it's unique ID
52         * 
53         * @param key the collection unique ID
54         * @return the matching collection. Null if this ID is unknown
55         */
56        public PropertyCollection<?, ?> getCollection(
57                Object key)
58        {
59                return index.get(key);
60        }
61 
62        /**
63         * (non-JSDoc)
64         * 
65         * @see org.deduced.RecursiveModelListener#addAllListeners(org.deduced.PropertyCollection)
66         */
67        @Override
68        protected void addAllListeners(
69                PropertyCollection<?, ?> currentCollection)
70        {
71                Object key =
72                        AbstractPropertyCollection
73                                .getInstanceIdentityKey(currentCollection);
74                index.put(key, currentCollection);
75                super.addAllListeners(currentCollection);
76        }
77 
78        /**
79         * (non-JSDoc)
80         * 
81         * @see org.deduced.RecursiveModelListener#removeAllListeners(org.deduced.PropertyCollection)
82         */
83        @Override
84        protected void removeAllListeners(
85                PropertyCollection<?, ?> currentCollection)
86        {
87                Object key =
88                        AbstractPropertyCollection
89                                .getInstanceIdentityKey(currentCollection);
90                index.remove(key);
91                super.removeAllListeners(currentCollection);
92        }
93 
94}

[all classes][org.deduced.viewer.web.server]
EMMA 2.0.9525 (unsupported private build) (C) Vladimir Roubtsov