Class Structure

java.lang.Object
org.apache.juneau.commons.svl.Structure

public final class Structure extends Object
A typed, structured value (list, block or table) that an SVL expression function can return.

The core never emits markup. toString() gives a plain-text fallback; a layer that understands richer output (such as the J0439 template layer) interprets kind(), items() / rows() and options() itself.

Instances are immutable; all inputs are defensively copied (shallow: the elements themselves are not copied).

  • Method Details

    • ul

      public static Structure ul(List<?> items)
      Creates an unordered list.
      Parameters:
      items - The items. Must not be null.
      Returns:
      A new structure.
    • ul

      public static Structure ul(List<?> items, Map<String,Object> options)
      Creates an unordered list with options.
      Parameters:
      items - The items. Must not be null.
      options - Layer-defined options. May be null.
      Returns:
      A new structure.
    • ol

      public static Structure ol(List<?> items)
      Creates an ordered list.
      Parameters:
      items - The items. Must not be null.
      Returns:
      A new structure.
    • ol

      public static Structure ol(List<?> items, Map<String,Object> options)
      Creates an ordered list with options.
      Parameters:
      items - The items. Must not be null.
      options - Layer-defined options. May be null.
      Returns:
      A new structure.
    • block

      public static Structure block(Object content)
      Creates a block holding a single content item.
      Parameters:
      content - The content. May be null.
      Returns:
      A new structure.
    • block

      public static Structure block(Object content, Map<String,Object> options)
      Creates a block with options.
      Parameters:
      content - The content. May be null.
      options - Layer-defined options. May be null.
      Returns:
      A new structure.
    • table

      public static Structure table(List<String> columns, List<List<?>> rows)
      Creates a table.
      Parameters:
      columns - The column headers. Must not be null.
      rows - The rows. Must not be null.
      Returns:
      A new structure.
    • table

      public static Structure table(List<String> columns, List<List<?>> rows, Map<String,Object> options)
      Creates a table with options.
      Parameters:
      columns - The column headers. Must not be null.
      rows - The rows. Must not be null.
      options - Layer-defined options. May be null.
      Returns:
      A new structure.
    • kind

      public Structure.Kind kind()
      Returns the kind of this structure.
      Returns:
      The kind.
    • items

      public List<?> items()
      Returns the items of a list or block.
      Returns:
      An unmodifiable list, or an empty list for a table.
    • columns

      public List<String> columns()
      Returns the column headers of a table.
      Returns:
      An unmodifiable list, or an empty list for a non-table.
    • rows

      public List<List<?>> rows()
      Returns the rows of a table.
      Returns:
      An unmodifiable list, or an empty list for a non-table.
    • options

      public Map<String,Object> options()
      Returns the layer-defined options.
      Returns:
      An unmodifiable map; never null.
    • toString

      public String toString()
      Plain-text fallback.

      Lists render one item per line prefixed with - or N. ; a block renders its content; a table renders the header and then each row as tab-separated values, one per line.

      Overrides:
      toString in class Object