1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.http.conn.scheme;
29
30 import java.io.IOException;
31 import java.net.InetAddress;
32 import java.net.InetSocketAddress;
33 import java.net.Socket;
34 import java.net.UnknownHostException;
35
36 import org.apache.http.conn.ConnectTimeoutException;
37 import org.apache.http.params.HttpParams;
38
39
40
41
42 @Deprecated
43 class SchemeSocketFactoryAdaptor implements SchemeSocketFactory {
44
45 private final SocketFactory factory;
46
47 SchemeSocketFactoryAdaptor(final SocketFactory factory) {
48 super();
49 this.factory = factory;
50 }
51
52 @Override
53 public Socket connectSocket(
54 final Socket sock,
55 final InetSocketAddress remoteAddress,
56 final InetSocketAddress localAddress,
57 final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
58 final String host = remoteAddress.getHostName();
59 final int port = remoteAddress.getPort();
60 InetAddress local = null;
61 int localPort = 0;
62 if (localAddress != null) {
63 local = localAddress.getAddress();
64 localPort = localAddress.getPort();
65 }
66 return this.factory.connectSocket(sock, host, port, local, localPort, params);
67 }
68
69 @Override
70 public Socket createSocket(final HttpParams params) throws IOException {
71 return this.factory.createSocket();
72 }
73
74 @Override
75 public boolean isSecure(final Socket sock) throws IllegalArgumentException {
76 return this.factory.isSecure(sock);
77 }
78
79 public SocketFactory getFactory() {
80 return this.factory;
81 }
82
83 @Override
84 public boolean equals(final Object obj) {
85 if (obj == null) {
86 return false;
87 }
88 if (this == obj) {
89 return true;
90 }
91 return obj instanceof SchemeSocketFactoryAdaptor
92 ? this.factory.equals(((SchemeSocketFactoryAdaptor) obj).factory)
93 : this.factory.equals(obj);
94 }
95
96 @Override
97 public int hashCode() {
98 return this.factory.hashCode();
99 }
100
101 }