1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.newsclub.net.unix;
19
20 import java.io.IOException;
21 import java.net.DatagramSocketImpl;
22 import java.net.SocketOption;
23 import java.util.Set;
24
25
26
27
28
29
30 abstract class DatagramSocketImplShim extends DatagramSocketImpl {
31 protected DatagramSocketImplShim() {
32 super();
33 }
34
35 @Override
36 protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
37 if (name instanceof AFSocketOption<?>) {
38 ((AFDatagramSocketImpl<?>) this).getCore().setOption((AFSocketOption<T>) name, value);
39 return;
40 }
41 Integer optionId = SocketOptionsMapper.resolve(name);
42 if (optionId == null) {
43 super.setOption(name, value);
44 } else {
45 setOption(optionId, value);
46 }
47 }
48
49 @SuppressWarnings("unchecked")
50 @Override
51 protected <T> T getOption(SocketOption<T> name) throws IOException {
52 if (name instanceof AFSocketOption<?>) {
53 return ((AFDatagramSocketImpl<?>) this).getCore().getOption((AFSocketOption<T>) name);
54 }
55 Integer optionId = SocketOptionsMapper.resolve(name);
56 if (optionId == null) {
57 return super.getOption(name);
58 } else {
59 return (T) getOption(optionId);
60 }
61 }
62
63 @Override
64 protected Set<SocketOption<?>> supportedOptions() {
65 return SocketOptionsMapper.SUPPORTED_SOCKET_OPTIONS;
66 }
67 }