X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.datatypes%2Fsrc%2Forg%2Fsimantics%2Fdatatypes%2Futils%2FBTree.java;h=6138b05156f0f6a0ddf52a638dae52ac9cc414d8;hb=6c70e409e03187c96b057aa5705d49800c6b8b07;hp=1c1445a8602d521d33a302d30fdc632cb9c3502b;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.datatypes/src/org/simantics/datatypes/utils/BTree.java b/bundles/org.simantics.datatypes/src/org/simantics/datatypes/utils/BTree.java index 1c1445a86..6138b0515 100644 --- a/bundles/org.simantics.datatypes/src/org/simantics/datatypes/utils/BTree.java +++ b/bundles/org.simantics.datatypes/src/org/simantics/datatypes/utils/BTree.java @@ -1,69 +1,69 @@ -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 entriesOfBTree(ReadGraph graph) throws DatabaseException { - return utils.entries(graph); - } - - public List searchRangeBTree(ReadGraph graph, Variant min, Variant max) throws DatabaseException { - return utils.searchRange(graph, min, max); - } -} +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 entriesOfBTree(ReadGraph graph) throws DatabaseException { + return utils.entries(graph); + } + + public List searchRangeBTree(ReadGraph graph, Variant min, Variant max) throws DatabaseException { + return utils.searchRange(graph, min, max); + } +}