java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.SearchHelper
Helper for searches.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringEngine the search form submits to.The search engines, by name.private StringText being searched for.private static final StringEngine used when the property is unset.(package private) static final StringDefault search engine list.private static final StringProperty naming the default search engine.(package private) static final StringSearch engines config property.private static final charSeparator between engines in the config property.private static final StringThe separator as a string, for splitting.Fields inherited from class HelperBase
_context, _log, _out, CHECKED, PROP_ADVANCED, SELECTEDModifier and TypeFieldDescriptionprotected RouterContextThe router context.protected LogThe log instance.protected WriterThe writer for output.static final StringChecked attribute for HTML checkboxes.static final StringProperty key for advanced mode.static final StringSelected attribute for HTML select options.Constructor Summary
ConstructorsConstructorDescriptionNo query or engine chosen yet, and the engine map starts empty untilbuildEngineMap()parses the router property.Method Summary
Modifier and TypeMethodDescriptionprivate voidReads the engine list from the config.Builds the HTML select element listing configured engines, or a notice if none.getURL()Build and return the search URL for the current query.voidSelects the search engine, saving a non-default choice as the new default.voidStores the search string to hand to the selected engine.Methods inherited from class HelperBase
_t, _t, _t, _x, getChecked, isAdvanced, ngettext, setContextId, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected StringgetChecked(String prop) Get the checked attribute for a boolean property.booleanCheck if advanced mode is enabled.Translate a string with plural forms (ngettext).voidsetContextId(String contextId) Configure this bean to query a particular router context.voidstoreWriter(Writer out) Store the writer for output.
Field Details
_engine
Engine the search form submits to._query
Text being searched for._engines
S
private static final char SSeparator between engines in the config property.- See Also:
PROP_ENGINES
PROP_DEFAULT
Property naming the default search engine.- See Also:
DEFAULT
Engine used when the property is unset.- See Also:
ENGINES_DEFAULT
SS
The separator as a string, for splitting.
Constructor Details
SearchHelper
public SearchHelper()No query or engine chosen yet, and the engine map starts empty untilbuildEngineMap()parses the router property.
Method Details
setEngine
Selects the search engine, saving a non-default choice as the new default.- Parameters:
s- search engine name to select; a non-default value is saved as the new default
setQuery
Stores the search string to hand to the selected engine.- Parameters:
s- the search string to hand to the selected engine
buildEngineMap
private void buildEngineMap()Reads the engine list from the config.getSelector
Builds the HTML select element listing configured engines, or a notice if none.- Returns:
- the select markup, or the "no engines" notice
getURL