ManagedMap.java
上传用户:jiancairen
上传日期:2007-08-27
资源大小:26458k
文件大小:2k
源码类别:

Java编程

开发平台:

Java

  1. /*
  2.  * Copyright 2002-2004 the original author or authors.
  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.  */ 
  16. package org.springframework.beans.factory.support;
  17. import java.util.Collection;
  18. import java.util.Map;
  19. import java.util.Set;
  20. import org.springframework.core.CollectionFactory;
  21. /**
  22.  * Tag subclass used to hold managed Map values, which may
  23.  * include runtime bean references.
  24.  *
  25.  * <p>Wraps a target Map, which will be a linked map if possible
  26.  * (that is, if running on JDK 1.4 or if Commons Collections 3.x is available).
  27.  *
  28.  * @author Juergen Hoeller
  29.  * @since 27-May-2003
  30.  * @see org.springframework.core.CollectionFactory#createLinkedMapIfPossible
  31.  */
  32. public class ManagedMap implements Map {
  33. private final Map targetMap;
  34. public ManagedMap() {
  35. this(16);
  36. }
  37. public ManagedMap(int initialCapacity) {
  38. this.targetMap = CollectionFactory.createLinkedMapIfPossible(initialCapacity);
  39. }
  40. public ManagedMap(Map targetMap) {
  41. this.targetMap = targetMap;
  42. }
  43. public int size() {
  44. return this.targetMap.size();
  45. }
  46. public boolean isEmpty() {
  47. return this.targetMap.isEmpty();
  48. }
  49. public boolean containsKey(Object key) {
  50. return this.targetMap.containsKey(key);
  51. }
  52. public boolean containsValue(Object value) {
  53. return this.targetMap.containsValue(value);
  54. }
  55. public Object get(Object key) {
  56. return this.targetMap.get(key);
  57. }
  58. public Object put(Object key, Object value) {
  59. return this.targetMap.put(key, value);
  60. }
  61. public Object remove(Object key) {
  62. return this.targetMap.remove(key);
  63. }
  64. public void putAll(Map t) {
  65. this.targetMap.putAll(t);
  66. }
  67. public void clear() {
  68. this.targetMap.clear();
  69. }
  70. public Set keySet() {
  71. return this.targetMap.keySet();
  72. }
  73. public Collection values() {
  74. return this.targetMap.values();
  75. }
  76. public Set entrySet() {
  77. return this.targetMap.entrySet();
  78. }
  79. }