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

📄 wrappedfavoriteitem.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
package com.sslexplorer.navigation;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;

import org.apache.struts.taglib.TagUtils;
import org.apache.struts.util.MessageResources;

import com.sslexplorer.policyframework.ResourceType;
import com.sslexplorer.table.TableItem;

/**
 * Implementation of a {@link com.sslexplorer.table.TableItem} that wraps an
 * {@link AbstractFavoriteItem}. This is used for the <i>Favorites</i> page
 * that lists the favorites of all resource types.
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.6 $
 */
public class WrappedFavoriteItem implements TableItem {

    // Private instance variables
    private AbstractFavoriteItem favoriteItem;
    private String type;
    private List favoriteItemActionItems;

    /**
     * Constructor.
     * 
     * @param favoriteItem item
     * @param type will be one of {@link AbstractFavoriteItem#GLOBAL_FAVORITE} or
     *        {@link AbstractFavoriteItem#USER_FAVORITE}.
     */
    public WrappedFavoriteItem(AbstractFavoriteItem favoriteItem, String type) {
        this.favoriteItem = favoriteItem;
        this.type = type;
        this.favoriteItemActionItems = new ArrayList();
    }

    /**
     * Get the favorite type. Will be one of {@link AbstractFavoriteItem#GLOBAL_FAVORITE} or
     * {@link AbstractFavoriteItem#USER_FAVORITE}.
     * 
     * @return favorite type
     */
    public String getFavoriteType() {
        return type;
    }

    /**
     * Get the favorite item this table item is wrapping
     * 
     * @return favorite item
     */
    public AbstractFavoriteItem getFavoriteItem() {
        return favoriteItem;
    }

    /**
     * Get the resource type as a string
     * 
     * @param pageContext page context from which to get the message resources
     * @return resource type string
     * @throws JspException on error retrieving message resources
     */
    public String getResourceTypeName(PageContext pageContext) throws JspException {
        ResourceType rt = getFavoriteItem().getResource() == null ? null : getFavoriteItem().getResource().getResourceType();
        if (rt == null) {
            return "?";
        } else {
            MessageResources mr = TagUtils.getInstance().retrieveMessageResources(pageContext, rt.getBundle(), false);
            rt.getBundle();
            if (mr == null) {
                return "!Invalid bundle!";
            } else {
                String msg = mr.getMessage("resourceType." + rt.getResourceTypeId() + ".title");
                return msg == null || msg.equals("") ? "!No message!" : msg;
            }
        }

    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.table.TableItem#getColumnValue(int)
     */
    public Object getColumnValue(int col) {
        switch (col) {
            case 0:
                return favoriteItem.getResource().getResourceName();
            case 1:
                return favoriteItem.getResource().getResourceType();
            default:
                return favoriteItem.getFavoriteSubType();
        }
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj) {
        try {
            return getFavoriteItem().getResource().getResourceId() == ((WrappedFavoriteItem) obj).getFavoriteItem().getResource()
                .getResourceId()
                            && getFavoriteItem().getResource().getResourceType() == ((WrappedFavoriteItem) obj).getFavoriteItem()
                                .getResource().getResourceType();
        } catch (ClassCastException cse) {
            return false;
        }
    }

    public List getFavoriteItemActionItems() {
        return favoriteItemActionItems;
    }

    public void setFavoriteItemActionItems(List favoriteItemActionItems) {
        this.favoriteItemActionItems = favoriteItemActionItems;
    }
    
    public void addFavoriteItemActionItem(FavoriteItemActionItem favoriteItemActionItem) {
        this.favoriteItemActionItems.add(favoriteItemActionItem);
    }

}

⌨️ 快捷键说明

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