Class Literal

java.lang.Object
eu.bandm.tools.format.Format
eu.bandm.tools.format.Literal
All Implemented Interfaces:
Formattable, Serializable, Cloneable

public class Literal extends Format
Prints its contents literally to the output. The contents must not contain tab or newline characters, as tested by ILLEGAL_CONTENTS. The contents may, but should not, be empty. The factory method Format.literal(String) ensures this. The contents may, but should not, contain whitespace. Whitespace will not be correctly formatted, unlike explicit Space instances.
See Also:
  • Field Details

    • content

      public final String content
      The visible string content to print .
    • ILLEGAL_CONTENTS

      public static final Pattern ILLEGAL_CONTENTS
      Matches the characters which are currently not allowed in Literals. These are "carriage return", "linefeed", and "horizontal tab".
  • Constructor Details

  • Method Details

    • isValidContent

      public static boolean isValidContent(String s)
      Returns whether the argument is valid as content of a literal format, i.e. does neither contain tab nor newline characters.
      Parameters:
      s - vaue to test as an argument for a literal format.
      Returns:
      whether the argument is valid as content of a literal format.
    • getContent

      public String getContent()
      Returns the text content.
      Returns:
      the text content.
    • doprint

      protected void doprint(FormatPrinter v)
      Description copied from class: Format
      Over-ridden by all sub-classes of Format, for performing the print operations.
      Specified by:
      doprint in class Format
      Parameters:
      v - realizes the dynamic context for printing
    • debugPrefix

      public String debugPrefix(int n)
      Description copied from class: Format
      Deliver the concatenation of the text contents, limited by the given number of characters, approximately. Useful for debugging purpose.
      Specified by:
      debugPrefix in class Format
      Parameters:
      n - the maximal number of characters which can be generated per tree node.
      Returns:
      the concatenated, unformatted text contents.
    • indent

      public Literal indent(int i)
      Description copied from class: Format
      Returns a clone of this with the new value of Format.indent.
      Specified by:
      indent in class Format
      Parameters:
      i - the new value for indent.
      Returns:
      an new format with identical values but i, or this, if i is its indent value.