1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
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  /**
21   * <a href="Leaf.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Bruno Farache
24   */
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  }