KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > publisher > serverimpl > BlobInfoImpl


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.outerj.daisy.publisher.serverimpl;
17
18 import org.outerj.daisy.publisher.BlobInfo;
19 import org.outerj.daisy.repository.Part;
20 import org.outerj.daisy.repository.RepositoryException;
21
22 import java.util.Date JavaDoc;
23 import java.io.InputStream JavaDoc;
24
25 public class BlobInfoImpl implements BlobInfo {
26     private Part part;
27     private Date JavaDoc lastModified;
28     private boolean disposed = false;
29     private static final String JavaDoc DISPOSED_MESSAGE = "This BlobInfo object has been disposed.";
30
31     public BlobInfoImpl(Part part, Date JavaDoc lastModified) {
32         this.part = part;
33         this.lastModified = lastModified;
34     }
35
36     public Date JavaDoc getLastModified() {
37         if (disposed)
38             throw new RuntimeException JavaDoc(DISPOSED_MESSAGE);
39         return lastModified;
40     }
41
42     public String JavaDoc getMimeType() {
43         if (disposed)
44             throw new RuntimeException JavaDoc(DISPOSED_MESSAGE);
45         return part.getMimeType();
46     }
47
48     public long getSize() {
49         if (disposed)
50             throw new RuntimeException JavaDoc(DISPOSED_MESSAGE);
51         return part.getSize();
52     }
53
54     public InputStream JavaDoc getInputStream() throws RepositoryException {
55         if (disposed)
56             throw new RuntimeException JavaDoc(DISPOSED_MESSAGE);
57         return part.getDataStream();
58     }
59
60     public void dispose() {
61         this.disposed = true;
62         this.part = null;
63         this.lastModified = null;
64     }
65 }
66
Popular Tags