Package br.com.caelum.tubaina.parser.latex

Source Code of br.com.caelum.tubaina.parser.latex.TableTag

package br.com.caelum.tubaina.parser.latex;

import br.com.caelum.tubaina.TubainaException;
import br.com.caelum.tubaina.parser.Tag;

public class TableTag implements Tag {

  private final boolean noborder;
  private final int columns;

  public TableTag(boolean noborder, int columns) {
    this.noborder = noborder;
    this.columns = columns;
  }

  public String parse(String text, String title) {
    if (this.columns <= 0)
      throw new TubainaException("There are no columns inside table " + title);
    String tag =  "\\begin{table}[!h]\n\\caption{" + title + "}\n\\begin{center}\n";
    if (!noborder)
      tag += "\\rowcolors[]{1}{gray!30}{gray!15}\n";
    tag += "\\begin{tabular}{";
    for (int i = 0; i < columns; i++)
      tag += "l";
    tag += "}\n";
    if (!noborder)
      tag += "\\hline\n";
    tag += text;
    if (!noborder)
      tag += "\n\\hline";
    tag += "\n\\end{tabular}\n\\end{center}\n\\end{table}";
    return tag;
  }

}
TOP

Related Classes of br.com.caelum.tubaina.parser.latex.TableTag

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.