?? folderpart.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 + -