Generic Model
Spring IDE's core plugin provides interfaces with corresponding base implementations of a generic model.
Model Elements
The basic elements of this model provides the following features:
- name
- type
- unique ID
- parent-child relationships
- accessing an element by it's unique ID
- traversing the model tree via visitor pattern
The resource elements of this model provides the following features:
- Eclipse workspace resource
The source elements of this model provides the following features:
- start line number
- end line number
Accessing Model Elements
The model elements are accessed by traversing the nodes of model tree. This can be done in different ways:
1. Traversing the Model via Parent-Child Relationships
IModel model = BeansCorePlugin.getModel(); IModelElement[] projects = model.getElementChildren(); for (int i = 0; i < projects.length; i++) { if (project[i].getElementName().equals("TestProject")) { IModelElement[] configs = project[i].getElementChildren(); for (int j = 0; j < projects.length; j++) { if (config[j].getElementType() == IBeansModelElementTypes.CONFIG && config[j].getElementName().equals("application-context.xml")) { return true; } } } } return false;
2. Traversing the Model via the Visitor Pattern
class Visitor implements IModelElementVisitor { public boolean visit(IModelElement element, IProgressMonitor monitor) { // your code here return true; } } IModel model = BeansCorePlugin.getModel(); model.accept(new Visitor(), new NullProgressMonitor());
3. Accessing an Element via it's unique ID
IModel model = BeansCorePlugin.getModel();
IBean bean = model.getElement("1:BeansModel|2:TestProject|3:application-context.xml|5:TestBean");
Attachments
- GenericModel.png (5.7 kB) -
Class diagram of generic model
, added by tjuerge on 04/23/06 02:53:59.
Download in other formats:

