1 package org.simantics.db.layer0.variable;
\r
3 import org.simantics.databoard.Bindings;
\r
4 import org.simantics.databoard.adapter.AdaptException;
\r
5 import org.simantics.databoard.binding.Binding;
\r
6 import org.simantics.databoard.type.Datatype;
\r
7 import org.simantics.db.ReadGraph;
\r
8 import org.simantics.db.Resource;
\r
9 import org.simantics.db.WriteGraph;
\r
10 import org.simantics.db.exception.DatabaseException;
\r
12 public class ConstantValueStandardGraphPropertyVariable extends StandardGraphPropertyVariable {
\r
14 final private Object value;
\r
15 final private Datatype datatype;
\r
17 public ConstantValueStandardGraphPropertyVariable(ReadGraph graph, Variable parent, Resource parentResource, Resource predicate, Object value, Datatype datatype) throws DatabaseException {
\r
18 super(graph, parent, null, parentResource, predicate);
\r
20 this.datatype = datatype;
\r
23 @SuppressWarnings("unchecked")
\r
25 public <T> T getValue(ReadGraph graph) throws DatabaseException {
\r
29 @SuppressWarnings("unchecked")
\r
31 public <T> T getValue(ReadGraph graph, Binding binding) throws DatabaseException {
\r
33 return (T)Bindings.adapt(value, Bindings.getBinding(datatype), binding);
\r
34 } catch (AdaptException e) {
\r
35 throw new DatabaseException(e);
\r
40 public Datatype getDatatype(ReadGraph graph) throws DatabaseException {
\r
45 public void setValue(WriteGraph graph, Object value) throws DatabaseException {
\r
46 throw new DatabaseException("setValue is not supported.");
\r
50 public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException {
\r
51 throw new DatabaseException("setValue is not supported.");
\r