1 16 17 package org.springframework.core.io; 18 19 import java.io.FileNotFoundException ; 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 23 33 public class DescriptiveResource extends AbstractResource { 34 35 private final String description; 36 37 38 42 public DescriptiveResource(String description) { 43 this.description = (description != null ? description : ""); 44 } 45 46 47 public InputStream getInputStream() throws IOException { 48 throw new FileNotFoundException ( 49 getDescription() + " cannot be opened because it does not point to a readable resource"); 50 } 51 52 public String getDescription() { 53 return this.description; 54 } 55 56 57 60 public boolean equals(Object obj) { 61 return (obj == this || 62 (obj instanceof DescriptiveResource && ((DescriptiveResource) obj).description.equals(this.description))); 63 } 64 65 68 public int hashCode() { 69 return this.description.hashCode(); 70 } 71 72 } 73 | Popular Tags |