public class BookDao {
public static Map<String, String> bookMap=new LinkedHashMap<String, String>();
//程序先执行静态块,初始化数据
static{
bookMap.put("J2EE整合详解与典型案例", "89");
bookMap.put("VISUAL C# 2008开发技术实例祥解", "69");
bookMap.put("STRUTS 2技术详", "69");
bookMap.put("ASP经典模块开发大全", "79");
bookMap.put("ASP.NET 3.5网络数据库开发实例自学手册", "65");
bookMap.put("XML开发典型应用:数据标记、处理、共享与分析", "79");
}
public Map<String, String> find(String bookName){
//实例化hashmap用于返回查询数据
Map<String, String> books=new HashMap<String, String>();
//获取set视图
Set<Map.Entry<String, String>> set=bookMap.entrySet();
Iterator<Entry<String, String>> it=set.iterator();
while(it.hasNext()){
Map.Entry<String, String> entry=(Map.Entry<String, String>)it.next();
if(entry.getKey().contains(bookName)){
books.put(entry.getKey(), entry.getValue());
}
}
return books;
}
}
public static Map<String, String> bookMap=new LinkedHashMap<String, String>();
//程序先执行静态块,初始化数据
static{
bookMap.put("J2EE整合详解与典型案例", "89");
bookMap.put("VISUAL C# 2008开发技术实例祥解", "69");
bookMap.put("STRUTS 2技术详", "69");
bookMap.put("ASP经典模块开发大全", "79");
bookMap.put("ASP.NET 3.5网络数据库开发实例自学手册", "65");
bookMap.put("XML开发典型应用:数据标记、处理、共享与分析", "79");
}
public Map<String, String> find(String bookName){
//实例化hashmap用于返回查询数据
Map<String, String> books=new HashMap<String, String>();
//获取set视图
Set<Map.Entry<String, String>> set=bookMap.entrySet();
Iterator<Entry<String, String>> it=set.iterator();
while(it.hasNext()){
Map.Entry<String, String> entry=(Map.Entry<String, String>)it.next();
if(entry.getKey().contains(bookName)){
books.put(entry.getKey(), entry.getValue());
}
}
return books;
}
}