Class Delta

    • Constructor Detail

      • Delta

        protected Delta()
        Creates an uninitialized delta.
      • Delta

        protected Delta​(Chunk orig,
                        Chunk rev)
        Creates a delta object with the given chunks from the original and revised texts.
        Parameters:
        orig -
        rev -
    • Method Detail

      • newDelta

        public static Delta newDelta​(Chunk orig,
                                     Chunk rev)
        Returns a Delta that corresponds to the given chunks in the original and revised text respectively.
        Parameters:
        orig - the chunk in the original text.
        rev - the chunk in the revised text.
        Returns:
        Delta
      • init

        protected void init​(Chunk orig,
                            Chunk rev)
        Initializes the delta with the given chunks from the original and revised texts.
        Parameters:
        orig -
        rev -
      • applyTo

        public abstract void applyTo​(List<Object> target)
        Applies this delta as a patch to the given text.
        Parameters:
        target - the text to patch.
      • toString

        public void toString​(StringBuilder s)
        Converts this delta into its Unix diff style string representation.
        Overrides:
        toString in class ToString
        Parameters:
        s - a StringBuffer to which the string representation will be appended.
      • toRCSString

        public abstract void toRCSString​(StringBuilder s,
                                         String EOL)
        Converts this delta into its RCS style string representation.
        Parameters:
        s - a StringBuffer to which the string representation will be appended.
        EOL - the string to use as line separator.
      • toRCSString

        public String toRCSString​(String EOL)
        Converts this delta into its RCS style string representation.
        Parameters:
        EOL - the string to use as line separator.
        Returns:
        String
      • getOriginal

        public Chunk getOriginal()
        Accessor method to return the chunk representing the original sequence of items
        Returns:
        the original sequence
      • getRevised

        public Chunk getRevised()
        Accessor method to return the chunk representing the updated sequence of items.
        Returns:
        the updated sequence
      • accept

        public abstract void accept​(RevisionVisitor visitor)
        Accepts a visitor.

        See the Visitor pattern in "Design Patterns" by the GOF4.

        Parameters:
        visitor - The visitor.