vdmeer/asciitable

Empty text in cells cause an exception (when using CWC_LongestLine)

thnaeff opened this issue · 0 comments

If a cell content has a length == 0, it throws an exception when validating the content. It seems like this happens when all cells in a column are empty and when I am using CWC_LongestLine as column width calculator. When using CWC_AbsoluteEven it does not give this exception.

java.lang.IllegalStateException: text width is less than 1, was <0>
at org.apache.commons.lang3.Validate.validState(Validate.java:826)
at de.vandermeer.skb.interfaces.transformers.textformat.Text_To_FormattedText.transform(Text_To_FormattedText.java:215)
at de.vandermeer.asciitable.AT_Renderer.renderAsCollection(AT_Renderer.java:250)
at de.vandermeer.asciitable.AT_Renderer.render(AT_Renderer.java:128)
at de.vandermeer.asciitable.AT_Renderer.render(AT_Renderer.java:112)
at de.vandermeer.asciitable.AsciiTable.render(AsciiTable.java:185)
...

The validation happens in Text_To_FormattedText.java

Validate.validState(this.getTextWidth()>0, "text width is less than 1, was <" + this.getTextWidth() + ">");

In my opinion, it should be ok to have empty content in a cell for the whole column. Could this be changed to this.getTextWidth()>=0?