Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `PrettyTable` class handles a table as shown above. The `TableBuilder` class
Here are the basics for how to create a `PrettyTable` as shown above:
```Java
import rickwporter.prettytable.PrettyTable;
import rickwporter.prettytable.PrettyTable.OutputFormat;
import rickwporter.prettytable.OutputFormat;

PrettyTable table = new PrettyTable("Column A", "Column 2", "Column III");
table.addRow("A", "B", "c");
Expand Down Expand Up @@ -131,7 +131,7 @@ Using the **json** format (e.g. `OutputFormat.JSON`), you get the following outp
### Alignment
ASCII **text**, **rich**, and **html** support different alignments. Here's how you would update the above table:
```Java
import rickwporter.prettytable.PrettyTable.HorizontalAlign;
import rickwporter.prettytable.HorizontalAlign;

table.setHorizAligns(HorizontalAlign.LEFT, HorizontalAlign.CENTER, HorizontalAlign.RIGHT);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import org.apache.commons.lang3.StringUtils;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;

abstract class BaseTextTableRender implements TableRenderInterface {
private static final Pattern NEWLINE = Pattern.compile("\\R");

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/rickwporter/prettytable/HorizontalAlign.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package rickwporter.prettytable;

public enum HorizontalAlign {
CENTER("text-align:center"),
LEFT("text-align:left"),
RIGHT("text-align:right");

private final String htmlStyle;

HorizontalAlign(String html) {
this.htmlStyle = html;
}

public String getHtmlStyle() {
return this.htmlStyle;
}
}
3 changes: 0 additions & 3 deletions src/main/java/rickwporter/prettytable/HtmlTableRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import java.util.List;
import java.util.stream.Collectors;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;
import rickwporter.prettytable.PrettyTable.OutputFormat;

class HtmlTableRender implements TableRenderInterface {
private static final String HTML_TABLE_TAG = "table";
private static final String HTML_HEADER_TAG = "thead";
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/rickwporter/prettytable/JsonTableRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;

import rickwporter.prettytable.PrettyTable.OutputFormat;

class JsonTableRender implements TableRenderInterface {
String jsonEncode(Object object) {
if (object instanceof Integer) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/rickwporter/prettytable/OutputFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package rickwporter.prettytable;

public enum OutputFormat {
TEXT,
RICH,
CSV,
HTML,
JSON,
}
22 changes: 0 additions & 22 deletions src/main/java/rickwporter/prettytable/PrettyTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,6 @@
public final class PrettyTable {
private static final Pattern NEWLINE = Pattern.compile("\\R");

public enum HorizontalAlign {
CENTER("text-align:center"),
LEFT("text-align:left"),
RIGHT("text-align:right");

private final String htmlStyle;
HorizontalAlign(String html) {
this.htmlStyle = html;
}
public String getHtmlStyle() {
return this.htmlStyle;
}
}

public enum OutputFormat {
TEXT,
RICH,
CSV,
HTML,
JSON,
}

private List<String> headers = new ArrayList<>();
private List<List<Object>> rows = new ArrayList<>();
private List<HorizontalAlign> hAligns = new ArrayList<>();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/rickwporter/prettytable/RichTableRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;

class RichTableRender extends BaseTextTableRender {
// Four characters are left, fill, junction, right.
private static final TableGlyphs HEAVY_TOP = new TableGlyphs('┏', '━', '┳', '┓');
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/rickwporter/prettytable/TableBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import java.util.Map;
import java.util.Set;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;

public final class TableBuilder {
private static final String WILDCARD_COLUMN = "*";
private static final Object MANY_KEYS = new Object();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/rickwporter/prettytable/TextTableRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;

class TextTableRender extends BaseTextTableRender {
private static final TableGlyphs RULE = new TableGlyphs('+', '-', '+', '+');
private static final TableGlyphs VERTICAL = new TableGlyphs('|', ' ', '|', '|');
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/rickwporter/prettytable/PrettyTableTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package rickwporter.prettytable;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;
import rickwporter.prettytable.PrettyTable.OutputFormat;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;
import rickwporter.prettytable.PrettyTable.OutputFormat;

public class RichTableRenderTest {
@Test
public void testBasicRich() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/rickwporter/prettytable/TableBuilderTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package rickwporter.prettytable;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package rickwporter.prettytable;

import org.junit.jupiter.api.Test;

import rickwporter.prettytable.PrettyTable.HorizontalAlign;
import rickwporter.prettytable.PrettyTable.OutputFormat;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TextTableRenderTest {
@Test
Expand Down
Loading