Source Code Cross Referenced for SearchInfoFactory.java in  » IDE-Netbeans » library » org » openidex » 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 » IDE Netbeans » library » org.openidex.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 2004-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.openidex.search;
043:
044:        import org.openide.filesystems.FileObject;
045:        import org.openide.loaders.DataFolder;
046:        import org.openide.nodes.Node;
047:
048:        /**
049:         * Factory for creating <code>SearchInfo</code> objects.
050:         *
051:         * @see  SearchInfo
052:         * @since  org.openidex.util/3 3.3
053:         * @author  Marian Petras
054:         */
055:        public final class SearchInfoFactory {
056:
057:            /**
058:             * filter that skips files and folders which are not visible according
059:             * to the <code>VisibilityQuery</code>
060:             *
061:             * @see  org.netbeans.api.queries.VisibilityQuery  VisibilityQuery
062:             */
063:            public static final FileObjectFilter VISIBILITY_FILTER = new VisibilityFilter();
064:
065:            /**
066:             * filter that skips files and folders which are not sharable according
067:             * to the <code>SharabilityQuery</code>
068:             *
069:             * @see  org.netbeans.api.queries.SharabilityQuery  SharabilityQuery
070:             */
071:            public static final FileObjectFilter SHARABILITY_FILTER = new SharabilityFilter();
072:
073:            /**
074:             */
075:            private SearchInfoFactory() {
076:            }
077:
078:            //    /**
079:            //     * Creates a <code>SearchInfo</code> object for a given folder.
080:            //     * The returned <code>SearchInfo</code> object's method
081:            //     * {@link SearchInfo#canSearch()} always returns <code>true</code>
082:            //     * and iterates through <code>DataObject</code>s found in the given
083:            //     * folder. Non-sharable and/or non-visible <code>FileObject</code>s
084:            //     * may be skipped, according to enabled filters.
085:            //     *
086:            //     * @param  folder  folder which should be searched
087:            //     * @param  recursive  whether the folder's subfolders should be taken
088:            //     *                    into account
089:            //     * @param  checkVisibility  whether the visibility filter should be used
090:            //     * @param  checkSharability  whether the sharability filter should be used
091:            //     * @return  <code>SearchInfo</code> object which iterates through
092:            //     *          <code>DataObject</code>s found in the specified folder
093:            //     *          and (optionally) its subfolders
094:            //     * @see  org.netbeans.api.queries.SharabilityQuery
095:            //     * @see  org.netbeans.api.queries.VisibilityQuery
096:            //     */
097:            //    public static SearchInfo createSearchInfo(
098:            //                FileObject folder,
099:            //                boolean recursive,
100:            //                boolean checkVisibility,
101:            //                boolean checkSharability) {
102:            //        if (!folder.isFolder()) {
103:            //            throw new IllegalArgumentException("folder expected");      //NOI18N
104:            //        }
105:            //
106:            //        DataFolder dataFolder = DataFolder.findFolder(folder);
107:            //
108:            //        int filtersCount = 0;
109:            //        if (checkVisibility) {
110:            //            filtersCount++;
111:            //        }
112:            //        if (checkSharability) {
113:            //            filtersCount++;
114:            //        }
115:            //        
116:            //        if (filtersCount == 0) {
117:            //            return new SimpleSearchInfo(dataFolder, recursive, null);
118:            //        } else {
119:            //            FileObjectFilter[] filters = new FileObjectFilter[filtersCount];
120:            //            
121:            //            int i = 0;
122:            //            if (checkVisibility) {
123:            //                filters[i++] = VISIBILITY_FILTER;
124:            //            }
125:            //            if (checkSharability) {
126:            //                filters[i++] = SHARABILITY_FILTER;
127:            //            }
128:            //            return new SimpleSearchInfo(dataFolder, recursive, filters);
129:            //        }
130:            //    }
131:
132:            //    /**
133:            //     * Creates a <code>SearchInfo</code> object for given folders.
134:            //     * The returned <code>SearchInfo</code> object's method
135:            //     * {@link SearchInfo#canSearch()} always returns <code>true</code>
136:            //     * and iterates through <code>DataObject</code>s found in the given
137:            //     * folders. Non-sharable and/or non-visible <code>FileObject</code>s
138:            //     * may be skipped, according to enabled filters.
139:            //     *
140:            //     * @param  folders  folders which should be searched
141:            //     * @param  recursive  whether the folders' subfolders should be taken
142:            //     *                    into account
143:            //     * @param  checkVisibility  whether the visibility filter should be used
144:            //     * @param  checkSharability  whether the sharability filter should be used
145:            //     * @return  <code>SearchInfo</code> object which iterates through
146:            //     *          <code>DataObject</code>s found in the specified folders
147:            //     *          and (optionally) their subfolders
148:            //     * @see  org.netbeans.api.queries.SharabilityQuery
149:            //     * @see  org.netbeans.api.queries.VisibilityQuery
150:            //     */
151:            //    public static SearchInfo createSearchInfo(
152:            //                final FileObject[] folders,
153:            //                final boolean recursive,
154:            //                final boolean checkVisibility,
155:            //                final boolean checkSharability) {
156:            //        if (folders.length == 0) {
157:            //            return SimpleSearchInfo.EMPTY_SEARCH_INFO;
158:            //        }
159:            //        
160:            //        if (folders.length == 1) {
161:            //            return createSearchInfo(folders[0],
162:            //                                    recursive,
163:            //                                    checkVisibility,
164:            //                                    checkSharability);
165:            //        }
166:            //        
167:            //        for (int i = 0; i < folders.length; i++) {
168:            //            if (!folders[i].isFolder()) {
169:            //                throw new IllegalArgumentException(
170:            //                          "folder expected (index " + i + ')');         //NOI18N
171:            //            }
172:            //        }
173:            //        
174:            //        SearchInfo[] nested = new SearchInfo[folders.length];
175:            //        for (int i = 0; i < folders.length; i++) {
176:            //            nested[i] = createSearchInfo(folders[i],
177:            //                                         recursive,
178:            //                                         checkVisibility,
179:            //                                         checkSharability);
180:            //        }
181:            //        return new CompoundSearchInfo(nested);
182:            //    }
183:
184:            /**
185:             * Creates a <code>SearchInfo</code> object for a given folder.
186:             * The returned <code>SearchInfo</code> object's method
187:             * {@link SearchInfo#canSearch()} always returns <code>true</code>
188:             * and iterates through <code>DataObject</code>s found in the given
189:             * folder. Files and folders that do not pass any of the given filters
190:             * are skipped (not searched). If multiple filters are passed,
191:             * the filters are applied on each file/folder in the same order
192:             * as in the array passed to this method.
193:             *
194:             * @param  folder  folder which should be searched
195:             * @param  recursive  whether the folder's subfolders should be taken
196:             *                    into account
197:             * @param  filters  filters to be used when searching;
198:             *                  or <code>null</code> if no filters should be used
199:             * @return  <code>SearchInfo</code> object which iterates through
200:             *          <code>DataObject</code>s found in the specified folder
201:             *          and (optionally) its subfolders
202:             * @see  FileObjectFilter
203:             */
204:            public static SearchInfo createSearchInfo(final FileObject folder,
205:                    final boolean recursive, final FileObjectFilter[] filters) {
206:                if (!folder.isFolder()) {
207:                    throw new IllegalArgumentException("folder expected"); //NOI18N
208:                }
209:
210:                return new SimpleSearchInfo(DataFolder.findFolder(folder),
211:                        recursive, filters);
212:            }
213:
214:            /**
215:             * Creates a <code>SearchInfo</code> object for given folders.
216:             * The returned <code>SearchInfo</code> object's method
217:             * {@link SearchInfo#canSearch()} always returns <code>true</code>
218:             * and iterates through <code>DataObject</code>s found in the given
219:             * folders. Files and folders that do not pass any of the given filters
220:             * are skipped (not searched). If multiple filters are passed,
221:             * the filters are applied on each file/folder in the same order
222:             * as in the array passed to this method.
223:             *
224:             * @param  folders  folders which should be searched
225:             * @param  recursive  whether the folders' subfolders should be taken
226:             *                    into account
227:             * @param  filters  filters to be used when searching;
228:             *                  or <code>null</code> if no filters should be used
229:             * @return  <code>SearchInfo</code> object which iterates through
230:             *          <code>DataObject</code>s found in the specified folders
231:             *          and (optionally) their subfolders
232:             * @see  FileObjectFilter
233:             */
234:            public static SearchInfo createSearchInfo(
235:                    final FileObject[] folders, final boolean recursive,
236:                    final FileObjectFilter[] filters) {
237:                if (folders.length == 0) {
238:                    return SimpleSearchInfo.EMPTY_SEARCH_INFO;
239:                }
240:
241:                if (folders.length == 1) {
242:                    return createSearchInfo(folders[0], recursive, filters);
243:                }
244:
245:                for (int i = 0; i < folders.length; i++) {
246:                    if (!folders[i].isFolder()) {
247:                        throw new IllegalArgumentException(
248:                                "folder expected (index " + i + ')'); //NOI18N
249:                    }
250:                }
251:
252:                SearchInfo[] nested = new SearchInfo[folders.length];
253:                for (int i = 0; i < folders.length; i++) {
254:                    nested[i] = createSearchInfo(folders[i], recursive, filters);
255:                }
256:                return new CompoundSearchInfo(nested);
257:            }
258:
259:            /**
260:             * Creates a <code>SearchInfo</code> object combining
261:             * <code>SearchInfo</code> objects returned by the node's subnodes.
262:             *
263:             * Method {@link SearchInfo#canSearch()} of the resulting
264:             * <code>SearchInfo</code> objects returns <code>true</code> if and only if
265:             * at least one of the nodes is searchable
266:             * (its method <code>canSearch()</code> returns <code>true</code>).
267:             * The iterator iterates through all <code>DataObject</code>s returned
268:             * by the subnode's <code>SearchInfo</code> iterators.
269:             *
270:             * @param  node  node to create <code>SearchInfo</code> for
271:             * @return  <code>SearchInfo</code> object representing combination
272:             *          of <code>SearchInfo</code> objects of the node's subnodes
273:             */
274:            public static SearchInfo createSearchInfoBySubnodes(Node node) {
275:                return new SubnodesSearchInfo(node);
276:            }
277:
278:            /**
279:             * Creates a <code>SearchInfo</code> compound of the given delegates.
280:             * It combines the delegates such that:
281:             * <ul>
282:             *     <li>its method {@link SearchInfo#canSearch()} returns
283:             *         <code>true</code> if and only if at least one of the delegate's
284:             *         <code>canSearch()</code> returns <code>true</code></li>
285:             *     <li>its method {@link SearchInfo#objectsToSearch()} chains iterators
286:             *         of the delegates, skipping those delegates whose
287:             *         <code>canSearch()</code> method returns <code>false</code></li>
288:             * </ul>
289:             *
290:             * @param  delegates  delegates the compound <code>SearchInfo</code> should
291:             *                    delegate to
292:             * @return  created compound <code>SearchInfo</code>
293:             * @exception  java.lang.IllegalArgumentException
294:             *             if the argument is <code>null</code>
295:             * @since  3.13
296:             */
297:            public static SearchInfo createCompoundSearchInfo(
298:                    SearchInfo... delegates) {
299:                if (delegates == null) {
300:                    throw new IllegalArgumentException("null"); //NOI18N
301:                }
302:                return new CompoundSearchInfo(delegates);
303:            }
304:
305:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.