public interface Justification
This is the interface for a specific justification.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault Stringjustify(CharSequence value) This method applies the justification to the givenvalueand returns the result.voidjustify(CharSequence value, Appendable target) This method applies the justification to the givenvalueandappendsthe result to the giventarget.static JustificationThis method parses the givenformatasJustification.
-
Method Details
-
justify
This method applies the justification to the givenvalueandappendsthe result to the giventarget.- Parameters:
value- is the string to justify.target- is where toappendthe justified data.
-
justify
This method applies the justification to the givenvalueand returns the result.- Parameters:
value- is the string to justify.- Returns:
- the justified string.
-
of
This method parses the givenformatasJustification. It therefore expects the following format:
«filler»«alignment»«width»[«mode»]
The segments have the following meaning:
Examples: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 justifyis 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 420+4004242.-442..42_~11____42_____Hello World_+5Hello WorldHello World_+5|Hello- Parameters:
format- is the format as specified above.- Returns:
- the parsed
Justification
-