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.nio.entity;
29
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.io.OutputStream;
33
34 import org.apache.http.HttpEntity;
35 import org.apache.http.entity.HttpEntityWrapper;
36 import org.apache.http.nio.ContentDecoder;
37 import org.apache.http.nio.IOControl;
38
39
40
41
42
43
44
45
46
47
48
49 @Deprecated
50 public class ConsumingNHttpEntityTemplate
51 extends HttpEntityWrapper implements ConsumingNHttpEntity {
52
53 private final ContentListener contentListener;
54
55 public ConsumingNHttpEntityTemplate(
56 final HttpEntity httpEntity,
57 final ContentListener contentListener) {
58 super(httpEntity);
59 this.contentListener = contentListener;
60 }
61
62 public ContentListener getContentListener() {
63 return contentListener;
64 }
65
66 @Override
67 public InputStream getContent() throws IOException, UnsupportedOperationException {
68 throw new UnsupportedOperationException("Does not support blocking methods");
69 }
70
71 @Override
72 public boolean isStreaming() {
73 return true;
74 }
75
76 @Override
77 public void writeTo(final OutputStream out) throws IOException, UnsupportedOperationException {
78 throw new UnsupportedOperationException("Does not support blocking methods");
79 }
80
81 @Override
82 public void consumeContent(
83 final ContentDecoder decoder,
84 final IOControl ioControl) throws IOException {
85 this.contentListener.contentAvailable(decoder, ioControl);
86 }
87
88 @Override
89 public void finish() {
90 this.contentListener.finished();
91 }
92
93 }