01: /* *****************************************************************************
02: * Data.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.data;
11:
12: import org.openlaszlo.xml.DataEncoder;
13: import javax.servlet.http.HttpServletResponse;
14: import java.io.InputStream;
15: import java.io.IOException;
16: import java.io.InterruptedIOException;
17:
18: /**
19: * An abstraction for holding data.
20: *
21: * @author <a href="mailto:bloch@laszlosystems.com">Eric Bloch</a>
22: */
23: public abstract class Data {
24:
25: /**
26: * @return input stream on the data. IO operations on the stream that
27: * timeout should throw InterrupedIOExceptions
28: *
29: * @throws IOException on an io exception
30: * @throws InterruptedIOException on a timeout
31: */
32: public abstract InputStream getInputStream()
33: throws InterruptedIOException, IOException;
34:
35: /**
36: * @return mime type of data (or null if unknown)
37: */
38: public abstract String getMimeType();
39:
40: /**
41: * This method should be implemented for Data's who's mime-type is XML.
42: *
43: * @return a string containing the data
44: * @throws IOException on an IOException
45: * @throws InterruptedIOException on a timeout
46: */
47: public String getAsString() throws InterruptedIOException,
48: IOException {
49: throw new RuntimeException("unimplemented");
50: }
51:
52: /**
53: * This method should be implemented for Data's who's mime-type is XML.
54: *
55: * Append any response meta data into the given string as XML
56: */
57: public void appendResponseHeadersAsXML(StringBuffer xmlResponse) {
58: throw new RuntimeException("unimplemented");
59: }
60:
61: /**
62: * Checks if the data was not modified.
63: *
64: * @return true if the data was "not modified" since
65: * the last time it was accessed.
66: */
67: public boolean notModified() {
68: return false;
69: }
70:
71: /**
72: * @return size of the data if known or -1 if not known
73: */
74: public long size() {
75: return -1;
76: }
77:
78: /**
79: * @return the lastModified time of the data or -1
80: * if the last modified time is unknown.
81: */
82: public long lastModified() {
83: return -1;
84: }
85:
86: /**
87: * release any resources associated with this data
88: */
89: public void release() {
90: }
91: }
|