org.mockcentral.server
Class SignaturePartBean

java.lang.Object
  extended by org.mockcentral.server.SignaturePartBean

public class SignaturePartBean
extends java.lang.Object

A bean class storing data used to construct a single parameter or return value for a Mock Object method, or a simple Object to be bound into the InitialContext for the current Fixture. In the case that the "value type" of the Object to be created is a Collection or an Array, the bean will store a list of child instances to construct each entry. Additionally, this class stores a list of any child instances which are used as arguments to the Constructor of a new class instance when the "value type" of the Object to created is a new instance of a particular class, and for which Constructor arguments have been supplied in the configuration file.

The Object to be created will be built by the SignaturePartBuilder, which first reads the valueType field to determine a strategy for creating the Object. The valueClassName, value, collectionEntries and constructorArgs fields will then be accessed as appropriate for creating the Object (these fields are not all required for all "value types"). The various types for the Object to be created correspond to the values defined in the ValueType Enum, and the valueType field of this class must match the label defined by one of the ValueType Enum values.

The "add" and "set" methods defined in this class are invoked by the org.apache.commons.digester.Digester when the configuration file is parsed, and should not be called by clients.

Author:
David Hutchinson
See Also:
Fixture, SignaturePartBuilder, ValueType

Constructor Summary
SignaturePartBean()
          Creates a new instance.
 
Method Summary
 void addCollectionEntry(SignaturePartBean bean)
          Adds a child instance of this class to the list of entries for the Collection or Array modeled by this instance (if applicable).
 void addConstructorArg(SignaturePartBean bean)
          Adds a child instance of this class to the list of parameters for the Class constructor (if applicable).
 void addObserver(ISignaturePartBeanObserver observer)
          Adds an ISignaturePartBeanObserver to the list of observers.
 java.lang.Object clone()
           
 boolean equals(java.lang.Object o)
           
 void fireAllDataChanged()
          Notifies observers of changes to the valueType, valueClassName and value fields.
 java.util.List<SignaturePartBean> getCollectionEntries()
          Returns the list of entries for the Collection or Array modeled by this instance (if applicable).
 java.util.List<SignaturePartBean> getConstructorArgs()
          Returns the list of arguments for the Class constructor (if applicable).
 java.lang.String getValue()
          Returns the String used to create the value (if applicable).
 java.lang.String getValueClassName()
          Returns the String indicating the class type name for the value (if applicable).
 ValueType getValueType()
          Returns the ValueType for the value.
 int hashCode()
           
 void removeObserver(ISignaturePartBeanObserver observer)
          Removes an ISignaturePartBeanObserver from the list of observers.
 void setCollection(java.lang.String collection)
          Deprecated. this method does nothing, but is retained to accommodate pre-2.0 configuration files that include a "collection" element in SignaturePartBean definitions.
 void setCollectionEntries(java.util.List<SignaturePartBean> collectionEntries)
          Sets the list of entries for the Collection or Array modeled by this instance (if applicable).
 void setConstructorArgs(java.util.List<SignaturePartBean> constructorArgs)
          Sets the list of entries for the Collection or Array modeled by this instance (if applicable).
 void setValue(java.lang.String value)
          Sets the String used to create the value (if applicable).
 void setValueClassName(java.lang.String valueClassName)
          Sets the String indicating the class type name for the value (if applicable).
 void setValueType(ValueType type)
          Sets the ValueType for the value.
 void setValueTypeString(java.lang.String valueType)
          Sets the ValueType for the value using the supplied String to look up the appropriate Enum value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SignaturePartBean

public SignaturePartBean()
Creates a new instance.

Method Detail

setValueTypeString

public void setValueTypeString(java.lang.String valueType)
Sets the ValueType for the value using the supplied String to look up the appropriate Enum value. This method is called by the org.apache.commons.digester.Digester when the configuration data is parsed. Clients can more directly set the value with the setType(ValueType) method. Notifies any registered ISignaturePartBeanObserver instances.

Parameters:
valueType - the String indicating the ValueType for the value.

setValueType

public void setValueType(ValueType type)
Sets the ValueType for the value. Notifies any registered ISignaturePartBeanObserver instances.

Parameters:
type - the ValueType for the value.

getValueType

public ValueType getValueType()
Returns the ValueType for the value.

Returns:
the ValueType for the value.

setValueClassName

public void setValueClassName(java.lang.String valueClassName)
Sets the String indicating the class type name for the value (if applicable). Notifies any registered ISignaturePartBeanObserver instances.

Parameters:
valueClassName - the String indicating the class type name for the value (if applicable).

getValueClassName

public java.lang.String getValueClassName()
Returns the String indicating the class type name for the value (if applicable).

Returns:
the String indicating the class type name for the value (if applicable).

setValue

public void setValue(java.lang.String value)
Sets the String used to create the value (if applicable). Notifies any registered ISignaturePartBeanObserver instances.

Parameters:
value - the String used to create the value.

getValue

public java.lang.String getValue()
Returns the String used to create the value (if applicable).

Returns:
the String used to create the value.

addCollectionEntry

public void addCollectionEntry(SignaturePartBean bean)
Adds a child instance of this class to the list of entries for the Collection or Array modeled by this instance (if applicable).

Parameters:
bean - the child instance to add to the list.

setCollectionEntries

public void setCollectionEntries(java.util.List<SignaturePartBean> collectionEntries)
Sets the list of entries for the Collection or Array modeled by this instance (if applicable).

Parameters:
collectionEntries - the list of entries for the Collection or Array modeled by this instance (if applicable).

getCollectionEntries

public java.util.List<SignaturePartBean> getCollectionEntries()
Returns the list of entries for the Collection or Array modeled by this instance (if applicable).

Returns:
the list of entries for the Collection or Array modeled by this instanc.

addConstructorArg

public void addConstructorArg(SignaturePartBean bean)
Adds a child instance of this class to the list of parameters for the Class constructor (if applicable).

Parameters:
bean - the child instance to add to the list.

setConstructorArgs

public void setConstructorArgs(java.util.List<SignaturePartBean> constructorArgs)
Sets the list of entries for the Collection or Array modeled by this instance (if applicable).

Parameters:
constructorArgs - the list of entries for the Collection or Array modeled by this instance (if applicable).

getConstructorArgs

public java.util.List<SignaturePartBean> getConstructorArgs()
Returns the list of arguments for the Class constructor (if applicable).

Returns:
the list of entries.

setCollection

@Deprecated
public void setCollection(java.lang.String collection)
Deprecated. this method does nothing, but is retained to accommodate pre-2.0 configuration files that include a "collection" element in SignaturePartBean definitions.

Sets the String for creating a boolean for whether the value should be wrapped in a Collection.

Parameters:
collection - the String for creating a boolean for whether the value should be wrapped in a Collection.

addObserver

public void addObserver(ISignaturePartBeanObserver observer)
Adds an ISignaturePartBeanObserver to the list of observers.

Parameters:
observer - the ISignaturePartBeanObserver to add.

removeObserver

public void removeObserver(ISignaturePartBeanObserver observer)
Removes an ISignaturePartBeanObserver from the list of observers.

Parameters:
observer - the ISignaturePartBeanObserver to remove.

fireAllDataChanged

public void fireAllDataChanged()
Notifies observers of changes to the valueType, valueClassName and value fields.


equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object