com.citytechinc.aem.bedrock.api.page
Interface PageDecorator

All Superinterfaces:
Accessible, Adaptable, ImageSource, Inheritable, LabeledResource, Linkable, Page, Traversable<PageDecorator>

public interface PageDecorator
extends Page, Accessible, Inheritable, Linkable, ImageSource, Traversable<PageDecorator>

Decorates the CQ Page interface with additional convenience methods for traversing the content hierarchy and getters for Bedrock classes.


Method Summary
 PageDecorator getAbsoluteParent(int level)
          Returns the absolute parent page.
 List<PageDecorator> getChildren()
          Get the child pages of the current page.
 List<PageDecorator> getChildren(boolean displayableOnly)
          Get the child pages of the current page, excluding children that are not "displayable" (i.e.
 List<PageDecorator> getChildren(Predicate<PageDecorator> predicate)
          Get the child pages of the current page filtered using the given predicate.
 Optional<ComponentNode> getComponentNode()
          Get the component node for the "jcr:content" node for this page.
 Optional<ComponentNode> getComponentNode(String relativePath)
          Get the component node for the node at the given path relative to the "jcr:content" node for this page.
 ImageLink getImageLink(String imageSource)
          Get a link for this page with an attached image source.
 Link getLink(TitleType titleType)
          Get a link with a specified title type for this item.
 Link getLink(TitleType titleType, boolean mapped)
          Get a link with a specified title type for this item.
 LinkBuilder getLinkBuilder(TitleType titleType)
          Get a link builder for the current resource path.
 LinkBuilder getLinkBuilder(TitleType titleType, boolean mapped)
          Get a link builder for the current resource path.
 NavigationLink getNavigationLink()
          Get a navigation link for this page.
 NavigationLink getNavigationLink(boolean isActive)
          Get a navigation link for this page containing an active state.
 NavigationLink getNavigationLink(boolean isActive, boolean mapped)
          Get a navigation link for this page containing an active state.
 PageManagerDecorator getPageManager()
          Convenience method that returns the manager of this page.
 PageDecorator getParent()
          Returns the parent page if it's resource adapts to page.
 PageDecorator getParent(int level)
          Returns the relative parent page.
 String getTemplatePath()
          Get the template path for this page.
 Optional<String> getTitle(TitleType titleType)
          Get the title with the given type for this page.
 
Methods inherited from interface com.day.cq.wcm.api.Page
canUnlock, getContentResource, getContentResource, getDepth, getLanguage, getLastModified, getLastModifiedBy, getLockOwner, getName, getNavigationTitle, getOffTime, getOnTime, getPageTitle, getPath, getProperties, getProperties, getTags, getTemplate, getTitle, getVanityUrl, hasChild, hasContent, isHideInNav, isLocked, isValid, listChildren, listChildren, listChildren, lock, timeUntilValid, unlock
 
Methods inherited from interface org.apache.sling.api.adapter.Adaptable
adaptTo
 
Methods inherited from interface com.day.cq.commons.LabeledResource
getDescription
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.Accessible
asMap, get, get, getAsHref, getAsHref, getAsHref, getAsLink, getAsLink, getAsLink, getAsList, getAsPage, getAsType, getImageReference, getImageReference, getImageRendition, getImageRendition
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.Inheritable
getAsHrefInherited, getAsHrefInherited, getAsHrefInherited, getAsLinkInherited, getAsLinkInherited, getAsLinkInherited, getAsListInherited, getAsPageInherited, getAsTypeInherited, getImageReferenceInherited, getImageReferenceInherited, getImageSourceInherited, getImageSourceInherited, getImageSourceInherited, getImageSourceInherited, getInherited, getInherited
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.Linkable
getHref, getHref, getLink, getLink, getLinkBuilder, getLinkBuilder
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.ImageSource
getImageSource, getImageSource, getImageSource, getImageSource, isHasImage, isHasImage
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.Traversable
findAncestor, findAncestorWithProperty, findAncestorWithPropertyValue, findDescendants
 

Method Detail

getChildren

List<PageDecorator> getChildren()
Get the child pages of the current page.

Returns:
all child pages of current page or empty list if none exist

getChildren

List<PageDecorator> getChildren(boolean displayableOnly)
Get the child pages of the current page, excluding children that are not "displayable" (i.e. hidden in nav).

Parameters:
displayableOnly - if true, only pages that are not hidden in navigation will be returned
Returns:
child pages of current page or empty list if none exist

getChildren

List<PageDecorator> getChildren(Predicate<PageDecorator> predicate)
Get the child pages of the current page filtered using the given predicate.

Parameters:
predicate - predicate to filter pages on
Returns:
filtered list of child pages or empty list if none exist

getComponentNode

Optional<ComponentNode> getComponentNode()
Get the component node for the "jcr:content" node for this page. If the page does not have a content node, an "absent" Optional is returned.

Returns:
optional component node for page content

getComponentNode

Optional<ComponentNode> getComponentNode(String relativePath)
Get the component node for the node at the given path relative to the "jcr:content" node for this page. If the node does not exist, an "absent" Optional is returned.

Returns:
optional component node for resource relative to page content

getImageLink

ImageLink getImageLink(String imageSource)
Get a link for this page with an attached image source.

Parameters:
imageSource - image source to set on the returned image link
Returns:
image link with the provided image source

getLink

Link getLink(TitleType titleType)
Get a link with a specified title type for this item.

Parameters:
titleType - type of title to set on link
Returns:
link

getLink

Link getLink(TitleType titleType,
             boolean mapped)
Get a link with a specified title type for this item.

Parameters:
titleType - type of title to set on link
mapped - if true, the Link path will be routed through the resource resolver to determine the mapped path (e.g. without leading "/content").
Returns:
link

getLinkBuilder

LinkBuilder getLinkBuilder(TitleType titleType)
Get a link builder for the current resource path.

Parameters:
titleType - type of title to set on builder
Returns:
builder instance for this item

getLinkBuilder

LinkBuilder getLinkBuilder(TitleType titleType,
                           boolean mapped)
Get a link builder for the current resource path.

Parameters:
titleType - type of title to set on builder
mapped - if true, the Link path will be routed through the resource resolver to determine the mapped path (e.g. without leading "/content").
Returns:
builder instance for this item

getNavigationLink

NavigationLink getNavigationLink()
Get a navigation link for this page. The returned link will use the navigation title as the link title, defaulting to the JCR title if it does not exist.

Returns:
navigation link

getNavigationLink

NavigationLink getNavigationLink(boolean isActive)
Get a navigation link for this page containing an active state. The returned link will use the navigation title as the link title, defaulting to the JCR title if it does not exist.

Parameters:
isActive - active state to be set on returned link
Returns:
navigation link

getNavigationLink

NavigationLink getNavigationLink(boolean isActive,
                                 boolean mapped)
Get a navigation link for this page containing an active state. The returned link will use the navigation title as the link title, defaulting to the JCR title if it does not exist.

Parameters:
isActive - active state to be set on returned link
mapped - if true, the NavigationLink path will be routed through the resource resolver to determine the mapped path (e.g. without leading "/content").
Returns:
navigation link

getTemplatePath

String getTemplatePath()
Get the template path for this page. This method is preferred over getTemplate().getPath(), which is dependent on access to /apps and will therefore fail in publish mode.

Returns:
value of cq:template property or empty string if none exists

getTitle

Optional<String> getTitle(TitleType titleType)
Get the title with the given type for this page. If the title value is empty or non-existent, an absent Optional is returned.

Parameters:
titleType - type of title to retrieve
Returns:
title value or absent Optional

getAbsoluteParent

PageDecorator getAbsoluteParent(int level)
Returns the absolute parent page. If no page exists at that level, null is returned.

Example (this path == /content/geometrixx/en/products)

 | level | returned                        |
 |     0 | /content                        |
 |     1 | /content/geometrixx             |
 |     2 | /content/geometrixx/en          |
 |     3 | /content/geometrixx/en/products |
 |     4 | null                            |
 

Specified by:
getAbsoluteParent in interface Page
Parameters:
level - hierarchy level of the parent page to retrieve
Returns:
the respective parent page or null

getPageManager

PageManagerDecorator getPageManager()
Convenience method that returns the manager of this page.

Specified by:
getPageManager in interface Page
Returns:
the page manager

getParent

PageDecorator getParent()
Returns the parent page if it's resource adapts to page.

Specified by:
getParent in interface Page
Returns:
the parent page or null

getParent

PageDecorator getParent(int level)
Returns the relative parent page. If no page exists at that level, null is returned.

Example (this path == /content/geometrixx/en/products)

 | level | returned                        |
 |     0 | /content/geometrixx/en/products |
 |     1 | /content/geometrixx/en          |
 |     2 | /content/geometrixx             |
 |     3 | /content                        |
 |     4 | null                            |
 

Specified by:
getParent in interface Page
Parameters:
level - hierarchy level of the parent page to retrieve
Returns:
the respective parent page or null


Copyright © 2015 CITYTECH, Inc.. All rights reserved.