Class EachCommand

All Implemented Interfaces:
Command

public class EachCommand extends AbstractCommand

Implements iteration over collection or array of items

  • 'items' is a bean name of the collection or array in context
  • 'var' is a name of a collection item to put into the context during the iteration
  • 'varIndex' is name of variable in context that holds current iteration index, 0 based. Use ${varIndex+1} for 1 based.
  • 'direction' defines expansion by rows (DOWN) or by columns (RIGHT). Default is DOWN.
  • 'select' holds an expression for filtering collection.
  • 'groupBy' is the name for grouping (prepend var+".").
  • 'groupOrder' defines the grouping order. Case does not matter. "ASC" for ascending, "DESC" for descending sort order. Other values or null: no sorting.
  • 'orderBy' contains the names separated with comma and each with an optional postfix " ASC" (default) or " DESC" for the sort order. Prepend var+'.' before each name.
  • 'multisheet' is the name of the sheet names container.
  • 'cellRefGenerator' defines custom strategy for target cell references.

The variables defined in 'var' and 'varIndex' will be saved using the special method Context.getRunVar()

Author:
Leonid Vysochyn
  • Field Details

  • Constructor Details

    • EachCommand

      public EachCommand()
    • EachCommand

      public EachCommand(String var, String items, EachCommand.Direction direction)
      Parameters:
      var - name of the key in the context to contain each collection items during iteration
      items - name of collection or array in the context
      direction - defines processing by rows (DOWN - default) or columns (RIGHT)
    • EachCommand

      public EachCommand(String items, Area area)
    • EachCommand

      public EachCommand(String var, String items, Area area)
    • EachCommand

      public EachCommand(String var, String items, Area area, EachCommand.Direction direction)
    • EachCommand

      public EachCommand(String var, String items, Area area, CellRefGenerator cellRefGenerator)
      Parameters:
      var - name of the key in the context to contain each collection items during iteration
      items - name of collection or array in the context
      area - body area for this command
      cellRefGenerator - generates target cell ref for each collection item during iteration
  • Method Details

    • getName

      public String getName()
      Returns:
      command name
    • getItems

      public String getItems()
      Gets collection bean name
      Returns:
      collection name of collection or array in the context
    • setItems

      public void setItems(String items)
      Sets collection bean name
      Parameters:
      items - name of collection or array in the context
    • getVar

      public String getVar()
      Gets current variable name for collection item in the context during iteration
      Returns:
      collection item key name in the context
    • setVar

      public void setVar(String var)
      Sets current variable name for collection item in the context during iteration
      Parameters:
      var - name of the loop var
    • getVarIndex

      public String getVarIndex()
      Returns:
      variable name to put the current iteration index, 0 based
    • setVarIndex

      public void setVarIndex(String varIndex)
    • getDirection

      public EachCommand.Direction getDirection()
      Gets iteration direction
      Returns:
      current direction for iteration
    • setDirection

      public void setDirection(EachCommand.Direction direction)
      Sets iteration direction
      Parameters:
      direction - iteration direction
    • setDirection

      public void setDirection(String direction)
      Parameters:
      direction - "DOWN" or "RIGHT"
    • getSelect

      public String getSelect()
      Gets current 'select' expression for filtering out collection items
      Returns:
      current 'select' expression or null if undefined
    • setSelect

      public void setSelect(String select)
      Sets current 'select' expression for filtering collection
      Parameters:
      select - filtering expression
    • getGroupBy

      public String getGroupBy()
      Returns:
      property name for grouping the collection
    • setGroupBy

      public void setGroupBy(String groupBy)
      Parameters:
      groupBy - property name for grouping the collection. You should write the run var name + "." before the property name.
    • getGroupOrder

      public String getGroupOrder()
      Returns:
      group order
    • setGroupOrder

      public void setGroupOrder(String groupOrder)
      Parameters:
      groupOrder - group ordering: "ASC" for ascending, "DESC" for descending, other value or null: no sorting. Case does not matter.
    • setOrderBy

      public void setOrderBy(String orderBy)
      Parameters:
      orderBy - property names for ordering the list. You should write the run var name + "." before each property name. You can write " ASC" or " DESC" after each property name for ascending/descending sorting order. ASC is the default.
    • getOrderBy

      public String getOrderBy()
      Returns:
      property names for ordering the list
    • getMultisheet

      public String getMultisheet()
      Returns:
      Context variable name holding a list of Excel sheet names to output the collection to
    • setMultisheet

      public void setMultisheet(String multisheet)
      Sets name of context variable holding a list of Excel sheet names to output the collection to
      Parameters:
      multisheet - var name
    • getCellRefGenerator

      public CellRefGenerator getCellRefGenerator()
      Gets defined cell ref generator
      Returns:
      current CellRefGenerator instance or null
    • setCellRefGenerator

      public void setCellRefGenerator(CellRefGenerator cellRefGenerator)
    • isOldSelectBehavior

      public boolean isOldSelectBehavior()
    • setOldSelectBehavior

      public void setOldSelectBehavior(boolean oldSelectBehavior)
    • setOldSelectBehavior

      public void setOldSelectBehavior(String oldSelectBehavior)
    • addArea

      public Command addArea(Area area)
      Description copied from interface: Command
      Adds an area to this command
      Specified by:
      addArea in interface Command
      Overrides:
      addArea in class AbstractCommand
      Parameters:
      area - to be added area
      Returns:
      this command instance
    • applyAt

      public Size applyAt(CellRef cellRef, Context context)
      Description copied from interface: Command
      Applies a command at the given cell reference
      Parameters:
      cellRef - cell reference where the command must be applied
      context - bean context to use
      Returns:
      size of enclosing command area after transformation