-package org.simantics.graph.compiler.internal.templates;\r
-\r
-import java.io.IOException;\r
-import java.util.Collection;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.binding.mutable.Variant;\r
-import org.simantics.databoard.serialization.Serializer;\r
-import org.simantics.graph.compiler.ExternalFileLoader;\r
-import org.simantics.graph.compiler.internal.store.LocationStore;\r
-import org.simantics.graph.compiler.internal.store.PreValueStore;\r
-import org.simantics.graph.query.IGraph;\r
-import org.simantics.graph.store.GraphStore;\r
-import org.simantics.ltk.Location;\r
-import org.simantics.ltk.Problem;\r
-\r
-public enum LoadDataValueTemplate implements ITemplate {\r
- INSTANCE;\r
- \r
- @Override\r
- public void apply(IGraph graph, GraphStore store,\r
- int[] parameters, ExternalFileLoader fileLoader, Collection<Problem> problems) {\r
- String fileName = store.getStore(PreValueStore.class).getStringValue(parameters[1]);\r
- if(fileName == null) {\r
- Location location = store.getStore(LocationStore.class)\r
- .getLocation(parameters[1]);\r
- problems.add(new Problem(\r
- location, "Expected a string"));\r
- } \r
- try {\r
- byte[] bytes = fileLoader.load(fileName);\r
- Serializer variantSerializer = Bindings.getSerializerUnchecked(Bindings.VARIANT);\r
- Variant value = (Variant)variantSerializer.deserialize(bytes);\r
- store.values.setValue(parameters[0], value);\r
- } catch (IOException e) {\r
- Location location = store.getStore(LocationStore.class)\r
- .getLocation(parameters[1]);\r
- problems.add(new Problem(\r
- location, e.getMessage()));\r
- } \r
- }\r
-\r
-}\r
+package org.simantics.graph.compiler.internal.templates;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.databoard.serialization.Serializer;
+import org.simantics.graph.compiler.ExternalFileLoader;
+import org.simantics.graph.compiler.internal.store.LocationStore;
+import org.simantics.graph.compiler.internal.store.PreValueStore;
+import org.simantics.graph.query.IGraph;
+import org.simantics.graph.store.GraphStore;
+import org.simantics.ltk.Location;
+import org.simantics.ltk.Problem;
+
+public enum LoadDataValueTemplate implements ITemplate {
+ INSTANCE;
+
+ @Override
+ public void apply(IGraph graph, GraphStore store,
+ int[] parameters, ExternalFileLoader fileLoader, Collection<Problem> problems) {
+ String fileName = store.getStore(PreValueStore.class).getStringValue(parameters[1]);
+ if(fileName == null) {
+ Location location = store.getStore(LocationStore.class)
+ .getLocation(parameters[1]);
+ problems.add(new Problem(
+ location, "Expected a string"));
+ }
+ try {
+ byte[] bytes = fileLoader.load(fileName);
+ Serializer variantSerializer = Bindings.getSerializerUnchecked(Bindings.VARIANT);
+ Variant value = (Variant)variantSerializer.deserialize(bytes);
+ store.values.setValue(parameters[0], value);
+ } catch (IOException e) {
+ Location location = store.getStore(LocationStore.class)
+ .getLocation(parameters[1]);
+ problems.add(new Problem(
+ location, e.getMessage()));
+ }
+ }
+
+}