org.mockcentral.editor.nodes.fixture
Class FixtureModel

java.lang.Object
  extended by org.mockcentral.editor.nodes.MockCentralNodeModel
      extended by org.mockcentral.editor.nodes.fixture.FixtureModel
All Implemented Interfaces:
IFixtureNameEditor, IMockObjectDataManager, INodeProblemParticipant

public class FixtureModel
extends MockCentralNodeModel
implements IFixtureNameEditor, IMockObjectDataManager, INodeProblemParticipant

A class that models data for Mock Object Fixture instances.

Author:
David Hutchinson

Field Summary
 
Fields inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
element, node, observers
 
Constructor Summary
FixtureModel(FixtureNode node)
          Creates a new instance.
 
Method Summary
 void addSimpleBoundObject(SimpleBoundObjectModel simpleBoundObjectModel, boolean refresh)
          Adds a new simple JNDI-bound Object to the Fixture.
 void deleteSimpleBoundObject(SimpleBoundObjectModel simpleBoundObjectModel, boolean refresh)
          Removes a simple JNDI-bound Object from the Fixture.
 void editMockObjects()
          Activates the MockObjectGroupNode for this Fixture.
 java.lang.String getDefaultNewJndiName()
          Returns a default value for a new JNDI name.
 java.lang.String getDefaultNewMockObjectName()
          Returns a default value for a new Mock Object name.
 FixtureNode getEnclosingFixtureNode()
          Returns the enclosing FixtureNode.
 java.lang.String getFixtureDescription()
          Returns the fixture description.
 java.util.List<MockCentralNode> getFixtureImportsList()
          Returns the list containing the FixtureNode instances for the Fixtures imported by this one.
 java.lang.String getFixtureName()
          Returns the fixtureName.
 java.util.ArrayList<java.lang.String> getMockObjectNames(java.lang.Object excluded)
          Returns the list of Mock Object names within the current Fixture.
 NodeProblem getNodeProblem(java.lang.Object o)
          Returns the stored NodeProblem associated with the supplied Object, if any.
 java.lang.String getNotRemovableMessage()
          Returns a message for display indicating why the corresposing MockCentralNode instance cannot be deleted, or null (as this default implementation does).
 java.util.List<SimpleBoundObjectModel> getSimpleBoundObjectsList()
          Returns the list of this Fixture's simple (that is, non-Mock) Objects that are to be bound into the naming context at runtime.
 boolean isFixtureNameInUse(java.lang.String fixtureName)
          Returns whether the supplied Fixture name is already in use within the document.
 boolean isJndiNameInUse(java.lang.String jndiName, java.lang.Object o)
          Returns whether the supplied JNDI name is currently in use within the Fixture.
 java.lang.String isValidInterface(java.lang.String interfaceName)
          Returns an error message indicating an invalid Mock Object interface, or null if the supplied interface name is valid.
 java.lang.String isValidJndiName(java.lang.String jndiName, java.lang.Object o)
          Returns an error message indicating an invalid JNDI name, or null if the supplied JNDI name is valid.
 java.lang.String isValidMockObjectName(java.lang.String mockObjectName, java.lang.Object o)
          Returns an error message indicating an invalid Mock Object name, or null if the supplied name is valid.
 void loadElementData(boolean refreshUI)
          Loads the data from the JDOM Element provided by the MockCentralNode into the model.
 void setFixtureData(java.lang.String fixtureName, java.lang.String fixtureDescription)
          Sets the Fixture name and Fixture description values.
 void setFixtureImports(java.util.List<MockCentralNode> imports)
          Sets the list of imported Fixture instances.
 
Methods inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
addObserver, getElement, getNode, getObservers, registerChanges, removeObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixtureModel

public FixtureModel(FixtureNode node)
Creates a new instance.

Parameters:
node - the MockCentralNode containing the JDOM Element whose data this class models.
Method Detail

loadElementData

public void loadElementData(boolean refreshUI)
Loads the data from the JDOM Element provided by the MockCentralNode into the model.

Specified by:
loadElementData in class MockCentralNodeModel
Parameters:
refreshUI - whether to send notification to ui components to update the display.

isFixtureNameInUse

public boolean isFixtureNameInUse(java.lang.String fixtureName)
Description copied from interface: IFixtureNameEditor
Returns whether the supplied Fixture name is already in use within the document.

Specified by:
isFixtureNameInUse in interface IFixtureNameEditor
Parameters:
fixtureName - the proposed name for the Fixture.
Returns:
whether the supplied Fixture name is already in use within the document.

setFixtureData

public void setFixtureData(java.lang.String fixtureName,
                           java.lang.String fixtureDescription)
Sets the Fixture name and Fixture description values.

Parameters:
fixtureName - the value for the Fixture name.
fixtureDescription - the value for the Fixture description.

getFixtureName

public java.lang.String getFixtureName()
Returns the fixtureName.

Returns:
the fixtureName.

getFixtureDescription

public java.lang.String getFixtureDescription()
Returns the fixture description.

Returns:
the fixture description.

setFixtureImports

public void setFixtureImports(java.util.List<MockCentralNode> imports)
Sets the list of imported Fixture instances.

Parameters:
imports - the list of imported Fixture instances.

getFixtureImportsList

public java.util.List<MockCentralNode> getFixtureImportsList()
Returns the list containing the FixtureNode instances for the Fixtures imported by this one.

