Package com.topologi.diffx.sequence

Examples of com.topologi.diffx.sequence.EventSequence


            //  id!)
          }
          leftIdx = rdi.leftStart();
        }

        EventSequence seq1 = new EventSequence();
        // Evil hack - doesn't work
        // seq1.mapPrefix("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");

        for (int k = rdi.leftStart() ; k< rdi.leftEnd() ; k++) {

          if (rdi.kind()==rdi.CHANGE) {
            // This we need to diff
            //leftReport.append( "#" );
            seq1.addSequence(leftESC.getItem(k));

            // Don't forget our existing prefix mappings!
            PrefixMapping existingPM = leftESC.getItem(k).getPrefixMapping();
            addToPrefixMapping(seq1.getPrefixMapping(), existingPM);
          } else {
            // Does this happen?
            // This just goes straight into the output,
              formatter.declarePrefixMapping(leftESC.getItem(k).getPrefixMapping());
            //out.append("\n<!-- Adding same II -->\n");
            addComment("Adding same II", formatter);
            formatEventSequence(leftESC.getItem(k), formatter);
            //out.append("\n<!-- .. Adding same done -->");
            addComment(".. Adding same done", formatter);
          }
        }


        EventSequence seq2 = new EventSequence();
        // Evil hack - doesn't work
        //seq2.mapPrefix("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
        for (int k = rdi.rightStart() ; k< rdi.rightEnd() ; k++) {
          if (rdi.kind()==rdi.CHANGE) {
            // This is the RHS of the diff
            //rightReport.append( "#" );
            seq2.addSequence(rightESC.getItem(k));

            // Don't forget our existing prefix mappings!
            PrefixMapping existingPM = rightESC.getItem(k).getPrefixMapping();
            addToPrefixMapping(seq2.getPrefixMapping(), existingPM);

          }
        }

        leftIdx = rdi.leftEnd();

        // ok, now perform this diff
        //log("performing diff");
        //out.append("\n<!-- Differencing -->\n");
        addComment("Differencing", formatter);


        if (seq1.size() + seq2.size() < 5000) {
          mainDiff(seq1, seq2, formatter, diffxConfig);
        } else {
          for (int i1=0; i1 < seq1.size(); i1++) {
            formatter.delete(seq1.getEvent(i1));
          }
          for (int i2=0; i2 < seq2.size(); i2++) {
            formatter.insert(seq2.getEvent(i2));
          }
        }

        //out.append("\n<!-- .. Differencing done -->");
        addComment(".. Differencing done", formatter);
View Full Code Here


    DiffXConfig config = toConfig(whitespace, granularity);

    // Get Sequences
    DOMRecorder loader = new DOMRecorder();
    loader.setConfig(config);
    EventSequence seq1 = loader.process(xml1);
    EventSequence seq2 = loader.process(xml2);
    if (seq1.size() == 0 && seq1.size() == 0) return null;

    // Start comparing
    StringWriter out = new StringWriter();
    diff(seq1, seq2, out, config);
View Full Code Here

   */
  public EventSequence process(File file) throws LoadingException, IOException {
    BufferedReader reader = new BufferedReader(new FileReader(file));
    String line = reader.readLine();
    int count = 0;
    EventSequence seq = new EventSequence();
    while (line != null) {
      seq.addEvent(new LineEvent(line, ++count));
      line = reader.readLine();
    }
    reader.close();
    return seq;
  }
View Full Code Here

   */
  public EventSequence process(String text) throws LoadingException, IOException {
    BufferedReader reader = new BufferedReader(new StringReader(text));
    String line = reader.readLine();
    int count = 0;
    EventSequence seq = new EventSequence();
    while (line != null) {
      seq.addEvent(new LineEvent(line, ++count));
      line = reader.readLine();
    }
    return seq;
  }
View Full Code Here

   * @throws IOException    Should an I/O exception occur.
   */
  public static boolean equivalent(File xml1, File xml2)
      throws DiffXException, IOException {
    Recorder recorder = new SAXRecorder();
    EventSequence seq0 = recorder.process(xml1);
    EventSequence seq1 = recorder.process(xml2);
    return seq0.equals(seq1);
  }
View Full Code Here

   * @throws IOException    Should an I/O exception occur.
   */
  public static boolean equivalent(InputStream xml1, InputStream xml2)
      throws DiffXException, IOException {
    SAXRecorder recorder = new SAXRecorder();
    EventSequence seq0 = recorder.process(new InputSource(xml1));
    EventSequence seq1 = recorder.process(new InputSource(xml2));
    return seq0.equals(seq1);
  }
View Full Code Here

   * @throws IOException    Should an I/O exception occur.
   */
  public static boolean equivalent(Reader xml1, Reader xml2)
      throws DiffXException, IOException {
    SAXRecorder recorder = new SAXRecorder();
    EventSequence seq0 = recorder.process(new InputSource(xml1));
    EventSequence seq1 = recorder.process(new InputSource(xml2));
    return seq0.equals(seq1);
  }
View Full Code Here

    // records the events from the XML
    DOMRecorder loader = new DOMRecorder();
    if (config != null) {
      loader.setConfig(config);
    }
    EventSequence seq1 = loader.process(xml1);
    EventSequence seq2 = loader.process(xml2);
    // start slicing
    diff(seq1, seq2, out, config);
  }
View Full Code Here

    // records the events from the XML
    DOMRecorder loader = new DOMRecorder();
    if (config != null) {
      loader.setConfig(config);
    }
    EventSequence seq1 = loader.process(xml1);
    EventSequence seq2 = loader.process(xml2);
    // start slicing
    diff(seq1, seq2, out, config);
  }
View Full Code Here

    // records the events from the XML
    SAXRecorder recorder = new SAXRecorder();
    if (config != null) {
      recorder.setConfig(config);
    }
    EventSequence seq1 = recorder.process(new InputSource(xml1));
    EventSequence seq2 = recorder.process(new InputSource(xml2));
    // start slicing
    diff(seq1, seq2, out, config);
  }
View Full Code Here

TOP

Related Classes of com.topologi.diffx.sequence.EventSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.