History

Copied some classes from openjdk7

Dmitry Kabak (userdima committed 13 years ago

Commit b1be2201 parent 555225f128 files · +83387 −0Browse files

Showing the changes to java/pkg/sun/nio/ch/SocketOptionRegistry.java (1 of 128 files). Show all

Unified · Split

java/pkg/sun/nio/ch/SocketOptionRegistry.java+83−0
@@ -0,0 +1,83 @@
1+/*
2+ * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
3+ *
4+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+ *
6+ * This code is free software; you can redistribute it and/or modify it
7+ * under the terms of the GNU General Public License version 2 only, as
8+ * published by the Free Software Foundation. Oracle designates this
9+ * particular file as subject to the "Classpath" exception as provided
10+ * by Oracle in the LICENSE file that accompanied this code.
11+ *
12+ * This code is distributed in the hope that it will be useful, but WITHOUT
13+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+ * version 2 for more details (a copy is included in the LICENSE file that
16+ * accompanied this code).
17+ *
18+ * You should have received a copy of the GNU General Public License version
19+ * 2 along with this work; if not, write to the Free Software Foundation,
20+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+ *
22+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+ * or visit www.oracle.com if you need additional information or have any
24+ * questions.
25+ *
26+ */
27+// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
28+package sun.nio.ch;
29+import java.net.SocketOption;
30+import java.net.StandardSocketOptions;
31+import java.net.ProtocolFamily;
32+import java.net.StandardProtocolFamily;
33+import java.util.Map;
34+import java.util.HashMap;
35+class SocketOptionRegistry {
36+ private SocketOptionRegistry() { }
37+ private static class RegistryKey {
38+ private final SocketOption<?> name;
39+ private final ProtocolFamily family;
40+ RegistryKey(SocketOption<?> name, ProtocolFamily family) {
41+ this.name = name;
42+ this.family = family;
43+ }
44+ public int hashCode() {
45+ return name.hashCode() + family.hashCode();
46+ }
47+ public boolean equals(Object ob) {
48+ if (ob == null) return false;
49+ if (!(ob instanceof RegistryKey)) return false;
50+ RegistryKey other = (RegistryKey)ob;
51+ if (this.name != other.name) return false;
52+ if (this.family != other.family) return false;
53+ return true;
54+ }
55+ }
56+ private static class LazyInitialization {
57+ static final Map<RegistryKey,OptionKey> options = options();
58+ private static Map<RegistryKey,OptionKey> options() {
59+ Map<RegistryKey,OptionKey> map =
60+ new HashMap<RegistryKey,OptionKey>();
61+ map.put(new RegistryKey(StandardSocketOptions.SO_BROADCAST, Net.UNSPEC), new OptionKey(65535, 32));
62+ map.put(new RegistryKey(StandardSocketOptions.SO_KEEPALIVE, Net.UNSPEC), new OptionKey(65535, 8));
63+ map.put(new RegistryKey(StandardSocketOptions.SO_LINGER, Net.UNSPEC), new OptionKey(65535, 128));
64+ map.put(new RegistryKey(StandardSocketOptions.SO_SNDBUF, Net.UNSPEC), new OptionKey(65535, 4097));
65+ map.put(new RegistryKey(StandardSocketOptions.SO_RCVBUF, Net.UNSPEC), new OptionKey(65535, 4098));
66+ map.put(new RegistryKey(StandardSocketOptions.SO_REUSEADDR, Net.UNSPEC), new OptionKey(65535, 4));
67+ map.put(new RegistryKey(StandardSocketOptions.TCP_NODELAY, Net.UNSPEC), new OptionKey(6, 1));
68+ map.put(new RegistryKey(StandardSocketOptions.IP_TOS, StandardProtocolFamily.INET), new OptionKey(0, 3));
69+ map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_IF, StandardProtocolFamily.INET), new OptionKey(0, 9));
70+ map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_TTL, StandardProtocolFamily.INET), new OptionKey(0, 10));
71+ map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_LOOP, StandardProtocolFamily.INET), new OptionKey(0, 11));
72+ map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_IF, StandardProtocolFamily.INET6), new OptionKey(41, 9));
73+ map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_TTL, StandardProtocolFamily.INET6), new OptionKey(41, 10));
74+ map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_LOOP, StandardProtocolFamily.INET6), new OptionKey(41, 11));
75+ map.put(new RegistryKey(ExtendedSocketOption.SO_OOBINLINE, Net.UNSPEC), new OptionKey(65535, 256));
76+ return map;
77+ }
78+ }
79+ public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) {
80+ RegistryKey key = new RegistryKey(name, family);
81+ return LazyInitialization.options.get(key);
82+ }
83+}