1 19 20 package org.netbeans.modules.javadoc.search; 21 22 import java.util.*; 23 import java.util.regex.*; 24 25 import org.openide.filesystems.FileObject; 26 import org.openide.ServiceType; 27 import org.openide.util.NbBundle; 28 import org.openide.ErrorManager; 29 30 37 public abstract class JavadocSearchType extends ServiceType { 38 39 40 static final long serialVersionUID =-7643543247564581246L; 41 42 47 public abstract FileObject getDocFileObject( FileObject apidocRoot ); 48 49 private Pattern[] overviewLabelFilters; 50 51 private synchronized void prepareOverviewFilter() { 52 if (overviewLabelFilters != null) 53 return; 54 String filter = NbBundle.getMessage(JavadocSearchType.class, "FILTER_OverviewIndiceLabel"); StringTokenizer tok = new StringTokenizer(filter, "\n"); LinkedList ll = new LinkedList(); 57 while (tok.hasMoreTokens()) { 58 try { 59 String expr = tok.nextToken(); 60 Pattern re = Pattern.compile(expr); 61 ll.add(re); 62 } catch (PatternSyntaxException e) { 63 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 64 } 65 } 66 overviewLabelFilters = (Pattern[])ll.toArray(new Pattern[ll.size()]); 67 } 68 69 76 public String getOverviewTitleBase(String overviewTitle) { 77 prepareOverviewFilter(); 78 Matcher match; 79 String t = overviewTitle.trim(); 80 81 for (int i = 0; i < overviewLabelFilters.length; i++) { 82 match = overviewLabelFilters[i].matcher(t); 83 if (match.matches()) { 84 return match.group(1); 85 } 86 } 87 return overviewTitle; 88 } 89 90 96 public abstract IndexSearchThread getSearchThread( String toFind, FileObject fo, IndexSearchThread.DocIndexItemConsumer diiConsumer ); 97 98 99 104 public abstract boolean accepts (FileObject apidocRoot, String encoding); 105 106 } 107 | Popular Tags |