001    /**
002     * Copyright (c) 2000-2013 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    import java.util.ArrayList;
021    import java.util.List;
022    
023    /**
024     * @author Bruno Farache
025     */
026    public class Tree implements ResponseElement {
027    
028            public static final String CLOSE_UL = "</ul>";
029    
030            public static final String OPEN_UL = "<ul>";
031    
032            public void addChild(ResponseElement node) {
033                    _children.add(node);
034            }
035    
036            @Override
037            public String parse() {
038                    StringBundler sb = new StringBundler(_children.size() * 4 + 4);
039    
040                    sb.append(OPEN_UL);
041                    sb.append(StringPool.NEW_LINE);
042    
043                    for (ResponseElement child : _children) {
044                            sb.append(child.parse());
045                    }
046    
047                    sb.append(CLOSE_UL);
048                    sb.append(StringPool.NEW_LINE);
049    
050                    return sb.toString();
051            }
052    
053            private List<ResponseElement> _children = new ArrayList<ResponseElement>();
054    
055    }