1 18 package org.apache.batik.apps.svgbrowser; 19 20 import java.io.File ; 21 22 import org.apache.batik.util.ParsedURL; 23 24 31 public class SVGInputHandler implements SquiggleInputHandler { 32 public static final String [] SVG_MIME_TYPES = 33 { "image/svg+xml" }; 34 35 public static final String [] SVG_FILE_EXTENSIONS = 36 { ".svg", ".svgz" }; 37 38 41 public String [] getHandledMimeTypes() { 42 return SVG_MIME_TYPES; 43 } 44 45 48 public String [] getHandledExtensions() { 49 return SVG_FILE_EXTENSIONS; 50 } 51 52 55 public String getDescription() { 56 return ""; 57 } 58 59 62 public void handle(ParsedURL purl, JSVGViewerFrame svgViewerFrame) { 63 svgViewerFrame.getJSVGCanvas().loadSVGDocument(purl.toString()); 64 } 65 66 69 public boolean accept(File f) { 70 return f != null && f.isFile() && accept(f.getPath()); 71 } 72 73 76 public boolean accept(ParsedURL purl) { 77 if (purl == null) { 81 return false; 82 } 83 84 String path = purl.getPath(); 85 if (path == null) return false; 86 87 return accept(path); 88 } 89 90 93 public boolean accept(String path) { 94 if (path == null) return false; 95 for (int i=0; i<SVG_FILE_EXTENSIONS.length; i++) { 96 if (path.endsWith(SVG_FILE_EXTENSIONS[i])) { 97 return true; 98 } 99 } 100 101 return false; 102 } 103 } 104 | Popular Tags |