ContentDAOImpl.java
上传用户:qing5858
上传日期:2015-10-27
资源大小:6056k
文件大小:1k
源码类别:

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.core.storage.memory;
  2. import net.javacoding.jspider.core.storage.spi.ContentDAOSPI;
  3. import net.javacoding.jspider.core.storage.spi.StorageSPI;
  4. import net.javacoding.jspider.core.model.ResourceInternal;
  5. import java.io.InputStream;
  6. import java.io.ByteArrayInputStream;
  7. import java.util.Map;
  8. import java.util.HashMap;
  9. /**
  10.  * $Id: ContentDAOImpl.java,v 1.2 2003/04/11 16:37:06 vanrogu Exp $
  11.  */
  12. class ContentDAOImpl implements ContentDAOSPI {
  13.     protected Map contents;
  14.     protected StorageSPI storage;
  15.     public ContentDAOImpl ( StorageSPI storage ) {
  16.         this.storage = storage;
  17.         this.contents = new HashMap ( );
  18.     }
  19.     public InputStream getInputStream(int id) {
  20.         byte[] bytes = (byte[]) contents.get(new Integer(id));
  21.         return new ByteArrayInputStream ( bytes );
  22.     }
  23.     public void setBytes(int id, byte[] bytes) {
  24.         contents.put(new Integer(id), bytes);
  25.     }
  26. }