MCPcopy Create free account
hub / github.com/xmlet/HtmlFlow / HtmlPage

Class HtmlPage

htmlflow-core/src/main/java/htmlflow/HtmlPage.java:53–124  ·  view source on GitHub ↗

The root container for HTML elements. It is responsible for managing the org.xmlet.htmlapi.ElementVisitor implementation, which is responsible for printing the tree of elements and attributes. Instances of HtmlPage are immutable. Any change to its properties returns a new instance of Htm

Source from the content-addressed store, hash-verified

51 * @author Miguel Gamboa, Luís Duare created on 29-03-2012
52 */
53public abstract class HtmlPage implements Element<HtmlPage, Element<?, ?>> {
54
55 public static final String HEADER;
56 private static final String NEWLINE = System.getProperty("line.separator");
57 private static final String HEADER_TEMPLATE =
58 "templates/HtmlView-Header.txt";
59
60 static {
61 try {
62 URL headerUrl =
63 HtmlPage.class.getClassLoader().getResource(HEADER_TEMPLATE);
64 if (headerUrl == null) throw new FileNotFoundException(
65 HEADER_TEMPLATE
66 );
67 InputStream headerStream = headerUrl.openStream();
68 try (
69 BufferedReader reader = new BufferedReader(
70 new InputStreamReader(headerStream)
71 )
72 ) {
73 HEADER = reader.lines().collect(joining(NEWLINE));
74 }
75 } catch (IOException e) {
76 throw new UncheckedIOException(e);
77 }
78 }
79
80 public abstract Html<HtmlPage> html();
81
82 public final Div<HtmlPage> div() {
83 return new Div<>(this);
84 }
85
86 public final Tr<HtmlPage> tr() {
87 return new Tr<>(this);
88 }
89
90 public final Span<HtmlPage> span() {
91 return new Span<>(this);
92 }
93
94 public final Tbody<HtmlPage> tbody() {
95 return new Tbody<>(this);
96 }
97
98 /**
99 * Returns a new instance of HtmlFlow with the same properties of this object but with indented
100 * set to the value of isIndented parameter.
101 */
102 public abstract HtmlPage setIndented(boolean isIndented);
103
104 @Override
105 public final HtmlPage self() {
106 return this;
107 }
108
109 public abstract HtmlPage threadSafe();
110

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected