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