1 package org.kuali.maven.mojo.s3;
2
3 import org.apache.commons.lang.StringUtils;
4
5
6
7
8 public class HtmlUtils {
9
10 int indent = 0;
11
12 public String getIndentedContent(final String content) {
13 return getIndent() + content;
14 }
15
16 public String getIndent() {
17 return StringUtils.repeat(" ", indent);
18 }
19
20
21
22
23 public String getHref(final String dest, final String show) {
24 return getIndent() + "<a href=\"" + dest + "\">" + show + "</a>";
25 }
26
27
28
29
30 public String getImage(final String image) {
31 return getIndent() + "<img src=\"" + image + "\">";
32 }
33
34 public String openTag(final Tag tag) {
35 StringBuffer sb = new StringBuffer();
36 sb.append(getIndent());
37 indent++;
38 sb.append("<" + tag.getName());
39 if (tag.getId() != null) {
40 sb.append(" id=\"" + tag.getId() + '"');
41 }
42 if (tag.getClazz() != null) {
43 sb.append(" class=\"" + tag.getClazz() + '"');
44 }
45 sb.append(">\n");
46 return sb.toString();
47 }
48
49 public String closeTag(final Tag tag) {
50 indent--;
51 return getIndent() + "</" + tag.getName() + ">\n";
52 }
53
54 public String getTag(final Tag tag, final String content) {
55 StringBuffer sb = new StringBuffer();
56 sb.append(openTag(tag));
57 sb.append(getIndent());
58 sb.append(content);
59 sb.append("\n");
60 sb.append(closeTag(tag));
61 return sb.toString();
62 }
63 }