java.lang.Object
com.betterdiff.core.protocol.command.Chunk
All Implemented Interfaces:
Command

public class Chunk
extends java.lang.Object
implements Command
Chunk of text bounded by a start and an end index in a given text. Every chunk has 4 identification keys: - Ordinal Number - Ordinal number of the given text. @see bdiff.core.pairing.Preparation phase for more information about texts and their ordering and identification - Start Index - Ordinal number of a character in given text where the chunk starts. This character is included in the chunk. - End Index - Ordinal number of a character in given text where the chunk ends. This character is included in the chunk. - Y Axis - When the same given text has multiple chunks then every chunk has a different Y Axis. Axis should be numbered starting with number 1 without gaps. Every white space including new lines (\n, \n\r, \r) are counted as 1 character. *********************************************************************** Note. Start Index and End Index are different from routines like substring. Example: This is a dog. If we split the sentence into words we get 4 chunks: chunk 1-4 (This) chunk 6-7 (is) chunk 9-9 (a) chunk 11-13 (dog) But start and end indexes don't match parameters for substring! ***********************************************************************
Author:
troomar
  • Constructor Summary

    Constructors
    Constructor Description
    Chunk​(int ordinalNumber, int startIndex, int endIndex, int yAxis)  
    Chunk​(Chunk chunk)
    Constructor for clone purposes.
  • Method Summary

    Modifier and Type Method Description
    void accept​(ProtocolVisitor protocolVisitor)
    Accepting a visitor to go through the protocol without having to care what command it actually is.
    Chunk clone()
    Method for copying commands from generic lists and data structures.
    boolean equals​(java.lang.Object obj)  
    int getEndIndex()  
    java.lang.String getIdentification()  
    int getOrdinalNumber()  
    int getStartIndex()  
    int getYAxis()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Chunk

      public Chunk​(int ordinalNumber, int startIndex, int endIndex, int yAxis)
    • Chunk

      public Chunk​(Chunk chunk)
      Constructor for clone purposes.
      Parameters:
      chunk - Original chunk to be cloned from
  • Method Details

    • getOrdinalNumber

      public int getOrdinalNumber()
    • getStartIndex

      public int getStartIndex()
    • getEndIndex

      public int getEndIndex()
    • getYAxis

      public int getYAxis()
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getIdentification

      public java.lang.String getIdentification()
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • clone

      public Chunk clone()
      Description copied from interface: Command
      Method for copying commands from generic lists and data structures. Cloning shouldn't use standard Java cloning routines, it should always call its supposed cloning constructor or factory method.
      Specified by:
      clone in interface Command
    • accept

      public void accept​(ProtocolVisitor protocolVisitor)
      Description copied from interface: Command
      Accepting a visitor to go through the protocol without having to care what command it actually is.
      Specified by:
      accept in interface Command