]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterMapSmall.java
Fail safe import fixes made by Antti
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / ClusterMapSmall.java
index c609560a7592ac1dea4631bb038af92c2f5c69d3..334e1199134835166670c3608fba7e892d5f8b74 100644 (file)
@@ -1,69 +1,69 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.db.procore.cluster;\r
-\r
-import gnu.trove.map.hash.TIntShortHashMap;\r
-\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.impl.TableSizeListener;\r
-import org.simantics.db.service.ClusterUID;\r
-import org.simantics.db.service.ResourceUID;\r
-\r
-public class ClusterMapSmall {\r
-    private TableSizeListener sizeListener;\r
-    private ForeignTableSmall foreignTable;\r
-    //private TObjectIntHashMap<ResourceUID> hashMap;\r
-    private TIntShortHashMap hashMap;\r
-    public ClusterMapSmall(TableSizeListener sizeListener, ForeignTableSmall foreignTable) {\r
-        this.sizeListener = sizeListener;\r
-        this.foreignTable = foreignTable;\r
-        hashMap = null;\r
-    }\r
-    public ResourceUID getForeignResourceUID(short reference) {\r
-        assert(reference >>> 15 > 0);\r
-        short foreignIndex = (short)(reference ^ 1<<15);\r
-        return foreignTable.getResourceUID(foreignIndex);\r
-    }\r
-    public void compact() {\r
-        if(hashMap == null) return;\r
-        hashMap.compact();\r
-        sizeListener.resized();\r
-    }\r
-    public int getUsedSpace() {\r
-        if(hashMap == null) return 0;\r
-        int size = hashMap.size();\r
-        int cap = hashMap.capacity();\r
-        // int[], Object[], actual objects\r
-        return cap*(4+ObjectSizes.POINTER_SIZE)+size*ObjectSizes.ResourceUIDSize;\r
-    }\r
-   \r
-    public short getForeignReferenceOrCreateByResourceKey(int resourceKey, ClusterUID uid) throws DatabaseException {\r
-        if (null == hashMap)\r
-            hashMap = foreignTable.getResourceHashMap();\r
-        short foreignIndex = hashMap.get(resourceKey);\r
-        if (0 == foreignIndex) {\r
-            if (hashMap.size() >= ClusterTraitsSmall.FOREIGN_INDEX_MAX)\r
-                throw new OutOfSpaceException("Out of space for foreign resources=" + hashMap.size());\r
-            foreignIndex = foreignTable.createForeign(resourceKey, uid);\r
-            hashMap.put(resourceKey, foreignIndex);\r
-        }\r
-        return foreignIndex;\r
-    }\r
-\r
-    public short getForeignReferenceOrZero(int resourceKey) throws DatabaseException {\r
-        if (null == hashMap)\r
-            hashMap = foreignTable.getResourceHashMap();\r
-        return hashMap.get(resourceKey);\r
-    }\r
-    \r
-    \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.procore.cluster;
+
+import gnu.trove.map.hash.TIntShortHashMap;
+
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.impl.TableSizeListener;
+import org.simantics.db.service.ClusterUID;
+import org.simantics.db.service.ResourceUID;
+
+public class ClusterMapSmall {
+    private TableSizeListener sizeListener;
+    private ForeignTableSmall foreignTable;
+    //private TObjectIntHashMap<ResourceUID> hashMap;
+    private TIntShortHashMap hashMap;
+    public ClusterMapSmall(TableSizeListener sizeListener, ForeignTableSmall foreignTable) {
+        this.sizeListener = sizeListener;
+        this.foreignTable = foreignTable;
+        hashMap = null;
+    }
+    public ResourceUID getForeignResourceUID(short reference) {
+        assert(reference >>> 15 > 0);
+        short foreignIndex = (short)(reference ^ 1<<15);
+        return foreignTable.getResourceUID(foreignIndex);
+    }
+    public void compact() {
+        if(hashMap == null) return;
+        hashMap.compact();
+        sizeListener.resized();
+    }
+    public int getUsedSpace() {
+        if(hashMap == null) return 0;
+        int size = hashMap.size();
+        int cap = hashMap.capacity();
+        // int[], Object[], actual objects
+        return cap*(4+ObjectSizes.POINTER_SIZE)+size*ObjectSizes.ResourceUIDSize;
+    }
+   
+    public short getForeignReferenceOrCreateByResourceKey(int resourceKey, ClusterUID uid) throws DatabaseException {
+        if (null == hashMap)
+            hashMap = foreignTable.getResourceHashMap();
+        short foreignIndex = hashMap.get(resourceKey);
+        if (0 == foreignIndex) {
+            if (hashMap.size() >= ClusterTraitsSmall.FOREIGN_INDEX_MAX)
+                throw new OutOfSpaceException("Out of space for foreign resources=" + hashMap.size());
+            foreignIndex = foreignTable.createForeign(resourceKey, uid);
+            hashMap.put(resourceKey, foreignIndex);
+        }
+        return foreignIndex;
+    }
+
+    public short getForeignReferenceOrZero(int resourceKey) throws DatabaseException {
+        if (null == hashMap)
+            hashMap = foreignTable.getResourceHashMap();
+        return hashMap.get(resourceKey);
+    }
+    
+    
+}