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