]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRequests.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / VariableRequests.java
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRequests.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRequests.java
new file mode 100644 (file)
index 0000000..1985d23
--- /dev/null
@@ -0,0 +1,128 @@
+package org.simantics.db.layer0.variable;\r
+\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.common.request.BinaryRead;\r
+import org.simantics.db.common.request.TernaryRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+\r
+\r
+public class VariableRequests {\r
+\r
+//     /*\r
+//      * Convenience method for getting the value of a named property.\r
+//      */\r
+//     <T> T getPropertyValue(ReadGraph graph, String name) throws DatabaseException;\r
+//     <T> T getPossiblePropertyValue(ReadGraph graph, String name) throws DatabaseException;\r
+//     /*\r
+//      * Convenience method for getting the value of a named property.\r
+//      */\r
+//     <T> T getPropertyValue(ReadGraph graph, String name, Binding binding) throws DatabaseException;\r
+//     <T> T getPossiblePropertyValue(ReadGraph graph, String name, Binding binding) throws DatabaseException;\r
+\r
+       public static <T> Read<T> getPossiblePropertyValue(Variable variable, String name) {\r
+               return new BinaryRead<Variable, String, T>(variable, name) {\r
+\r
+                       @Override\r
+                       public T perform(ReadGraph graph) throws DatabaseException {\r
+                               return parameter.getPossiblePropertyValue(graph, parameter2);\r
+                       }\r
+                       \r
+               };\r
+       }\r
+       \r
+       public static <T> Read<T> getPossiblePropertyValue(Variable variable, String name, Binding binding) {\r
+               return new TernaryRead<Variable, String, Binding, T>(variable, name, binding) {\r
+\r
+                       @Override\r
+                       public T perform(ReadGraph graph) throws DatabaseException {\r
+                               return parameter.getPossiblePropertyValue(graph, parameter2, parameter3);\r
+                       }\r
+                       \r
+               };\r
+       }\r
+       \r
+//     /*\r
+//      * Gets the value of the property. Binding is default.\r
+//      */\r
+//     <T> T getValue(ReadGraph graph) throws DatabaseException;\r
+//     <T> T getPossibleValue(ReadGraph graph) throws DatabaseException;\r
+//     /*\r
+//      * Gets the value of the property. Binding is explicitly given.\r
+//      */\r
+//     <T> T getValue(ReadGraph graph, Binding binding) throws DatabaseException;\r
+//     <T> T getPossibleValue(ReadGraph graph, Binding binding) throws DatabaseException;\r
+//     \r
+//     /*\r
+//      * Writes a value using the given binding\r
+//      */\r
+//     void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException;\r
+//     /*\r
+//      * Writes a value with default binding\r
+//      */\r
+//     void setValue(WriteGraph graph, Object value) throws DatabaseException;\r
+//\r
+//     /*\r
+//      * Writes a value to the given property using the given binding\r
+//      */\r
+//     void setPropertyValue(WriteGraph graph, String name, Object value, Binding binding) throws DatabaseException;\r
+//     /*\r
+//      * Writes a value to the given property using the default binding\r
+//      */\r
+//     void setPropertyValue(WriteGraph graph, String name, Object value) throws DatabaseException;\r
+//     \r
+//     // TODO methods?\r
+//     \r
+//     /*\r
+//      * Gets a named child of this variable. A child corresponds to a '/' in URI notation\r
+//      */\r
+//     Variable getChild(ReadGraph graph, String name) throws DatabaseException;\r
+//     Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException;\r
+//     /*\r
+//      * Gets a named property of this variable. A property corresponds to a '#' in URI notation\r
+//      */\r
+//     Variable getProperty(ReadGraph graph, String name) throws DatabaseException;    \r
+//     Variable getPossibleProperty(ReadGraph graph, String name) throws DatabaseException;    \r
+//     \r
+//     /*\r
+//      * Browses all children of this variable.\r
+//      */\r
+//     Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException;\r
+//     /*\r
+//      * Browses all properties of this variable.\r
+//      */\r
+//     Collection<Variable> browseProperties(ReadGraph graph) throws DatabaseException;\r
+//\r
+//     /*\r
+//      * Browses a single variable using the given suffix path. The suffix can contain various '/' and '#'. \r
+//      */\r
+//     Variable browse(ReadGraph graph, String suffix) throws DatabaseException;\r
+//     Variable browsePossible(ReadGraph graph, String suffix) throws DatabaseException;\r
+//\r
+//     /*\r
+//      * Browses a single variable using the given configuration resource. \r
+//      */\r
+//     Variable browse(ReadGraph graph, Resource config) throws DatabaseException;\r
+//     Variable browsePossible(ReadGraph graph, Resource config) throws DatabaseException;\r
+//     \r
+//     /*\r
+//      * Gets the requested interface associated to this variable if available.\r
+//      * Examples: \r
+//      * -Resource\r
+//      * -Accessor\r
+//      * -Binding\r
+//      * \r
+//      */\r
+//     @Deprecated\r
+//     <T> T getInterface(ReadGraph graph, Class<T> clazz) throws DatabaseException;\r
+//     \r
+//     <T> T adapt(ReadGraph graph, Class<T> clazz) throws DatabaseException;\r
+//     \r
+//     /*\r
+//      * Gets the unique URI reference for this variable.\r
+//      */\r
+//     String getURI(ReadGraph graph) throws DatabaseException;\r
+       \r
+       \r
+}\r