Class FormatProxy<F>

java.lang.Object
eu.bandm.tools.format.spi.FormatProxy<F>
Type Parameters:
F - the type of format objects to produce
All Implemented Interfaces:
FormatProvider<F>
Direct Known Subclasses:
FormatServer

public class FormatProxy<F> extends Object implements FormatProvider<F>
A proxy provider that delegates creation of format objects to some other provider.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final FormatProvider<F>
    The provider to delegate to.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new instancce.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(List<? extends F> elems)
    Returns a compound format object that concatenates the given elements horizontally with absolute indentation.
    beneath(List<? extends F> elems)
    Returns a compound format object that concatenates the given elements vertically.
    beside(List<? extends F> elems)
    Returns a compound format object that concatenates the given elements horizontally with relative indentation.
    block(List<? extends F> elems)
    Returns a compound format object that concatenates the given elements first horizontally and then vertically.
    line(List<? extends F> elems)
    Returns a compound format object that concatenates the given elements either horizontally or vertically.
    Returns an atomic format object that displays the given string.
    space(int width)
    Returns an atomic format object that displays breakable whitespace.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • provider

      protected final FormatProvider<F> provider
      The provider to delegate to.
  • Constructor Details

    • FormatProxy

      protected FormatProxy(FormatProvider<F> provider)
      Creates a new instancce.
      Parameters:
      provider - the provider to delegate to
      Throws:
      NullPointerException - if provider == null
  • Method Details

    • literal

      public F literal(String text)
      Returns an atomic format object that displays the given string.

      If the given string contains whitespace, that will not be considered for line breaks.

      The default implementation just delegates to provider.

      Specified by:
      literal in interface FormatProvider<F>
      Parameters:
      text - the string to display
      Returns:
      an atomic format object that displays the given string
    • space

      public F space(int width)
      Returns an atomic format object that displays breakable whitespace.

      The default implementation just delegates to provider.

      Specified by:
      space in interface FormatProvider<F>
      Parameters:
      width - the number of whitespace characters to display
      Returns:
      an atomic format object that displays breakable whitespace of the given width
    • append

      public F append(List<? extends F> elems)
      Returns a compound format object that concatenates the given elements horizontally with absolute indentation.

      The default implementation just delegates to provider.

      Specified by:
      append in interface FormatProvider<F>
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • beside

      public F beside(List<? extends F> elems)
      Returns a compound format object that concatenates the given elements horizontally with relative indentation.

      The default implementation just delegates to provider.

      Specified by:
      beside in interface FormatProvider<F>
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • beneath

      public F beneath(List<? extends F> elems)
      Returns a compound format object that concatenates the given elements vertically.

      The default implementation just delegates to provider.

      Specified by:
      beneath in interface FormatProvider<F>
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • line

      public F line(List<? extends F> elems)
      Returns a compound format object that concatenates the given elements either horizontally or vertically.

      The default implementation just delegates to provider.

      Specified by:
      line in interface FormatProvider<F>
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • block

      public F block(List<? extends F> elems)
      Returns a compound format object that concatenates the given elements first horizontally and then vertically.

      The default implementation just delegates to provider.

      Specified by:
      block in interface FormatProvider<F>
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object