Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StreamXmlDoc |
|
| 1.3333333333333333;1.333 |
1 | /* | |
2 | * Copyright 2007-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kew.batch; | |
17 | ||
18 | import org.apache.commons.io.IOUtils; | |
19 | ||
20 | import java.io.ByteArrayInputStream; | |
21 | import java.io.IOException; | |
22 | import java.io.InputStream; | |
23 | ||
24 | /** | |
25 | * Stream-based XML doc | |
26 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
27 | */ | |
28 | 0 | public class StreamXmlDoc extends BaseXmlDoc { |
29 | private byte[] bytes; | |
30 | private InputStream stream; | |
31 | public StreamXmlDoc(InputStream stream, XmlDocCollection collection) { | |
32 | 0 | super(collection); |
33 | 0 | this.stream = stream; |
34 | 0 | } |
35 | public synchronized InputStream getStream() throws IOException { | |
36 | // this sucks, but does it suck less than copying the file? | |
37 | // or dealing with concurrency issues on a surveilling input stream | |
38 | 0 | if (bytes == null) { |
39 | 0 | bytes = IOUtils.toByteArray(stream); |
40 | } | |
41 | 0 | return new ByteArrayInputStream(bytes); |
42 | } | |
43 | public String getName() { | |
44 | 0 | return stream.toString(); |
45 | } | |
46 | } |