-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathHTMLContainer.java
More file actions
48 lines (40 loc) · 945 Bytes
/
Copy pathHTMLContainer.java
File metadata and controls
48 lines (40 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package javaforce.webui;
/** HTML container for generic types
*
* @author pquiring
*/
public class HTMLContainer extends Container {
private String tag, text;
private boolean enclosed = true;
public HTMLContainer(String tag) {
this.tag = tag;
if (tag.equals("hr") || tag.equals("br")) {
enclosed = false;
}
text = "";
}
public HTMLContainer(String tag, String text) {
this.tag = tag;
this.text = text;
}
public void setEnclosed(boolean state) {
this.enclosed = state;
}
public void setText(String text) {
this.text = text;
}
public String html() {
StringBuilder sb = new StringBuilder();
sb.append("<" + tag + getAttrs() + ">");
int cnt = count();
if (cnt == 0) {
sb.append(text);
} else {
for(int a=0;a<cnt;a++) {
sb.append(get(a).html());
}
}
if (enclosed) sb.append("</" + tag + ">");
return sb.toString();
}
}