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 legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014-2015 ForgeRock AS 026 */ 027package org.opends.server.admin; 028import org.forgerock.i18n.LocalizableMessage; 029 030import 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 */ 045public final class AliasDefaultBehaviorProvider<T> extends 046 DefaultBehaviorProvider<T> { 047 048 /** 049 * The managed object definition associated with this default 050 * behavior. 051 */ 052 private final AbstractManagedObjectDefinition<?, ?> definition; 053 054 /** 055 * The name of the property definition associated with this default 056 * behavior. 057 */ 058 private final String propertyName; 059 060 061 062 /** 063 * Create an alias default behavior provider. 064 * 065 * @param d 066 * The managed object definition associated with this 067 * default behavior. 068 * @param propertyName 069 * The name of the property definition associated with this 070 * default behavior. 071 */ 072 public AliasDefaultBehaviorProvider( 073 AbstractManagedObjectDefinition<?, ?> d, String propertyName) { 074 this.definition = d; 075 this.propertyName = propertyName; 076 } 077 078 079 080 /** {@inheritDoc} */ 081 public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { 082 return v.visitAlias(this, p); 083 } 084 085 086 087 /** 088 * Gets the synopsis of this alias default behavior in the 089 * default locale. 090 * 091 * @return Returns the synopsis of this alias default behavior in 092 * the default locale. 093 */ 094 public final LocalizableMessage getSynopsis() { 095 return getSynopsis(Locale.getDefault()); 096 } 097 098 099 100 /** 101 * Gets the synopsis of this alias default behavior in the specified 102 * locale. 103 * 104 * @param locale 105 * The locale. 106 * @return Returns the synopsis of this alias default behavior in 107 * the specified locale. 108 */ 109 public final LocalizableMessage getSynopsis(Locale locale) { 110 ManagedObjectDefinitionI18NResource resource = 111 ManagedObjectDefinitionI18NResource.getInstance(); 112 String property = "property." + propertyName 113 + ".default-behavior.alias.synopsis"; 114 return resource.getMessage(definition, property, locale); 115 } 116 117}