1 19 20 package edu.umd.cs.findbugs.classfile.impl; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import java.util.HashMap ; 25 import java.util.Iterator ; 26 import java.util.Map ; 27 28 import edu.umd.cs.findbugs.classfile.ICodeBaseEntry; 29 import edu.umd.cs.findbugs.classfile.ICodeBaseIterator; 30 import edu.umd.cs.findbugs.classfile.ICodeBaseLocator; 31 import edu.umd.cs.findbugs.classfile.IScannableCodeBase; 32 import edu.umd.cs.findbugs.classfile.ResourceNotFoundException; 33 34 42 public abstract class AbstractScannableCodeBase implements IScannableCodeBase { 43 private ICodeBaseLocator codeBaseLocator; 44 private boolean checkedForSourceFiles; 45 private boolean containsSourceFiles; 46 private boolean isAppCodeBase; 47 private int howDiscovered; 48 private long lastModifiedTime; 49 private Map <String , String > resourceNameTranslationMap; 50 51 public AbstractScannableCodeBase(ICodeBaseLocator codeBaseLocator) { 52 this.codeBaseLocator = codeBaseLocator; 53 this.lastModifiedTime = -1L; 54 this.resourceNameTranslationMap = new HashMap <String , String >(); 55 } 56 57 60 public ICodeBaseLocator getCodeBaseLocator() { 61 return codeBaseLocator; 62 } 63 64 67 public boolean containsSourceFiles() throws InterruptedException { 68 if (true) return false; 70 if (!checkedForSourceFiles) { 71 ICodeBaseIterator i = iterator(); 72 while (i.hasNext()) { 73 ICodeBaseEntry entry = i.next(); 74 if (entry.getResourceName().endsWith(".java")) { 75 containsSourceFiles = true; 76 break; 77 } 78 } 79 checkedForSourceFiles = true; 80 } 81 return containsSourceFiles; 82 } 83 84 87 public void setApplicationCodeBase(boolean isAppCodeBase) { 88 this.isAppCodeBase = isAppCodeBase; 89 } 90 91 94 public boolean isApplicationCodeBase() { 95 return isAppCodeBase; 96 } 97 98 101 public void setHowDiscovered(int howDiscovered) { 102 this.howDiscovered = howDiscovered; 103 } 104 105 108 public int getHowDiscovered() { 109 return howDiscovered; 110 } 111 112 115 public void setLastModifiedTime(long lastModifiedTime) { 116 if (lastModifiedTime > 0) { 117 this.lastModifiedTime = lastModifiedTime; 118 } 119 } 120 121 124 public long getLastModifiedTime() { 125 return lastModifiedTime; 126 } 127 128 public void addResourceNameTranslation(String origResourceName, String newResourceName) { 129 resourceNameTranslationMap.put(origResourceName, newResourceName); 130 } 131 132 public String translateResourceName(String resourceName) { 133 String translatedName = resourceNameTranslationMap.get(resourceName); 134 return translatedName != null ? translatedName : resourceName; 135 } 136 } 137 | Popular Tags |