From 826e7e5d70450bd954d561024a497b4887dedfcf Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 19 Apr 2007 09:48:46 +0000
Subject: [PATCH] Fix for issue 1442.

---
 opends/src/server/org/opends/server/admin/EnumPropertyDefinition.java |   68 ++++++++++++++++++++++++++++++----
 1 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/opends/src/server/org/opends/server/admin/EnumPropertyDefinition.java b/opends/src/server/org/opends/server/admin/EnumPropertyDefinition.java
index 375e25a..f4cc154 100644
--- a/opends/src/server/org/opends/server/admin/EnumPropertyDefinition.java
+++ b/opends/src/server/org/opends/server/admin/EnumPropertyDefinition.java
@@ -33,7 +33,9 @@
 
 import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
+import java.util.MissingResourceException;
 
 
 
@@ -64,8 +66,9 @@
 
 
     // Private constructor
-    private Builder(String propertyName) {
-      super(propertyName);
+    private Builder(
+        AbstractManagedObjectDefinition<?, ?> d, String propertyName) {
+      super(d, propertyName);
       this.enumClass = null;
     }
 
@@ -90,14 +93,15 @@
      */
     @Override
     protected EnumPropertyDefinition<E> buildInstance(
-        String propertyName, EnumSet<PropertyOption> options,
+        AbstractManagedObjectDefinition<?, ?> d, String propertyName,
+        EnumSet<PropertyOption> options,
         DefaultBehaviorProvider<E> defaultBehavior) {
       // Make sure that the enumeration class has been defined.
       if (enumClass == null) {
         throw new IllegalStateException("Enumeration class undefined");
       }
 
-      return new EnumPropertyDefinition<E>(propertyName, options,
+      return new EnumPropertyDefinition<E>(d, propertyName, options,
           defaultBehavior, enumClass);
     }
   }
@@ -115,13 +119,16 @@
    * @param <E>
    *          The enumeration that should be used for values of this
    *          property definition.
+   * @param d
+   *          The managed object definition associated with this
+   *          property definition.
    * @param propertyName
    *          The property name.
    * @return Returns the new enumeration property definition builder.
    */
   public static <E extends Enum<E>> Builder<E> createBuilder(
-      String propertyName) {
-    return new Builder<E>(propertyName);
+      AbstractManagedObjectDefinition<?, ?> d, String propertyName) {
+    return new Builder<E>(d, propertyName);
   }
 
   // The enumeration class.
@@ -133,10 +140,11 @@
 
 
   // Private constructor.
-  private EnumPropertyDefinition(String propertyName,
+  private EnumPropertyDefinition(
+      AbstractManagedObjectDefinition<?, ?> d, String propertyName,
       EnumSet<PropertyOption> options,
       DefaultBehaviorProvider<E> defaultBehavior, Class<E> enumClass) {
-    super(enumClass, propertyName, options, defaultBehavior);
+    super(d, enumClass, propertyName, options, defaultBehavior);
     this.enumClass = enumClass;
 
     // Initialize the decoding map.
@@ -191,6 +199,50 @@
 
 
   /**
+   * Gets the synopsis of the specified enumeration value of this
+   * enumeration property definition in the default locale.
+   *
+   * @param value
+   *          The enumeration value.
+   * @return Returns the synopsis of the specified enumeration value
+   *         of this enumeration property definition in the default
+   *         locale.
+   */
+  public final String getValueSynopsis(E value) {
+    return getValueSynopsis(Locale.getDefault(), value);
+  }
+
+
+
+  /**
+   * Gets the synopsis of the specified enumeration value of this
+   * enumeration property definition in the specified locale.
+   *
+   * @param value
+   *          The enumeration value.
+   * @param locale
+   *          The locale.
+   * @return Returns the synopsis of the specified enumeration value
+   *         of this enumeration property definition in the specified
+   *         locale.
+   */
+  public final String getValueSynopsis(Locale locale, E value) {
+    ManagedObjectDefinitionI18NResource resource =
+      ManagedObjectDefinitionI18NResource.getInstance();
+    String property = "property." + getName()
+        + ".syntax.enumeration.value." + value.toString()
+        + ".synopsis";
+    try {
+      return resource.getMessage(getManagedObjectDefinition(),
+          property, locale);
+    } catch (MissingResourceException e) {
+      return null;
+    }
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   @Override

--
Gitblit v1.10.0