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 public void close() throws IOException {
50 getInputStream().close();
51 }
52
53 public int available() throws IOException {
54 return getInputStream().available();
55 }
56
57 public synchronized void mark(int readlimit) {
58 try {
59 getInputStream().mark(readlimit);
60 }
61 catch (IOException e) {
62
63 }
64 }
65
66 public boolean markSupported() {
67 try {
68 return getInputStream().markSupported();
69 }
70 catch (IOException e) {
71 return false;
72 }
73 }
74
75 public int read(byte b[]) throws IOException {
76 return getInputStream().read(b);
77 }
78
79 public int read(byte b[], int off, int len) throws IOException {
80 return getInputStream().read(b, off, len);
81 }
82
83 public synchronized void reset() throws IOException {
84 getInputStream().reset();
85 }
86
87 public long skip(long n) throws IOException {
88 return getInputStream().skip(n);
89 }
90
91 public int read() throws IOException {
92 return getInputStream().read();
93 }
94
95
96 protected abstract InputStream createInputStream() throws IOException;
97
98
99
100
101
102 public abstract Iterator getHeaderNames() throws IOException;
103
104
105
106
107
108 public abstract Iterator getHeaders(String name) throws IOException;
109 }