KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > data > Data


1 /* *****************************************************************************
2  * Data.java
3 * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.data;
11
12 import org.openlaszlo.xml.DataEncoder;
13 import javax.servlet.http.HttpServletResponse JavaDoc;
14 import java.io.InputStream JavaDoc;
15 import java.io.IOException JavaDoc;
16 import java.io.InterruptedIOException JavaDoc;
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 JavaDoc getInputStream()
33         throws InterruptedIOException JavaDoc, IOException JavaDoc;
34
35     /**
36      * @return mime type of data (or null if unknown)
37      */

38     public abstract String JavaDoc 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 JavaDoc getAsString() throws InterruptedIOException JavaDoc, IOException JavaDoc {
48         throw new RuntimeException JavaDoc("unimplemented");
49     }
50
51     /**
52      * This method should be implemented for Data's who's mime-type is XML.
53      *
54      * Append any response meta data into the given string as XML
55      */

56     public void appendResponseHeadersAsXML(StringBuffer JavaDoc xmlResponse) {
57         throw new RuntimeException JavaDoc("unimplemented");
58     }
59
60     /**
61      * Checks if the data was not modified.
62      *
63      * @return true if the data was "not modified" since
64      * the last time it was accessed.
65      */

66     public boolean notModified() {
67         return false;
68     }
69
70     /**
71      * @return size of the data if known or -1 if not known
72      */

73     public long size() {
74         return -1;
75     }
76
77     /**
78      * @return the lastModified time of the data or -1
79      * if the last modified time is unknown.
80      */

81     public long lastModified() {
82         return -1;
83     }
84
85     /**
86      * release any resources associated with this data
87      */

88     public void release() {
89     }
90 }
91
Popular Tags