org.mockcentral.editor.nodes.expectation.part
Class SignaturePartUtil

java.lang.Object
  extended by org.mockcentral.editor.nodes.expectation.part.SignaturePartUtil

public class SignaturePartUtil
extends java.lang.Object

A Class supplying data for use in editing SignaturePartBean instances. Specifically, this class provides Strings to use to label controls for editing the "value class name" and "value" fields, booleans for whether these controls should be enabled, default values for the fields, lists of options for the fields and validators for the user input, all as necessary. Depending on the ValueType (and, as appropriate, class name) defined in the SignaturePartBean, some or all of these data will be returned. For instance, no list of options is provided for Mock Object ValueType class names, but one is for Object ValueType class names, etc.

Author:
David Hutchinson

Constructor Summary
SignaturePartUtil()
           
 
Method Summary
static org.mockcentral.server.SignaturePartBean createDefault()
          Returns a new SignaturePartBean with default field values.
static java.lang.String getDefaultValue(java.lang.Object... objects)
          Returns a default value for the value field.
static java.lang.String getDefaultValueClassName(org.mockcentral.server.ValueType valueType)
          Returns a default value for the value class name field.
static java.lang.String[] getEditChildrenPrompts(org.mockcentral.server.SignaturePartBean bean)
          Returns an array of Strings for prompting the user during editing of nested SignaturePartBean instances.
static boolean getEnableValue(org.mockcentral.server.ValueType valueType)
          Returns a boolean for whether a view's controls associated with the value field should be enabled.
static boolean getEnableValueClassName(org.mockcentral.server.ValueType valueType)
          Returns a boolean for whether the control associated with the value class name field should be enabled.
static IMockCentralDialogInputValidator getValueClassNameInputValidator(org.mockcentral.server.ValueType valueType)
          Returns the IMockCentralDialogInputValidator used to validate a prospective value for the value class name field.
static java.lang.String getValueClassNameLabel(org.mockcentral.server.ValueType valueType)
          Returns a String used to label the control used for editing the value class name field.
static java.util.List<java.lang.String> getValueClassNameOptions(org.mockcentral.server.ValueType valueType)
          Returns a list of available options for a view component used to select the value for the value class name field.
static IMockCentralDialogInputValidator getValueInputValidator(org.mockcentral.server.SignaturePartBean bean)
          Returns the IMockCentralDialogInputValidator used to validate a prospective value for the value field.
static java.lang.String getValueLabel(org.mockcentral.server.SignaturePartBean bean)
          Returns a String used to label the control used for editing the value field.
static java.util.List<java.lang.String> getValueOptions(java.lang.Object... objects)
          Returns a list of available options for a view component used to select the value for the value field.
static java.lang.String getValueTypeDisplayLabel(org.mockcentral.server.ValueType valueType)
          Returns a displayable label for a ValueType value.
static java.util.List<NodeProblem> validateSignaturePartBean(org.mockcentral.server.SignaturePartBean bean, FixtureNode fixtureNode)
          Performs validation for the supplied SignaturePartBean, returning a list of any NodeProblem objects that were generated during the process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignaturePartUtil

public SignaturePartUtil()
Method Detail

createDefault

public static org.mockcentral.server.SignaturePartBean createDefault()
Returns a new SignaturePartBean with default field values.

Returns:
a new SignaturePartBean with default field values.

getValueTypeDisplayLabel

public static java.lang.String getValueTypeDisplayLabel(org.mockcentral.server.ValueType valueType)
Returns a displayable label for a ValueType value.

Parameters:
valueType - the ValueType.
Returns:
a displayable label for a ValueType value.

getValueClassNameLabel

public static java.lang.String getValueClassNameLabel(org.mockcentral.server.ValueType valueType)
Returns a String used to label the control used for editing the value class name field.

Parameters:
valueType - the ValueType for the object being edited.
Returns:
a String used to label the control used for editing the value class name field.

getEnableValueClassName

public static boolean getEnableValueClassName(org.mockcentral.server.ValueType valueType)
Returns a boolean for whether the control associated with the value class name field should be enabled. The return value is specific for the current value type (ie, if primitive, yes; if runtime variable, no, etc).

