Difference between revisions of "Extending the Rodin Database"

From Event-B
Jump to: navigation, search
m (Getting the)
m (Getting the corresponding type)
Line 34: Line 34:
 
After declaring the attribute with the ID and the kind of the attribute, we need to access the value corresponding to the attribute of any internal element.
 
After declaring the attribute with the ID and the kind of the attribute, we need to access the value corresponding to the attribute of any internal element.
  
==== Getting the corresponding type ====
+
==== Getting the corresponding Java attribute kind ====
 
Firstly, we need to get the corresponding Java attribute kind.
 
Firstly, we need to get the corresponding Java attribute kind.
  
Line 47: Line 47:
 
* '''string''': org.rodinp.core.IAttributeTypes.String
 
* '''string''': org.rodinp.core.IAttributeTypes.String
  
The following methods get the corresponding Java attribute kind, given an ID and the kind (as declared via the extension points).
+
The following methods get the corresponding Java attribute kind, given an ID and the kind (as declared via the extension point).
  
* <code>org.rodinp.core.IAttributeTypes.Boolean RodinCore.getBoolAttrType(ID)</code>
+
* <code>org.rodinp.core.IAttributeTypes.Boolean RodinCore.getBoolAttrType(String ID)</code>
 
   
 
   
* <code>org.rodinp.core.IAttributeTypes.Handle RodinCore.getHandleAttrType(ID)</code>
+
* <code>org.rodinp.core.IAttributeTypes.Handle RodinCore.getHandleAttrType(String ID)</code>
  
* <code>org.rodinp.core.IAttributeTypes.Integer RodinCore.getIntegerAttrType(ID)</code>
+
* <code>org.rodinp.core.IAttributeTypes.Integer RodinCore.getIntegerAttrType(String ID)</code>
  
* <code>org.rodinp.core.IAttributeTypes.Long RodinCore.getLongAttrType(ID)</code>
+
* <code>org.rodinp.core.IAttributeTypes.Long RodinCore.getLongAttrType(String ID)</code>
  
* <code>org.rodinp.core.IAttributeTypes.String RodinCore.getStringAttrType(ID)</code>
+
* <code>org.rodinp.core.IAttributeTypes.String RodinCore.getStringAttrType(String ID)</code>
  
Depending on the kind of the attribute, one can use one of the following method to access the value corresponding to the attribute of any
+
Note: There is a general method for getting the Java attribute kind (without knowing in advance the kind as declared via the extension point).
 +
 
 +
* <code>org.rodinp.core.IAttributeTypes RodinCore.getAttrubuteType(String ID)</code>

Revision as of 17:56, 24 March 2010

There are different ways to extend the Rodin Database:

  • adding a new element.
  • adding a new attribute.

Adding a New Element

Adding a New Attribute to Existing Elements

Declare a New Attribute

The extension point org.rodinp.core.attributeTypes to declare a new attribute.

In the example below, we assume that the extensions are developed within a plug-in project with name org.eventb.developer.examples

The following extension declares a new string attribute.

<extension
        point="org.rodinp.core.attributeTypes">
     <attributeType
           id="stringAttr"
           kind="string"
           name="%eventBStringAttribute">
     </attributeType>
 </extension>
  • The attribute has an ID (which should be always unique) which also contain the project name, i.e. org.eventb.developer.examples.stringAttr. This unique ID will be used for access the value corresponding to this attribute of an element later.
  • The name of the attribute is a string that could be externalised to be used for displaying to the users in the future.
  • There are five different attribute kinds: boolean, handle, integer, long, string.

Access (Programmatically) the Newly Created Attribute

After declaring the attribute with the ID and the kind of the attribute, we need to access the value corresponding to the attribute of any internal element.

Getting the corresponding Java attribute kind

Firstly, we need to get the corresponding Java attribute kind.

  • boolean: org.rodinp.core.IAttributeTypes.Boolean
  • handle: org.rodinp.core.IAttributeTypes.Handle
  • integer: org.rodinp.core.IAttributeTypes.Integer
  • long: org.rodinp.core.IAttributeTypes.Long
  • string: org.rodinp.core.IAttributeTypes.String

The following methods get the corresponding Java attribute kind, given an ID and the kind (as declared via the extension point).

  • org.rodinp.core.IAttributeTypes.Boolean RodinCore.getBoolAttrType(String ID)
  • org.rodinp.core.IAttributeTypes.Handle RodinCore.getHandleAttrType(String ID)
  • org.rodinp.core.IAttributeTypes.Integer RodinCore.getIntegerAttrType(String ID)
  • org.rodinp.core.IAttributeTypes.Long RodinCore.getLongAttrType(String ID)
  • org.rodinp.core.IAttributeTypes.String RodinCore.getStringAttrType(String ID)

Note: There is a general method for getting the Java attribute kind (without knowing in advance the kind as declared via the extension point).

  • org.rodinp.core.IAttributeTypes RodinCore.getAttrubuteType(String ID)