Class Section

java.lang.Object
com.yahoo.component.provider.FreezableClass
com.yahoo.search.pagetemplates.model.Section
All Implemented Interfaces:
com.yahoo.component.provider.Freezable, PageElement

public class Section extends com.yahoo.component.provider.FreezableClass implements PageElement
An element of a page template corresponding to a physical area of the layout of the final physical page. Pages are freezable - once frozen calling a setter will cause an IllegalStateException, and returned live collection references are unmodifiable
Author:
bratseth
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Creates a section with an id (or null if no id)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Accepts a visitor to this structure
    Returns the elements of this - sources, subsections and presentations and/or choices of these, as a live reference which can be modified to change the content of this (unless this is frozen).
    elements(Class pageTemplateModelElementClass)
    Convenience method which returns the elements and choices of the given type in elements as a read-only list.
    void
     
    Returns a unique id of this section within the page.
    Returns the layout identifier describing the kind of layout which should be used by the rendering engine to lay out the content of this section.
    int
    Returns max number of (immediate) elements/sections permissible within this, -1 means unrestricted.
    int
    Returns min number of (immediate) elements/sections desired within this, -1 means unrestricted.
    Returns the choice of ways to sort immediate children in this, or empty meaning sort by default order (relevance)
    Returns the identifier telling the layout of the containing section where this section should be placed.
    void
    setLayout(Layout layout)
    Sets the layout.
    void
    setMax(int max)
     
    void
    setMin(int min)
     
    void
     
    void
    setRegion(String region)
     
     

    Methods inherited from class com.yahoo.component.provider.FreezableClass

    clone, ensureNotFrozen, isFrozen

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.yahoo.component.provider.Freezable

    isFrozen
  • Constructor Details

    • Section

      public Section()
    • Section

      public Section(String id)
      Creates a section with an id (or null if no id)
  • Method Details

    • getId

      public String getId()
      Returns a unique id of this section within the page. Used for referencing and identification. Never null.
    • getLayout

      public Layout getLayout()
      Returns the layout identifier describing the kind of layout which should be used by the rendering engine to lay out the content of this section. This is never null. Default: "column".
    • setLayout

      public void setLayout(Layout layout)
      Sets the layout. If the layout is set to null it will become Layout.column
    • getRegion

      public String getRegion()
      Returns the identifier telling the layout of the containing section where this section should be placed. Permissible values, and whether this is mandatory is determined by the particular layout identifier of the parent. May be null if a placement is not required by the containing layout, or if this is the top-level section. This is null by default.
    • setRegion

      public void setRegion(String region)
    • elements

      public List<PageElement> elements()
      Returns the elements of this - sources, subsections and presentations and/or choices of these, as a live reference which can be modified to change the content of this (unless this is frozen).

      All elements are kept in a single list to allow multiple elements of each type to be nested within separate choices, and to maintain the internal order of elements of various types, which is sometimes significant. To extract a certain kind of elements (say, sources), the element list must be traversed to collect all source elements as well as all choices of sources.

      This list is never null but may be empty.

    • elements

      public List<PageElement> elements(Class pageTemplateModelElementClass)
      Convenience method which returns the elements and choices of the given type in elements as a read-only list. Not that as this returns both concrete elements and choices betwen them, the list element cannot be case to the given class - this must be used in conjunction with a resolve which contains the resolution to the choices.
      Parameters:
      pageTemplateModelElementClass - type to returns elements and choices of, a subtype of PageElement
    • getOrder

      public Sorting getOrder()
      Returns the choice of ways to sort immediate children in this, or empty meaning sort by default order (relevance)
    • setOrder

      public void setOrder(Sorting order)
    • getMax

      public int getMax()
      Returns max number of (immediate) elements/sections permissible within this, -1 means unrestricted. Default: -1.
    • setMax

      public void setMax(int max)
    • getMin

      public int getMin()
      Returns min number of (immediate) elements/sections desired within this, -1 means unrestricted. Default: -1.
    • setMin

      public void setMin(int min)
    • freeze

      public void freeze()
      Specified by:
      freeze in interface com.yahoo.component.provider.Freezable
      Overrides:
      freeze in class com.yahoo.component.provider.FreezableClass
    • accept

      public void accept(PageTemplateVisitor visitor)
      Accepts a visitor to this structure
      Specified by:
      accept in interface PageElement
    • toString

      public String toString()
      Overrides:
      toString in class Object