Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'pages/customdatatypes.html')
-rw-r--r--pages/customdatatypes.html31
1 files changed, 31 insertions, 0 deletions
diff --git a/pages/customdatatypes.html b/pages/customdatatypes.html
index 6b60f00..7e459d4 100644
--- a/pages/customdatatypes.html
+++ b/pages/customdatatypes.html
@@ -34,6 +34,37 @@ In order to overcome this issue, Edapt offers the org.eclipse.emf.edapt.factorie
The easiest way to create such a custom factory for usage with Edapt is to subclass EFactoryImpl and to override createFromString(EDataType, String) and convertToString(EDataType, Object) respectively.
Please note that eDataType.getClassifierID() does not necessarily give the same ids in a dynamic instance.
The ids are generated and might vary. So it is not possible to simply copy the existing EFactory-code, but you have to adjust the switch() statements accordingly, e.g by identifying datatypes via the name attribute.
+</p><p>
+<hr/>
+<a>Listing 2</a> - Example Custom Factory
+<pre class="codebox">
+public class LibraryFactoryImpl extends EFactoryImpl {
+
+ @Override
+ public Object createFromString(EDataType eDataType, String initialValue) {
+ switch (eDataType.getName()) {
+ case "MyCustomDataType":
+ return createMyCustomDataTypeFromString(eDataType, initialValue);
+ default:
+ return super.createFromString(eDataType, initialValue);
+ }
+ }
+
+ @Override
+ public String convertToString(EDataType eDataType, Object instanceValue) {
+ switch (eDataType.getName()) {
+ case "MyCustomDataType":
+ return convertMyCustomDataTypeToString(eDataType, instanceValue);
+ default:
+ return super.convertToString(eDataType, instanceValue);
+ }
+ }
+
+ private String convertMyCustomDataTypeToString(EDataType eDataType, Object instanceValue) {/* TODO */return null;}
+ private Object createMyCustomDataTypeFromString(EDataType eDataType, String initialValue) {/* TODO */return null;}
+}
+</pre>
+<hr/>
</p>
</div>
</div> \ No newline at end of file

Back to the top