MCPcopy Index your code
hub / github.com/apache/tomcat / ParameterMap

Class ParameterMap

java/org/apache/catalina/util/ParameterMap.java:37–276  ·  view source on GitHub ↗

Implementation of java.util.Map that includes a locked property. This class can be used to safely expose Catalina internal parameter map objects to user classes without having to clone them in order to avoid modifications. When first created, a ParameterMap

Source from the content-addressed store, hash-verified

35 * @param <V> The type of Value
36 */
37public final class ParameterMap<K, V> implements Map<K,V>, Serializable {
38
39 @Serial
40 private static final long serialVersionUID = 2L;
41
42 /** The underlying map to which operations are delegated. */
43 private final Map<K,V> delegatedMap;
44
45 /** An unmodifiable view of the delegated map. */
46 private final Map<K,V> unmodifiableDelegatedMap;
47
48
49 /**
50 * Construct a new, empty map with the default initial capacity and load factor.
51 */
52 public ParameterMap() {
53 delegatedMap = new LinkedHashMap<>();
54 unmodifiableDelegatedMap = Collections.unmodifiableMap(delegatedMap);
55 }
56
57
58 /**
59 * Construct a new, empty map with the specified initial capacity and default load factor.
60 *
61 * @param initialCapacity The initial capacity of this map
62 */
63 public ParameterMap(int initialCapacity) {
64 delegatedMap = new LinkedHashMap<>(initialCapacity);
65 unmodifiableDelegatedMap = Collections.unmodifiableMap(delegatedMap);
66 }
67
68
69 /**
70 * Construct a new, empty map with the specified initial capacity and load factor.
71 *
72 * @param initialCapacity The initial capacity of this map
73 * @param loadFactor The load factor of this map
74 */
75 public ParameterMap(int initialCapacity, float loadFactor) {
76 delegatedMap = new LinkedHashMap<>(initialCapacity, loadFactor);
77 unmodifiableDelegatedMap = Collections.unmodifiableMap(delegatedMap);
78 }
79
80
81 /**
82 * Construct a new map with the same mappings as the given map.
83 *
84 * @param map Map whose contents are duplicated in the new map
85 */
86 public ParameterMap(Map<K,V> map) {
87 // Unroll loop for performance - https://bz.apache.org/bugzilla/show_bug.cgi?id=69820
88 int mapSize = map.size();
89 delegatedMap = new LinkedHashMap<>((int) (mapSize * 1.5));
90 for (Map.Entry<K,V> entry : map.entrySet()) {
91 delegatedMap.put(entry.getKey(), entry.getValue());
92 }
93 unmodifiableDelegatedMap = Collections.unmodifiableMap(delegatedMap);
94 }

Callers

nothing calls this directly

Calls 1

getManagerMethod · 0.95

Tested by

no test coverage detected