URIs

Uniform Resource Identifiers (URIs) can be used in a table. No special rules are applied to them for line breaks. The renderer tries to put as many characters of a URI into a single line as possible.

The following example shows a table with various columns and URIs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]", "scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]");
at.addRule();
at.addRow(null, "scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]");
at.addRule();
at.addRow("abc://username:password@example.com:123/path/data?key=value#fragid1", "abc://username:password@example.com:123/path/data?key=value#fragid1");
at.addRule();
at.addRow(null, "abc://username:password@example.com:123/path/data?key=value#fragid1");
at.addRule();
at.addRow("urn:example:mammal:monotreme:echidna", "urn:example:mammal:monotreme:echidna");
at.addRule();
at.addRow(null, "urn:example:mammal:monotreme:echidna");
at.addRule();
at.addRow("http://www.example.com/test1/test2", "http://www.example.com/test1/test2");
at.addRule();
at.addRow(null, "http://www.example.com/test1/test2");
at.addRule();
at.addRow("mailto:user1@example.com", "mailto:firstname.lastname@example.com");
at.addRule();
at.addRow(null, "mailto:firstname.lastname@example.com");
at.addRule();

System.out.println(at.render(73));

The resulting output:

┌───────────────────────────────────┬───────────────────────────────────┐
│scheme:[//[user:password@]host[:por│scheme:[//[user:password@]host[:por│
│t]][/]path[?query][#fragment]      │t]][/]path[?query][#fragment]      │
├───────────────────────────────────┴───────────────────────────────────┤
│scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]       │
├───────────────────────────────────┬───────────────────────────────────┤
│abc://username:password@example.com│abc://username:password@example.com│
│:123/path/data?key=value#fragid1   │:123/path/data?key=value#fragid1   │
├───────────────────────────────────┴───────────────────────────────────┤
│abc://username:password@example.com:123/path/data?key=value#fragid1    │
├───────────────────────────────────┬───────────────────────────────────┤
│urn:example:mammal:monotreme:echidn│urn:example:mammal:monotreme:echidn│
│a                                  │a                                  │
├───────────────────────────────────┴───────────────────────────────────┤
│urn:example:mammal:monotreme:echidna                                   │
├───────────────────────────────────┬───────────────────────────────────┤
│http://www.example.com/test1/test2 │http://www.example.com/test1/test2 │
├───────────────────────────────────┴───────────────────────────────────┤
│http://www.example.com/test1/test2                                     │
├───────────────────────────────────┬───────────────────────────────────┤
│mailto:user1@example.com           │mailto:firstname.lastname@example.c│
│                                   │om                                 │
├───────────────────────────────────┴───────────────────────────────────┤
│mailto:firstname.lastname@example.com                                  │
└───────────────────────────────────────────────────────────────────────┘