📄 searchresulthighlisht.java
字号:
package Common;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.util.ArrayList;
public class SearchResultHighLisht{
public void searchResultHighLisht(){
}
ArrayList setResultHighLight(ArrayList list,String[] key,int num){
if(list!=null){
//System.out.println("好东西"+list.size());
ArrayList resultList=new ArrayList();
for(int l=0;l<list.size();l++){
Hashtable searchTable=(Hashtable)list.get(l);
Hashtable table=searchTable;
Hashtable temp=table;
String str="";
System.out.println("list you "+list.size()+" num="+num);
String s="";
for(int i=0;i<num;i++){
if(key!=null&&!key.equals("")){
s="<font color=red>"+key[i]+"</font>";
System.out.println("i的时候"+i+"keyword is "+s);
}
if(table.get("id".toUpperCase())!=null){
str=table.get("id".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
System.out.println("id str "+str);
temp.put("id".toUpperCase(),str);
}
if(table.get("card".toUpperCase())!=null){
str=table.get("card".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("card".toUpperCase(),str);
}
if(table.get("num".toUpperCase())!=null){
str=table.get("num".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("num".toUpperCase(),str);
}
if(table.get("net".toUpperCase())!=null){
str=table.get("net".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("net".toUpperCase(),str);
}
if(table.get("photo".toUpperCase())!=null){
str=table.get("photo".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("photo".toUpperCase(),str);
}
if(table.get("price".toUpperCase())!=null){
str=table.get("price".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("price".toUpperCase(),str);
}
if(table.get("model".toUpperCase())!=null){
str=table.get("model".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("model".toUpperCase(),str);
}
if(table.get("special".toUpperCase())!=null){
str=table.get("special".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
System.out.println(str);
temp.put("special".toUpperCase(),str);
}
if(table.get("picture".toUpperCase())!=null){
str=table.get("picture".toUpperCase()).toString();
//System.out.println("old str "+str);
str=str.replace(key[i],s);
//System.out.println(str);
temp.put("picture".toUpperCase(),str);
}
System.out.println("check one");
}
if(temp!=null)resultList.add(temp);
}
return resultList;
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -