/**
   * Renders a single option within the check box select.
   *
   * @param select the check box select being rendered.
   * @param option the option to render.
   * @param optionIndex the index of the option. OptionGroups are not counted.
   * @param html the XmlStringBuilder to paint to.
   * @param selections the list of selected options.
   * @param renderSelectionsOnly true to only render selected options, false to render all options.
   * @param encode true if the option description should be encoded, false if not.
   */
  private void renderOption(
      final WCheckBoxSelect select,
      final Object option,
      final int optionIndex,
      final XmlStringBuilder html,
      final List<?> selections,
      final boolean renderSelectionsOnly,
      final boolean encode) {
    boolean selected = selections.contains(option);

    if (selected || !renderSelectionsOnly) {
      // Get Code and Desc
      String code = select.getCode(option, optionIndex);
      String desc = select.getDesc(option, optionIndex);

      // Render Option
      html.appendTagOpen("ui:option");
      html.appendAttribute("value", code);
      html.appendOptionalAttribute("selected", selected, "true");
      html.appendClose();
      html.append(desc, encode);
      html.appendEndTag("ui:option");
    }
  }