-package org.simantics.datatypes.utils;\r
-\r
-import java.util.List;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.binding.mutable.Variant;\r
-import org.simantics.datatypes.DatatypeResource;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.scl.runtime.tuple.Tuple2;\r
-\r
-public class BTree {\r
- \r
- final private BTreeUtils utils;\r
- \r
- public BTree(WriteGraph graph, int t, Resource ownerRelation) throws DatabaseException {\r
- this(graph, t, ownerRelation, false);\r
- }\r
- \r
- public BTree(WriteGraph graph, int t, Resource ownerRelation, boolean cached) throws DatabaseException {\r
- utils = BTreeUtils.create(graph, ownerRelation, t, cached);\r
- }\r
- \r
- public BTree(WriteGraph graph, int t, Resource type, Resource nodeType, Resource ownerRelation, boolean cached) throws DatabaseException {\r
- utils = BTreeUtils.create(graph, type, nodeType, ownerRelation, t, cached);\r
- }\r
-\r
- public BTree(ReadGraph graph, Resource tree) throws DatabaseException {\r
- this(graph, tree, false);\r
- }\r
- \r
- public BTree(ReadGraph graph, Resource tree, boolean cached) throws DatabaseException {\r
- DatatypeResource DATA = DatatypeResource.getInstance(graph);\r
- int t = graph.getRelatedValue(tree, DATA.BTree_t, Bindings.INTEGER);\r
- Resource ownerRelation = graph.getPossibleObject(tree, DATA.BTree_HasOwnerRelation);\r
- Resource nodeType = graph.getPossibleObject(tree, DATA.BTree_HasNodeType);\r
- utils = new BTreeUtils(graph, tree, t, nodeType, ownerRelation, cached);\r
- }\r
- \r
- public void flushCachedBTree(WriteGraph graph) throws DatabaseException {\r
- utils.flushCache(graph);\r
- }\r
- \r
- public Resource rootOfBTree() {\r
- return utils.getTree();\r
- }\r
- \r
- public void insertBTree(WriteGraph graph, Variant key, Resource value) throws DatabaseException {\r
- utils.insert(graph, key, value);\r
- }\r
- \r
- public Resource searchBTree(ReadGraph graph, Variant key) throws DatabaseException {\r
- return utils.search(graph, key);\r
- }\r
-\r
- public void removeBTree(WriteGraph graph, Variant key) throws DatabaseException {\r
- utils.remove(graph, key);\r
- }\r
- \r
- public List<Tuple2> entriesOfBTree(ReadGraph graph) throws DatabaseException {\r
- return utils.entries(graph);\r
- }\r
- \r
- public List<Tuple2> searchRangeBTree(ReadGraph graph, Variant min, Variant max) throws DatabaseException {\r
- return utils.searchRange(graph, min, max);\r
- }\r
-}\r
+package org.simantics.datatypes.utils;
+
+import java.util.List;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.datatypes.DatatypeResource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.scl.runtime.tuple.Tuple2;
+
+public class BTree {
+
+ final private BTreeUtils utils;
+
+ public BTree(WriteGraph graph, int t, Resource ownerRelation) throws DatabaseException {
+ this(graph, t, ownerRelation, false);
+ }
+
+ public BTree(WriteGraph graph, int t, Resource ownerRelation, boolean cached) throws DatabaseException {
+ utils = BTreeUtils.create(graph, ownerRelation, t, cached);
+ }
+
+ public BTree(WriteGraph graph, int t, Resource type, Resource nodeType, Resource ownerRelation, boolean cached) throws DatabaseException {
+ utils = BTreeUtils.create(graph, type, nodeType, ownerRelation, t, cached);
+ }
+
+ public BTree(ReadGraph graph, Resource tree) throws DatabaseException {
+ this(graph, tree, false);
+ }
+
+ public BTree(ReadGraph graph, Resource tree, boolean cached) throws DatabaseException {
+ DatatypeResource DATA = DatatypeResource.getInstance(graph);
+ int t = graph.getRelatedValue(tree, DATA.BTree_t, Bindings.INTEGER);
+ Resource ownerRelation = graph.getPossibleObject(tree, DATA.BTree_HasOwnerRelation);
+ Resource nodeType = graph.getPossibleObject(tree, DATA.BTree_HasNodeType);
+ utils = new BTreeUtils(graph, tree, t, nodeType, ownerRelation, cached);
+ }
+
+ public void flushCachedBTree(WriteGraph graph) throws DatabaseException {
+ utils.flushCache(graph);
+ }
+
+ public Resource rootOfBTree() {
+ return utils.getTree();
+ }
+
+ public void insertBTree(WriteGraph graph, Variant key, Resource value) throws DatabaseException {
+ utils.insert(graph, key, value);
+ }
+
+ public Resource searchBTree(ReadGraph graph, Variant key) throws DatabaseException {
+ return utils.search(graph, key);
+ }
+
+ public void removeBTree(WriteGraph graph, Variant key) throws DatabaseException {
+ utils.remove(graph, key);
+ }
+
+ public List<Tuple2> entriesOfBTree(ReadGraph graph) throws DatabaseException {
+ return utils.entries(graph);
+ }
+
+ public List<Tuple2> searchRangeBTree(ReadGraph graph, Variant min, Variant max) throws DatabaseException {
+ return utils.searchRange(graph, min, max);
+ }
+}