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 public Socket connectSocket(
53 final Socket sock,
54 final InetSocketAddress remoteAddress,
55 final InetSocketAddress localAddress,
56 final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
57 final String host = remoteAddress.getHostName();
58 final int port = remoteAddress.getPort();
59 InetAddress local = null;
60 int localPort = 0;
61 if (localAddress != null) {
62 local = localAddress.getAddress();
63 localPort = localAddress.getPort();
64 }
65 return this.factory.connectSocket(sock, host, port, local, localPort, params);
66 }
67
68 public Socket createSocket(final HttpParams params) throws IOException {
69 return this.factory.createSocket();
70 }
71
72 public boolean isSecure(final Socket sock) throws IllegalArgumentException {
73 return this.factory.isSecure(sock);
74 }
75
76 public SocketFactory getFactory() {
77 return this.factory;
78 }
79
80 @Override
81 public boolean equals(final Object obj) {
82 if (obj == null) {
83 return false;
84 }
85 if (this == obj) {
86 return true;
87 }
88 if (obj instanceof SchemeSocketFactoryAdaptor) {
89 return this.factory.equals(((SchemeSocketFactoryAdaptor)obj).factory);
90 } else {
91 return this.factory.equals(obj);
92 }
93 }
94
95 @Override
96 public int hashCode() {
97 return this.factory.hashCode();
98 }
99
100 }