001    /**
002     * Copyright (c) 2000-present 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.util;
016    
017    import com.liferay.portal.kernel.util.HtmlUtil;
018    import com.liferay.portal.kernel.util.StringBundler;
019    
020    import java.io.Serializable;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class LayoutDescription implements Serializable {
026    
027            public LayoutDescription(long plid, String name, int depth) {
028                    _plid = plid;
029                    _name = name;
030                    _depth = depth;
031            }
032    
033            public int getDepth() {
034                    return _depth;
035            }
036    
037            public String getDisplayName() {
038                    StringBundler sb = new StringBundler(_depth + 1);
039    
040                    for (int i = 0; i < _depth; i++) {
041                            sb.append("-&nbsp;");
042                    }
043    
044                    sb.append(HtmlUtil.escape(_name));
045    
046                    return sb.toString();
047            }
048    
049            public String getName() {
050                    return _name;
051            }
052    
053            public long getPlid() {
054                    return _plid;
055            }
056    
057            @Override
058            public String toString() {
059                    StringBundler sb = new StringBundler(7);
060    
061                    sb.append("{depth=");
062                    sb.append(_depth);
063                    sb.append(", name=");
064                    sb.append(_name);
065                    sb.append(", plid=");
066                    sb.append(_plid);
067                    sb.append("}");
068    
069                    return sb.toString();
070            }
071    
072            private final int _depth;
073            private final String _name;
074            private final long _plid;
075    
076    }