com.novell.nds.dirxml.engine.gcv
Class GCEnumValue

java.lang.Object
  extended bycom.novell.nds.dirxml.engine.gcv.GCValue
      extended bycom.novell.nds.dirxml.engine.gcv.GCEnumValue
All Implemented Interfaces:
ConfigElement

public class GCEnumValue
extends GCValue

Class representing "enum" type Global Configuration Values.

GCVs of type "enum" must have a value that corresponds to one of the GCV's enum choices.

"enum" GCVs may have one or more enum choices. Each choice is a non-null, non-empty string that represents a possible value for the GCV.

Enum choices are represented by an inner class of GCEnumValue named EnumChoice.

Enum choices have a defined order according to how the choices are added to the GCEnumValue. The order is maintained when creating XML and when constructing a GCEnumValue from XML. The order is maintained solely for user interface purposes. The order does not affect the value.

Enum choice values and the value of an enum GCV must match the following production:

String ::= Char*

The default value of a newly-constructed GCEnumValue object is "". Note that this is an invalid value. The newly-constructed value is not valid until a an enum choice has been set.


Nested Class Summary
static class GCEnumValue.EnumChoice
          Class representing a single enum choice.
 
Field Summary
 
Fields inherited from class com.novell.nds.dirxml.engine.gcv.GCValue
modified, parent, TYPE_BOOLEAN, TYPE_DN, TYPE_DN_REF, TYPE_ENUM, TYPE_GCV_REF, TYPE_GROUP, TYPE_HEADER, TYPE_INTEGER, TYPE_LIST, TYPE_PASSWORD_REF, TYPE_REAL, TYPE_STRING, TYPE_SUBORDINATES
 
Method Summary
 void appendEnumChoice(GCEnumValue.EnumChoice enumChoice)
          Append a new enum choice to the choices in this instance.
 void appendEnumChoice(String enumString, String displayName)
          Append a new enum choice to the choices in this instance.
 void appendEnumChoice(String enumString, String displayName, String displayNameRef)
          Append a new enum choice to the choices in this instance.
 GCEnumValue.EnumChoice getEnumChoice(String enumString)
          Return the EnumChoice instance for the passed enum value string.
 String getValue()
          Return the current value of this instance.
 boolean hasBeenModified()
          Return true if this instance has been modified.
 void insertEnumChoice(GCEnumValue.EnumChoice enumChoice, GCEnumValue.EnumChoice insertionPoint)
          Insert a new enum choice in front of an existing enum choice.
 void insertEnumChoice(String enumString, String displayName, String insertionPoint)
          Insert a new enum choice in front of an existing enum choice.
 void insertEnumChoice(String enumString, String displayName, String displayNameRef, String insertionPoint)
          Insert a new enum choice in front of an existing enum choice.
 Iterator iterator()
          Return an Iterator for use in iterating through the EnumChoice objects in this GCEnumValue instance.
 void localize(LocalizedMessageSource messageSource)
          Localize the display name and/or descriptions if there are localization refs for them.
 void parseValue(String value)
          Parse the passed value based on the type and instance rules for "enum" GCVs.
 boolean removeEnumChoice(GCEnumValue.EnumChoice enumChoice)
          Remove an existing enum choice from the current enum choices.
 boolean removeEnumChoice(String enumValue)
          Remove an existing enum choice from the current enum choices.
 void resetModified()
          Reset the modified flag for this instance such that hasBeenModified() will return false.
 void setValue(String value)
          Set the value for this instance.
 
Methods inherited from class com.novell.nds.dirxml.engine.gcv.GCValue
construct, construct, constructGCVRef, constructGroup, constructHeader, constructSubordinates, getDescription, getDescriptionRef, getDisplayName, getDisplayNameRef, getHidden, getName, getType, getTypeString, getXMLValue, setDescription, setDescriptionRef, setDisplayName, setDisplayNameRef, setHidden, toXML, typeFromString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasBeenModified

public boolean hasBeenModified()
Return true if this instance has been modified.

The instance is considered to have been modified if a change was made that affects the persistent representation since:

  1. The instance was constructed from an XML representation.
  2. resetModified() was last called

Specified by:
hasBeenModified in interface ConfigElement
Overrides:
hasBeenModified in class GCValue
Returns:
true or false
See Also:
resetModified()

resetModified

public void resetModified()
Reset the modified flag for this instance such that hasBeenModified() will return false.

Specified by:
resetModified in interface ConfigElement
Overrides:
resetModified in class GCValue
See Also:
hasBeenModified()

parseValue

public void parseValue(String value)
                throws GCVException
Parse the passed value based on the type and instance rules for "enum" GCVs.

The passed value must be equal to one of the enum choice values.

If there are no enum choice values GCVStateStateException is thrown.

Specified by:
parseValue in class GCValue
Parameters:
value - Value String to parse
Throws:
GCVException - thrown if value is null, empty, or does not equal one of the enum choice values.
GCVStateException - thrown if no enum choices have been set.

getValue

public String getValue()
Return the current value of this instance.

If no enum choices have been set this will return the empty String.

Specified by:
getValue in class GCValue
Returns:
Value String.

setValue

public void setValue(String value)
              throws GCVException
Set the value for this instance.

The passed value must be equal to one of the enum choice values.