Parameters:
valueType - the ValueType for the object being edited.
Returns:
a boolean for whether a view's controls associated with the value class name field should be enabled.

getDefaultValueClassName

public static java.lang.String getDefaultValueClassName(org.mockcentral.server.ValueType valueType)
Returns a default value for the value class name field. The return value is specific for the current value type (ie, if primitive, "boolean"; if wrapped primitive, "java.lang.String", etc). Returns an empty String if the value type does not require a value for the value class name.

Parameters:
valueType - the ValueType for the object being edited.
Returns:
a default value for the value class name field or an empty String.

getValueClassNameOptions

public static java.util.List<java.lang.String> getValueClassNameOptions(org.mockcentral.server.ValueType valueType)
Returns a list of available options for a view component used to select the value for the value class name field. This applies to "primitive", "object" and "collection" value types only; the return value will be null for any other type.

Parameters:
valueType - the ValueType for the object being edited.
Returns:
a list of options to be used in a control used to select a choice for the value class name field.

getValueClassNameInputValidator

public static IMockCentralDialogInputValidator getValueClassNameInputValidator(org.mockcentral.server.ValueType valueType)
Returns the IMockCentralDialogInputValidator used to validate a prospective value for the value class name field. Returns null if the value type does not require validation for the field.

Parameters:
valueType - the ValueType for the object being edited.
Returns:
the IMockCentralDialogInputValidator used to validate a prospective value for the value class name field.

getValueLabel

public static java.lang.String getValueLabel(org.mockcentral.server.SignaturePartBean bean)
Returns a String used to label the control used for editing the value field.

Parameters:
bean - the SignaturePartBean
Returns:
a String used to label the control used for editing the value field.

getEnableValue

public static boolean getEnableValue(org.mockcentral.server.ValueType valueType)
Returns a boolean for whether a view's controls associated with the value field should be enabled. The return value is specific for the current value type (ie, if primitive, yes; if new class instance, no, etc).

Parameters:
valueType - the ValueType for the object being edited.
Returns:
a boolean for whether a view's controls associated with the value field should be enabled.

getDefaultValue

public static java.lang.String getDefaultValue(java.lang.Object... objects)
Returns a default value for the value field. The return value is specific for the current value type (ie, if primitive, "boolean"; if wrapped primitive, "java.lang.String", etc). Returns an empty String if the value type does not require a value.

Parameters:
objects - a Object array containing the ValueType and any other data required to create the return value.
Returns:
a default value for the value field or an empty String.

getValueOptions

public static java.util.List<java.lang.String> getValueOptions(java.lang.Object... objects)
Returns a list of available options for a view component used to select the value for the value field. The return value is specific for the current value type (ie, if Mock Object, the list of Mock Objects defined in the current Fixture, etc). Returns null if the value type does not require a value for the value field or the value is not constrained to a list of predefined options.

Returns:
a list of available options for a view component used to select the value for the value field, or null.

getValueInputValidator

public static IMockCentralDialogInputValidator getValueInputValidator(org.mockcentral.server.SignaturePartBean bean)
Returns the IMockCentralDialogInputValidator used to validate a prospective value for the value field. Returns null if the value type does not require validation for the field.

Returns:
the IMockCentralDialogInputValidator used to validate a prospective value for the value field or null.

getEditChildrenPrompts

public static java.lang.String[] getEditChildrenPrompts(org.mockcentral.server.SignaturePartBean bean)
Returns an array of Strings for prompting the user during editing of nested SignaturePartBean instances. These may be constructor arguments for instantiatable types or collection/array entries.

Parameters:
bean - the SignaturePartBean being edited, the ValueType and value classname of which are used to build the prompts.
Returns:
an array of Strings for prompting the user during editing of nested SignaturePartBean instances.

validateSignaturePartBean

public static java.util.List<NodeProblem> validateSignaturePartBean(org.mockcentral.server.SignaturePartBean bean,
                                                                    FixtureNode fixtureNode)
Performs validation for the supplied SignaturePartBean, returning a list of any NodeProblem objects that were generated during the process.

Parameters:
bean - the bean to validate.
fixtureNode - the enclosing FixtureNode which is required to validate Mock Object references.
Returns:
a List containing any NodeProblem objects generated during validation.