001
014
015 package com.liferay.portal.sharepoint;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019
020
023 public class Leaf implements ResponseElement {
024
025 public static final String OPEN_LI = "<li>";
026
027 public Leaf(String key, ResponseElement value) {
028 this(key, StringPool.NEW_LINE + value.parse(), true, false);
029 }
030
031 public Leaf(String key, String value, boolean useEqualSymbol) {
032 this(key, value, useEqualSymbol, true);
033 }
034
035 public Leaf(
036 String key, String value, boolean useEqualSymbol, boolean newLine) {
037
038 _key = key;
039 _value = value;
040 _useEqualSymbol = useEqualSymbol;
041 _newLine = newLine;
042 }
043
044 @Override
045 public String parse() {
046 StringBundler sb = new StringBundler(7);
047
048 if (_useEqualSymbol) {
049 sb.append(OPEN_LI);
050
051 sb.append(_key);
052 sb.append(StringPool.EQUAL);
053 sb.append(_value);
054 }
055 else {
056 sb.append(OPEN_LI);
057 sb.append(_key);
058
059 sb.append(StringPool.NEW_LINE);
060
061 sb.append(OPEN_LI);
062 sb.append(_value);
063 }
064
065 if (_newLine) {
066 sb.append(StringPool.NEW_LINE);
067 }
068
069 return sb.toString();
070 }
071
072 private String _key;
073 private boolean _newLine;
074 private boolean _useEqualSymbol;
075 private String _value;
076
077 }