Additions:
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. The default application, [[StarmapperAppCli starmapper-app-cli]], creates instances of implementations of this interface dynamically, so they have a public no-argument constructor.
Deletions:
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. The default application, [[starmapper-app-cli]], creates instances of implementations of this interface dynamically, so they have a public no-argument constructor.
Revision [91]
Edited on
2007-09-19 11:40:33 by KrzysztofSobolewski
[Rewrite to accomodate recent redesign of the API.]
Additions:
Version 3 of Starmapper brought a new cool thing: Starmapper is no longer tied to Stars!, that is it no longer talks of Planets, Players and so on. Now it talks of Nodes, Regions and Node Infos. These are all interfaces - Starmapper cares only about some data it expects to get from concrete implementations. Where necessary, interfaces are generified to provide some additional type safety for implementers of Data Model - every concrete implementation of an interface is supposed to work with types belonging to this Data Model, not with base interfaces - this allows for Data-Model-private additional methods and properties of these classes that can be used internally for whatever purpose (usually to calculate node value). See the default implementation in [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/stars/package-summary.html jezuch.utils.starmapper3.model.stars]] package for examples and some enlightenment, if you find that my explanations don't explain enything ;) Code speaks for itself the best!
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/Region.html Region]]**: this one's easy. Just a name, and "region number", assigned to it by a configuration file or internally by the Data Model (generally the same as passed to [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html#createRegion(jezuch.utils.starmapper3.config.Config,%20int) DataModel.createNode()]]).
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. The default application, [[starmapper-app-cli]], creates instances of implementations of this interface dynamically, so they have a public no-argument constructor.
Some of the methods also return a plain old [[http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html Iterables]] to simplify processing (and complicate error handling (yes, I've fallen into my own trap ;) )) instead of custom "readers" for model objects. The Data Model implementation knows best where to get the data and how to process it and return to Starmapper.
The Data Model has a concept of "session", which makes an instance of **DataModel** interface a stateful object (which, fortunately, doesn't have to be thread-safe). At the start of a session a Starmapper application passes a [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/config/Config.html Config]] object, from which the Data Model can read additional configuration data (the default Stars! data model does this too, if you're curious). It is even allowed to modify the **Config** object, but then it is required to undo any modifications at the end of the session.
The DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic stuff. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
There's also another convenience class: [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractNodeInfo.html AbstractNodeInfo]]. It takes care of some basic tasks, like providing getters for standard properties (and providing storage for them), implementing [[http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object) equals]] (you still need to override it if you add your own properties, but calling super.equals() is not a bad idea) and defining an additional method [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractNodeInfo.html#shouldMergeWith(I) shouldMergeWith]] which performs basic conflict detection for NodeInfos (conflict is when two NodeInfos describe the same Node in the same point in time).
Deletions:
Version 3 of Starmapper brought a new cool thing: Starmapper is no longer tied to Stars!, that is it no longer talks of Planets, Players and so on [the only remnant is "years" to describe time scale, but it might go away soon]. Now it talks of Nodes, Regions and Node Infos. These are all interfaces - Starmapper cares only about some data it expects to get from concrete implementations. Where necessary, interfaces are generified to provide some additional type safety for implementers of Data Model - every concrete implementation of an interface is supposed to work with types belonging to this Data Model, not with base interfaces - this allows for Data-Model-private additional methods and properties of these classes that can be used internally for whatever purpose. See the default implementation in [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/stars/package-summary.html jezuch.utils.starmapper3.model.stars]] package for examples and some enlightenment, if you find that my explanations don't explain enything ;) Code speaks for itself the best!
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/Region.html Region]]**: this one's easy. Just a name.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. It may seem a bit awkward in a way it produces these objects - this is a result of evolution from previous versions; it provides what turned out to be needed in current state of things.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/NodeReader.html NodeReader]]**: ok, it's not a perfect name, because this is not the thing that produces Nodes. It produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]], which produces Nodes, given a [[http://starmapper.sourceforge.net/api/jezuch-utils/trunk/jezuch/utils/io/ReaderSource.html ReaderSource]], which produces a [[http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html Reader]] to read from... This basically is how The Map is created.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/ReportReader.html ReportReader>]]**: finally, we have the thing that produces Node Infos (so it need the full generic declaration). Like NodeReader, it takes a [[http://starmapper.sourceforge.net/api/jezuch-utils/trunk/jezuch/utils/io/ReaderSource.html ReaderSource]] and produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]]. Starmapper then uses it to generate proper [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Report.html Report]].
If you've kept attention, you probably noticed that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
There's also another convenience class: [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractNodeInfo.html AbstractNodeInfo]]. It takes care of some janitorial tasks, like providing getters for standard properties (and providing storage for them), implementing [[http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object) equals]] (you still need to override it if you add your own properties, but calling super.equals() is not a bad idea) and defining an additional method [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractNodeInfo.html#shouldMergeWith(I) shouldMergeWith]] which performs basic conflict detection for NodeInfos (conflict is when two NodeInfos describe the same Node in the same point in time).
Additions:
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/NodeReader.html NodeReader]]**: ok, it's not a perfect name, because this is not the thing that produces Nodes. It produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]], which produces Nodes, given a [[http://starmapper.sourceforge.net/api/jezuch-utils/trunk/jezuch/utils/io/ReaderSource.html ReaderSource]], which produces a [[http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html Reader]] to read from... This basically is how The Map is created.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/ReportReader.html ReportReader>]]**: finally, we have the thing that produces Node Infos (so it need the full generic declaration). Like NodeReader, it takes a [[http://starmapper.sourceforge.net/api/jezuch-utils/trunk/jezuch/utils/io/ReaderSource.html ReaderSource]] and produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]]. Starmapper then uses it to generate proper [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Report.html Report]].
Deletions:
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/NodeReader.html NodeReader]]**: ok, it's not a perfect name, because this is not the thing that produces Nodes. It produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]], which produces Nodes, given a [[http://starmapper.sourceforge.net/api/jezuch-utils/jezuch/utils/io/ReaderSource.html ReaderSource]], which produces a [[http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html Reader]] to read from... This basically is how The Map is created.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/ReportReader.html ReportReader>]]**: finally, we have the thing that produces Node Infos (so it need the full generic declaration). Like NodeReader, it takes a [[http://starmapper.sourceforge.net/api/jezuch-utils/jezuch/utils/io/ReaderSource.html ReaderSource]] and produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]]. Starmapper then uses it to generate proper [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Report.html Report]].
Additions:
Version 3 of Starmapper brought a new cool thing: Starmapper is no longer tied to Stars!, that is it no longer talks of Planets, Players and so on [the only remnant is "years" to describe time scale, but it might go away soon]. Now it talks of Nodes, Regions and Node Infos. These are all interfaces - Starmapper cares only about some data it expects to get from concrete implementations. Where necessary, interfaces are generified to provide some additional type safety for implementers of Data Model - every concrete implementation of an interface is supposed to work with types belonging to this Data Model, not with base interfaces - this allows for Data-Model-private additional methods and properties of these classes that can be used internally for whatever purpose. See the default implementation in [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/stars/package-summary.html jezuch.utils.starmapper3.model.stars]] package for examples and some enlightenment, if you find that my explanations don't explain enything ;) Code speaks for itself the best!
So, Data Model consists of concrete implementations of interfaces in [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/package-summary.html jezuch.utils.starmapper3.model]] package:
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/Node.html Node]]**: Starmapper wants to know only node's position (x and y on The Map) and its name. That's all.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/Region.html Region]]**: this one's easy. Just a name.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/NodeInfo.html NodeInfo>]]**: this is where fun begins. NodeInfo is the most important thing in all this mess, the former two are just supporters. NodeInfo descibes a Node (so it needs to be generified with proper implementation - **N**); Node has an owner, a Region (so we have generification on **R**); NodeInfo also consumes (and produces) other NodeInfos, and needs to know concrete implementation of itself (hence **I**). Actually you'll see this generic declaration in lots of places in Starmapper.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. It may seem a bit awkward in a way it produces these objects - this is a result of evolution from previous versions; it provides what turned out to be needed in current state of things.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/NodeReader.html NodeReader]]**: ok, it's not a perfect name, because this is not the thing that produces Nodes. It produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]], which produces Nodes, given a [[http://starmapper.sourceforge.net/api/jezuch-utils/jezuch/utils/io/ReaderSource.html ReaderSource]], which produces a [[http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html Reader]] to read from... This basically is how The Map is created.
- **[[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/ReportReader.html ReportReader>]]**: finally, we have the thing that produces Node Infos (so it need the full generic declaration). Like NodeReader, it takes a [[http://starmapper.sourceforge.net/api/jezuch-utils/jezuch/utils/io/ReaderSource.html ReaderSource]] and produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]]. Starmapper then uses it to generate proper [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Report.html Report]].
If you've kept attention, you probably noticed that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
There's also another convenience class: [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractNodeInfo.html AbstractNodeInfo]]. It takes care of some janitorial tasks, like providing getters for standard properties (and providing storage for them), implementing [[http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object) equals]] (you still need to override it if you add your own properties, but calling super.equals() is not a bad idea) and defining an additional method [[http://starmapper.sourceforge.net/api/starmapper3/trunk/jezuch/utils/starmapper3/model/AbstractNodeInfo.html#shouldMergeWith(I) shouldMergeWith]] which performs basic conflict detection for NodeInfos (conflict is when two NodeInfos describe the same Node in the same point in time).
Deletions:
Version 3 of Starmapper brought a new cool thing: Starmapper is no longer tied to Stars!, that is it no longer talks of Planets, Players and so on [the only remnant is "years" to describe time scale, but it might go away soon]. Now it talks of Nodes, Regions and Node Infos. These are all interfaces - Starmapper cares only about some data it expects to get from concrete implementations. Where necessary, interfaces are generified to provide some additional type safety for implementers of Data Model - every concrete implementation of an interface is supposed to work with types belonging to this Data Model, not with base interfaces - this allows for Data-Model-private additional methods and properties of these classes that can be used internally for whatever purpose. See the default implementation in [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/stars/package-summary.html jezuch.utils.starmapper3.model.stars]] package for examples and some enlightenment, if you find that my explanations don't explain enything ;) Code speaks for itself the best!
So, Data Model consists of concrete implementations of interfaces in [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/package-summary.html jezuch.utils.starmapper3.model]] package:
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/Node.html Node]]**: Starmapper wants to know only node's position (x and y on The Map) and its name. That's all.
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/Region.html Region]]**: this one's easy. Just a name.
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/NodeInfo.html NodeInfo>]]**: this is where fun begins. NodeInfo is the most important thing in all this mess, the former two are just supporters. NodeInfo descibes a Node (so it needs to be generified with proper implementation - **N**); Node has an owner, a Region (so we have generification on **R**); NodeInfo also consumes (and produces) other NodeInfos, and needs to know concrete implementation of itself (hence **I**). Actually you'll see this generic declaration in lots of places in Starmapper.
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. It may seem a bit awkward in a way it produces these objects - this is a result of evolution from previous versions; it provides what turned out to be needed in current state of things.
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/NodeReader.html NodeReader]]**: ok, it's not a perfect name, because this is not the thing that produces Nodes. It produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]], which produces Nodes, given a [[http://starmapper.sourceforge.net/api/jezuch-utils/jezuch/utils/io/ReaderSource.html ReaderSource]], which produces a [[http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html Reader]] to read from... This basically is how The Map is created.
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/ReportReader.html ReportReader>]]**: finally, we have the thing that produces Node Infos (so it need the full generic declaration). Like NodeReader, it takes a [[http://starmapper.sourceforge.net/api/jezuch-utils/jezuch/utils/io/ReaderSource.html ReaderSource]] and produces an [[http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html Iterator]]. Starmapper then uses it to generate proper [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Report.html Report]].
If you've kept attention, you probably noticed that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
There's also another convenience class: [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractNodeInfo.html AbstractNodeInfo]]. It takes care of some janitorial tasks, like providing getters for standard properties (and providing storage for them), implementing [[http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object) equals]] (you still need to override it if you add your own properties, but calling super.equals() is not a bad idea) and defining an additional method [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractNodeInfo.html#shouldMergeWith(I) shouldMergeWith]] which performs basic conflict detection for NodeInfos (conflict is when two NodeInfos describe the same Node in the same point in time).
Additions:
If you've kept attention, you probably noticed that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
There's also another convenience class: [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractNodeInfo.html AbstractNodeInfo]]. It takes care of some janitorial tasks, like providing getters for standard properties (and providing storage for them), implementing [[http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object) equals]] (you still need to override it if you add your own properties, but calling super.equals() is not a bad idea) and defining an additional method [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractNodeInfo.html#shouldMergeWith(I) shouldMergeWith]] which performs basic conflict detection for NodeInfos (conflict is when two NodeInfos describe the same Node in the same point in time).
Deletions:
If you've kept attention, you probably notices that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
Additions:
If you've kept attention, you probably notices that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method. If you don't want to do it in your DataModel, you can extend [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/AbstractDataModel.html AbstractDataModel]], which does what's necessary (it's pretty straightforward and classifies as a boilerplate code).
Deletions:
If you've kept attention, you probably notices that DataModel interface has a [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html#startApplication(jezuch.utils.starmapper3.Application,%20jezuch.utils.starmapper3.config.Config) startApplication]] method. This is a trick to make Data Models and Starmapper work with all this generic cruft. The trick is called "double dispatch" (although usually used for a bit different purposes) - the application knows nothing about concrete implementations in the Data Model, but the Model should know what it provides, so the application it asks the DataModel instance to call back with proper types. That's what the [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html Application]] interface is for, and its generified (with the usual declaration) [[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/Application.html#start(jezuch.utils.starmapper3.config.Config,%20jezuch.utils.starmapper3.model.DataModel) start]] method.
Additions:
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. It may seem a bit awkward in a way it produces these objects - this is a result of evolution from previous versions; it provides what turned out to be needed in current state of things.
Deletions:
- **[[http://starmapper.sourceforge.net/api/starmapper3/jezuch/utils/starmapper3/model/DataModel.html DataModel>]]**: finally, the thing that keeps it all together. When Starmapper wants a "Data Model", it expects an implemetation of this interface. It is basically a factory of objects in this Data Model. It may seem a bit awkward in a way it produces these objects - this is a result of evolution from previous versions; it provides what turned out to be needed in current state of things.