Class 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
      Section()  
      Section​(java.lang.String id)
      Creates a section with an id (or null if no id)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(PageTemplateVisitor visitor)
      Accepts a visitor to this structure
      java.util.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).
      java.util.List<PageElement> elements​(java.lang.Class pageTemplateModelElementClass)
      Convenience method which returns the elements and choices of the given type in elements as a read-only list.
      void freeze()  
      java.lang.String getId()
      Returns a unique id of this section within the page.
      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.
      int getMax()
      Returns max number of (immediate) elements/sections permissible within this, -1 means unrestricted.
      int getMin()
      Returns min number of (immediate) elements/sections desired within this, -1 means unrestricted.
      Sorting getOrder()
      Returns the choice of ways to sort immediate children in this, or empty meaning sort by default order (relevance)
      java.lang.String getRegion()
      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 setOrder​(Sorting order)  
      void setRegion​(java.lang.String region)  
      java.lang.String toString()  
      • 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 Detail

      • Section

        public Section()
      • Section

        public Section​(java.lang.String id)
        Creates a section with an id (or null if no id)
    • Method Detail

      • getId

        public java.lang.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 java.lang.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​(java.lang.String region)
      • elements

        public java.util.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 java.util.List<PageElement> elements​(java.lang.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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object