1 18 package org.apache.batik.apps.rasterizer; 19 20 import java.io.File ; 21 import java.io.FileInputStream ; 22 import java.io.FileNotFoundException ; 23 import java.io.InputStream ; 24 import java.net.MalformedURLException ; 25 26 32 public class SVGConverterFileSource implements SVGConverterSource { 33 File file; 34 String ref; 35 36 public SVGConverterFileSource(File file){ 37 this.file = file; 38 } 39 40 public SVGConverterFileSource(File file, String ref){ 41 this.file = file; 42 this.ref = ref; 43 } 44 45 public String getName(){ 46 String name = file.getName(); 47 if (ref != null && !"".equals(ref)){ 48 name += "#" + ref; 49 } 50 return name; 51 } 52 53 public File getFile(){ 54 return file; 55 } 56 57 public String toString(){ 58 return getName(); 59 } 60 61 public String getURI(){ 62 try{ 63 String uri = file.toURL().toString(); 64 if (ref != null && !"".equals(ref)){ 65 uri += "#" + ref; 66 } 67 return uri; 68 } catch(MalformedURLException e){ 69 throw new Error (); 70 } 71 } 72 73 public boolean equals(Object o){ 74 if (o == null || !(o instanceof SVGConverterFileSource)){ 75 return false; 76 } 77 78 return file.equals(((SVGConverterFileSource)o).file); 79 } 80 81 public InputStream openStream() throws FileNotFoundException { 82 return new FileInputStream (file); 83 } 84 85 public boolean isSameAs(String srcStr){ 86 if (file.toString().equals(srcStr)){ 87 return true; 88 } 89 90 return false; 91 } 92 93 public boolean isReadable(){ 94 return file.canRead(); 95 } 96 } 97 98 | Popular Tags |