java.lang.Object
visitorDemoExercises.basicVisitorDemo.model.VisitorDemoModel
The main model object for the Visitor Demo system.
- Author:
- swong
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IObjectLoader<IVisitor>
The dynamic class loader for the IVisitors.private ILogger
logger to useThe installed painting command instance.private IViewAdapter
The adapter out to the view -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIHost[]
getHosts()
Get an array of the available host types, i.e.private IVisitor
loadVisitor(String classname)
Utility method to load a visitor given its classname, without the leading "visitors.impl.".void
Paint on the given Graphics object using the current IPaintCmd object in the model.Return the results of having the given host object execute the visitor corresponding to the given class name.
-
Field Details
-
logger
logger to use -
view
The adapter out to the view -
paintCmd
The installed painting command instance. Initially set to a no-op cmd. -
loader
The dynamic class loader for the IVisitors.
-
-
Constructor Details
-
VisitorDemoModel
The constructor for the class- Parameters:
view
- the adapter to the view
-
-
Method Details
-
getHosts
Get an array of the available host types, i.e. IHost subclasses.- Returns:
- An array of IHost objects
-
run
Return the results of having the given host object execute the visitor corresponding to the given class name. A reference to this model object is given as the visitor's input parameter.- Parameters:
host
- An IHost objectvisitorClassname
- The name of the visitor class, without the leading "visitors.impl."- Returns:
- The results of the visitor execution on the given host.
-
loadVisitor
Utility method to load a visitor given its classname, without the leading "visitors.impl.".- Parameters:
classname
- the visitor's classname- Returns:
- An IVisitor object
-
paint
Paint on the given Graphics object using the current IPaintCmd object in the model.- Parameters:
g
- The Graphics context on which to draw.
-