Source Code Cross Referenced for SearchProxy.java in  » Portal » DLOG4J » dlog4j » search » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » DLOG4J » dlog4j.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  This program is free software; you can redistribute it and/or modify
003:         *  it under the terms of the GNU General Public License as published by
004:         *  the Free Software Foundation; either version 2 of the License, or
005:         *  (at your option) any later version.
006:         *
007:         *  This program is distributed in the hope that it will be useful,
008:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
009:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
010:         *  GNU Library General Public License for more details.
011:         *
012:         *  You should have received a copy of the GNU General Public License
013:         *  along with this program; if not, write to the Free Software
014:         *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015:         */
016:        package dlog4j.search;
017:
018:        import java.io.IOException;
019:        import java.util.List;
020:
021:        import org.apache.lucene.analysis.Analyzer;
022:        import org.apache.lucene.index.IndexReader;
023:        import org.apache.lucene.index.IndexWriter;
024:        import org.apache.lucene.queryParser.ParseException;
025:        import org.apache.lucene.search.IndexSearcher;
026:        import org.apache.lucene.search.Searcher;
027:        import org.apache.lucene.store.Directory;
028:        import org.apache.lucene.store.FSDirectory;
029:
030:        /**
031:         * 信息搜索的代理类,通过该类可以获取对日记以及评论信息的搜索,索引的删除增加等功能
032:         * 两个子类:LogSearchProxy;ReplySearchProxy
033:         * 
034:         * @author Liudong
035:         */
036:        public abstract class SearchProxy {
037:
038:            public final static String SEGMENTS = "segments";
039:
040:            /**
041:             * 获取日记搜索代理
042:             * @return
043:             */
044:            public static SearchProxy getLogQuery() {
045:                return new LogSearchProxy();
046:            }
047:
048:            /**
049:             * 获取评论搜索代理
050:             * @return
051:             */
052:            public static SearchProxy getReplyQuery() {
053:                return new ReplySearchProxy();
054:            }
055:
056:            /**
057:             * 搜索信息
058:             * @param word 要搜索的关键字
059:             * @param from 结果集合的起点
060:             * @param count 取结果数(当该值小于零时取全部信息)
061:             * @return
062:             */
063:            public abstract List searchFor(int site, int catid, String word,
064:                    int from, int count) throws IOException, ParseException;
065:
066:            /**
067:             * 增加某个对象的索引
068:             * @param obj
069:             * @return
070:             * @throws IOException
071:             */
072:            public abstract int addIndex(Object obj) throws IOException;
073:
074:            /**
075:             * 删除指定编号的信息的索引
076:             * @param id
077:             * @return
078:             */
079:            public abstract int deleteIndex(int[] id) throws IOException;
080:
081:            /**
082:             * 更新索引信息
083:             * @param obj
084:             * @return
085:             */
086:            public abstract int updateIndex(Object obj) throws IOException;
087:
088:            /**
089:             * 获取一个索引的Writer
090:             * @return
091:             */
092:            public abstract IndexWriter getWriter() throws IOException;
093:
094:            /**
095:             * 获取一个搜索的助理
096:             * @param idxPath
097:             * @return
098:             * @throws IOException
099:             */
100:            protected Searcher getSearcher(String idxPath) throws IOException {
101:                Searcher searcher = null;
102:                //Acquire a lock -- analyzer is a convenient object to do this on.
103:                synchronized (getAnalyzer()) {
104:                    Directory searchDirectory = FSDirectory.getDirectory(
105:                            idxPath, false);
106:                    IndexReader reader = IndexReader.open(searchDirectory);
107:                    searcher = new IndexSearcher(reader);
108:                }
109:                return searcher;
110:            }
111:
112:            /**
113:             * 获取日记索引所在的目录
114:             * @return
115:             */
116:            protected String getLogIndexPath() {
117:                return SearchEnginePlugIn.getLogIndexPath();
118:            }
119:
120:            /**
121:             * 获取评论索引所在的目录
122:             * @return
123:             */
124:            protected String getReplyIndexPath() {
125:                return SearchEnginePlugIn.getReplyIndexPath();
126:            }
127:
128:            /**
129:             * 得到查询分析器
130:             * @return
131:             */
132:            protected Analyzer getAnalyzer() {
133:                return SearchEnginePlugIn.getAnalyzer();
134:            }
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.