Author: mes
Date: 2011-04-29 10:47:18 -0700 (Fri, 29 Apr 2011)
New Revision: 24853

Modified:
   core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java
   
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
Log:
added rowExists method to CyTable

Modified: core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java        
2011-04-28 23:50:39 UTC (rev 24852)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java        
2011-04-29 17:47:18 UTC (rev 24853)
@@ -144,6 +144,13 @@
        CyRow getRow(Object primaryKey);
 
        /**
+        * Returns true if a row exists for the specified primary key and false 
otherwise. 
+        * @param primaryKey The primary key index of the row.
+        * @return True if a row exists for the specified primary key and false 
otherwise. 
+        */
+       boolean rowExists(Object primaryKey);
+
+       /**
         * Return a list of all the rows stored in this data table.
         * @return a list of all the rows stored in this data table.
         */

Modified: 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
===================================================================
--- 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
    2011-04-28 23:50:39 UTC (rev 24852)
+++ 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
    2011-04-29 17:47:18 UTC (rev 24853)
@@ -823,4 +823,25 @@
         List<Boolean> res = attrs.getList("simpson",Boolean.class);
         assertEquals(ls,res);
     }
+
+    @Test
+    public void testRowExistsFalse() {
+               assertFalse(table.rowExists(new Object()));
+    }
+
+    @Test
+    public void testRowExistsTrue() {
+               Long l = Long.valueOf(4444L);
+               table.getRow(l);
+               assertTrue(table.rowExists(l));
+    }
+
+    @Test
+    public void testRowExistsFalseAndDoesntCreateRow() {
+               Long l = Long.valueOf(54444L);
+               assertFalse(table.rowExists(l));
+               // Make sure it *still* doesn't exist, i.e. that calling 
rowExists
+               // doesn't create a row like getRow does.
+               assertFalse(table.rowExists(l));
+    }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to