userattributevalueitem.java
来自「这是linux下ssl vpn的实现程序」· Java 代码 · 共 150 行
JAVA
150 行
/*
* 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.boot.Util;
/**
* Wrapper bean for displaying and editing a user attribute and its value.
*
* @author Brett Smith <a href="mailto: brett@3sp.com"><brett@3sp.com></a>
* @version $Revision: 1.8 $
*/
public class UserAttributeValueItem implements Comparable {
private UserAttributeDefinition definition;
private String label;
private String value;
private String categoryLabel;
private String categoryId;
/**
* Constructor.
*
* @param definition definition
* @param messageResources message resources from which to get the label and
* category label or <code>null</code> to use values in definition
* @param value initial value
*/
public UserAttributeValueItem(UserAttributeDefinition definition, MessageResources messageResources, String value) {
super();
this.definition = definition;
this.value = value;
this.label = definition.getLabel();
this.categoryLabel = definition.getCategoryLabel();
String s = messageResources == null ? null : messageResources.getMessage("userAttributeCategory." + definition.getCategory() + ".title");
if (s != null && !s.equals("")) {
this.categoryLabel = s;
} else {
if(categoryLabel == null || categoryLabel.equals("")) {
this.categoryLabel = "Attributes";
}
}
s = messageResources == null ? null : messageResources.getMessage("userAttribute." + definition.getName() + ".title");
if (s != null && !s.equals("")) {
label = s;
} else {
if(label != null && label.equals("")) {
label = definition.getName();
}
}
if (getCategoryLabel() != null)
categoryId = Util.makeConstantKey(getCategoryLabel());
}
/**
* Get the label. This will either the label in the definition itself or a
* label from a message resource (passed in the constructor) if it exists.
*
* @return label
*/
public String getLabel() {
return label;
}
/**
* Get the attribute definition this object wraps.
*
* @return definition
*/
public UserAttributeDefinition getDefinition() {
return definition;
}
/**
* Get the value
*
* @return value
*/
public String getValue() {
return value;
}
/**
* Set the value
*
* @param value value
*/
public void setValue(String value) {
this.value = value;
}
/**
* Get the category label
*
* @return category label
*/
public String getCategoryLabel() {
return categoryLabel;
}
/**
* Get the category Id
*
* @return category ID
*/
public String getCategoryId() {
return categoryId;
}
/**
* Compare this value item with another based on its definitions sort order
* and name.
*
* @param arg0 object to compare against.
* @return comparison
*/
public int compareTo(Object arg0) {
int i = ( categoryId == null ? "" : categoryId ).compareTo(((UserAttributeValueItem) arg0).categoryId == null ? "" : ((UserAttributeValueItem) arg0).categoryId);
if(i == 0) {
i = new Integer(getDefinition().getSortOrder()).compareTo(new Integer(((UserAttributeValueItem) arg0).getDefinition()
.getSortOrder()));
return i == 0 ? (getDefinition().getLabel().compareTo(((UserAttributeValueItem) arg0).getLabel())) : i;
}
else {
return i;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?