]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "(refs #7428) Added predicatesOf function to Simantics/DB"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 14 Aug 2017 12:41:22 +0000 (15:41 +0300)
committerGerrit Code Review <gerrit2@www.simantics.org>
Mon, 14 Aug 2017 12:41:22 +0000 (15:41 +0300)
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/IntSet.java
bundles/org.simantics.scl.db/scl/Simantics/DB.scl

index a84f8fc5553aa04c31537ecedad7ec4e182a7666..7c32b8e593e19ea7757355d3c1768c0757abe7c1 100644 (file)
@@ -37,6 +37,8 @@ final public class IntSet implements ResourceSet {
     protected static final int DEFAULT_CAPACITY = 3;
 
     public static final int NO_DATA = -1;
+    
+    private static final Object[] EMPTY_ARRAY = new Object[0];
 
     public IntSet() {
         support = null;
@@ -241,7 +243,16 @@ final public class IntSet implements ResourceSet {
 
     @Override
     public Object[] toArray() {
-        throw new UnsupportedOperationException();
+        if(data != null) {
+            Object[] result = new Object[sizeOrData];
+            for(int i=0;i<sizeOrData;++i)
+                result[i] = new ResourceImpl(support, data[i]);
+            return result;
+        }
+        else if(sizeOrData == NO_DATA)
+            return EMPTY_ARRAY;
+        else
+            return new Object[] { new ResourceImpl(support, sizeOrData) };
     }
 
     @Override
index 32019768b2f08e7c6bb930a014fa8d656413ba0b..30608067d7a6353545f53a5a4d00c5a93962826c 100644 (file)
@@ -140,6 +140,9 @@ importJava "org.simantics.db.ReadGraph" where
     isInheritedFrom :: Resource -> Resource -> <ReadGraph> Boolean
     
     getRootLibrary :: () -> <ReadGraph> Resource
+    
+    @JavaName getPredicates
+    predicatesOf :: Resource -> <ReadGraph> [Resource]
 
 importJava "org.simantics.db.layer0.util.ExtendedUris" where
     "Converts an absolute URI to a resource"
@@ -477,4 +480,4 @@ possibleChildWithPath parent path =
               Just c -> possibleChild c name
               Nothing -> Nothing 
           ) 
-          (Just parent) path
+          (Just parent) path
\ No newline at end of file