If there are no enum choice values GCVStateStateException is thrown.

Specified by:
setValue in class GCValue
Parameters:
value - Value string for this instance.
Throws:
GCVException - thrown if value is null, empty, or does not equal one of the enum choice values.
GCVStateException - thrown if no enum choices have been set.

getEnumChoice

public GCEnumValue.EnumChoice getEnumChoice(String enumString)
Return the EnumChoice instance for the passed enum value string.

Parameters:
enumString - enum choice value string.
Returns:
EnumChoice instance or null, if no enum choice has been set that matches the passed enumString value.

appendEnumChoice

public void appendEnumChoice(String enumString,
                             String displayName)
                      throws GCVException
Append a new enum choice to the choices in this instance.

Parameters:
enumString - The String value of the enum choice.
displayName - The String containing the display name for use in the user interface.
Throws:
GCVException - thrown if:
  • enumString is empty or null
  • enumString matches an existing enum value in this instance
  • displayName is empty or null

appendEnumChoice

public void appendEnumChoice(String enumString,
                             String displayName,
                             String displayNameRef)
                      throws GCVException
Append a new enum choice to the choices in this instance.

Parameters:
enumString - The String value of the enum choice.
displayName - The String containing the display name for use in the user interface.
displayNameRef - A string identifier in a Properties collection that can be used with a LocalizedMessageSource instance.
Throws:
GCVException - thrown if:
  • enumString is empty or null
  • enumString matches an existing enum value in this instance
  • displayName is empty or null

appendEnumChoice

public void appendEnumChoice(GCEnumValue.EnumChoice enumChoice)
                      throws GCVException
Append a new enum choice to the choices in this instance.

Parameters:
enumChoice - The new EnumChoice instance to add.
Throws:
GCVException - thrown if the new EnumChoice value matches an existing enum choice in this instance.

insertEnumChoice

public void insertEnumChoice(String enumString,
                             String displayName,
                             String insertionPoint)
                      throws GCVException
Insert a new enum choice in front of an existing enum choice.

Parameters:
enumString - The String value of the enum choice.
displayName - The String containing the display name for use in the user interface.
insertionPoint - The String value of the enum choice in front of which the new enum choice is to be inserted. If this value is null this method is equivalent to calling appendEnumChoice(String, String).
Throws:
GCVException - thrown if:
  • enumString is empty or null
  • enumString matches an existing enum value in this instance
  • displayName is empty or null
  • insertionPoint is non-null and does not match any existing enum choice

insertEnumChoice

public void insertEnumChoice(String enumString,
                             String displayName,
                             String displayNameRef,
                             String insertionPoint)
                      throws GCVException
Insert a new enum choice in front of an existing enum choice.

Parameters:
enumString - The String value of the enum choice.
displayName - The String containing the display name for use in the user interface.
displayNameRef - A string identifier in a Properties collection that can be used with a LocalizedMessageSource instance.
insertionPoint - The String value of the enum choice in front of which the new enum choice is to be inserted. If this value is null this method is equivalent to calling appendEnumChoice(String, String).
Throws:
GCVException - thrown if:
  • enumString is empty or null
  • enumString matches an existing enum value in this instance
  • displayName is empty or null
  • insertionPoint is non-null and does not match any existing enum choice

insertEnumChoice

public void insertEnumChoice(GCEnumValue.EnumChoice enumChoice,
                             GCEnumValue.EnumChoice insertionPoint)
                      throws GCVException
Insert a new enum choice in front of an existing enum choice.

Parameters:
enumChoice - The new EnumChoice instance to add.
insertionPoint - The EnumChoice in front of which the new EnumChoice is to be inserted. If this value is null this method is equivalent to calling appendEnumChoice(EnumChoice).
Throws:
GCVException - thrown if:
  • enumChoice value matches an existing enum choice
  • insertionPoint is non-null and does not match any existing enum choice

removeEnumChoice

public boolean removeEnumChoice(String enumValue)
Remove an existing enum choice from the current enum choices.

If the current value of this instance matches the enum choice that is being removed the value is set to the value of the first enum choice remaining in this instance.

If the last existing enum choice is removed from this instance the current value of this instance is set to the empty string.

Parameters:
enumValue - value String of the enum choice to remove.
Returns:
true if an enum choice was found and removed, false otherwise.

removeEnumChoice

public boolean removeEnumChoice(GCEnumValue.EnumChoice enumChoice)
Remove an existing enum choice from the current enum choices.

If the current value of this instance matches the enum choice that is being removed the value is set to the value of the first enum choice remaining in this instance.

If the last existing enum choice is removed from this instance the current value of this instance is set to the empty string.

Parameters:
enumChoice - EnumChoice instance to remove.
Returns:
true if the passed EnumChoice was in the instance and removed, false otherwise.

iterator

public Iterator iterator()
Return an Iterator for use in iterating through the EnumChoice objects in this GCEnumValue instance.

Returns:
Iterator that returns EnumChoice objects.

localize

public void localize(LocalizedMessageSource messageSource)
Localize the display name and/or descriptions if there are localization refs for them.

If the display name or description has a localization refs, but the localized string cannot be located in the passed LocalizedMessageSource they are left unlocalized.

Overrides:
localize in class GCValue
Parameters:
messageSource - Source for localized strings.