public class Indent
extends java.lang.Object
Represents a single indent for formatting functionality which requires indentation. The main functionality that this class provides over and above a simple String is validation. Then there is the obvious benefit of strict typing.
Validation is very important because without it the integrity of parsed output can be compromised. In particular, if non-white-space characters are supplied, this is likely to violate whatever syntax the output was meant to conform to. Having said this, by requiring that indents must be empty or a single horizontal tab or one or more simple spaces, this class is probably somewhat stricter than it needs to be.
I was very tempted to make this an enumeration. If one assumes that there is no need for indents bigger that eight spaces, then ten different values would cover it. But then I thought that at some point I might want to relax the validation rules.
Modifier and Type | Field and Description |
---|---|
java.lang.String |
_indent |
java.lang.String |
_label |
static Indent |
DEFAULT |
static Indent |
FOUR_SPACES |
static Indent |
TAB |
static Indent |
THREE_SPACES |
static Indent |
TWO_SPACES |
Constructor and Description |
---|
Indent(java.lang.String indent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
toString() |
public final java.lang.String _indent
public final java.lang.String _label
public static final Indent TAB
public static final Indent TWO_SPACES
public static final Indent THREE_SPACES
public static final Indent FOUR_SPACES
public static final Indent DEFAULT