commit | author | age
|
466492
|
1 |
/* |
U |
2 |
http-base - Extensions to jdk.httpserver |
|
3 |
Copyright (C) 2021 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.httpserver.base.handler; |
|
19 |
|
|
20 |
import com.sun.net.httpserver.HttpExchange; |
|
21 |
import com.sun.net.httpserver.HttpHandler; |
|
22 |
import java.io.IOException; |
|
23 |
import java.util.HashMap; |
|
24 |
import java.util.Map; |
|
25 |
|
|
26 |
/** |
|
27 |
* Ein HttpHandler, der eigene Attribute besitzen kann |
|
28 |
* |
|
29 |
* @author Ulrich Hilger |
|
30 |
* @version 1, 30.6.2021 |
|
31 |
*/ |
|
32 |
public abstract class AttributeHandler implements HttpHandler { |
|
33 |
|
|
34 |
protected Map<String, String> attributes = new HashMap(); |
|
35 |
|
|
36 |
@Override |
|
37 |
public abstract void handle(HttpExchange exchange) throws IOException; |
|
38 |
|
|
39 |
public void setAttribute(String key, String value) { |
|
40 |
attributes.put(key, value); |
|
41 |
} |
|
42 |
|
|
43 |
public String getAttribute(String key) { |
|
44 |
return attributes.get(key); |
|
45 |
} |
|
46 |
|
|
47 |
} |