| Property.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
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="Property.java.html"><b><i>View Source</i></b></a>
22 *
23 * @author Bruno Farache
24 */
25 public class Property implements ResponseElement {
26
27 public static final String OPEN_PARAGRAPH = "<p>";
28
29 public Property(String key, String value) {
30 this(key, value, true);
31 }
32
33 public Property(String key, ResponseElement value) {
34 this(key, StringPool.NEW_LINE + value.parse(), false);
35 }
36
37 public Property(String key, String value, boolean newLine) {
38 _key = key;
39 _value = value;
40 _newLine = newLine;
41 }
42
43 public String parse() {
44 StringBundler sb = new StringBundler(5);
45
46 sb.append(OPEN_PARAGRAPH);
47 sb.append(_key);
48 sb.append(StringPool.EQUAL);
49 sb.append(_value);
50
51 if (_newLine) {
52 sb.append(StringPool.NEW_LINE);
53 }
54
55 return sb.toString();
56 }
57
58 private String _key;
59 private String _value;
60 private boolean _newLine;
61
62 }