| Home >> All >> org >> apache >> batik >> apps >> [ rasterizer Javadoc ] |
Source code: org/apache/batik/apps/rasterizer/SVGConverterFileSource.java
1 /* 2 3 Copyright 2001,2003 The Apache Software Foundation 4 5 Licensed under the Apache License, Version 2.0 (the "License"); 6 you may not use this file except in compliance with the License. 7 You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 17 */ 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 /** 27 * Describes a file source for the <tt>SVGConverter</tt> 28 * 29 * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a> 30 * @version $Id: SVGConverterFileSource.java,v 1.5 2004/08/18 07:12:26 vhardy Exp $ 31 */ 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