Interface Justification


public interface Justification
This is the interface for a specific justification.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    This method applies the justification to the given value and returns the result.
    void
    This method applies the justification to the given value and appends the result to the given target.
    of(String format)
    This method parses the given format as Justification.
  • Method Details

    • justify

      void justify(CharSequence value, Appendable target)
      This method applies the justification to the given value and appends the result to the given target.
      Parameters:
      value - is the string to justify.
      target - is where to append the justified data.
    • justify

      default String justify(CharSequence value)
      This method applies the justification to the given value 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 given format as Justification. 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").
      Examples:
      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