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