1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils.datastructures.map;
\r
14 import java.util.ArrayList;
\r
15 import java.util.Collection;
\r
16 import java.util.Iterator;
\r
18 import org.simantics.utils.datastructures.map.AssociativeMap;
\r
19 import org.simantics.utils.datastructures.map.Associativity;
\r
20 import org.simantics.utils.datastructures.map.Tuple;
\r
22 public class TestCase {
\r
24 public static final String RootLibrary = "http:/";
\r
25 public static final String ConsistsOf = "http://www.simantics.org/Layer0-1.0/ConsistsOf";
\r
26 public static final String Float = "http://www.simantics.org/Layer0-1.0/Float";
\r
27 public static final String InstanceOf = "http://www.simantics.org/Layer0-1.0/InstanceOf";
\r
28 public static final String Relation = "http://www.simantics.org/Layer0-1.0/Relation";
\r
29 public static final String Library = "http://www.simantics.org/Layer0-1.0/Library";
\r
30 public static final String HasValue = "http://www.simantics.org/Layer0-1.0/HasValue";
\r
32 public static void main(String[] args) {
\r
33 Object c = "Cluster";
\r
34 Object node = "MyNode";
\r
36 Tuple stms[] = new Tuple[] {
\r
37 new Tuple(c, RootLibrary, InstanceOf, Library),
\r
38 new Tuple(c, RootLibrary, ConsistsOf, node),
\r
39 new Tuple(c, node, InstanceOf, Float),
\r
40 new Tuple(c, node, HasValue, 0.5f)
\r
44 AssociativeMap g = new AssociativeMap( Associativity.fullAssociativity(4) );
\r
47 Tuple queryAllInstanceOfs = new Tuple(null, null, InstanceOf, null);
\r
48 Collection<Tuple> list = g.get(queryAllInstanceOfs, new ArrayList<Tuple>());;
\r
51 AssociativeMap bijectionMap =
\r
52 new AssociativeMap( new Associativity(false, true), new Associativity(true, false), new Associativity(false, false) );
\r
54 bijectionMap.add( new Tuple("x", "y") );
\r
55 Collection<Tuple> res2 = bijectionMap.get(new Tuple("x", "y"), null);;
\r
60 public static void print(Collection<?> c)
\r
63 Iterator<?> iter = c.iterator();
\r
64 while (iter.hasNext()) {
\r
66 System.out.println(i+") "+iter.next());
\r