public class MobileUtil
extends java.lang.Object
MobileUtil
provides various utility methods revolving around WCM Mobile.Constructor and Description |
---|
MobileUtil() |
Modifier and Type | Method and Description |
---|---|
static DeviceGroup |
getDefaultDeviceGroup(Page page)
This method finds the device groups currently assigned to the given page or its closest ancestor.
|
static java.lang.String |
getDeviceGroupSelector(SlingHttpServletRequest request)
Returns the last selector found in the request URL.
|
static boolean |
hasCapability(SlingHttpServletRequest request,
DeviceCapability capability)
This method retrieves the
DeviceGroup from the current request and checks the group whether it offers the
given capability . |
static boolean |
isDeviceGroup(Page page)
Checks whether the given
Page represents a WCM Mobile Device Group. |
static boolean |
isDeviceGroup(Resource resource)
Checks whether the given
Resource represents a WCM Mobile Device Group. |
static boolean |
isMobileRequest(SlingHttpServletRequest r)
True if the request's user agent is a mobile device.
|
static boolean |
isMobileResource(Resource r)
True if given resource's parent page (or page itself) or any of its parent pages is based on the mobile resource
type
MobileConstants.MOBILE_BASE_RESOURCE_TYPE . |
static boolean |
isMobileResource(Resource r,
java.lang.String[] types)
True if given resource's parent page (or page itself) or any of its parent pages is based on the mobile resource
type
MobileConstants.MOBILE_BASE_RESOURCE_TYPE or any other type provided in the types array. |
static boolean |
isNoMatch(java.lang.String[] selectors) |
static boolean |
isPreventRedirect(Resource r)
Checks if the given resource prevents redirection
|
public static boolean isDeviceGroup(Resource resource)
Resource
represents a WCM Mobile Device Group. Resource that match the
resource type DeviceGroup.RESOURCE_TYPE
are considered device groups.resource
- The resource to check.true
if the resource is in fact a device group.DeviceGroup
public static boolean isDeviceGroup(Page page)
Page
represents a WCM Mobile Device Group. The check is performed on the
page's content resource.page
- The page to check.true
if the page is in fact a device group.isDeviceGroup(org.apache.sling.api.resource.Resource)
,
DeviceGroup
public static DeviceGroup getDefaultDeviceGroup(Page page)
page
- The page to check for device group mappings.DeviceGroup
.public static java.lang.String getDeviceGroupSelector(SlingHttpServletRequest request)
request
- The SlingHttpServletRequest
to retrieve selectors from.String
representing the selector or null
if not found.public static boolean hasCapability(SlingHttpServletRequest request, DeviceCapability capability)
DeviceGroup
from the current request and checks the group whether it offers the
given capability
.request
- The current request.capability
- The DeviceCapability
to check for.true
if the current device group offers the capability.public static boolean isMobileRequest(SlingHttpServletRequest r)
r
- The request to check.true
if this is a mobile request.public static boolean isMobileResource(Resource r)
MobileConstants.MOBILE_BASE_RESOURCE_TYPE
.r
- The resource to check, may be null.true
if this resource is a mobile resource.public static boolean isMobileResource(Resource r, java.lang.String[] types)
MobileConstants.MOBILE_BASE_RESOURCE_TYPE
or any other type provided in the types array.r
- The resource to check, may be null.types
- The additional resource types to check. May be null.true
if this resource is a mobile resource.public static boolean isPreventRedirect(Resource r)
r
- resourcetrue
if redirection is preventedpublic static boolean isNoMatch(java.lang.String[] selectors)
Copyright © 2010 - 2020 Adobe. All Rights Reserved