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.graph.representation;
14 import java.util.TreeMap;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.databoard.binding.Binding;
18 import org.simantics.databoard.binding.mutable.Variant;
19 import org.simantics.databoard.serialization.Serializer;
23 * Transferable graph datatype.
24 * See <a href="http://dev.simantics.org/index.php/Transferable_Graph">specification</a>.
25 * @author Hannu Niemistö
27 public class TransferableGraph1 {
28 public static Binding BINDING = Bindings.getBindingUnchecked(TransferableGraph1.class);
29 public static Serializer SERIALIZER = Bindings.getSerializerUnchecked(BINDING);
31 public int resourceCount;
32 public TreeMap<String, Variant> extensions;
33 public Identity[] identities;
34 public int[] statements;
35 public Value[] values;
37 public TransferableGraph1() {
40 public TransferableGraph1(int resourceCount, Identity[] identities,
41 int[] statements, Value[] values) {
42 this(resourceCount, identities, statements, values,
43 new TreeMap<String, Variant>());
46 public TransferableGraph1(int resourceCount, Identity[] identities,
47 int[] statements, Value[] values, TreeMap<String, Variant> extensions) {
48 this.resourceCount = resourceCount;
49 this.identities = identities;
50 this.statements = statements;
52 this.extensions = extensions;
56 System.out.println("Identities");
57 for(Identity id : identities) {
58 System.out.print(" " + id.resource + " = ");
59 if(id.definition instanceof Root) {
60 Root def = (Root)id.definition;
61 System.out.println("ROOT(" + def.name + ")");
63 else if(id.definition instanceof External) {
64 External def = (External)id.definition;
65 System.out.println("EXTERNAL(" + def.parent + ", " + def.name + ")");
67 else if(id.definition instanceof Internal) {
68 Internal def = (Internal)id.definition;
69 System.out.println("INTERNAL(" + def.parent + ", " + def.name + ")");
72 System.out.println("Statements:");
73 for(int i=0;i<statements.length;i+=4)
74 System.out.println(" " +
76 statements[i+1] + " " +
77 statements[i+2] + " " +