1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.util.Iterator;
22
23 import org.springframework.util.Assert;
24
25
26
27
28
29
30
31
32
33
34 public abstract class TransportInputStream extends InputStream {
35
36 private InputStream inputStream;
37
38 protected TransportInputStream() {
39 }
40
41 private InputStream getInputStream() throws IOException {
42 if (inputStream == null) {
43 inputStream = createInputStream();
44 Assert.notNull(inputStream, "inputStream must not be null");
45 }
46 return inputStream;
47 }
48
49 @Override
50 public void close() throws IOException {
51 getInputStream().close();
52 }
53
54 @Override
55 public int available() throws IOException {
56 return getInputStream().available();
57 }
58
59 @Override
60 public synchronized void mark(int readlimit) {
61 try {
62 getInputStream().mark(readlimit);
63 }
64 catch (IOException e) {
65
66 }
67 }
68
69 @Override
70 public boolean markSupported() {
71 try {
72 return getInputStream().markSupported();
73 }
74 catch (IOException e) {
75 return false;
76 }
77 }
78
79 @Override
80 public int read(byte b[]) throws IOException {
81 return getInputStream().read(b);
82 }
83
84 @Override
85 public int read(byte b[], int off, int len) throws IOException {
86 return getInputStream().read(b, off, len);
87 }
88
89 @Override
90 public synchronized void reset() throws IOException {
91 getInputStream().reset();
92 }
93
94 @Override
95 public long skip(long n) throws IOException {
96 return getInputStream().skip(n);
97 }
98
99 @Override
100 public int read() throws IOException {
101 return getInputStream().read();
102 }
103
104
105 protected abstract InputStream createInputStream() throws IOException;
106
107
108
109
110
111 public abstract Iterator<String> getHeaderNames() throws IOException;
112
113
114
115
116
117 public abstract Iterator<String> getHeaders(String name) throws IOException;
118 }