|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DelegateMap.java | 0% | 33.3% | 44.4% | 36.6% |
|
||||||||||||||
| 1 | // | |
| 2 | //Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. | |
| 3 | //All rights reserved. | |
| 4 | // | |
| 5 | //Redistribution and use in source and binary forms, with or without modification, | |
| 6 | //are permitted provided that the following conditions are met: | |
| 7 | // | |
| 8 | //* Redistributions of source code must retain the above copyright notice, | |
| 9 | //this list of conditions and the following disclaimer. | |
| 10 | //* Redistributions in binary form must reproduce the above copyright notice, | |
| 11 | //this list of conditions and the following disclaimer in the documentation | |
| 12 | //and/or other materials provided with the distribution. | |
| 13 | //* Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. | |
| 14 | //nor the names of its contributors may be used to endorse or promote products | |
| 15 | //derived from this software without specific prior written permission. | |
| 16 | // | |
| 17 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 18 | //AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 19 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
| 20 | //IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 21 | //INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 22 | //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | |
| 23 | //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 24 | //WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 25 | //ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 26 | //POSSIBILITY OF SUCH DAMAGE. | |
| 27 | // | |
| 28 | ||
| 29 | package org.objectledge.cache.impl; | |
| 30 | ||
| 31 | import java.util.Collection; | |
| 32 | import java.util.Iterator; | |
| 33 | import java.util.Map; | |
| 34 | import java.util.Set; | |
| 35 | ||
| 36 | import org.objectledge.cache.spi.LayeredMap; | |
| 37 | ||
| 38 | /** | |
| 39 | * A map that delegates all it's methods to another Map object. | |
| 40 | * | |
| 41 | * @author <a href="mailto:rafal@caltha.pl">Rafal Krzewski</a> | |
| 42 | * @version $Id: DelegateMap.java,v 1.2 2005/02/10 17:47:03 rafal Exp $ | |
| 43 | */ | |
| 44 | public abstract class DelegateMap | |
| 45 | implements LayeredMap | |
| 46 | { | |
| 47 | // memeber objects /////////////////////////////////////////////////////// | |
| 48 | ||
| 49 | /** The delegate object. */ | |
| 50 | protected Map delegate; | |
| 51 | ||
| 52 | // initialization //////////////////////////////////////////////////////// | |
| 53 | ||
| 54 | /** | |
| 55 | * Constructs a new DelegateMap object without initial delegate. | |
| 56 | */ | |
| 57 | 4094 | public DelegateMap() |
| 58 | { | |
| 59 | // default constructor | |
| 60 | } | |
| 61 | ||
| 62 | /** | |
| 63 | * Constructs a new DelegateMap object. | |
| 64 | * | |
| 65 | * @param delegate the delegate object. | |
| 66 | */ | |
| 67 | 5704 | public DelegateMap(Map delegate) |
| 68 | { | |
| 69 | 5704 | this.delegate = delegate; |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Sets the map that provides value storage. | |
| 74 | * | |
| 75 | * @param map the delegate map. | |
| 76 | */ | |
| 77 | 4094 | public void setDelegate(Map map) |
| 78 | { | |
| 79 | 4094 | delegate = map; |
| 80 | } | |
| 81 | ||
| 82 | /** | |
| 83 | * Returns the map that provides value storage. | |
| 84 | * | |
| 85 | * @return the delegate map. | |
| 86 | */ | |
| 87 | 92 | public Map getDelegate() |
| 88 | { | |
| 89 | 92 | return delegate; |
| 90 | } | |
| 91 | ||
| 92 | // Map interaface //////////////////////////////////////////////////////// | |
| 93 | ||
| 94 | /** | |
| 95 | * {@inheritDoc} | |
| 96 | */ | |
| 97 | 0 | public void clear() |
| 98 | { | |
| 99 | 0 | delegate.clear(); |
| 100 | } | |
| 101 | ||
| 102 | /** | |
| 103 | * {@inheritDoc} | |
| 104 | */ | |
| 105 | 0 | public boolean containsKey(Object key) |
| 106 | { | |
| 107 | 0 | return delegate.containsKey(key); |
| 108 | } | |
| 109 | ||
| 110 | /** | |
| 111 | * {@inheritDoc} | |
| 112 | */ | |
| 113 | 0 | public boolean containsValue(Object value) |
| 114 | { | |
| 115 | 0 | return delegate.containsValue(value); |
| 116 | } | |
| 117 | ||
| 118 | /** | |
| 119 | * {@inheritDoc} | |
| 120 | */ | |
| 121 | 0 | public Set entrySet() |
| 122 | { | |
| 123 | 0 | return delegate.entrySet(); |
| 124 | } | |
| 125 | ||
| 126 | /** | |
| 127 | * {@inheritDoc} | |
| 128 | */ | |
| 129 | 184 | public boolean equals(Object o) |
| 130 | { | |
| 131 | 184 | return delegate.equals(o); |
| 132 | } | |
| 133 | ||
| 134 | /** | |
| 135 | * {@inheritDoc} | |
| 136 | */ | |
| 137 | 0 | public Object get(Object key) |
| 138 | { | |
| 139 | 0 | return delegate.get(key); |
| 140 | } | |
| 141 | ||
| 142 | /** | |
| 143 | * {@inheritDoc} | |
| 144 | */ | |
| 145 | 368 | public int hashCode() |
| 146 | { | |
| 147 | 368 | return delegate.hashCode(); |
| 148 | } | |
| 149 | ||
| 150 | /** | |
| 151 | * {@inheritDoc} | |
| 152 | */ | |
| 153 | 0 | public boolean isEmpty() |
| 154 | { | |
| 155 | 0 | return delegate.isEmpty(); |
| 156 | } | |
| 157 | ||
| 158 | /** | |
| 159 | * {@inheritDoc} | |
| 160 | */ | |
| 161 | 0 | public Set keySet() |
| 162 | { | |
| 163 | 0 | return delegate.keySet(); |
| 164 | } | |
| 165 | ||
| 166 | /** | |
| 167 | * {@inheritDoc} | |
| 168 | */ | |
| 169 | 138 | public Object put(Object key, Object value) |
| 170 | { | |
| 171 | 138 | return delegate.put(key, value); |
| 172 | } | |
| 173 | ||
| 174 | /** | |
| 175 | * {@inheritDoc} | |
| 176 | */ | |
| 177 | 0 | public void putAll(Map map) |
| 178 | { | |
| 179 | 0 | Set entries = map.entrySet(); |
| 180 | 0 | Iterator i = entries.iterator(); |
| 181 | 0 | while(i.hasNext()) |
| 182 | { | |
| 183 | 0 | Map.Entry entry = (Map.Entry)i.next(); |
| 184 | 0 | put(entry.getKey(), entry.getValue()); |
| 185 | } | |
| 186 | } | |
| 187 | ||
| 188 | /** | |
| 189 | * {@inheritDoc} | |
| 190 | */ | |
| 191 | 0 | public Object remove(Object key) |
| 192 | { | |
| 193 | 0 | return delegate.remove(key); |
| 194 | } | |
| 195 | ||
| 196 | /** | |
| 197 | * {@inheritDoc} | |
| 198 | */ | |
| 199 | 276 | public int size() |
| 200 | { | |
| 201 | 276 | return delegate.size(); |
| 202 | } | |
| 203 | ||
| 204 | /** | |
| 205 | * {@inheritDoc} | |
| 206 | */ | |
| 207 | 0 | public Collection values() |
| 208 | { | |
| 209 | 0 | return delegate.values(); |
| 210 | } | |
| 211 | } | |
| 212 |
|
||||||||||