Boolean, Double, and Integer conversions.
gitlab #881
Change-Id: Idaa4885470e580a0b0b4e5994c6a1e2a88bfd020
adapterClass="org.simantics.db.layer0.adapter.LiteralStringAdapter"/>
<adapter uri="http://www.simantics.org/Layer0-0.0/RVI"
adapterClass="org.simantics.db.layer0.adapter.RVIStringAdapter"/>
+
+ <adapter uri="http://www.simantics.org/Layer0-0.0/Double"
+ contextClass="org.simantics.db.RelationContext" adapterClass="org.simantics.db.layer0.adapter.LiteralDoubleStringAdapter" />
+ <adapter uri="http://www.simantics.org/Layer0-0.0/DoubleArray"
+ contextClass="org.simantics.db.RelationContext" adapterClass="org.simantics.db.layer0.adapter.LiteralDoubleArrayStringAdapter" />
+ <adapter uri="http://www.simantics.org/Layer0-0.0/Integer"
+ contextClass="org.simantics.db.RelationContext" adapterClass="org.simantics.db.layer0.adapter.LiteralIntegerStringAdapter" />
+ <adapter uri="http://www.simantics.org/Layer0-0.0/IntegerArray"
+ contextClass="org.simantics.db.RelationContext" adapterClass="org.simantics.db.layer0.adapter.LiteralIntegerArrayStringAdapter" />
+ <adapter uri="http://www.simantics.org/Layer0-0.0/Boolean"
+ contextClass="org.simantics.db.RelationContext" adapterClass="org.simantics.db.layer0.adapter.LiteralBooleanStringAdapter" />
</target>
<target interface="java.lang.String">
--- /dev/null
+package org.simantics.db.layer0.adapter;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.RelationContext;
+import org.simantics.db.Resource;
+import org.simantics.db.adaption.Adapter;
+import org.simantics.db.procedure.AsyncProcedure;
+
+public class LiteralBooleanStringAdapter implements Adapter<String, RelationContext> {
+
+ @Override
+ public void adapt(AsyncReadGraph g, Resource source, RelationContext s, final AsyncProcedure<String> procedure) {
+ g.forValue(s.getStatement().getObject(), Bindings.BOOLEAN, new ProcedureWrapper(procedure));
+ }
+
+ private static class ProcedureWrapper implements AsyncProcedure<Boolean> {
+ AsyncProcedure<String> procedure;
+
+ public ProcedureWrapper(AsyncProcedure<String> procedure) {
+ this.procedure = procedure;
+ }
+
+ public void execute(AsyncReadGraph graph, Boolean result) {
+ procedure.execute(graph, result.toString());
+ };
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ procedure.exception(graph, throwable);
+
+ }
+ }
+
+}
--- /dev/null
+package org.simantics.db.layer0.adapter;
+
+import java.util.Arrays;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.RelationContext;
+import org.simantics.db.Resource;
+import org.simantics.db.adaption.Adapter;
+import org.simantics.db.procedure.AsyncProcedure;
+
+public class LiteralDoubleArrayStringAdapter implements Adapter<String, RelationContext> {
+
+ @Override
+ public void adapt(AsyncReadGraph g, Resource source, RelationContext s, final AsyncProcedure<String> procedure) {
+ g.forValue(s.getStatement().getObject(), Bindings.DOUBLE_ARRAY, new ProcedureWrapper(procedure));
+ }
+
+ private static class ProcedureWrapper implements AsyncProcedure<double[]> {
+ AsyncProcedure<String> procedure;
+
+ public ProcedureWrapper(AsyncProcedure<String> procedure) {
+ this.procedure = procedure;
+ }
+
+ public void execute(AsyncReadGraph graph, double[] result) {
+ procedure.execute(graph, Arrays.toString(result));
+ };
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ procedure.exception(graph, throwable);
+
+ }
+ }
+
+}
--- /dev/null
+package org.simantics.db.layer0.adapter;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.RelationContext;
+import org.simantics.db.Resource;
+import org.simantics.db.adaption.Adapter;
+import org.simantics.db.procedure.AsyncProcedure;
+
+public class LiteralDoubleStringAdapter implements Adapter<String, RelationContext> {
+
+ @Override
+ public void adapt(AsyncReadGraph g, Resource source, RelationContext s, final AsyncProcedure<String> procedure) {
+ g.forValue(s.getStatement().getObject(), Bindings.DOUBLE, new ProcedureWrapper(procedure));
+ }
+
+ private static class ProcedureWrapper implements AsyncProcedure<Double> {
+ AsyncProcedure<String> procedure;
+
+ public ProcedureWrapper(AsyncProcedure<String> procedure) {
+ this.procedure = procedure;
+ }
+
+ public void execute(AsyncReadGraph graph, Double result) {
+ procedure.execute(graph, result.toString());
+ };
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ procedure.exception(graph, throwable);
+
+ }
+ }
+
+}
--- /dev/null
+package org.simantics.db.layer0.adapter;
+
+import java.util.Arrays;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.RelationContext;
+import org.simantics.db.Resource;
+import org.simantics.db.adaption.Adapter;
+import org.simantics.db.procedure.AsyncProcedure;
+
+public class LiteralIntegerArrayStringAdapter implements Adapter<String, RelationContext> {
+
+ @Override
+ public void adapt(AsyncReadGraph g, Resource source, RelationContext s, final AsyncProcedure<String> procedure) {
+ g.forValue(s.getStatement().getObject(), Bindings.INT_ARRAY, new ProcedureWrapper(procedure));
+ }
+
+ private static class ProcedureWrapper implements AsyncProcedure<int[]> {
+ AsyncProcedure<String> procedure;
+
+ public ProcedureWrapper(AsyncProcedure<String> procedure) {
+ this.procedure = procedure;
+ }
+
+ public void execute(AsyncReadGraph graph, int[] result) {
+ procedure.execute(graph, Arrays.toString(result));
+ };
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ procedure.exception(graph, throwable);
+
+ }
+ }
+
+}
--- /dev/null
+package org.simantics.db.layer0.adapter;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.RelationContext;
+import org.simantics.db.Resource;
+import org.simantics.db.adaption.Adapter;
+import org.simantics.db.procedure.AsyncProcedure;
+
+public class LiteralIntegerStringAdapter implements Adapter<String, RelationContext> {
+
+ @Override
+ public void adapt(AsyncReadGraph g, Resource source, RelationContext s, final AsyncProcedure<String> procedure) {
+ g.forValue(s.getStatement().getObject(), Bindings.INTEGER, new ProcedureWrapper(procedure));
+ }
+
+ private static class ProcedureWrapper implements AsyncProcedure<Integer> {
+ AsyncProcedure<String> procedure;
+
+ public ProcedureWrapper(AsyncProcedure<String> procedure) {
+ this.procedure = procedure;
+ }
+
+ public void execute(AsyncReadGraph graph, Integer result) {
+ procedure.execute(graph, result.toString());
+ };
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ procedure.exception(graph, throwable);
+
+ }
+ }
+
+}