1 package org.simantics.db.layer0.variable;
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.adapter.AdaptException;
5 import org.simantics.databoard.binding.Binding;
6 import org.simantics.databoard.type.Datatype;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.WriteGraph;
9 import org.simantics.db.exception.DatabaseException;
12 * A default implementation of value accessor that has fixed binding.
14 public abstract class ValueAccessorWithBinding implements ValueAccessor {
16 public abstract Binding getBinding();
19 public Object getValue(ReadGraph graph, Variable context, Binding binding)
20 throws DatabaseException {
22 return Bindings.adapt(getValue(graph, context), getBinding(), binding);
23 } catch (AdaptException e) {
24 throw new DatabaseException(e);
29 public void setValue(WriteGraph graph, Variable context, Object value,
30 Binding binding) throws DatabaseException {
32 setValue(graph, context, Bindings.adapt(value, binding, getBinding()));
33 } catch (AdaptException e) {
34 throw new DatabaseException(e);
39 public Datatype getDatatype(ReadGraph graph, Variable context) throws DatabaseException {
40 return getBinding().type();