Conflict.java :  » Source-Control » gruntspud » gruntspud » editor » Java Open Source

Java Open Source » Source Control » gruntspud 
gruntspud » gruntspud » editor » Conflict.java
/*
 * Gruntspud
 * 
 * Copyright (C) 2002 Brett Smith.
 * 
 * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
 * 
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
package gruntspud.editor;

/**
 * <o>Encapsulate a conflict and its positions in the file. These positions include the CVS conflict markers, so these
 * must be taken into account when rendering the conflict
 * </p>
 * 
 * <p>
 * Each conflict consists of two parts, known in Gruntspud as the <strong>local</strong> and the <strong>remote</code>. The
 * local contains the piece of the file that is held locally, the remote is the piece that has been merged in from the remote
 * repository. Inbetween is the separator
 * </p>
 * 
 * <p>
 * For each block the first character position in the complete file is stored, together with how many characters there are up to
 * the separator or the end of the conflict.
 * </p>
 */
public class Conflict {
  private int start1;
  private int len1;
  private int start2;
  private int len2;

  /**
   * Construct a new Conflict
   * 
   * @param start1 start position of the local conflict block
   * @param len1 length of the local conflict block
   * @param start2 start position of the remove conflict block
   * @param len2 length of the remote conflict block
   */
  public Conflict(int start1, int len1, int start2, int len2) {
    this.start1 = start1;
    this.len1 = len1;
    this.start2 = start2;
    this.len2 = len2;
  }

  /**
   * Get the starting character position in the file for the local block
   * 
   * @return local block character position
   */
  public int getStart1() {
    return start1;
  }

  /**
   * Get the starting character position in the file for the remote block
   * 
   * @return remote block character position
   */
  public int getStart2() {
    return start2;
  }

  /**
   * Get the length of the local block
   * 
   * @return length of local block
   */
  public int getLength1() {
    return len1;
  }

  /**
   * Get the length of the remote block
   * 
   * @return length of remote block
   */
  public int getLength2() {
    return len2;
  }

  /**
   * Set the starting character position in the file for the local block
   * 
   * @param start1 local block character position
   */
  public void setStart1(int start1) {
    this.start1 = start1;
  }

  /**
   * Set the starting character position in the file for the remote block
   * 
   * @param start2 remote block character position
   */
  public void setStart2(int start2) {
    this.start2 = start2;
  }

  /**
   * Set the length of the local block
   * 
   * @param len1 length of local block
   */
  public void setLength1(int len1) {
    this.len1 = len1;
  }

  /**
   * Set the length of the remote block
   * 
   * @param len2 length of remote block
   */
  public void setLength2(int len2) {
    this.len2 = len2;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#toString()
   */
  public String toString() {
    return " s1=" + start1 + " s2=" + start2 + " l1=" + len1 + " l2=" + len2;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.