Returns:
the list containing the FixtureNode instances for the Fixtures imported by this one.

getSimpleBoundObjectsList

public java.util.List<SimpleBoundObjectModel> getSimpleBoundObjectsList()
Returns the list of this Fixture's simple (that is, non-Mock) Objects that are to be bound into the naming context at runtime.

Returns:
the list of this Fixture's simple (that is, non-Mock) Objects that are to be bound into the naming context at runtime.

addSimpleBoundObject

public void addSimpleBoundObject(SimpleBoundObjectModel simpleBoundObjectModel,
                                 boolean refresh)
Adds a new simple JNDI-bound Object to the Fixture.

Parameters:
simpleBoundObjectModel - the model for the new Object.
refresh - whether the UI should be refreshed after the addition.

deleteSimpleBoundObject

public void deleteSimpleBoundObject(SimpleBoundObjectModel simpleBoundObjectModel,
                                    boolean refresh)
Removes a simple JNDI-bound Object from the Fixture.

Parameters:
simpleBoundObjectModel - the model to remove.
refresh - whether the UI should be refreshed after the add.

editMockObjects

public void editMockObjects()
Activates the MockObjectGroupNode for this Fixture.


isJndiNameInUse

public boolean isJndiNameInUse(java.lang.String jndiName,
                               java.lang.Object o)
Description copied from interface: IMockObjectDataManager
Returns whether the supplied JNDI name is currently in use within the Fixture.

Specified by:
isJndiNameInUse in interface IMockObjectDataManager
Parameters:
jndiName - the JNDI name.
o - an Object to exclude from duplicate-checking.
Returns:
whether the supplied JNDI name is currently in use within the Fixture.

getDefaultNewMockObjectName

public java.lang.String getDefaultNewMockObjectName()
Description copied from interface: IMockObjectDataManager
Returns a default value for a new Mock Object name.

Specified by:
getDefaultNewMockObjectName in interface IMockObjectDataManager
Returns:
a default value for a new Mock Object name.

getDefaultNewJndiName

public java.lang.String getDefaultNewJndiName()
Description copied from interface: IMockObjectDataManager
Returns a default value for a new JNDI name.

Specified by:
getDefaultNewJndiName in interface IMockObjectDataManager
Returns:
a default value for a new JNDI name.

getMockObjectNames

public java.util.ArrayList<java.lang.String> getMockObjectNames(java.lang.Object excluded)
Description copied from interface: IMockObjectDataManager
Returns the list of Mock Object names within the current Fixture.

Specified by:
getMockObjectNames in interface IMockObjectDataManager
Parameters:
excluded - an Object the name of which to exclude from the list.
Returns:
the list of Mock Object names within the current Fixture.

isValidJndiName

public java.lang.String isValidJndiName(java.lang.String jndiName,
                                        java.lang.Object o)
Description copied from interface: IMockObjectDataManager
Returns an error message indicating an invalid JNDI name, or null if the supplied JNDI name is valid.

Specified by:
isValidJndiName in interface IMockObjectDataManager
Parameters:
jndiName - the JNDI name.
o - the Object being edited, if any, to exclude from duplicate-checking.
Returns:
an error message indicating an invalid JNDI name, or null if the supplied JNDI name is valid.

isValidMockObjectName

public java.lang.String isValidMockObjectName(java.lang.String mockObjectName,
                                              java.lang.Object o)
Description copied from interface: IMockObjectDataManager
Returns an error message indicating an invalid Mock Object name, or null if the supplied name is valid.

Specified by:
isValidMockObjectName in interface IMockObjectDataManager
Parameters:
mockObjectName - the name for the Mock Object.
o - an Object to exclude from duplicated-name testing.
Returns:
an error message indicating an invalid Mock Object name, or null if the supplied name is valid.

isValidInterface

public java.lang.String isValidInterface(java.lang.String interfaceName)
Description copied from interface: IMockObjectDataManager
Returns an error message indicating an invalid Mock Object interface, or null if the supplied interface name is valid.

Specified by:
isValidInterface in interface IMockObjectDataManager
Parameters:
interfaceName - the class name of the interface.
Returns:
an error message indicating an invalid Mock Object interface, or null if the supplied interface name is valid.

getEnclosingFixtureNode

public FixtureNode getEnclosingFixtureNode()
Description copied from class: MockCentralNodeModel
Returns the enclosing FixtureNode.

Overrides:
getEnclosingFixtureNode in class MockCentralNodeModel
Returns:
the enclosing FixtureNode.

getNodeProblem

public NodeProblem getNodeProblem(java.lang.Object o)
Description copied from interface: INodeProblemParticipant
Returns the stored NodeProblem associated with the supplied Object, if any.

Specified by:
getNodeProblem in interface INodeProblemParticipant
Parameters:
o - the Object which may have an associated NodeProblem.
Returns:
the stored NodeProblem associated with the supplied Object, if any.

getNotRemovableMessage

public java.lang.String getNotRemovableMessage()
Description copied from class: MockCentralNodeModel
Returns a message for display indicating why the corresposing MockCentralNode instance cannot be deleted, or null (as this default implementation does).

Overrides:
getNotRemovableMessage in class MockCentralNodeModel
Returns:
a message for display indicating why the corresposing MockCentralNode instance cannot be deleted, or null.