java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.SearchHelper

public class SearchHelperextends HelperBase
Helper for searches.
  • Field Details

    • _engine

      private String _engine
      Engine the search form submits to.
    • _query

      private String _query
      Text being searched for.
    • _engines

      private Map<String,String> _engines
      The search engines, by name.
    • S

      private static final char S
      Separator between engines in the config property.
      See Also:
    • PROP_ENGINES

      static final String PROP_ENGINES
      Search engines config property.
      See Also:
    • PROP_DEFAULT

      private static final String PROP_DEFAULT
      Property naming the default search engine.
      See Also:
    • DEFAULT

      private static final String DEFAULT
      Engine used when the property is unset.
      See Also:
    • ENGINES_DEFAULT

      static final String ENGINES_DEFAULT
      Default search engine list.
      See Also:
    • SS

      private static final String 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 until buildEngineMap() parses the router property.
  • Method Details

    • setEngine

      public void setEngine(String s)
      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

      public void setQuery(String s)
      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

      public String getSelector()
      Builds the HTML select element listing configured engines, or a notice if none.
      Returns:
      the select markup, or the "no engines" notice
    • getURL

      public String getURL()
      Build and return the search URL for the current query.
      Returns:
      null on error