コード例 #1
0
        public void threeSix()
        {
            MasterNodeList<string> nodeList = new MasterNodeList<string>();
            Dictionary<Node, List<Route>> prefixD = new Dictionary<Node, List<Route>>();
            DataChunkRouteBlazerTest.threeSixChunks(nodeList, prefixD);
            XmlDocument threeSixDoc = new XMLGraphFormat<string>().ToXMLDocument(nodeList);
            XmlNode nodesElement = threeSixDoc.DocumentElement.ChildNodes[0];
            Assert.AreEqual(XMLGraphFormat<int>.NODESROOTELEM, nodesElement.LocalName);
            XmlNodeList nodeElements = nodesElement.ChildNodes;

            XmlNode firstStartNode = nodeElements[0];
            Assert.AreEqual(XMLGraphFormat<int>.NODEELEM, firstStartNode.LocalName);
            Assert.AreEqual("0", firstStartNode.Attributes[XMLGraphFormat<int>.SEQNUMATTR].Value);
            Assert.AreEqual(NodeKind.GateNode.ToString(), firstStartNode.Attributes[XMLGraphFormat<int>.NODEKINDATTR].Value);

            XmlNode firstValueNode = nodeElements[3];
            Assert.AreEqual("3", firstValueNode.Attributes[XMLGraphFormat<int>.SEQNUMATTR].Value);
            Assert.AreEqual(NodeKind.ValueNode.ToString(), firstValueNode.Attributes[XMLGraphFormat<int>.NODEKINDATTR].Value);
            Assert.AreEqual("A", firstValueNode.InnerText);

            XmlNode edgesElement = threeSixDoc.DocumentElement.ChildNodes[1];
            Assert.AreEqual(XMLGraphFormat<int>.EDGESROOTELEM, edgesElement.LocalName);
            XmlNodeList edgeElements = edgesElement.ChildNodes;

            XmlNode firstEdge = edgeElements[0];
            Assert.AreEqual(XMLGraphFormat<int>.EDGEELEM, firstEdge.LocalName);
            Assert.AreEqual("0", firstEdge.Attributes[XMLGraphFormat<int>.FROMATTR].Value);
            Assert.AreEqual("3", firstEdge.Attributes[XMLGraphFormat<int>.TOATTR].Value);
            Assert.AreEqual("-1,-1", firstEdge.Attributes[XMLGraphFormat<int>.REQATTR].Value);
        }
コード例 #2
0
 public void testEmptyNodeList()
 {
     MasterNodeList<int> nodeList = new MasterNodeList<int>();
     XmlDocument emptyDoc = new XMLGraphFormat<int>().ToXMLDocument(nodeList);
     Assert.AreEqual(XMLGraphFormat<int>.ROOTELEM, emptyDoc.DocumentElement.LocalName);
 }
コード例 #3
0
        public void threeSixFromXMLToList()
        {
            XMLGraphFormat<string> format = new XMLGraphFormat<string>();
            format.nodeValueParser = new StringNodeValueParser();
            XmlDocument sampleDoc = new XmlDocument();
            string myDocTempl =
            @"<{0}><{1}>
            <{2} {3}=""0"" {4}=""GateNode"" />
            <{2} {3}=""1"" {4}=""ValueNode"">Here</{2}>
            </{1}><{5}>
            <{6} {7}=""0"" {8}=""1"" {9}="""" />
            <{6} {7}=""1"" {8}=""0"" {9}="""" />
            </{5}></{0}>";
            string myDoc = String.Format(myDocTempl, XMLGraphFormat<int>.ROOTELEM,
                XMLGraphFormat<uint>.NODESROOTELEM, XMLGraphFormat<bool>.NODEELEM,
                XMLGraphFormat<long>.SEQNUMATTR, XMLGraphFormat<byte>.NODEKINDATTR,
                XMLGraphFormat<short>.EDGESROOTELEM, XMLGraphFormat<sbyte>.EDGEELEM,
                XMLGraphFormat<float>.FROMATTR, XMLGraphFormat<double>.TOATTR,
                XMLGraphFormat<char>.REQATTR);
            MasterNodeList<string> nodeList = format.ToNodeList(XmlReader.Create(new StringReader(myDoc)));
            Assert.AreEqual(2, nodeList.AllNodes.Count());
            Assert.IsInstanceOf<ValueNode<string>>(nodeList.AllNodes.ElementAt(1));
            Assert.AreEqual(1, nodeList.getValueNodesByValue("Here").Count());

            format.XMLFilename = "graph_test.xml";
            format.ToXMLFile(nodeList);
            MasterNodeList<string> loadedList = format.ToNodeListFromFile();
            Assert.AreEqual(loadedList.AllNodes.Count(), nodeList.AllNodes.Count());
            Assert.AreEqual(loadedList.AllEdgeSpecs.Count(), nodeList.AllEdgeSpecs.Count());
        }
