java.lang.Object
nl.talsmasoftware.umldoclet.rendering.indent.Indentation
All Implemented Interfaces:
Serializable, CharSequence

public final class Indentation extends Object implements CharSequence, Serializable
Type to capture the indentation as an immutable type containing a pre-filled buffer to quickly be written.
Author:
Sjoerd Talsma
See Also:
Serialized Form
  • Field Details

    • DEFAULT

      public static final Indentation DEFAULT
      The default indentation is four spaces, initially at level 0.
    • NONE

      public static final Indentation NONE
      A reusable constant for no indentation at all (even after calls to increase()).
  • Method Details

    • tabs

      public static Indentation tabs(int level)
      Returns an indentation of level tabs, increasing or decreasing by one tab at a time.
      Parameters:
      level - The number of tabs for this indentation.
      Returns:
      The indentation of level tabs.
    • spaces

      public static Indentation spaces(int width, int level)
      Returns an indentation of width spaces, initially indented at width * level spaces. This indentation increases or decreases by width spaces at a time.
      Parameters:
      width - The number of spaces for a single indentation level (often 2 or 4).
      level - The current indentation level (multiply this with the width for the initial number of spaces).
      Returns:
      The indentation level as level multiples of width spaces.
    • increase

      public Indentation increase()
      Returns:
      An indentation instance with the level increased by one.
    • decrease

      public Indentation decrease()
      Returns:
      An indentation instance with the level decreased by one (if there was indentation left to decrease).
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      hashCode of this indentation object.
    • equals

      public boolean equals(Object other)
      Whether the other object represents the exact same indentation object.
      Overrides:
      equals in class Object
      Parameters:
      other - The other indentation object to compare with.
      Returns:
      true if the other object is the same indentation object.
    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
      Returns:
      The indentation as a string.