KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > core > storage > memory > ContentDAOImpl


1 package net.javacoding.jspider.core.storage.memory;
2
3 import net.javacoding.jspider.core.storage.spi.ContentDAOSPI;
4 import net.javacoding.jspider.core.storage.spi.StorageSPI;
5 import net.javacoding.jspider.core.model.ResourceInternal;
6
7 import java.io.InputStream JavaDoc;
8 import java.io.ByteArrayInputStream JavaDoc;
9 import java.util.Map JavaDoc;
10 import java.util.HashMap JavaDoc;
11
12 /**
13  * $Id: ContentDAOImpl.java,v 1.2 2003/04/11 16:37:06 vanrogu Exp $
14  */

15 class ContentDAOImpl implements ContentDAOSPI {
16
17     protected Map JavaDoc contents;
18     protected StorageSPI storage;
19
20     public ContentDAOImpl ( StorageSPI storage ) {
21         this.storage = storage;
22         this.contents = new HashMap JavaDoc ( );
23     }
24
25     public InputStream JavaDoc getInputStream(int id) {
26         byte[] bytes = (byte[]) contents.get(new Integer JavaDoc(id));
27         return new ByteArrayInputStream JavaDoc ( bytes );
28     }
29
30     public void setBytes(int id, byte[] bytes) {
31         contents.put(new Integer JavaDoc(id), bytes);
32     }
33
34 }
35
Popular Tags