001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.admin;
028 import org.opends.messages.Message;
029
030 import java.util.Locale;
031
032
033
034 /**
035 * A default behavior provider which indicates special behavior. It should be
036 * used by properties which have a default behavior which cannot be directly
037 * represented using real values of the property. For example, a property
038 * containing a set of user names might default to "all users" when no values
039 * are provided. This meaning cannot be represented using a finite set of
040 * values.
041 *
042 * @param <T>
043 * The type of values represented by this provider.
044 */
045 public final class AliasDefaultBehaviorProvider<T> extends
046 DefaultBehaviorProvider<T> {
047
048 // The managed object definition associated with this default
049 // behavior.
050 private final AbstractManagedObjectDefinition<?, ?> definition;
051
052 // The name of the property definition associated with this default
053 // behavior.
054 private final String propertyName;
055
056
057
058 /**
059 * Create an alias default behavior provider.
060 *
061 * @param d
062 * The managed object definition associated with this
063 * default behavior.
064 * @param propertyName
065 * The name of the property definition associated with this
066 * default behavior.
067 */
068 public AliasDefaultBehaviorProvider(
069 AbstractManagedObjectDefinition<?, ?> d, String propertyName) {
070 this.definition = d;
071 this.propertyName = propertyName;
072 }
073
074
075
076 /**
077 * {@inheritDoc}
078 */
079 public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) {
080 return v.visitAlias(this, p);
081 }
082
083
084
085 /**
086 * Gets the synopsis of this alias default behavior in the
087 * default locale.
088 *
089 * @return Returns the synopsis of this alias default behavior in
090 * the default locale.
091 */
092 public final Message getSynopsis() {
093 return getSynopsis(Locale.getDefault());
094 }
095
096
097
098 /**
099 * Gets the synopsis of this alias default behavior in the specified
100 * locale.
101 *
102 * @param locale
103 * The locale.
104 * @return Returns the synopsis of this alias default behavior in
105 * the specified locale.
106 */
107 public final Message getSynopsis(Locale locale) {
108 ManagedObjectDefinitionI18NResource resource =
109 ManagedObjectDefinitionI18NResource.getInstance();
110 String property = "property." + propertyName
111 + ".default-behavior.alias.synopsis";
112 return resource.getMessage(definition, property, locale);
113 }
114
115 }