Class Indentation
java.lang.Object
nl.talsmasoftware.umldoclet.rendering.indent.Indentation
- All Implemented Interfaces:
Serializable
,CharSequence
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 Summary
Modifier and TypeFieldDescriptionstatic Indentation
The default indentation is four spaces, initially at level 0.static Indentation
A reusable constant for no indentation at all (even after calls toincrease()
). -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt(int index)
decrease()
boolean
Whether the other object represents the exact same indentation object.int
hashCode()
increase()
int
length()
static Indentation
spaces(int width, int level)
Returns an indentation ofwidth
spaces, initially indented atwidth * level
spaces.subSequence(int start, int end)
static Indentation
tabs(int level)
Returns an indentation oflevel
tabs, increasing or decreasing by one tab at a time.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
DEFAULT
The default indentation is four spaces, initially at level 0. -
NONE
A reusable constant for no indentation at all (even after calls toincrease()
).
-
-
Method Details
-
tabs
Returns an indentation oflevel
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
Returns an indentation ofwidth
spaces, initially indented atwidth * level
spaces. This indentation increases or decreases bywidth
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 ofwidth
spaces.
-
increase
- Returns:
- An indentation instance with the level increased by one.
-
decrease
- Returns:
- An indentation instance with the level decreased by one (if there was indentation left to decrease).
-
hashCode
public int hashCode() -
equals
Whether the other object represents the exact same indentation object. -
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index)- Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
- Returns:
- The indentation as a string.
-