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.hc.core5.http.io.entity;
29
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.io.OutputStream;
33 import java.util.List;
34 import java.util.Set;
35
36 import org.apache.hc.core5.annotation.Contract;
37 import org.apache.hc.core5.annotation.ThreadingBehavior;
38 import org.apache.hc.core5.function.Supplier;
39 import org.apache.hc.core5.http.Header;
40 import org.apache.hc.core5.http.HttpEntity;
41 import org.apache.hc.core5.util.Args;
42
43
44
45
46
47
48
49
50 @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
51 public class HttpEntityWrapper implements HttpEntity {
52
53
54 private final HttpEntity wrappedEntity;
55
56
57
58
59
60
61 public HttpEntityWrapper(final HttpEntity wrappedEntity) {
62 super();
63 this.wrappedEntity = Args.notNull(wrappedEntity, "Wrapped entity");
64 }
65
66 @Override
67 public boolean isRepeatable() {
68 return wrappedEntity.isRepeatable();
69 }
70
71 @Override
72 public boolean isChunked() {
73 return wrappedEntity.isChunked();
74 }
75
76 @Override
77 public long getContentLength() {
78 return wrappedEntity.getContentLength();
79 }
80
81 @Override
82 public String getContentType() {
83 return wrappedEntity.getContentType();
84 }
85
86 @Override
87 public String getContentEncoding() {
88 return wrappedEntity.getContentEncoding();
89 }
90
91 @Override
92 public InputStream getContent()
93 throws IOException {
94 return wrappedEntity.getContent();
95 }
96
97 @Override
98 public void writeTo(final OutputStream outStream)
99 throws IOException {
100 wrappedEntity.writeTo(outStream);
101 }
102
103 @Override
104 public boolean isStreaming() {
105 return wrappedEntity.isStreaming();
106 }
107
108 @Override
109 public Supplier<List<? extends Header>> getTrailers() {
110 return wrappedEntity.getTrailers();
111 }
112
113 @Override
114 public Set<String> getTrailerNames() {
115 return wrappedEntity.getTrailerNames();
116 }
117
118 @Override
119 public void close() throws IOException {
120 wrappedEntity.close();
121 }
122
123 @Override
124 public String toString() {
125 return "Wrapper [" + wrappedEntity + "]";
126 }
127
128 }