01: package com.flexive.war.webdav.catalina;
02:
03: import java.io.ByteArrayInputStream;
04: import java.io.IOException;
05: import java.io.InputStream;
06:
07: /**
08: * Catalina sources cloned for packaging issues to the flexive source tree.
09: * Refactored to JDK 1.5 compatibility.
10: * Licensed under the Apache License, Version 2.0
11: * <p/>
12: * Encapsultes the contents of a resource.
13: *
14: * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
15: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
16: */
17: public class Resource {
18:
19: // ----------------------------------------------------------- Constructors
20:
21: public Resource() {
22: }
23:
24: public Resource(InputStream inputStream) {
25: setContent(inputStream);
26: }
27:
28: public Resource(byte[] binaryContent) {
29: setContent(binaryContent);
30: }
31:
32: // ----------------------------------------------------- Instance Variables
33:
34: /**
35: * Binary content.
36: */
37: protected byte[] binaryContent = null;
38:
39: /**
40: * Input stream.
41: */
42: protected InputStream inputStream = null;
43:
44: // ------------------------------------------------------------- Properties
45:
46: /**
47: * Content accessor.
48: *
49: * @return InputStream
50: */
51: public InputStream streamContent() throws IOException {
52: if (binaryContent != null) {
53: return new ByteArrayInputStream(binaryContent);
54: }
55: return inputStream;
56: }
57:
58: /**
59: * Content accessor.
60: *
61: * @return binary content
62: */
63: public byte[] getContent() {
64: return binaryContent;
65: }
66:
67: /**
68: * Content mutator.
69: *
70: * @param inputStream New input stream
71: */
72: public void setContent(InputStream inputStream) {
73: this .inputStream = inputStream;
74: }
75:
76: /**
77: * Content mutator.
78: *
79: * @param binaryContent New bin content
80: */
81: public void setContent(byte[] binaryContent) {
82: this.binaryContent = binaryContent;
83: }
84:
85: }
|