blob: d38f416b57765639531d8443b8cd7f0c88af5fc1 [file] [log] [blame]
Stuart McCulloch42151ee2012-07-16 13:43:38 +00001package aQute.bnd.osgi;
Stuart McCullochf3173222012-06-07 21:57:32 +00002
3import java.io.*;
4import java.util.*;
5
6public class CombinedResource extends WriteResource {
Stuart McCulloch4482c702012-06-15 13:27:53 +00007 final List<Resource> resources = new ArrayList<Resource>();
8 long lastModified = 0;
9
Stuart McCullochf3173222012-06-07 21:57:32 +000010 @Override
11 public void write(final OutputStream out) throws IOException, Exception {
12 OutputStream unclosable = new FilterOutputStream(out) {
13 public void close() {
14 // Ignore
15 }
16 };
Stuart McCulloch4482c702012-06-15 13:27:53 +000017 for (Resource r : resources) {
Stuart McCullochf3173222012-06-07 21:57:32 +000018 r.write(unclosable);
19 unclosable.flush();
20 }
21 }
22
23 @Override
24 public long lastModified() {
25 return lastModified;
26 }
27
28 public void addResource(Resource r) {
29 lastModified = Math.max(lastModified, r.lastModified());
30 resources.add(r);
31 }
32
Stuart McCullochf3173222012-06-07 21:57:32 +000033}