Class Format.BoundVariable

All Implemented Interfaces:
Formattable, Serializable, Cloneable
Enclosing class:
Format

public static class Format.BoundVariable extends Format.Variable
Variable identified by an index number, resolved by un-named arguments by counting their positions. This mechanism is ubiquituously used in meta-tools, eg. with metajava.FormatClosure, and well tested (in contrast to Format.FreeVariable !-)
See Also:
  • Field Details

    • index

      public final int index
      The position of the argument to be replaced by this variable.
  • Constructor Details

    • BoundVariable

      public BoundVariable(int index)
    • BoundVariable

      public BoundVariable(int index, int indent)
  • Method Details

    • indent

      public Format.BoundVariable indent(int i)
      Unsupported Operation. Variables will be replaced completely> by some other format before the containing format will be laid out and printed. This includes the indentation value. For a constant indentation behaviour for any such replacement use an expression like
       append(empty.ident(i), new BoundVariable(index))
      Specified by:
      indent in class Format
    • eval

      public Format eval(Format.Context c, boolean partial)
      Return the Format value bound to position index of this variable in the given context. If the index is higher than the defined range of arguemnts: if partial==true the index is adjusted by subtracting the number of arguments in the context. Otherwise an exception is thrown by returning Format.Variable.bottom().
      Overrides:
      eval in class Format
      partial - decides when a Variable not defined in the context is found: if true the Variable stays aunaltered; if false an IllegalArgumentException is thrown.