AdminPageBean.java 3.76 KB
Newer Older
Bill Lynch's avatar
Bill Lynch committed
1 2
/**
 * $RCSfile$
Bill Lynch's avatar
Bill Lynch committed
3
 * $Revision$
Bill Lynch's avatar
Bill Lynch committed
4 5
 * $Date$
 *
6
 * Copyright (C) 2004-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
7
 *
8 9 10 11 12 13 14 15 16 17 18
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
Bill Lynch's avatar
Bill Lynch committed
19 20 21 22 23 24 25 26 27
 */

package org.jivesoftware.admin;

import org.jivesoftware.util.StringUtils;

import java.util.Collection;
import java.util.ArrayList;

Bill Lynch's avatar
Bill Lynch committed
28 29 30
/**
 * A bean to hold page information for the admin console.
 */
Bill Lynch's avatar
Bill Lynch committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
public class AdminPageBean {

    private String title;
    private Collection breadcrumbs;
    private String pageID;
    private String subPageID;
    private String extraParams;
    private Collection scripts;

    public AdminPageBean() {
    }

    /**
     * Returns the title of the page with HTML escaped.
     */
    public String getTitle() {
        if (title != null) {
            return StringUtils.escapeHTMLTags(title);
        }
        else {
            return title;
        }
    }

    /**
     * Sets the title of the admin console page.
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * Returns a collection of breadcrumbs. Use the Collection API to get/set/remove crumbs.
     */
    public Collection getBreadcrumbs() {
        if (breadcrumbs == null) {
            breadcrumbs = new ArrayList();
        }
        return breadcrumbs;
    }

    /**
     * Returns the page ID (corresponds to sidebar ID's).
     */
    public String getPageID() {
        return pageID;
    }

    /**
     * Sets the ID of the page (corresponds to sidebar ID's).
     * @param pageID
     */
    public void setPageID(String pageID) {
        this.pageID = pageID;
    }

    /**
     * Returns the subpage ID (corresponds to sidebar ID's).
     */
    public String getSubPageID() {
        return subPageID;
    }

    /**
     * Sets the subpage ID (corresponds to sidebar ID's).
     * @param subPageID
     */
    public void setSubPageID(String subPageID) {
        this.subPageID = subPageID;
    }

    /**
     * Returns a string of extra parameters for the URLs - these might be specific IDs for resources.
     */
    public String getExtraParams() {
        return extraParams;
    }

    /**
     * Sets the string of extra parameters for the URLs.
     */
    public void setExtraParams(String extraParams) {
        this.extraParams = extraParams;
    }

    /**
     * Returns a collection of scripts. Use the Collection API to get/set/remove scripts.
     */
    public Collection getScripts() {
        if (scripts == null) {
            scripts = new ArrayList();
        }
        return scripts;
    }

    /**
     * A simple model of a breadcrumb. A bread crumb is a link with a display name.
     */
    public static class Breadcrumb {
        private String name;
        private String url;

        /**
         * Creates a crumb given a name an URL.
         */
        public Breadcrumb(String name, String url) {
            this.name = name;
            this.url = url;
        }

        /**
         * Returns the name, with HTML escaped.
         */
        public String getName() {
            if (name != null) {
                return StringUtils.escapeHTMLTags(name);
            }
            else {
                return name;
            }
        }

        /**
         * Returns the URL.
         */
        public String getUrl() {
            return url;
        }
    }
}