protected void encodeCell(
      FacesContext context, DataTable table, UIColumn column, String clientId, boolean selected)
      throws IOException {
    if (!column.isRendered()) {
      return;
    }

    ResponseWriter writer = context.getResponseWriter();
    boolean selectionEnabled = column.getSelectionMode() != null;
    String style = column.getStyle();
    String styleClass =
        selectionEnabled
            ? DataTable.SELECTION_COLUMN_CLASS
            : (column.getCellEditor() != null) ? DataTable.EDITABLE_COLUMN_CLASS : null;
    String userStyleClass = column.getStyleClass();
    styleClass =
        userStyleClass == null
            ? styleClass
            : (styleClass == null) ? userStyleClass : styleClass + " " + userStyleClass;

    writer.startElement("td", null);
    writer.writeAttribute("role", "gridcell", null);
    if (style != null) writer.writeAttribute("style", style, null);
    if (styleClass != null) writer.writeAttribute("class", styleClass, null);

    if (selectionEnabled) encodeColumnSelection(context, table, clientId, column, selected);
    else column.encodeAll(context);

    writer.endElement("td");
  }