--- /dev/null
+/*******************************************************************************\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.utils.datastructures.map;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+\r
+import org.simantics.utils.datastructures.map.AssociativeMap;\r
+import org.simantics.utils.datastructures.map.Associativity;\r
+import org.simantics.utils.datastructures.map.Tuple;\r
+\r
+public class TestCase {\r
+\r
+ public static final String RootLibrary = "http:/";\r
+ public static final String ConsistsOf = "http://www.simantics.org/Layer0-1.0/ConsistsOf";\r
+ public static final String Float = "http://www.simantics.org/Layer0-1.0/Float";\r
+ public static final String InstanceOf = "http://www.simantics.org/Layer0-1.0/InstanceOf";\r
+ public static final String Relation = "http://www.simantics.org/Layer0-1.0/Relation";\r
+ public static final String Library = "http://www.simantics.org/Layer0-1.0/Library";\r
+ public static final String HasValue = "http://www.simantics.org/Layer0-1.0/HasValue";\r
+\r
+ public static void main(String[] args) { \r
+ Object c = "Cluster";\r
+ Object node = "MyNode";\r
+ \r
+ Tuple stms[] = new Tuple[] {\r
+ new Tuple(c, RootLibrary, InstanceOf, Library),\r
+ new Tuple(c, RootLibrary, ConsistsOf, node), \r
+ new Tuple(c, node, InstanceOf, Float),\r
+ new Tuple(c, node, HasValue, 0.5f)\r
+ };\r
+ \r
+ // Test Graph\r
+ AssociativeMap g = new AssociativeMap( Associativity.fullAssociativity(4) ); \r
+ g.add( stms );\r
+\r
+ Tuple queryAllInstanceOfs = new Tuple(null, null, InstanceOf, null);\r
+ Collection<Tuple> list = g.get(queryAllInstanceOfs, new ArrayList<Tuple>());; \r
+ print(list);\r
+ \r
+ AssociativeMap bijectionMap = \r
+ new AssociativeMap( new Associativity(false, true), new Associativity(true, false), new Associativity(false, false) );\r
+ \r
+ bijectionMap.add( new Tuple("x", "y") );\r
+ Collection<Tuple> res2 = bijectionMap.get(new Tuple("x", "y"), null);;\r
+ print( res2 );\r
+ \r
+ }\r
+ \r
+ public static void print(Collection<?> c)\r
+ {\r
+ int i=0;\r
+ Iterator<?> iter = c.iterator();\r
+ while (iter.hasNext()) {\r
+ i++;\r
+ System.out.println(i+") "+iter.next());\r
+ }\r
+ }\r
+\r
+ \r
+}\r
+\r