Author: ruschein
Date: 2010-06-28 15:04:11 -0700 (Mon, 28 Jun 2010)
New Revision: 20699

Modified:
   cytoscape/trunk/src/cytoscape/data/attr/util/MultiHashMapModel.java
Log:
Possibly fixed the bug that Allan reported with loading of list attributes and 
attribute equations.

Modified: cytoscape/trunk/src/cytoscape/data/attr/util/MultiHashMapModel.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/attr/util/MultiHashMapModel.java 
2010-06-28 21:39:57 UTC (rev 20698)
+++ cytoscape/trunk/src/cytoscape/data/attr/util/MultiHashMapModel.java 
2010-06-28 22:04:11 UTC (rev 20699)
@@ -35,7 +35,12 @@
 import cytoscape.data.attr.MultiHashMapDefinitionListener;
 import cytoscape.data.attr.MultiHashMapListener;
 
+import org.cytoscape.equations.BooleanList;
+import org.cytoscape.equations.DoubleList;
 import org.cytoscape.equations.Equation;
+import org.cytoscape.equations.FunctionUtil;
+import org.cytoscape.equations.LongList;
+import org.cytoscape.equations.StringList;
 
 import java.util.HashMap;
 
@@ -445,19 +450,23 @@
 
                switch (def.valueType) { // I'm wondering what the most 
efficient way of doing this is.
                        case MultiHashMapDefinition.TYPE_BOOLEAN:
-                               if ((actualType == Boolean.class) || 
(isEquation && (actualType == Long.class || actualType == Double.class)))
+                               if (actualType == Boolean.class
+                                   || (isEquation && (actualType == Long.class 
|| actualType == Double.class || actualType == BooleanList.class)))
                                        break;
                                throw new ClassCastException("found " + 
actualType + " for \"" + attributeName + "\", expected Boolean!");
                        case MultiHashMapDefinition.TYPE_FLOATING_POINT:
-                               if ((actualType == Double.class) || (isEquation 
&& (actualType == Long.class || actualType == Boolean.class)))
+                               if (actualType == Double.class
+                                   || (isEquation && (actualType == Long.class 
|| actualType == Boolean.class || actualType == DoubleList.class)))
                                        break;
                                throw new ClassCastException("found " + 
actualType + " for \"" + attributeName + "\", expected Double!");
                        case MultiHashMapDefinition.TYPE_INTEGER:
-                               if ((actualType == Integer.class) || 
(isEquation && (actualType == Double.class || actualType == Boolean.class || 
actualType == Long.class)))
+                               if (actualType == Integer.class
+                                   || (isEquation && (actualType == 
Double.class || actualType == Boolean.class
+                                                      || actualType == 
Long.class || actualType == LongList.class)))
                                        break;
                                throw new ClassCastException("found " + 
actualType + " for \"" + attributeName + "\", expected Integer!");
                        case MultiHashMapDefinition.TYPE_STRING:
-                               if ((actualType == String.class) || isEquation)
+                               if (actualType == String.class || isEquation)
                                        break;
                                throw new ClassCastException("found " + 
actualType + " for \"" + attributeName + "\", expected String!");
                }
@@ -469,11 +478,31 @@
                                                                   + "' has no 
keyspace"
                                                                   + " defined, 
yet keyIntoValue is not empty");
                        }
+                       if (FunctionUtil.isSomeKindOfList(actualType))
+                               throw new ClassCastException("found " + 
actualType + " for \"" + attributeName + "\", expected String!");
                } else { // Keyspace is not empty.
                        final int keyIntoValueLength = ((keyIntoValue == null) 
? 0 : keyIntoValue.length);
-
-                       if (def.keyTypes.length != keyIntoValueLength) {
+                       if (def.keyTypes.length != keyIntoValueLength)
                                throw new 
IllegalArgumentException("keyIntoValue has incorrect dimensionality");
+                       if (isEquation) {
+                               switch (def.valueType) {
+                               case MultiHashMapDefinition.TYPE_BOOLEAN:
+                                       if (actualType != BooleanList.class)
+                                               throw new 
ClassCastException("found " + actualType + " for \"" + attributeName + "\", 
expected String!");
+                                       break;
+                               case MultiHashMapDefinition.TYPE_FLOATING_POINT:
+                                       if (actualType != DoubleList.class)
+                                               throw new 
ClassCastException("found " + actualType + " for \"" + attributeName + "\", 
expected String!");
+                                       break;
+                               case MultiHashMapDefinition.TYPE_INTEGER:
+                                       if (actualType != LongList.class)
+                                               throw new 
ClassCastException("found " + actualType + " for \"" + attributeName + "\", 
expected String!");
+                                       break;
+                               case MultiHashMapDefinition.TYPE_STRING:
+                                       if (actualType != StringList.class)
+                                               throw new 
ClassCastException("found " + actualType + " for \"" + attributeName + "\", 
expected String!");
+                                       break;
+                               }                       
                        }
                }
 

-- 
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