1 package net.sourceforge.importscrubber; 2 3 import java.io.File ; 4 import java.io.FilenameFilter ; 5 import java.util.*; 6 7 10 public class FilePair 11 { 12 13 16 private class InnerClassFilter implements FilenameFilter 17 { 18 public boolean accept(File dir, String name) 19 { 20 if (name.indexOf("$") == -1) { 22 return false; 23 } 24 String className = _classFile.getName(); 26 className = className.substring(0, className.indexOf(".")); 27 return name.startsWith(className); 28 } 29 } 30 private File _sourceFile; 31 private File _classFile; 32 33 38 public FilePair(File sourceFile, File classFile) 39 { 40 _sourceFile = sourceFile; 41 _classFile = classFile; 42 } 43 44 public File getSourceFile() 45 { 46 return _sourceFile; 47 } 48 49 public ListIterator getClassFiles() 50 { 51 List files = new ArrayList(); 52 files.add(_classFile); 53 if (_classFile.getParent() != null) { 54 File dir = new File (_classFile.getParent()); 55 files.addAll(Arrays.asList(dir.listFiles(new InnerClassFilter()))); 56 } 57 return files.listIterator(); 58 } 59 60 public int hashCode() 61 { 62 return _sourceFile.hashCode(); 63 } 64 65 public boolean equals(Object o) 66 { 67 return o instanceof FilePair 68 && ((FilePair)o).getSourceFile().compareTo(_sourceFile) == 0; 69 } 70 71 public String toString() 72 { 73 return _sourceFile.getAbsolutePath(); 74 } 75 } 76 | Popular Tags |