コード例 #4
0
        public void reuseNodeValueByRef()
        {
            MasterNodeList<string> nodeList = new MasterNodeList<string>();
            Dictionary<Node, List<Route>> prefixD = new Dictionary<Node, List<Route>>();
            DataChunkRouteBlazerTest.threeThreeChunks(nodeList, prefixD);
            XmlDocument threeThreeDoc = new XMLGraphFormat<string>().ToXMLDocument(nodeList);
            XmlNode nodesElement = threeThreeDoc.DocumentElement.ChildNodes[0];
            XmlNodeList nodeElements = nodesElement.ChildNodes;

            int firstAIndex = nodeList.getValueNodesByValue("A").ElementAt(0).SequenceNumber;
            int secondAIndex = nodeList.getValueNodesByValue("A").ElementAt(1).SequenceNumber;
            XmlNode secondAXmlElem = nodeElements[secondAIndex];
            Assert.AreEqual(firstAIndex.ToString(), secondAXmlElem.Attributes[XMLGraphFormat<ushort>.VALUEREFATTR].Value);
            Assert.AreEqual("", secondAXmlElem.InnerText);

            MasterNodeList<string> destinationList = new MasterNodeList<string>();
            Dictionary<Node, List<Route>> destinationDict = new Dictionary<Node, List<Route>>();
            DataChunkRoute<string> firstRoute = nodeList.nthDataChunkRoute(0);
            var missingComponents = firstRoute.specsForMissingComponents(destinationList);
            Assert.AreEqual(4, missingComponents.Item1.Count);
            Assert.AreEqual(3, missingComponents.Item2.Count);
            destinationList.reloadNodesThenRoutesFromSpecs(missingComponents.Item1, missingComponents.Item2);

            DataChunkRoute<string> secondRoute = nodeList.nthDataChunkRoute(1);
            Assert.AreEqual(3,secondRoute.componentEdges.Count);
            Assert.AreEqual(1, secondRoute.componentEdges[0].edge.link.from.SequenceNumber);
            Assert.AreEqual(3, secondRoute.componentEdges[1].edge.link.from.SequenceNumber);
            Assert.AreEqual(6, secondRoute.componentEdges[2].edge.link.from.SequenceNumber);
            Assert.AreEqual(7, secondRoute.componentEdges[2].edge.link.to.SequenceNumber);
            foreach(EdgeRoute rt in secondRoute.componentEdges)
            {
                Assert.AreNotEqual(0, rt.edge.link.from.SequenceNumber);
                Assert.AreNotEqual(0, rt.edge.link.to.SequenceNumber);
            }
            var secondMissingComponents = secondRoute.specsForMissingComponents(destinationList);
            var secondMissingNodeSpecs = secondMissingComponents.Item1;
            Assert.AreEqual(3, secondMissingNodeSpecs.Count);
            var secondMissingEdgeSpecs = secondMissingComponents.Item2;
            XmlDocument secondMissingDoc = new XMLGraphFormat<string>().ToXMLDocument(destinationList, secondMissingNodeSpecs, secondMissingEdgeSpecs);
            Assert.AreEqual(2, secondMissingDoc.DocumentElement.ChildNodes.Count);
            nodesElement = secondMissingDoc.DocumentElement.ChildNodes[0];
            nodeElements = nodesElement.ChildNodes;
            Assert.AreEqual(3, nodeElements.Count);
            Assert.AreEqual(NodeKind.GateNode.ToString(), nodeElements[0].Attributes[XMLGraphFormat<bool>.NODEKINDATTR].Value);
            Assert.AreEqual(NodeKind.ValueNode.ToString(), nodeElements[1].Attributes[XMLGraphFormat<bool>.NODEKINDATTR].Value);
            XmlNode AXmlElem = nodeElements[1];
            Assert.AreEqual(6, Convert.ToInt32(AXmlElem.Attributes[XMLGraphFormat<bool>.SEQNUMATTR].Value));
            Assert.AreEqual("", AXmlElem.InnerText);
            Assert.AreEqual(firstAIndex.ToString(), AXmlElem.Attributes[XMLGraphFormat<long>.VALUEREFATTR].Value);

            DataChunkRouteBlazer<string> blaz = new DataChunkRouteBlazer<string>(new List<string> { "G", "G", "G" }, nodeList);
            blaz.computeFullRoute();
            DataChunkRoute<string> GGG = nodeList.nthDataChunkRoute(3);
            secondMissingComponents = GGG.specsForMissingComponents(destinationList);
            secondMissingNodeSpecs = secondMissingComponents.Item1;
            Assert.AreEqual(4, secondMissingNodeSpecs.Count);
            secondMissingDoc = new XMLGraphFormat<string>().ToXMLDocument(destinationList, secondMissingNodeSpecs, secondMissingEdgeSpecs);
            nodesElement = secondMissingDoc.DocumentElement.ChildNodes[0];
            nodeElements = nodesElement.ChildNodes;
            XmlNode G2Elem = nodeElements[2];
            Assert.AreEqual(NodeKind.ValueNode.ToString(), G2Elem.Attributes[XMLGraphFormat<bool>.NODEKINDATTR].Value);
            Assert.AreEqual("", G2Elem.InnerText);
            Assert.IsNotNull(G2Elem.Attributes[XMLGraphFormat<bool>.VALUEREFATTR]);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: ArtV/DataSequenceGraph
        static void Main(string[] args)
        {
            Args arguments = new Args();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            if (parser.ParseArguments(args, arguments))
            {
                if (arguments.HandCodedList != -1 && (arguments.InDatFile != null || arguments.InTxtFile != null
                    || arguments.InXMLFile != null))
                {
                    Console.Out.WriteLine("Hand-coded graph is in place of loading a primary graph.");
                }
                else if (arguments.HandCodedList == -1 && arguments.InXMLFile == null && arguments.InDatFile == null
                    && arguments.InSrcFile == null && arguments.InSrcLetterFile == null)
                {
                    Console.Out.WriteLine("Must specify a primary graph, and/or a sentence source file to split.");
                }
                else if (arguments.Quiet && arguments.OutXMLFile == null && arguments.OutDatFile == null &&
                    arguments.OutTxtFile == null && arguments.OutChunkFile == null)
                {
                    Console.Out.WriteLine("Quiet display and nowhere to send file output. Nothing to do.");
                }
                else if (arguments.InXMLFile != null && (arguments.InDatFile != null || arguments.InTxtFile != null))
                {
                    Console.Out.WriteLine("For primary graph, specify XML file, or both edge data file and value text file.");
                }
                else if ((arguments.InDatFile == null && arguments.InTxtFile != null) ||
                         (arguments.InDatFile != null && arguments.InTxtFile == null))
                {
                    Console.Out.WriteLine("Primary graph edge data file must be paired with a values text file.");
                }
                else if (arguments.OutXMLFile != null && (arguments.OutDatFile != null || arguments.OutTxtFile != null))
                {
                    Console.Out.WriteLine("For output file, specify XML filename, or both edge data filename and value text filename.");
                }
                else if ((arguments.OutDatFile == null && arguments.OutTxtFile != null) ||
                         (arguments.OutDatFile != null && arguments.OutDatFile == null))
                {
                    Console.Out.WriteLine("Output edge data file must be paired with a values text file.");
                }
                else if ((arguments.InSrcFile != null || arguments.InSrcLetterFile != null) &&
                    (arguments.InXMLFile2 != null || arguments.InDatFile2 != null || arguments.InTxtFile2 != null))
                {
                    Console.Out.WriteLine("Sentence source file cannot be processed simultaneously with a secondary graph.");
                }
                else if (arguments.InXMLFile2 != null && (arguments.InDatFile2 != null || arguments.InTxtFile2 != null))
                {
                    Console.Out.WriteLine("For secondary graph, specify XML filename, or both edge data filename and value text filename.");
                }
                else if ((arguments.InDatFile2 == null && arguments.InTxtFile2 != null) ||
                         (arguments.InDatFile2 != null && arguments.InTxtFile2 == null))
                {
                    Console.Out.WriteLine("Secondary graph data file must be paired with a values text file.");
                }
                else
                {
                    // automatically switch on verbose graph reporting if no other output
                    // passing delta directory parameter will produce its own output/effects
                    if (arguments.OutDatFile == null && arguments.OutTxtFile == null &&
                        arguments.OutXMLFile == null && arguments.OutChunkFile == null &&
                        arguments.DeltaDirectory == null)
                    {
                        arguments.Verbose = true;
                    }

                    // ---- stage 1
                    MasterNodeList<string> firstList;
                    MasterNodeList<string> secondList = null;
                    bool dupeList = false;
                    if ((arguments.InSrcFile != null || arguments.InSrcLetterFile != null)
                        && arguments.Missing)
                    {
                        dupeList = true;
                    }
                    if (arguments.InXMLFile != null)
                    {
                        XMLGraphFormat<string> inXml = new XMLGraphFormat<string>(arguments.InXMLFile);
                        inXml.nodeValueParser = new StringNodeValueParser();
                        firstList = inXml.ToNodeListFromFile();
                        if (dupeList)
                        {
                            secondList = inXml.ToNodeListFromFile();
                        }
                    }
                    else if (arguments.InDatFile != null && arguments.InTxtFile != null)
                    {
                        BinaryAndTXTFormat<string> inOth = new BinaryAndTXTFormat<string>(arguments.InDatFile, arguments.InTxtFile);
                        inOth.nodeValueParser = new StringNodeValueParser();
                        firstList = inOth.ToNodeListFromFiles();
                        if (dupeList)
                        {
                            secondList = inOth.ToNodeListFromFiles();
                        }
                    }
                    else if (arguments.HandCodedList == 0)
                    {
                        firstList = setupNodeList33();
                        if (dupeList)
                        {
                            secondList = setupNodeList33();
                        }
                    }
                    else if (arguments.HandCodedList == 1)
                    {
                        firstList = setupNodeList();
                        if (dupeList)
                        {
                            secondList = setupNodeList();
                        }
                    }
                    else
                    {
                        firstList = new MasterNodeList<string>();
                        if (dupeList)
                        {
                            secondList = new MasterNodeList<string>();
                        }
                    }

                    // ---- stage 2
                    IList<NodeAndReqSpec> nodeReqSpecs = null;
                    IList<NodeSpec> nodeSpecs = null;
                    IList<EdgeRouteSpec> edgeSpecs = null;
                    MasterNodeList<string> commonBaseList = null;
                    if (arguments.BaseXMLFile != null ||
                        (arguments.BaseDatFile != null && arguments.BaseTxtFile != null))
                    {
                        if (arguments.BaseXMLFile != null)
                        {
                            XMLGraphFormat<string> inXml3 = new XMLGraphFormat<string>(arguments.BaseXMLFile);
                            inXml3.nodeValueParser = new StringNodeValueParser();
                            commonBaseList = inXml3.ToNodeListFromFile();
                            secondList = inXml3.ToNodeListFromFile();
                        }
                        else if (arguments.BaseDatFile != null && arguments.BaseTxtFile != null)
                        {
                            BinaryAndTXTFormat<string> inOth3 = new BinaryAndTXTFormat<string>(arguments.BaseDatFile, arguments.BaseTxtFile);
                            inOth3.nodeValueParser = new StringNodeValueParser();
                            commonBaseList = inOth3.ToNodeListFromFiles();
                            secondList = inOth3.ToNodeListFromFiles();
                        }

                    }
                    if (arguments.InXMLFile2 != null)
                    {
                        XMLGraphFormat<string> inXml2 = new XMLGraphFormat<string>(arguments.InXMLFile2);
                        inXml2.nodeValueParser = new StringNodeValueParser();
                        MasterNodeList<string> tempList;
                        if (commonBaseList != null && !arguments.ReapplyLater)
                        {
                            tempList = inXml2.ToNodeListFromFile();
                            secondList.reloadNodesThenRoutesFromSpecs(tempList.AllNodeSpecs, tempList.AllEdgeSpecs);
                            firstList.addLaterChunksThanBaseToOtherList(commonBaseList, secondList);
                            firstList = secondList;
                        }
                        else if (arguments.Chunk == -1 && !arguments.Missing && arguments.LeastChunk == -1)
                        {
                            tempList = inXml2.ToNodeListFromFile();
                            firstList.reloadNodesThenRoutesFromSpecs(tempList.AllNodeSpecs, tempList.AllEdgeSpecs);
                        }
                        else
                        {
                            secondList = inXml2.ToNodeListFromFile();
                        }
                    }
                    else if (arguments.InDatFile2 != null && arguments.InTxtFile2 != null)
                    {
                        BinaryAndTXTFormat<string> inOth2 = new BinaryAndTXTFormat<string>(arguments.InDatFile2, arguments.InTxtFile2);
                        inOth2.nodeValueParser = new StringNodeValueParser();
                        if (commonBaseList != null && !arguments.ReapplyLater)
                        {
                            inOth2.ToNodeListFromFiles(secondList);
                            firstList.addLaterChunksThanBaseToOtherList(commonBaseList, secondList);
                            firstList = secondList;
                        }
                        else if (arguments.Chunk == -1 && !arguments.Missing && arguments.LeastChunk == -1 &&
                            !arguments.ReapplyLater)
                        {
                            inOth2.ToNodeListFromFiles(firstList);   // means to merge 2nd into 1st
                        }
                        else
                        {
                            secondList = inOth2.ToNodeListFromFiles();
                        }
                    }

                    if (arguments.InSrcFile != null || arguments.InSrcLetterFile != null)
                    {
                        string inFileNym = (arguments.InSrcFile != null ? arguments.InSrcFile : arguments.InSrcLetterFile);
                        loadFile(inFileNym, firstList, arguments.Quiet,
                            arguments.InSrcLetterFile != null);
                    }
                    if (secondList != null && commonBaseList == null)
                    {
                        if (arguments.Chunk != -1)
                        {
                            DataChunkRoute<string> nthRoute = firstList.nthDataChunkRoute(arguments.Chunk - 1);
                            if (arguments.OutDatFile != null || arguments.OutXMLFile == null)
                            {
                                nodeReqSpecs = nthRoute.comboSpecsForMissingComponents(secondList);
                            }
                            if (arguments.OutXMLFile != null)
                            {
                                var missing = nthRoute.specsForMissingComponents(secondList);
                                nodeSpecs = missing.Item1;
                                edgeSpecs = missing.Item2;
                            }
                        }
                        else if (arguments.Missing)
                        {
                            if (arguments.OutDatFile != null || arguments.OutXMLFile == null)
                            {
                                nodeReqSpecs = firstList.getSpecsAbsentIn(secondList);
                            }
                            if (arguments.OutXMLFile != null)
                            {
                                var missing = firstList.getSegregatedSpecsAbsentIn(secondList);
                                nodeSpecs = missing.Item1;
                                edgeSpecs = missing.Item2;
                            }
                        }
                    }
                    else if (arguments.Chunk != -1)
                    {
                        secondList = new MasterNodeList<string>();
                        DataChunkRoute<string> nthRoute = firstList.nthDataChunkRoute(arguments.Chunk - 1);
                        if (arguments.OutXMLFile != null)
                        {
                            var missing = nthRoute.specsForMissingComponents(secondList);
                            nodeSpecs = missing.Item1;
                            edgeSpecs = missing.Item2;
                        }
                        else if (arguments.OutDatFile != null && arguments.OutTxtFile != null)
                        {
                            nodeReqSpecs = nthRoute.comboSpecsForMissingComponents(secondList);
                        }
                        secondList = new MasterNodeList<string>();
                    }
                    else if (arguments.LeastChunk != -1)
                    {
                        if (arguments.OutDatFile != null || arguments.OutXMLFile == null)
                        {
                            nodeReqSpecs = firstList.getRoutePartsForChunksStarting(arguments.LeastChunk - 1);
                        }
                        if (arguments.OutXMLFile != null)
                        {
                            var missing = firstList.getSegregatedRoutePartsForChunksStarting(arguments.LeastChunk - 1);
                            nodeSpecs = missing.Item1;
                            edgeSpecs = missing.Item2;
                        }
                        secondList = new MasterNodeList<string>();
                    }
                    else if (arguments.ReapplyLater && commonBaseList != null)
                    {
                        secondList.addLaterChunksThanBaseToOtherList(commonBaseList, firstList);
                    }
                    else if (arguments.DeltaDirectory != null)
                    {
                        NodeValueParser<string> nodeValueParser = new StringNodeValueParser();
                        NodeValueExporter<string> nodeValueExporter = new ToStringNodeValueExporter<string>();
                        DeltaDirectory deltaDir = new DeltaDirectory(arguments.DeltaDirectory);
                        DeltaRequestResultKind requestResultKind;
                        DeltaResponseResultKind responseResultKind;
                        MasterNodeList<string> newLocalNodeList;
                        if (arguments.InitDeltaDirectory)
                        {
                            deltaDir.initDirectory(firstList, nodeValueExporter);
                            Console.Out.WriteLine("Initialized delta directory ");
                        }
                        else if (arguments.MakeDeltaRequest)
                        {
                            DeltaRequest newReq = new DeltaRequest(deltaDir);
                            string newFilename = deltaDir.CurrentBase + ".base";
                            using (TextWriter textWriter = new StreamWriter(new FileStream(newFilename, FileMode.Create)))
                            {
                                newReq.writeDefaultRequest(textWriter);
                            }
                            Console.Out.WriteLine("Wrote new delta request to " + newFilename);
                        }
                        else if (arguments.DeltaRequest != null)
                        {
                            using (TextReader textReader = new StreamReader(new FileStream(arguments.DeltaRequest, FileMode.Open, FileAccess.Read)))
                            {
                                MemoryStream outReq = new MemoryStream();
                                requestResultKind = DeltaRequestHandler.handleDeltaRequest(deltaDir,
                                    deltaDir.getLastFullGraph(nodeValueParser, nodeValueExporter), firstList,
                                    nodeValueExporter, textReader, outReq);
                                if (requestResultKind == DeltaRequestResultKind.Deltas)
                                {
                                    string newFilename = DateTime.Now.ToString("yyyy-MM-dd'T'HH-mm-ss'Z'") + ".tar.gz";
                                    using (FileStream fileStream = new FileStream(newFilename, FileMode.Create))
                                    {
                                        new MemoryStream(outReq.ToArray()).CopyTo(fileStream);
                                    }
                                    Console.Out.WriteLine("Wrote archive response to " + newFilename);
                                }
                                else
                                {
                                    StreamReader resRdr = new StreamReader(new MemoryStream(outReq.ToArray()));
                                    string[] deltArr = DeltaList.readList(resRdr);
                                    if (File.Exists(deltArr[0] + ".base"))
                                    {
                                        Console.Out.WriteLine("New delta request already exists: " + deltArr[0] + ".base");
                                    }
                                    else
                                    {
                                        using (FileStream fileStream = new FileStream(deltArr[0] + ".base", FileMode.Create))
                                        {
                                            new MemoryStream(outReq.ToArray()).CopyTo(fileStream);
                                        }
                                        Console.Out.WriteLine("Wrote .base counter-request response " + deltArr[0] + ".base");
                                    }
                                }
                            }
                        }
                        else if (arguments.BaseResponseToRequest != null)
                        {
                            using (TextReader textReader = new StreamReader(new FileStream(arguments.BaseResponseToRequest, FileMode.Open, FileAccess.Read)))
                            {
                                MemoryStream outReq = new MemoryStream();
                                responseResultKind = DeltaResponseHandler.handleDeltaBaseResponse(deltaDir, textReader, new StreamWriter(outReq));
                                if (responseResultKind == DeltaResponseResultKind.UpdateRequest)
                                {
                                    StreamReader resRdr = new StreamReader(new MemoryStream(outReq.ToArray()));
                                    string[] deltArr = DeltaList.readList(resRdr);
                                    if (File.Exists(deltArr[0] + ".base"))
                                    {
                                        Console.Out.WriteLine("New delta request already exists: " + deltArr[0] + ".base");
                                    }
                                    else
                                    {
                                        using (FileStream fileStream = new FileStream(deltArr[0] + ".base", FileMode.Create))
                                        {
                                            new MemoryStream(outReq.ToArray()).CopyTo(fileStream);
                                        }
                                        Console.Out.WriteLine("Wrote new delta request to " + deltArr[0] + ".base");
                                    }
                                }
                                else
                                {
                                    Console.Out.WriteLine("Matching .base response indicates no new deltas. No action taken.");
                                }
                            }
                        }
                        else if (arguments.ArchiveResponseToRequest != null)
                        {
                            using (FileStream fs = new FileStream(arguments.ArchiveResponseToRequest, FileMode.Open, FileAccess.Read))
                            {
                                responseResultKind = DeltaResponseHandler.handleDeltaArchiveResponse(firstList, deltaDir,
                                     nodeValueParser, nodeValueExporter, fs, out newLocalNodeList);
                                if (responseResultKind == DeltaResponseResultKind.Acceptance ||
                                    responseResultKind == DeltaResponseResultKind.Rewrite)
                                {
                                    Console.Out.WriteLine("Delta archive has been loaded.");
                                    firstList = newLocalNodeList;
                                }
                                else
                                {
                                    Console.Out.WriteLine("Delta archive has been ignored.");
                                }
                            }
                        }
                    }

                    // ---- stage 3
                    if (arguments.Verbose && arguments.Chunk == -1 && arguments.LeastChunk == -1)
                    {
                        defaultTestOutput(firstList);
                        printEnumeratedChunks(firstList);
                    }
                    if (arguments.Chunk != -1 && !arguments.Quiet)
                    {
                        printChunk(firstList.nthDataChunkRoute(arguments.Chunk - 1));
                    }
                    if (arguments.LeastChunk != -1 && !arguments.Quiet)
                    {
                        foreach (var chRoute in firstList.chunkRoutesStartingAt(arguments.LeastChunk - 1))
                        {
                            printChunk(chRoute);
                        }
                    }
                    if ((arguments.Chunk != -1 || arguments.LeastChunk != -1) &&
                        arguments.Verbose && nodeReqSpecs != null)
                    {
                        nodeAndReqOutput(nodeReqSpecs);
                    }
                    if (arguments.Missing && !arguments.Quiet && nodeReqSpecs != null)
                    {
                        nodeAndReqOutput(nodeReqSpecs);
                    }

                    // ---- stage 4
                    if (arguments.OutXMLFile != null)
                    {
                        XMLGraphFormat<string> outX = new XMLGraphFormat<string>(arguments.OutXMLFile);
                        if (nodeSpecs != null)
                        {
                            outX.ToXMLFile(secondList, nodeSpecs, edgeSpecs);
                        }
                        else
                        {
                            outX.ToXMLFile(firstList);
                        }
                    }

                    if (arguments.OutDatFile != null && arguments.OutTxtFile != null)
                    {
                        BinaryAndTXTFormat<string> outOth = new BinaryAndTXTFormat<string>(arguments.OutDatFile, arguments.OutTxtFile);
                        if (nodeReqSpecs != null)
                        {
                            outOth.ToBinaryAndTXTFiles(firstList, secondList, nodeReqSpecs);
                        }
                        else
                        {
                            outOth.ToBinaryAndTXTFiles(firstList);
                        }
                    }

                    if (arguments.OutChunkFile != null)
                    {
                        IEnumerable<IEnumerable<string>> dumpChunks = Enumerable.Empty<IEnumerable<string>>();
                        if (arguments.Chunk != -1)
                        {
                            DataChunkRoute<string> dumpedChunk = firstList.nthDataChunkRoute(arguments.Chunk - 1);
                            dumpChunks = new List<IEnumerable<string>>() { dumpedChunk.dataChunk };
                        }
                        else if (arguments.LeastChunk != -1)
                        {
                            dumpChunks = firstList.chunkRoutesStartingAt(arguments.LeastChunk - 1)
                                .Select(chRoute => chRoute.dataChunk);
                        }
                        else if (arguments.Missing)
                        {
                            dumpChunks = firstList.dataChunksLaterThan(secondList);
                        }
                        using (TextWriter textWriter = new StreamWriter(new FileStream(arguments.OutChunkFile, FileMode.Create)))
                        {
                            foreach (var dumpChunk in dumpChunks)
                            {
                                foreach (var dumpVal in dumpChunk)
                                {
                                    textWriter.Write(dumpVal + " ");
                                }
                                textWriter.WriteLine(".");
                            }
                        }
                    }

                }
            }
        }