Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java
41159 views
1
/*
2
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.net.httpserver;
27
28
import java.util.*;
29
import java.util.function.BiFunction;
30
import com.sun.net.httpserver.*;
31
32
public class UnmodifiableHeaders extends Headers {
33
34
private final Headers headers; // modifiable, but no reference to it escapes
35
private final Map<String, List<String>> map; // unmodifiable
36
37
public UnmodifiableHeaders(Headers headers) {
38
var h = headers;
39
var unmodHeaders = new Headers();
40
h.forEach((k, v) -> unmodHeaders.put(k, Collections.unmodifiableList(v)));
41
this.map = Collections.unmodifiableMap(unmodHeaders);
42
this.headers = unmodHeaders;
43
}
44
45
public int size() {return headers.size();}
46
47
public boolean isEmpty() {return headers.isEmpty();}
48
49
public boolean containsKey(Object key) { return headers.containsKey(key); }
50
51
public boolean containsValue(Object value) { return headers.containsValue(value); }
52
53
public List<String> get(Object key) { return headers.get(key); }
54
55
public String getFirst(String key) { return headers.getFirst(key); }
56
57
public List<String> put(String key, List<String> value) {
58
throw new UnsupportedOperationException ("unsupported operation");
59
}
60
61
public void add(String key, String value) {
62
throw new UnsupportedOperationException ("unsupported operation");
63
}
64
65
public void set(String key, String value) {
66
throw new UnsupportedOperationException ("unsupported operation");
67
}
68
69
public List<String> remove(Object key) {
70
throw new UnsupportedOperationException ("unsupported operation");
71
}
72
73
public void putAll(Map<? extends String,? extends List<String>> t) {
74
throw new UnsupportedOperationException ("unsupported operation");
75
}
76
77
public void clear() {
78
throw new UnsupportedOperationException ("unsupported operation");
79
}
80
81
public Set<String> keySet() { return map.keySet(); }
82
83
public Collection<List<String>> values() { return map.values(); }
84
85
/* TODO check that contents of set are not modifable : security */
86
87
public Set<Map.Entry<String, List<String>>> entrySet() { return map.entrySet(); }
88
89
public List<String> replace(String key, List<String> value) {
90
throw new UnsupportedOperationException("unsupported operation");
91
}
92
93
public boolean replace(String key, List<String> oldValue, List<String> newValue) {
94
throw new UnsupportedOperationException ("unsupported operation");
95
}
96
97
public void replaceAll(BiFunction<? super String, ? super List<String>, ? extends List<String>> function) {
98
throw new UnsupportedOperationException ("unsupported operation");
99
}
100
101
public boolean equals(Object o) {return headers.equals(o);}
102
103
public int hashCode() {return headers.hashCode();}
104
}
105
106