⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jbmenus.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.struts.service.beans;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


/**
 * This calls corresponds to the top level element of the menus_config.xml file.
 *
 */
public class JBMenus
{
    /** List of per profiles menus. Key = profileName, value = JBProfileMenu. */
    private Map profilesMenuMap = new HashMap();

    /** List of menu elements. */
    private Map featuresMap = new HashMap();

    /**
     * Returns the list of menu elements.
     * @return Map with key = name, value = JBFeature
     */
    public Map getFeaturesMap()
    {
        return featuresMap;
    }

    /**
     * Sets the list of menu elements.
     * @param afeaturesMap Map with key = name, value = JBFeature
     */
    public void setFeaturesMap(Map afeaturesMap)
    {
        this.featuresMap = afeaturesMap;
    }

    /**
     * Adds a menu element.
     *
     * @param fea menu element
     */
    public void addFeature(JBFeature fea)
    {
        featuresMap.put(fea.getName().trim().toLowerCase(), fea);
    }

    /**
     * Adds a per profile menu.
     *
     * @param pm per profile menu
     */
    public void addProfileMenu(JBProfileMenu pm)
    {
        profilesMenuMap.put(pm.getName().trim().toLowerCase(), pm);
    }

    /**
     * Searches a menu element.
     *
     * @param name menu element name
     *
     * @return menu element
     */
    public JBFeature findFeatureByName(String name)
    {
        // rendre case insensitive en mettant le param en lowercase
        String key = name.trim().toLowerCase();

        return (JBFeature) featuresMap.get(key);
    }

    /**
     * Creates the list of menu elements in each per profile menu.
     */
    public void compute()
    {
        Iterator itOuter = profilesMenuMap.values().iterator();

        JBMenu menu = null;
        JBMenuElement elt = null;
        JBProfileMenu profileMenu = null;

        while (itOuter.hasNext())
        {
            // boucle sur tous les profiles
            profileMenu = (JBProfileMenu) itOuter.next();

            Iterator itInner = profileMenu.getMenusMap().values().iterator();

            while (itInner.hasNext())
            {
                // sur tous les menus d'un profiles
                menu = (JBMenu) itInner.next();

                Iterator itElement = menu.getElements().iterator();

                while (itElement.hasNext())
                {
                    elt = (JBMenuElement) itElement.next();
                    elt.setFeature(findFeatureByName(elt.getName()));
                }
            }
        }
    }

    /**
     * Searches a menu from its name for a given profile.
     *
     * @param menuName menu na鵨
     * @param profileName profile name
     *
     * @return menu
     */
    public JBMenu findMenuByName(String menuName, String profileName)
    {
        JBProfileMenu profileMenu = (JBProfileMenu) profilesMenuMap.get(profileName.trim()
                                                                                   .toLowerCase());

        return (JBMenu) profileMenu.findMenuByName(menuName);
    }

    /**
     * Gets menu for a given profile.
     *
     * @param profileName profile name
     *
     * @return Map with key = manu name, value = JBMenu
     */
    public Map getMenusMapByProfile(String profileName)
    {
        JBProfileMenu profileMenu = (JBProfileMenu) profilesMenuMap.get(profileName.trim()
                                                                                   .toLowerCase());

        return profileMenu.getMenusMap();
    }

    /**
     * Displays the menus configuration.
     *
     * @return String formatted menus configuration
     */
    public String toString()
    {
        StringBuffer buf = new StringBuffer();
        java.util.Iterator it = null;

        if (profilesMenuMap != null)
        {
            buf.append("Map components of profilesMenuMap = ");
            buf.append(System.getProperty("line.separator"));
            it = profilesMenuMap.keySet().iterator();

            Object key;

            while (it.hasNext())
            {
                buf.append("...");
                key = it.next();
                buf.append(key);
                buf.append(" = ");
                buf.append(profilesMenuMap.get(key));
                buf.append(System.getProperty("line.separator"));
            }
        }

        if (featuresMap != null)
        {
            buf.append("Map components of featuresMap = ");
            buf.append(System.getProperty("line.separator"));
            it = featuresMap.keySet().iterator();

            Object key;

            while (it.hasNext())
            {
                buf.append("...");
                key = it.next();
                buf.append(key);
                buf.append(" = ");
                buf.append(featuresMap.get(key));
                buf.append(System.getProperty("line.separator"));
            }
        }

        return buf.toString();
    }

    // end of toString method
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -