Class IndentationContext


  • public class IndentationContext
    extends java.lang.Object
    Maintains the current indentation state during lexical preservation operations. This class encapsulates a mutable list of indentation elements (spaces/tabs) that represents the current indentation level. It provides methods to increase/decrease indentation and query the current state. Instances of this class are typically created at the start of a difference application and maintained throughout the process.
    • Constructor Summary

      Constructors 
      Constructor Description
      IndentationContext()
      Creates a new IndentationContext with empty indentation.
      IndentationContext​(java.util.List<TextElement> initialIndentation)
      Creates a new IndentationContext with the specified initial indentation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears all indentation, resetting to zero indentation.
      void decrease()
      Decreases indentation by one level.
      boolean equals​(java.lang.Object o)  
      java.util.List<TextElement> getCurrent()
      Returns a copy of the current indentation elements.
      int hashCode()  
      void increase()
      Increases indentation by one level.
      void set​(java.util.List<TextElement> newIndentation)
      Replaces the current indentation with the specified elements.
      int size()
      Returns the number of indentation characters currently stored.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • IndentationContext

        public IndentationContext()
        Creates a new IndentationContext with empty indentation.
      • IndentationContext

        public IndentationContext​(java.util.List<TextElement> initialIndentation)
        Creates a new IndentationContext with the specified initial indentation. The provided list is copied to prevent external modifications.
        Parameters:
        initialIndentation - the initial indentation elements (will be copied)
    • Method Detail

      • increase

        public void increase()
        Increases indentation by one level. Adds STANDARD_INDENTATION_SIZE space characters to the current indentation.
      • decrease

        public void decrease()
        Decreases indentation by one level. Removes up to STANDARD_INDENTATION_SIZE characters from the end of the current indentation. Does nothing if the current indentation has fewer elements than STANDARD_INDENTATION_SIZE.
      • getCurrent

        public java.util.List<TextElement> getCurrent()
        Returns a copy of the current indentation elements. The returned list is unmodifiable to prevent accidental modifications.
        Returns:
        unmodifiable view of current indentation elements
      • size

        public int size()
        Returns the number of indentation characters currently stored.
        Returns:
        count of indentation elements
      • clear

        public void clear()
        Clears all indentation, resetting to zero indentation.
      • set

        public void set​(java.util.List<TextElement> newIndentation)
        Replaces the current indentation with the specified elements. The provided list is copied to prevent external modifications.
        Parameters:
        newIndentation - the new indentation elements (will be copied)
      • toString

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object