X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph%2Ftests%2Forg%2Fsimantics%2Fgraph%2Ftests%2Fconversion%2FTG0_TG1.java;h=a0aae4ffd1cece58b5cea9af752ced4376b75b73;hb=63f6a68f31de96e8e8f31cd99b79c365029aa557;hp=72c72136e9d4160c5fd9ed1eda06bdec6b51f4db;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph/tests/org/simantics/graph/tests/conversion/TG0_TG1.java b/bundles/org.simantics.graph/tests/org/simantics/graph/tests/conversion/TG0_TG1.java index 72c72136e..a0aae4ffd 100644 --- a/bundles/org.simantics.graph/tests/org/simantics/graph/tests/conversion/TG0_TG1.java +++ b/bundles/org.simantics.graph/tests/org/simantics/graph/tests/conversion/TG0_TG1.java @@ -1,55 +1,55 @@ -package org.simantics.graph.tests.conversion; - -import java.io.File; - -import org.simantics.databoard.Files; -import org.simantics.databoard.binding.mutable.Variant; -import org.simantics.databoard.container.DataContainer; -import org.simantics.databoard.container.DataContainers; -import org.simantics.graph.representation.TransferableGraph1; - -public class TG0_TG1 { - - public static void main(String[] args) throws Exception { - if(args.length != 3) { - System.err.println(TG0_TG1.class.getName() + " formatName input.tg output.tg"); - return; - } - String formatName = args[0]; - File input = new File(args[1]); - File output = new File(args[2]); - - if(!input.exists()) { - System.err.println(input + " does not exist."); - return; - } - if(output.exists()) - output.delete(); - - try { - DataContainer header = DataContainers.readHeader(input); - if (formatName.equals(header.format)) { - System.err.println(input + " already has a data container with the required format, version is " + header.version); - return; - } else { - System.err.println(input + " already has a data container with another format '" + header.format + ", version is " + header.version); - return; - } - } catch (Throwable e) { - // There is no DataContainer in the input file yet. - // Continue conversion. - } - - TransferableGraph0 tg0 = (TransferableGraph0)Files.readFile(input, TransferableGraph0.BINDING); - TransferableGraph1 tg1 = new TransferableGraph1( - tg0.resourceCount, - tg0.identities, - tg0.statements, - tg0.values, - tg0.extensions - ); - DataContainers.writeFile(output, - new DataContainer(formatName, 1, new Variant(TransferableGraph1.BINDING, tg1))); - } - -} +package org.simantics.graph.tests.conversion; + +import java.io.File; + +import org.simantics.databoard.Files; +import org.simantics.databoard.binding.mutable.Variant; +import org.simantics.databoard.container.DataContainer; +import org.simantics.databoard.container.DataContainers; +import org.simantics.graph.representation.TransferableGraph1; + +public class TG0_TG1 { + + public static void main(String[] args) throws Exception { + if(args.length != 3) { + System.err.println(TG0_TG1.class.getName() + " formatName input.tg output.tg"); + return; + } + String formatName = args[0]; + File input = new File(args[1]); + File output = new File(args[2]); + + if(!input.exists()) { + System.err.println(input + " does not exist."); + return; + } + if(output.exists()) + output.delete(); + + try { + DataContainer header = DataContainers.readHeader(input); + if (formatName.equals(header.format)) { + System.err.println(input + " already has a data container with the required format, version is " + header.version); + return; + } else { + System.err.println(input + " already has a data container with another format '" + header.format + ", version is " + header.version); + return; + } + } catch (Throwable e) { + // There is no DataContainer in the input file yet. + // Continue conversion. + } + + TransferableGraph0 tg0 = (TransferableGraph0)Files.readFile(input, TransferableGraph0.BINDING); + TransferableGraph1 tg1 = new TransferableGraph1( + tg0.resourceCount, + tg0.identities, + tg0.statements, + tg0.values, + tg0.extensions + ); + DataContainers.writeFile(output, + new DataContainer(formatName, 1, new Variant(TransferableGraph1.BINDING, tg1))); + } + +}