⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 folderpart.java

📁 JDK1.4编译器前端
💻 JAVA
字号:

package AST;
import java.util.HashSet;import java.util.LinkedHashSet;import java.io.FileNotFoundException;import java.io.File;import java.util.*;import beaver.*;import java.util.ArrayList;import java.util.zip.*;import java.io.*;// load files from a folderpublic class FolderPart extends PathPart {
    // Declared in ClassPath.jrag at line 378    private HashMap map = new HashMap();    // Declared in ClassPath.jrag at line 379    private File folder;    // Declared in ClassPath.jrag at line 381    public FolderPart(File folder) {      this.folder = folder;    }    // Declared in ClassPath.jrag at line 385    public boolean hasPackage(String name) {      return filesInPackage(name) != null;    }    // Declared in ClassPath.jrag at line 389    public boolean hasCompilationUnit(String canonicalName) {      int index = canonicalName.lastIndexOf('.');      String packageName = index == -1 ? "" : canonicalName.substring(0, index);      String typeName = canonicalName.substring(index + 1, canonicalName.length());      Collection c = filesInPackage(packageName);      boolean result = c != null && c.contains(typeName + fileSuffix());      return result;    }    // Declared in ClassPath.jrag at line 398        private Collection filesInPackage(String packageName) {      if(!map.containsKey(packageName)) {        File f = new File(folder, packageName.replace('.', File.separatorChar));        Collection c = Collections.EMPTY_LIST;        if(f.exists() && f.isDirectory()) {          String[] files = f.list();          if(files.length > 0) {            c = new HashSet();            for(int i = 0; i < files.length; i++)              c.add(files[i]);          }        }        else          c = null;        map.put(packageName, c);      }      return (Collection)map.get(packageName);    }    // Declared in ClassPath.jrag at line 417        public boolean selectCompilationUnit(String canonicalName) throws IOException {      if(hasCompilationUnit(canonicalName)) {        String fileName = canonicalName.replace('.', File.separatorChar);        File classFile = new File(folder, fileName + fileSuffix());        if(classFile.isFile()) {          is = new FileInputStream(classFile);          age = classFile.lastModified();          pathName = classFile.getAbsolutePath();          relativeName = fileName + fileSuffix();          fullName = canonicalName;          return true;        }      }      return false;    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -