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