All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nocrala.tools.texttablefmt.Row Maven / Gradle / Ivy

Go to download

Java Text Table Formatter is a Java library that renders tables made of characters. The user add cells and can add format characteristics like predefined/custom table styles, text alignment, abbreviation, column width, border types, colspan, etc.

The newest version!
package org.nocrala.tools.texttablefmt;

import java.util.ArrayList;
import java.util.List;

import org.nocrala.tools.utils.Log;

class Row {

  private List cells;

  Row() {
    this.cells = new ArrayList();
  }

  public void addCell(final String content, final CellStyle style,
      final int colSpan) {
    this.cells.add(new Cell(content, style, colSpan));
  }

  public boolean hasSeparator(final int pos) {
    Log.debug("----> pos=" + pos);
    if (pos == 0) {
      return true;
    }
    int i = 0;
    for (Cell cell : this.cells) {
      Log.debug("i=" + i);
      if (i < pos) {
        if (i + cell.getColSpan() > pos) {
          Log.debug("TRUE");
          return false;
        }
      } else {
        return true;
      }
      i = i + cell.getColSpan();
    }
    return true;
  }

  int getSize() {
    return this.cells.size();
  }

  Cell get(final int index) {
    return this.cells.get(index);
  }

  List getCells() {
    return this.cells;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy