| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.config; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.types.AttributeValue; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | /** |
| | | * This class defines a configuration attribute that is only intended for use |
| | | * in displaying information. It will not allow its value to be altered. |
| | |
| | | * @param isMultiValued Indicates whether this configuration attribute may |
| | | * have multiple values. |
| | | */ |
| | | public ReadOnlyConfigAttribute(String name, String description, |
| | | public ReadOnlyConfigAttribute(String name, Message description, |
| | | boolean isMultiValued) |
| | | { |
| | | super(name, description, false, isMultiValued, false); |
| | |
| | | * @param description The description for this configuration attribute. |
| | | * @param value The value for this configuration attribute. |
| | | */ |
| | | public ReadOnlyConfigAttribute(String name, String description, String value) |
| | | public ReadOnlyConfigAttribute(String name, Message description, String value) |
| | | { |
| | | super(name, description, false, false, false, getValueSet(value)); |
| | | |
| | |
| | | * @param description The description for this configuration attribute. |
| | | * @param values The set of values for this configuration attribute. |
| | | */ |
| | | public ReadOnlyConfigAttribute(String name, String description, |
| | | public ReadOnlyConfigAttribute(String name, Message description, |
| | | List<String> values) |
| | | { |
| | | super(name, description, false, true, false, getValueSet(values)); |
| | |
| | | { |
| | | if ((values == null) || values.isEmpty()) |
| | | { |
| | | int msgID = MSGID_CONFIG_ATTR_NO_STRING_VALUE; |
| | | String message = getMessage(msgID, getName()); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | if (values.size() > 1) |
| | | { |
| | | int msgID = MSGID_CONFIG_ATTR_MULTIPLE_STRING_VALUES; |
| | | String message = getMessage(msgID, getName()); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | return values.get(0); |
| | |
| | | public void setValue(String value) |
| | | throws ConfigException |
| | | { |
| | | int msgID = MSGID_CONFIG_ATTR_READ_ONLY; |
| | | String message = getMessage(msgID, getName()); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CONFIG_ATTR_READ_ONLY.get(getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | |
| | |
| | | public void setValues(List<String> values) |
| | | throws ConfigException |
| | | { |
| | | int msgID = MSGID_CONFIG_ATTR_READ_ONLY; |
| | | String message = getMessage(msgID, getName()); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CONFIG_ATTR_READ_ONLY.get(getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | |
| | |
| | | public boolean valueIsAcceptable(AttributeValue value, |
| | | StringBuilder rejectReason) |
| | | { |
| | | rejectReason.append(getMessage(MSGID_CONFIG_ATTR_READ_ONLY, getName())); |
| | | rejectReason.append(ERR_CONFIG_ATTR_READ_ONLY.get(getName())); |
| | | return false; |
| | | } |
| | | |
| | |
| | | { |
| | | attributeInfoList.add(new MBeanAttributeInfo(getName(), |
| | | JMX_TYPE_STRING_ARRAY, |
| | | getDescription(), true, |
| | | false, false)); |
| | | String.valueOf( |
| | | getDescription()), |
| | | true, false, false)); |
| | | } |
| | | else |
| | | { |
| | | attributeInfoList.add(new MBeanAttributeInfo(getName(), |
| | | String.class.getName(), |
| | | getDescription(), true, |
| | | false, false)); |
| | | String.valueOf( |
| | | getDescription()), |
| | | true, false, false)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (isMultiValued()) |
| | | { |
| | | return new MBeanParameterInfo(getName(), JMX_TYPE_STRING_ARRAY, |
| | | getDescription()); |
| | | String.valueOf(getDescription())); |
| | | } |
| | | else |
| | | { |
| | | return new MBeanParameterInfo(getName(), String.class.getName(), |
| | | getDescription()); |
| | | String.valueOf(getDescription())); |
| | | } |
| | | } |
| | | |
| | |
| | | public void setValue(javax.management.Attribute jmxAttribute) |
| | | throws ConfigException |
| | | { |
| | | int msgID = MSGID_CONFIG_ATTR_READ_ONLY; |
| | | String message = getMessage(msgID, getName()); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CONFIG_ATTR_READ_ONLY.get(getName()); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | |