1 26 27 package net.sourceforge.groboutils.util.io.v1; 28 29 import java.io.InputStream ; 30 import java.io.IOException ; 31 import java.util.Hashtable ; 32 import java.io.ByteArrayInputStream ; 33 34 35 36 45 public class HashtableInputStreamGenerator implements IInputStreamGenerator 46 { 47 private Hashtable map; 48 private String orig; 49 50 54 public HashtableInputStreamGenerator( Hashtable map ) 55 { 56 this.map = map; 57 } 58 59 60 public String getFullName( String relativeName ) 61 { 62 return relativeName; 63 } 64 65 66 public InputStream createInputStream( String relativeName ) 67 throws IOException 68 { 69 if (relativeName == null) 70 { 71 throw new IOException ("null name"); 72 } 73 74 Object o = this.map.get( relativeName ); 75 if (o == null) 76 { 77 throw new IOException ("resource '"+relativeName+"' does not exist"); 78 } 79 80 return new ByteArrayInputStream ( o.toString().getBytes() ); 81 } 82 } 83 | Popular Tags |