net.i2p.router.web

## Class HelperBase

- java.lang.Object
- - net.i2p.router.web.HelperBase

- Direct Known Subclasses:
    CertHelper, ConfigAdvancedHelper, ConfigClientsHelper, ConfigFamilyHelper, ConfigKeyringHelper, ConfigLoggingHelper, ConfigNavHelper, ConfigNetHelper, ConfigPeerHelper, ConfigReseedHelper, ConfigStatsHelper, ConfigTunnelsHelper, ConfigUIHelper, ConfigUpdateHelper, ContentHelper, CSSHelper, FileDumpHelper, HelpSectionHelper, HomeHelper, InfoHelper, JobQueueHelper, LogsHelper, NewsFeedHelper, PeerHelper, ProfilesHelper, ReseedGenerator, ReseedHandler, SearchHelper, SidebarHelper, StatHelper, TransitSummaryHelper, TunnelBandwidthHelper, TunnelHelper, TunnelParticipatingFastestHelper, TunnelParticipatingHelper, TunnelPeerCountHelper, WizardHelper

      public abstract class HelperBase
      extends Object

  Base helper class for JSP helper beans. Provides common functionality for router context access, translation services, and UI helper methods.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RouterContext` | `_context` the router context
    `protected Writer` | `_out` the writer for output
    `static String` | `CHECKED` Checked attribute for HTML checkboxes.
    `static String` | `PROP_ADVANCED` Property key for advanced mode.
    `static String` | `SELECTED` Selected attribute for HTML select options.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HelperBase()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `_t(String s)` Translate a string.
    `String` | `_t(String s, Object o)` Translate a string with a parameter.
    `String` | `_t(String s, Object o, Object o2)` Translate a string with two parameters.
    `static String` | `_x(String s)` Mark a string for extraction by xgettext and translation.
    `protected String` | `getChecked(String prop)` Get the checked attribute for a boolean property.
    `protected String` | `getCheckedDefaultTrue(String prop)` Get the checked attribute for a boolean property that defaults to true.
    `boolean` | `isAdvanced()` Check if advanced mode is enabled.
    `String` | `ngettext(String s, String p, int n)` Translate a string with plural forms (ngettext).
    `void` | `setContextId(String contextId)` Configure this bean to query a particular router context.
    `void` | `storeWriter(Writer out)` Store the writer for output.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _context

          protected RouterContext _context

      the router context

    - #### _out

          protected Writer _out

      the writer for output

    - #### CHECKED

          public static final String CHECKED

      Checked attribute for HTML checkboxes.
      See Also:
        Constant Field Values

    - #### PROP_ADVANCED

          public static final String PROP_ADVANCED

      Property key for advanced mode.
      See Also:
        Constant Field Values

    - #### SELECTED

          public static final String SELECTED

      Selected attribute for HTML select options.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HelperBase

          public HelperBase()

  - ### Method Detail

    - #### _t

          public String _t(String s)

      Translate a string.
      Parameters:
        `s` - the string to translate
      Returns:
        the translated string

    - #### _t

          public String _t(String s,
                           Object o)

      Translate a string with a parameter. This is a lot more expensive than _t(s), so use sparingly.
      Parameters:
        `s` - string to be translated containing {0} The {0} will be replaced by the parameter. Single quotes must be doubled, i.e. ' -> '' in the string.
        `o` - parameter, not translated. To translate parameter also, use _t("foo {0} bar", _t("baz")) Do not double the single quotes in the parameter. Use autoboxing to call with ints, longs, floats, etc.
      Returns:
        the translated string

    - #### _t

          public String _t(String s,
                           Object o,
                           Object o2)

      Translate a string with two parameters.
      Parameters:
        `s` - string to be translated containing {0} and {1}
        `o` - first parameter
        `o2` - second parameter
      Returns:
        the translated string

    - #### _x

          public static String _x(String s)

      Mark a string for extraction by xgettext and translation. Use this only in static initializers. It does not translate!
      Parameters:
        `s` - the string to mark
      Returns:
        s

    - #### getChecked

          protected String getChecked(String prop)

      Get the checked attribute for a boolean property.
      Parameters:
        `prop` - the property name, must default to false
      Returns:
        non-null, either "" or " checked "

    - #### getCheckedDefaultTrue

          protected String getCheckedDefaultTrue(String prop)

      Get the checked attribute for a boolean property that defaults to true.
      Parameters:
        `prop` - the property name
      Returns:
        non-null, either "" or " checked "

    - #### isAdvanced

          public boolean isAdvanced()

      Check if advanced mode is enabled.
      Returns:
        true if advanced mode is enabled

    - #### ngettext

          public String ngettext(String s,
                                 String p,
                                 int n)

      Translate a string with plural forms (ngettext).
      Parameters:
        `s` - singular form
        `p` - plural form
        `n` - the count to determine which form to use
      Returns:
        the translated string

    - #### setContextId

          public void setContextId(String contextId)

      Configure this bean to query a particular router context.
      Parameters:
        `contextId` - beginning few characters of the routerHash, or null to pick the first one we come across.

    - #### storeWriter

          public void storeWriter(Writer out)

      Store the writer for output. Renamed from setWriter, we really don't want setFoo(non-String) to prevent jsp.error.beans.property.conversion 500 error for ?writer=foo
      Parameters:
        `out` - the writer to store