Interface Design


  • @ProviderType
    public interface Design
    Provides methods to access design information.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NN_STYLES
      Name of the node that holds special component styles
      static java.lang.String PN_DOCTYPE
      Name of the property that defines the doctype of a design
      static java.lang.String PN_STYLE_EXCLUDED_COMPONENTS
      Name of the property that defines components that are included when the style is generated via the getStyle(Resource, boolean) call
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​ComponentStyle> getComponentStyles​(Cell cell)
      Returns the component styles for the given cell.
      Resource getContentResource()
      Returns the resource of the design content or null if this design has no content.
      java.lang.String getCssPath()
      Returns the path of the css file for this design
      Doctype getDoctype​(Style currentStyle)
      Returns the doctype of the current style, as defined in the "cq:doctype" property.
      java.lang.String getId()
      Returns the id of the design.
      java.lang.String getJSON()
      Returns a json representation of this design
      java.util.Calendar getLastModified()
      Returns the time when the design was last modified or null if this information is not available or if the design has no content.
      java.lang.String getPath()
      Returns the path of the design
      java.lang.String getStaticCssPath()
      Returns the path of the static css file for this design or null if no such file exists.
      Style getStyle​(Cell cell)
      Returns the style for the given cell.
      Style getStyle​(java.lang.String path)
      Returns the style for the given cell path.
      Style getStyle​(Resource res)
      Returns the style for the given resource.
      Style getStyle​(Resource res, boolean ignoreExcludedComponents)
      Returns the style for the given resource
      boolean hasContent()
      Checks if this design has content attached.
      void writeCSS​(java.io.Writer out, boolean includeCustom)
      Writes the dynamic CSS of this design to the given writer.
      void writeCssIncludes​(java.io.Writer out)
      Convenience method that writes the CSS include strings to the given writer.
      void writeCssIncludes​(java.io.Writer out, Doctype doctype)
      Convenience method that writes the CSS include strings to the given writer.
      void writeCssIncludes​(PageContext page)
      Convenience method that writes the CSS include strings to the response.
    • Field Detail

      • PN_DOCTYPE

        static final java.lang.String PN_DOCTYPE
        Name of the property that defines the doctype of a design
        Since:
        5.4
        See Also:
        Constant Field Values
      • NN_STYLES

        static final java.lang.String NN_STYLES
        Name of the node that holds special component styles
        Since:
        5.4
        See Also:
        Constant Field Values
      • PN_STYLE_EXCLUDED_COMPONENTS

        static final java.lang.String PN_STYLE_EXCLUDED_COMPONENTS
        Name of the property that defines components that are included when the style is generated via the getStyle(Resource, boolean) call
        See Also:
        Constant Field Values
    • Method Detail

      • getPath

        java.lang.String getPath()
        Returns the path of the design
        Returns:
        the path of the design
      • getId

        java.lang.String getId()
        Returns the id of the design.
        Returns:
        the id of the design.
      • getContentResource

        Resource getContentResource()
        Returns the resource of the design content or null if this design has no content.
        Returns:
        resource or null
        See Also:
        hasContent()
      • hasContent

        boolean hasContent()
        Checks if this design has content attached.
        Returns:
        true if this design has content; false otherwise.
      • getStyle

        Style getStyle​(java.lang.String path)
        Returns the style for the given cell path. If the style is not defined and empty style is returned. Please note that this form of addressing does not respect style inheritance via the cell stack.
        Parameters:
        path - the path of the cell
        Returns:
        the style
      • getStyle

        Style getStyle​(Cell cell)
        Returns the style for the given cell. The returned style will respect cell stack inheritance.
        Parameters:
        cell - the cell
        Returns:
        the style
      • getStyle

        Style getStyle​(Resource res)
        Returns the style for the given resource. Note that only the content structure of the resource is respected and not the component include hierarchy.
        Parameters:
        res - resource
        Returns:
        the style
        Since:
        5.4
      • getStyle

        Style getStyle​(Resource res,
                       boolean ignoreExcludedComponents)
        Returns the style for the given resource

        Note that only the content structure of the resource is respected and not the component include hierarchy.

        The hierarchy may be modified by removing certain components based on the information from the request if the ignoreExcludedComponents parameter is set to true. Excluded components are defined in the design with the "cq:styleExcludedComponents" property.

        Parameters:
        res - the resource
        ignoreExcludedComponents - whether to ignore excluded components
        Returns:
        the style
        Since:
        6.2
        See Also:
        PN_STYLE_EXCLUDED_COMPONENTS
      • getCssPath

        java.lang.String getCssPath()
        Returns the path of the css file for this design
        Returns:
        the path of the css file.
      • getStaticCssPath

        java.lang.String getStaticCssPath()
        Returns the path of the static css file for this design or null if no such file exists.
        Returns:
        the path of the static css file or null
      • writeCssIncludes

        void writeCssIncludes​(java.io.Writer out)
                       throws java.io.IOException
        Convenience method that writes the CSS include strings to the given writer. This assumes a non XHTML doctype.
        Parameters:
        out - the writer
        Throws:
        java.io.IOException - if an I/O error occurs
      • writeCssIncludes

        void writeCssIncludes​(java.io.Writer out,
                              Doctype doctype)
                       throws java.io.IOException
        Convenience method that writes the CSS include strings to the given writer. The specified doctype ensures proper empty elements for XHTML types. If doctype is null, Doctype.HTML_401_STRICT is used.
        Parameters:
        out - the writer
        doctype - doctype of the document the include is written to.
        Throws:
        java.io.IOException - if an I/O error occurs
      • writeCssIncludes

        void writeCssIncludes​(PageContext page)
                       throws java.io.IOException
        Convenience method that writes the CSS include strings to the response. It uses the Doctype defined in the request or defaults to Doctype.HTML_401_STRICT if non defined.
        Parameters:
        page - the jsp page context
        Throws:
        java.io.IOException - if an I/O error occurs
        Since:
        5.3
      • writeCSS

        void writeCSS​(java.io.Writer out,
                      boolean includeCustom)
               throws java.io.IOException,
                      RepositoryException
        Writes the dynamic CSS of this design to the given writer.
        Parameters:
        out - writer to write to
        includeCustom - if true non-CSS rules are included as comments
        Throws:
        RepositoryException - if a repository error occurs
        java.io.IOException - if an I/O error occurs
      • getDoctype

        Doctype getDoctype​(Style currentStyle)
        Returns the doctype of the current style, as defined in the "cq:doctype" property. If the property does not exist or if currentStyle is null, the property is searched on the toplevel node. the value of the property needs to be a name of a Doctype enum. if any of the above fails, Doctype.XHTML_10_STRICT is returned.
        Parameters:
        currentStyle - current style or null
        Returns:
        the doctype
        Since:
        5.4
      • getComponentStyles

        java.util.Map<java.lang.String,​ComponentStyle> getComponentStyles​(Cell cell)
        Returns the component styles for the given cell.
        Parameters:
        cell - the cell
        Returns:
        the map of component styles
        Since:
        5.4
      • getJSON

        java.lang.String getJSON()
        Returns a json representation of this design
        Returns:
        a json string
        Since:
        5.4
      • getLastModified

        java.util.Calendar getLastModified()
        Returns the time when the design was last modified or null if this information is not available or if the design has no content.
        Returns:
        last modification date or null
        Since:
        5.4