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    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            public String parse() {
037                    StringBundler sb = new StringBundler(_children.size() * 4 + 4);
038    
039                    sb.append(OPEN_UL);
040                    sb.append(StringPool.NEW_LINE);
041    
042                    for (ResponseElement child : _children) {
043                            sb.append(child.parse());
044                    }
045    
046                    sb.append(CLOSE_UL);
047                    sb.append(StringPool.NEW_LINE);
048    
049                    return sb.toString();
050            }
051    
052            private List<ResponseElement> _children = new ArrayList<ResponseElement>();
053    
054    }