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    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    }