userattributedefinitionitem.java

来自「这是linux下ssl vpn的实现程序」· Java 代码 · 共 145 行

JAVA
145
字号
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.security;

import org.apache.struts.util.MessageResources;

import com.sslexplorer.table.TableItem;

/**
 * Implementation of a {@link com.sslexplorer.table.TableItem} that is used to
 * wrap {@link com.sslexplorer.security.AuthenticationScheme} objects for
 * display.
 * 
 * @author Brett Smith <a href="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.7 $
 */
public class UserAttributeDefinitionItem implements TableItem {

    // Private instance variables

    private UserAttributeDefinition definition;
    private String categoryLabel;
    private String description;
    private String label;

    /**
     * Constructor
     * 
     * @param definition definition
     * @param messageResources message resources for label, categoryLabel and
     *        description. Or <code>null</code> to use values in definition
     */
    public UserAttributeDefinitionItem(UserAttributeDefinition definition, MessageResources messageResources) {
        this.definition = definition;
        String s = messageResources == null ? null : messageResources.getMessage("userAttributeCategory." + definition.getCategory() + ".title");
        if (s != null && !s.equals("")) {
            categoryLabel = s;
        } else {
            categoryLabel = definition.getCategoryLabel() != null && !definition.getCategoryLabel().equals("") ? definition.getCategoryLabel() : "Attributes";
        }
        s = messageResources == null ? null : messageResources.getMessage("userAttribute." + definition.getName() + ".title");
        if (s != null && !s.equals("")) {
            label = s;
        } else {
            label = definition.getLabel() != null && !definition.getLabel().equals("") ? definition.getLabel() : definition.getName();
        }
        s = messageResources == null ? null : messageResources.getMessage("userAttribute." + definition.getName() + ".description");
        if (s != null && !s.equals("")) {
            description = s;
        } else {
            description = definition.getDescription() != null && !definition.getDescription().equals("") ? definition.getDescription() : label;
        }
    }

    /**
     * Get the description
     * 
     * @return description
     */
    public String getDescription() {
        return description;
    }

    /**
     * Set the description
     * 
     * @param description description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * Get the label
     * 
     * @return label
     */
    public String getLabel() {
        return label;
    }

    /**
     * Set the label
     * 
     * @param label label
     */
    public void setLabel(String label) {
        this.label = label;
    }

    /**
     * Get the user attribute definition object this item wraps
     * 
     * @return user attribute definition
     */
    public UserAttributeDefinition getDefinition() {
        return definition;
    }

    /**
     * Get the category label
     * 
     * @return category label
     */
    public String getCategoryLabel() {
        return categoryLabel;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sslexplorer.table.TableItem#getColumnValue(int)
     */
    public Object getColumnValue(int col) {
        switch (col) {
            case 0:
                return getDefinition().getName();
            case 1:
                return getDefinition().getLabel();
            case 2:
                return categoryLabel;
            default:
                return new Integer(getDefinition().getVisibility());
        }
    }

}

⌨️ 快捷键说明

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