Class Delta

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Delta()
      Creates an uninitialized delta.
      protected Delta​(Chunk orig, Chunk rev)
      Creates a delta object with the given chunks from the original and revised texts.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void accept​(RevisionVisitor visitor)
      Accepts a visitor.
      abstract void applyTo​(java.util.List<java.lang.Object> target)
      Applies this delta as a patch to the given text.
      Chunk getOriginal()
      Accessor method to return the chunk representing the original sequence of items
      Chunk getRevised()
      Accessor method to return the chunk representing the updated sequence of items.
      protected void init​(Chunk orig, Chunk rev)
      Initializes the delta with the given chunks from the original and revised texts.
      static Delta newDelta​(Chunk orig, Chunk rev)
      Returns a Delta that corresponds to the given chunks in the original and revised text respectively.
      void patch​(java.util.List<java.lang.Object> target)
      Applies this delta as a patch to the given text.
      java.lang.String toRCSString​(java.lang.String EOL)
      Converts this delta into its RCS style string representation.
      abstract void toRCSString​(java.lang.StringBuilder s, java.lang.String EOL)
      Converts this delta into its RCS style string representation.
      void toString​(java.lang.StringBuilder s)
      Converts this delta into its Unix diff style string representation.
      abstract void verify​(java.util.List<java.lang.Object> target)
      Verifies that this delta can be used to patch the given text.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • original

        protected Chunk original
      • revised

        protected Chunk revised
    • 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 -
      • verify

        public abstract void verify​(java.util.List<java.lang.Object> target)
                             throws PatchFailedException
        Verifies that this delta can be used to patch the given text.
        Parameters:
        target - the text to patch.
        Throws:
        PatchFailedException - if the patch cannot be applied.
      • patch

        public final void patch​(java.util.List<java.lang.Object> target)
                         throws PatchFailedException
        Applies this delta as a patch to the given text.
        Parameters:
        target - the text to patch.
        Throws:
        PatchFailedException - if the patch cannot be applied.
      • applyTo

        public abstract void applyTo​(java.util.List<java.lang.Object> target)
        Applies this delta as a patch to the given text.
        Parameters:
        target - the text to patch.
        Throws:
        PatchFailedException - if the patch cannot be applied.
      • toString

        public void toString​(java.lang.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​(java.lang.StringBuilder s,
                                         java.lang.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 java.lang.String toRCSString​(java.lang.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.