001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
021     * @author Bruno Farache
022     */
023    public class Property implements ResponseElement {
024    
025            public static final String OPEN_PARAGRAPH = "<p>";
026    
027            public Property(String key, ResponseElement value) {
028                    this(key, StringPool.NEW_LINE + value.parse(), false);
029            }
030    
031            public Property(String key, String value) {
032                    this(key, value, true);
033            }
034    
035            public Property(String key, String value, boolean newLine) {
036                    _key = key;
037                    _value = value;
038                    _newLine = newLine;
039            }
040    
041            @Override
042            public String parse() {
043                    StringBundler sb = new StringBundler(5);
044    
045                    sb.append(OPEN_PARAGRAPH);
046                    sb.append(_key);
047                    sb.append(StringPool.EQUAL);
048                    sb.append(_value);
049    
050                    if (_newLine) {
051                            sb.append(StringPool.NEW_LINE);
052                    }
053    
054                    return sb.toString();
055            }
056    
057            private String _key;
058            private boolean _newLine;
059            private String _value;
060    
061    }