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

📄 operator_filecontents.java

📁 java实现的全文搜索引擎
💻 JAVA
字号:
/**
 * 
 */
package cn.edu.nju.software.ruse;

import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author spring
 *
 */
public class Operator_FileContents extends Operator {

	/* (non-Javadoc)
	 * @see cn.edu.nju.software.ruse.Operator#getPRI()
	 */
	public Operator_FileContents() {
		desription = "FILECONTENTS";
		PRI = PRI_FILECONTENTS;
	}
	public int getPRI() {
		return PRI;
	}
	@SuppressWarnings("unchecked")
	public HashSet<File> getFileSet(String expre, Index index) {
		//System.err.println("@Operator_FileContents Starting to getFileSet from the index!");
		expre = expre.trim();
		expre = expre.toLowerCase();
		Pattern p = Pattern.compile("(?i)(fileContents\\s*:)");
		Matcher m = p.matcher(expre);
		if(m.find()) {
			expre = expre.substring(m.group().length());
		}
		HashMap<String,HashMap<File,HashSet<Integer>>> fileContentsIndex = index.getFileContentsIndex();
		if(!fileContentsIndex.containsKey(expre)) {
			return new HashSet<File>();
		}
		HashMap<File,HashSet<Integer>> temp = fileContentsIndex.get(expre);
		return new HashSet<File>(temp.keySet());
	}

}

⌨️ 快捷键说明

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