001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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, String value) {
028                    this(key, value, true);
029            }
030    
031            public Property(String key, ResponseElement value) {
032                    this(key, StringPool.NEW_LINE + value.parse(), false);
033            }
034    
035            public Property(String key, String value, boolean newLine) {
036                    _key = key;
037                    _value = value;
038                    _newLine = newLine;
039            }
040    
041            public String parse() {
042                    StringBundler sb = new StringBundler(5);
043    
044                    sb.append(OPEN_PARAGRAPH);
045                    sb.append(_key);
046                    sb.append(StringPool.EQUAL);
047                    sb.append(_value);
048    
049                    if (_newLine) {
050                            sb.append(StringPool.NEW_LINE);
051                    }
052    
053                    return sb.toString();
054            }
055    
056            private String _key;
057            private String _value;
058            private boolean _newLine;
059    
060    }