Package com.day.cq.wcm.mobile.core
Class MobileUtil
java.lang.Object
com.day.cq.wcm.mobile.core.MobileUtil
The
MobileUtil provides various utility methods revolving around WCM Mobile.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DeviceGroupgetDefaultDeviceGroup(Page page) This method finds the device groups currently assigned to the given page or its closest ancestor.static StringReturns the last selector found in the request URL.static booleanhasCapability(SlingHttpServletRequest request, DeviceCapability capability) This method retrieves theDeviceGroupfrom the current request and checks the group whether it offers the givencapability.static booleanisDeviceGroup(Page page) Checks whether the givenPagerepresents a WCM Mobile Device Group.static booleanisDeviceGroup(Resource resource) Checks whether the givenResourcerepresents a WCM Mobile Device Group.static booleanTrue if the request's user agent is a mobile device.static booleanTrue if given resource's parent page (or page itself) or any of its parent pages is based on the mobile resource typeMobileConstants.MOBILE_BASE_RESOURCE_TYPE.static booleanisMobileResource(Resource r, String[] types) True if given resource's parent page (or page itself) or any of its parent pages is based on the mobile resource typeMobileConstants.MOBILE_BASE_RESOURCE_TYPEor any other type provided in the types array.static booleanstatic booleanChecks if the given resource prevents redirection
-
Constructor Details
-
MobileUtil
public MobileUtil()
-
-
Method Details
-
isDeviceGroup
Checks whether the givenResourcerepresents a WCM Mobile Device Group. Resource that match the resource typeDeviceGroup.RESOURCE_TYPEare considered device groups.- Parameters:
resource- The resource to check.- Returns:
trueif the resource is in fact a device group.- See Also:
-
isDeviceGroup
Checks whether the givenPagerepresents a WCM Mobile Device Group. The check is performed on the page's content resource.- Parameters:
page- The page to check.- Returns:
trueif the page is in fact a device group.- See Also:
-
getDefaultDeviceGroup
This method finds the device groups currently assigned to the given page or its closest ancestor. From the assigned device groups, the first group is returned.- Parameters:
page- The page to check for device group mappings.- Returns:
- The first
DeviceGroup.
-
getDeviceGroupSelector
Returns the last selector found in the request URL. Within a mobile site context, this selector usually defines the device group name for the active device group.- Parameters:
request- TheSlingHttpServletRequestto retrieve selectors from.- Returns:
- A
Stringrepresenting the selector ornullif not found.
-
hasCapability
This method retrieves theDeviceGroupfrom the current request and checks the group whether it offers the givencapability.- Parameters:
request- The current request.capability- TheDeviceCapabilityto check for.- Returns:
trueif the current device group offers the capability.
-
isMobileRequest
True if the request's user agent is a mobile device. The user agent header is matched for "Mobile" and "Blackberry".- Parameters:
r- The request to check.- Returns:
trueif this is a mobile request.
-
isMobileResource
True if given resource's parent page (or page itself) or any of its parent pages is based on the mobile resource typeMobileConstants.MOBILE_BASE_RESOURCE_TYPE.- Parameters:
r- The resource to check, may be null.- Returns:
trueif this resource is a mobile resource.
-
isMobileResource
True if given resource's parent page (or page itself) or any of its parent pages is based on the mobile resource typeMobileConstants.MOBILE_BASE_RESOURCE_TYPEor any other type provided in the types array.- Parameters:
r- The resource to check, may be null.types- The additional resource types to check. May be null.- Returns:
trueif this resource is a mobile resource.
-
isPreventRedirect
Checks if the given resource prevents redirection- Parameters:
r- resource- Returns:
trueif redirection is prevented
-
isNoMatch
-