1
14
15 package com.liferay.portal.sharepoint;
16
17 import com.liferay.portal.kernel.util.StringBundler;
18 import com.liferay.portal.kernel.util.StringPool;
19
20
25 public class Leaf implements ResponseElement {
26
27 public static final String OPEN_LI = "<li>";
28
29 public Leaf(String key, ResponseElement value) {
30 this(key, StringPool.NEW_LINE + value.parse(), true, false);
31 }
32
33 public Leaf(String key, String value, boolean useEqualSymbol) {
34 this(key, value, useEqualSymbol, true);
35 }
36
37 public Leaf(
38 String key, String value, boolean useEqualSymbol, boolean newLine) {
39
40 _key = key;
41 _value = value;
42 _useEqualSymbol = useEqualSymbol;
43 _newLine = newLine;
44 }
45
46 public String parse() {
47 StringBundler sb = new StringBundler(7);
48
49 if (_useEqualSymbol) {
50 sb.append(OPEN_LI);
51
52 sb.append(_key);
53 sb.append(StringPool.EQUAL);
54 sb.append(_value);
55 }
56 else {
57 sb.append(OPEN_LI);
58 sb.append(_key);
59
60 sb.append(StringPool.NEW_LINE);
61
62 sb.append(OPEN_LI);
63 sb.append(_value);
64 }
65
66 if (_newLine) {
67 sb.append(StringPool.NEW_LINE);
68 }
69
70 return sb.toString();
71 }
72
73 private String _key;
74 private String _value;
75 private boolean _useEqualSymbol;
76 private boolean _newLine;
77
78 }