1 19 20 package edu.umd.cs.findbugs.classfile.impl; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 25 import edu.umd.cs.findbugs.classfile.ICodeBase; 26 import edu.umd.cs.findbugs.classfile.ICodeBaseLocator; 27 28 33 public class FilesystemCodeBaseLocator implements ICodeBaseLocator { 34 private final String pathName; 35 36 public FilesystemCodeBaseLocator(String pathName) { 37 this.pathName = pathName; 38 } 39 40 43 public String getPathName() { 44 return pathName; 45 } 46 47 50 public ICodeBaseLocator createRelativeCodeBaseLocator(String relativePath) { 51 File path = new File (pathName); 52 if (!path.isDirectory()) { 53 path = path.getParentFile(); 54 } 55 File relativeFile = new File (path, relativePath); 56 return new FilesystemCodeBaseLocator(relativeFile.getPath()); 57 } 58 59 62 public ICodeBase openCodeBase() throws IOException { 63 return ClassFactory.createFilesystemCodeBase(this); 64 } 65 66 69 @Override 70 public String toString() { 71 return "filesystem:" + pathName; 72 } 73 74 77 @Override 78 public boolean equals(Object obj) { 79 if (obj == null || obj.getClass() != this.getClass()) { 80 return false; 81 } 82 FilesystemCodeBaseLocator other = (FilesystemCodeBaseLocator) obj; 83 return this.pathName.equals(other.pathName); 84 } 85 86 89 @Override 90 public int hashCode() { 91 return pathName.hashCode(); 92 } 93 } 94 | Popular Tags |