Source Code Cross Referenced for FileSearchEngine.java in  » Wiki-Engine » VeryQuickWiki » vqwiki » file » 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 » Wiki Engine » VeryQuickWiki » vqwiki.file 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package vqwiki.file;
002:
003:        import java.io.File;
004:        import java.util.Collection;
005:        import java.util.TreeSet;
006:
007:        import vqwiki.AbstractSearchEngine;
008:        import vqwiki.WikiBase;
009:        import vqwiki.WikiException;
010:        import vqwiki.servlets.WikiServlet;
011:        import vqwiki.utils.TextFileFilter;
012:        import vqwiki.utils.Utilities;
013:
014:        /**
015:         * Very Quick Wiki - WikiWikiWeb clone
016:         * Copyright (C) 2001-2002 Gareth Cronin
017:         *
018:         * This is the search engine for the default file system. There are some idiosyncracies
019:         * in order to keep compatibility with the pre-virtual-wiki implementations:
020:         * Whenever the default virtual wiki with the context "jsp" is accessed, the path is
021:         * altered so the files are put/read to/from the root of the Wiki home directory as
022:         * with earlier versions.
023:         *
024:         *This program is free software; you can redistribute it and/or modify
025:         *it under the terms of the latest version of the GNU Lesser General
026:         *Public License as published by the Free Software Foundation;
027:         *
028:         *This program is distributed in the hope that it will be useful,
029:         *but WITHOUT ANY WARRANTY; without even the implied warranty of
030:         *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031:         *GNU Lesser General Public License for more details.
032:         *
033:         *You should have received a copy of the GNU Lesser General Public License
034:         *along with this program (gpl.txt); if not, write to the Free Software
035:         *Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
036:         *
037:         *
038:         */
039:        public class FileSearchEngine extends AbstractSearchEngine {
040:
041:            /** A pointer to self. Used for the singleton pattern */
042:            private static FileSearchEngine instance = null;
043:
044:            /**
045:             * Create the new FileSearchEnginge. The constructor is private, so that
046:             * it cannot be instanciated from outside thsi class. Use getInstance()
047:             * instead.
048:             *
049:             * @throws java.lang.Exception
050:             */
051:            private FileSearchEngine() throws Exception {
052:            }
053:
054:            /**
055:             * Create an instance of the FileSearchEngine
056:             * @return a reference to the only FileSearchEngine existing
057:             * @throws java.lang.Exception
058:             */
059:            public static synchronized FileSearchEngine getInstance()
060:                    throws Exception {
061:                if (instance == null) {
062:                    instance = new FileSearchEngine();
063:                    instance.initSearchEngine(WikiServlet.getCurrentContext());
064:                }
065:                return instance;
066:            }
067:
068:            /**
069:             * find the base directory to use for a virtual wiki
070:             * @param virtualWiki the virtual wiki to find the base directory for
071:             * @return base directory for a particular virtual wiki
072:             */
073:            protected String dir(String virtualWiki) {
074:                return FileHandler.fileBase(virtualWiki);
075:            }
076:
077:            /**
078:             * Return a list of all topic names for one given virtual Wiki
079:             *
080:             * @param virtualWiki The virtual viki, for which the topic names are requested
081:             *
082:             * @return A List of Topic Names (Collection of Strings).
083:             *
084:             * @throws Exception Exception during search
085:             * @throws WikiException Virtual wiki cannot be found
086:             */
087:            public Collection getAllTopicNames(String virtualWiki)
088:                    throws Exception {
089:                Collection all = new TreeSet();
090:                if (virtualWiki.equals(WikiBase.DEFAULT_VWIKI)) {
091:                    virtualWiki = "";
092:                }
093:                File file = new File(dir(virtualWiki));
094:                if (!file.exists()) {
095:                    throw new WikiException("Directory can not be accessed: "
096:                            + file);
097:                }
098:                File[] files = file.listFiles(new TextFileFilter());
099:                for (int i = 0; i < files.length; i++) {
100:                    String fileName = Utilities.decodeSafeFileName(files[i]
101:                            .getName());
102:                    all.add(fileName.substring(0, fileName.length()
103:                            - FileHandler.EXT.length()));
104:                }
105:                return all;
106:            }
107:
108:            /**
109:             * Get the filename of a topic file.
110:             * @see vqwiki.AbstractSearchEngine#getFilename(java.lang.String, java.lang.String)
111:             */
112:            protected String getFilename(String currentWiki, String topic) {
113:                return FileHandler.getPathFor(currentWiki,
114:                        topic + FileHandler.EXT).getName();
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.