Package com.topologi.diffx.event

Examples of com.topologi.diffx.event.DiffXEvent


    this.start = new EventSequence();
    int count = 0;
    Iterator<DiffXEvent> i = this.sequence1.eventIterator();
    Iterator<DiffXEvent> j = this.sequence2.eventIterator();
    while (i.hasNext() && j.hasNext()) {
      DiffXEvent e = i.next();
      if (j.next().equals(e)) {
        count++;
        i.remove();
        j.remove();
        this.start.addEvent(e);
View Full Code Here


    this.end = new EventSequence();
    int count = 0;
    int pos1 = this.sequence1.size() - 1;
    int pos2 = this.sequence2.size() - 1;
    while (pos1 >= 0 && pos2 >= 0) {
      DiffXEvent e1 = this.sequence1.getEvent(pos1);
      if (e1.equals(this.sequence2.getEvent(pos2))) {
        count++;
        this.sequence1.removeEvent(pos1--);
        this.sequence2.removeEvent(pos2--);
        this.end.addEvent(0, e1);
      } else {
View Full Code Here

      throw new IllegalStateException("The start buffer already contains a subsequence.");
    int count = 0;
    Iterator<DiffXEvent> i = this.sequence1.eventIterator();
    Iterator<DiffXEvent> j = this.sequence2.eventIterator();
    while (i.hasNext() && j.hasNext()) {
      DiffXEvent e = i.next();
      if (j.next().equals(e)) {
        count++;
        i.remove();
        j.remove();
        formatter.format(e);
View Full Code Here

   */
  public static boolean isWellFormed(EventSequence sequence) {
    // TODO: if the sequence is null ??
    if (sequence == null) return false;
    Stack<DiffXEvent> open = new Stack<DiffXEvent>();
    DiffXEvent e = null;
    for (int i = 0; i < sequence.size(); i++) {
      e = sequence.getEvent(i);
      if (e instanceof OpenElementEvent) {
        open.push(e);
      } else if (e instanceof CloseElementEvent) {
View Full Code Here

   */
  public static int getMaxElementContent(EventSequence sequence) {
    int max = 0;
    int tmp = 0;
    for (int i = 0; i < sequence.size(); i++) {
      DiffXEvent e = sequence.getEvent(i);
      if (e instanceof OpenElementEvent) {
        tmp = 0;
      } else if (e instanceof CloseElementEvent) {
        if (tmp > max) {
          max = tmp;
View Full Code Here

    Iterator<DiffXEvent> i = this.sequence1.eventIterator();
    Iterator<DiffXEvent> j = this.sequence2.eventIterator();
    int counter = 0;
    // calculate the max possible index for slicing.
    while (i.hasNext() && j.hasNext()) {
      DiffXEvent e = i.next();
      if (j.next().equals(e)) {
        counter++;
        // increase the depth
        if (e instanceof OpenElementEvent) {
          depth++;
          // decrease the depth
        } else if (e instanceof CloseElementEvent) {
          depth--;
        }
        // if depth = 1, it is a direct child of the document element,
        // so we can cut off the whole branch
        if (depth == 1 || depth == 0) {
          toBeRemoved = counter;
        }
      } else {
        break;
      }
    }
    // slice the beginning of the file
    for (int k = 0; k < toBeRemoved; k++) {
      DiffXEvent e = this.sequence1.removeEvent(0);
      this.sequence2.removeEvent(0);
      this.start.addEvent(e);
    }
    return toBeRemoved;
  }
View Full Code Here

    int toBeRemoved = 0; // number of events to be removed from the end
    int counter = 0;     // number of events evaluated
    int pos1 = this.sequence1.size() - 1// current position of the first sequence
    int pos2 = this.sequence2.size() - 1// current position of the second sequence
    while (pos1 >= 0 && pos2 >= 0) {
      DiffXEvent e1 = this.sequence1.getEvent(pos1);
      if (e1.equals(this.sequence2.getEvent(pos2))) {
        counter++;
        // increase the depth for close, decrease for open
        if (e1 instanceof CloseElementEvent) {
          depth++;
        } else if (e1 instanceof OpenElementEvent) {
          depth--;
        }
        // if depth = 1, it is a direct child of the document element,
        // so we can cut off the whole branch
        if (depth == 1 || depth == 0) {
          toBeRemoved = counter;
        }
        pos1--; pos2--;
      } else {
        break;
      }
    }
    // slice the end of the first sequence
    int downTo = this.sequence1.size() - toBeRemoved;
    for (int k = this.sequence1.size() - 1; k >= downTo; k--) {
      DiffXEvent e = this.sequence1.removeEvent(k);
      this.end.addEvent(0, e);
    }
    // slice the end of the second sequence
    downTo = this.sequence2.size() - toBeRemoved;
    for (int k = this.sequence2.size() - 1; k >= downTo; k--) {
View Full Code Here

  public boolean equals(EventSequence seq) {
    if (seq == null) return false;
    if (seq.getClass() != this.getClass()) return false;
    List<DiffXEvent> sequence2 = seq.sequence;
    if (this.sequence.size() != this.sequence.size()) return false;
    DiffXEvent x1 = null;
    DiffXEvent x2 = null;
    for (int i = 0; i < this.sequence.size(); i++) {
      x1 = this.sequence.get(i);
      x2 = sequence2.get(i);
      if (!x1.equals(x2)) return false;
    }
View Full Code Here

   * Export the sequence.
   *
   * @param w The print writer receiving the SAX events.
   */
  public void export(PrintWriter w) {
    DiffXEvent x = null;
    for (int i = 0; i < this.sequence.size(); i++) {
      x = (DiffXEvent)this.sequence.get(i);
      w.println(x.toString());
    }
    w.flush();
  }
View Full Code Here

    if (this.length1 == 0 || this.length2 == 0) return;
    // calculate the LCS length to fill the matrix
    length();
    int i = 0;
    int j = 0;
    DiffXEvent e1 = this.sequence1.getEvent(i);
    DiffXEvent e2 = this.sequence2.getEvent(j);
    // start walking the matrix
    while (i < super.length1 && j < super.length2) {
      e1 = this.sequence1.getEvent(i);
      e2 = this.sequence2.getEvent(j);
      // we can only insert or delete, priority to insert
View Full Code Here

TOP

Related Classes of com.topologi.diffx.event.DiffXEvent

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.