-
- All Known Implementing Classes:
JustificationImpl
public interface Justification
This is the interface for a specific justification.- See Also:
of(String)
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default String
justify(CharSequence value)
This method applies the justification to the givenvalue
and returns the result.void
justify(CharSequence value, Appendable target)
This method applies the justification to the givenvalue
andappends
the result to the giventarget
.static Justification
of(String format)
This method parses the givenformat
asJustification
.
-
-
-
Method Detail
-
justify
void justify(CharSequence value, Appendable target)
This method applies the justification to the givenvalue
andappends
the result to the giventarget
.- Parameters:
value
- is the string to justify.target
- is where toappend
the justified data.
-
justify
default String justify(CharSequence value)
This method applies the justification to the givenvalue
and returns the result.- Parameters:
value
- is the string to justify.- Returns:
- the justified string.
-
of
static Justification of(String format)
This method parses the givenformat
asJustification
. It therefore expects the following format:
«filler»«alignment»«width»[«mode»]
The segments have the following meaning:segment pattern meaning «filler»
.
character used to fill up with «alignment»
[+-~]
align to the right(+), left(-) or centered(~) «with»
[0-9]+
if the length of the string to justify
is less than this width, the string will be expanded using the filler according to the alignment.«mode»
[|]
if the mode is truncate(|) then the string will be truncated if its length is greater than «with» so the result will always have the length of «with». Please note that truncate can remove valuable information or cause wrong results (e.g. "10000" with a justification of " +3|" will result in "100"). value justification result 42
0+4
0042
42
.-4
42..
42
_~11
____42_____
Hello World
_+5
Hello World
Hello World
_+5|
Hello
- Parameters:
format
- is the format as specified above.- Returns:
- the parsed
Justification
-
-