Public Member Functions | |
FoundList | search (String value, boolean ignoreCase) |
ISearchable
interface must be implemented by all those searchable elements. Elephant's search implentation provides a set of utilities for helping this implementation. The only requirement for an element to be searchable is to implement this interface.
A sample implementation could be:
public FoundList search(String value, boolean ignoreCase) { // TODO: Prepare elements to query. // Create a FoundList to store concidences. FoundList fl = new FoundList(); // Create a SearchFormatter to check coincidences. SearchFormatter sf = new SearchFormatter(value, ignoreCase); // Process lines / strings from this element. sf.processLine(line); // Test whether something was found. if(sf.wasFound()) { // add the element fl.addItem( // Identifier getId() == null ? "" : getId(), // Link to element location (context.getPath().length() == 0 ? "/" : context.getPath()) + "#" + resource, // Image identifying the element "<img src='" + getConstructor().getRootWebPath() + "/_internal/system/images/webpage.gif'/>", // Context name context.getName(), // Result provided by SearchFormatter sf.getResult(), // Similarity provided by SearchFormatter (double)sf.getFound(), // Searched value, passed as parameter value ); } return fl; }
Definition at line 67 of file ISearchable.java.
FoundList org.turro.elephant.search.ISearchable.search | ( | String | value, |
boolean | ignoreCase | ||
) |
This method is called by Elephant search implementation.
value | Value to search. |
ignoreCase | Whether to ignore case. |
Implemented in org.turro.elephant.impl.context.DefaultElement, org.turro.elephant.impl.context.DefaultContext, org.turro.publication.www.PublicationWeb, and org.turro.newsletter.NewsletterDashboard.