-
Notifications
You must be signed in to change notification settings - Fork 3
HOWTOs
Nicolas Himmelmann edited this page Jul 27, 2018
·
16 revisions
(This process still requires some work to do, we plan to simplify this in future versions of the framework.)
Adding a new context type to the framework is a process of the following steps.
-
Add and implement the new class in the package
vstore.framework.context.types
:- Your context class should inherit from the base class
VContextType
. - The name of your context class should be appended as a type for the generic:
- Example:
public class MyContextType extends VContextType<MyContextType> { ... }
- Example:
- Give your new context class the desired attributes.
- The following abstract methods must be implemented:
- The constructor
MyContextType(JSONObject)
: Used for creating a new object of your context type from a given json object. -
JSONObject getJson()
: Used for retrieving a JSON representation of your new context type -
boolean matches(MyContextType other)
: Used for checking, if your context matches another given context of the same type
- The constructor
- Your context class should inherit from the base class
-
Add your new context type to the ContextDescription class in the package
vstore.framework.context
:- Add it as a private member.
- Add the necessary initializations in the constructors.
- Add getter and setter for your context type.
- Add a
void clear[MyContextType]Context()
method which sets the private member tonull
. - Add a
boolean has[MyContextType]Context()
method, which returns true if your context type is set in the ContextDescription - Add it to the
getJson()
function of theContextDescription
class.
-
Proceed similarly for the
RuleContextDescription
class, if you want to be able to use your context in the decision rules -
Finally, define the desired behavior when using the context during the matching procedure (class
Matching
in the packagevstore.framework.matching
):- Add a method
private boolean checkConditions_[yourConditionName](VStoreRule r, VStoreFile f) { ... }
- Must return true, if the rule should be kept in the result set
- Mus return false, if the rule should be deleted from the result set, because your context conditions are not met.
- Add your condition to the conjunction in the method
boolean eliminateRuleByContext()
.
- Add a method
-
That's it! Now you can pass a context description and rules to the framework which use your context type.