Package org.apache.sling.api.resource
Class ResourceWrapper
java.lang.Object
org.apache.sling.api.resource.ResourceWrapper
The
ResourceWrapper is a wrapper for any Resource
delegating all method calls to the wrapped resource by default. Extensions of
this class may overwrite any method to return different values as
appropriate.-
Field Summary
Fields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING -
Constructor Summary
ConstructorsConstructorDescriptionResourceWrapper(@NotNull Resource resource) Creates a new wrapper instance delegating all method calls to the givenresource. -
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypeReturns the value of callingadaptToon thewrapped resource.Returns the value of callinggetChildon thewrapped resource.Returns an iterable of the direct children of this resource.@NotNull StringgetName()Returns the value of callinggetNameon thewrapped resource.Returns the value of callinggetParenton thewrapped resource.@NotNull StringgetPath()Returns the value of callinggetPathon thewrapped resource.@NotNull ResourceReturns theResourcewrapped by this instance.@NotNull ResourceMetadataReturns the value of callinggetResourceMetadataon thewrapped resource.@NotNull ResourceResolverReturns the value of callinggetResourceResolveron thewrapped resource.Returns the value of callinggetResourceSuperTypeon thewrapped resource.@NotNull StringReturns the value of callinggetResourceTypeon thewrapped resource.@NotNull ValueMapReturns a value map for this resource.booleanReturns the value of callinghasChildrenon thewrapped resource.booleanisResourceType(String resourceType) Returns the value of callingisResourceTypeon thewrapped resource.Returns the value of callinglistChildrenon thewrapped resource.toString()Returns a string representation of this wrapper consisting of the class' simple name, theresource typeandpathas well as the string representation of thewrapped resource.
-
Constructor Details
-
ResourceWrapper
Creates a new wrapper instance delegating all method calls to the givenresource.- Parameters:
resource- The resource to wrap
-
-
Method Details
-
getResource
Returns theResourcewrapped by this instance. This method can be overwritten by subclasses if required. All methods implemented by this class use this method to get the resource object.- Returns:
- The resource wrapped by this instance.
-
getPath
Returns the value of callinggetPathon thewrapped resource. -
getName
Returns the value of callinggetNameon thewrapped resource. -
getParent
Returns the value of callinggetParenton thewrapped resource. -
getChild
Returns the value of callinggetChildon thewrapped resource. -
listChildren
Returns the value of callinglistChildrenon thewrapped resource.- Specified by:
listChildrenin interfaceResource- Returns:
- An iterator for child resources.
- Since:
- 2.1.0 (Sling API Bundle 2.1.0)
- See Also:
-
getChildren
Description copied from interface:ResourceReturns an iterable of the direct children of this resource.This method is a convenience and returns exactly the same resources as calling
getResourceResolver().getChildren(resource).- Specified by:
getChildrenin interfaceResource- Returns:
- An iterable for child resources
- See Also:
-
getResourceMetadata
Returns the value of callinggetResourceMetadataon thewrapped resource.- Specified by:
getResourceMetadatain interfaceResource- Returns:
- The resource meta data
- See Also:
-
getResourceResolver
Returns the value of callinggetResourceResolveron thewrapped resource.- Specified by:
getResourceResolverin interfaceResource- Returns:
- The resource resolver
-
getResourceType
Returns the value of callinggetResourceTypeon thewrapped resource.- Specified by:
getResourceTypein interfaceResource- Returns:
- The resource type
-
getResourceSuperType
Returns the value of callinggetResourceSuperTypeon thewrapped resource.- Specified by:
getResourceSuperTypein interfaceResource- Returns:
- The super type of the resource or
null.
-
hasChildren
public boolean hasChildren()Returns the value of callinghasChildrenon thewrapped resource.- Specified by:
hasChildrenin interfaceResource- Returns:
trueif the resource has any child resources- Since:
- 2.4.4 (Sling API Bundle 2.5.0)
-
isResourceType
Returns the value of callingisResourceTypeon thewrapped resource.- Specified by:
isResourceTypein interfaceResource- Parameters:
resourceType- the resource type to check this resource against- Returns:
trueif the resource type or any of the resource's super type(s) equals the given resource type,falseotherwise;falsecan also be returned ifresourceTypeis null- Since:
- 2.1.0 (Sling API Bundle 2.1.0)
- See Also:
-
adaptTo
Returns the value of callingadaptToon thewrapped resource.- Specified by:
adaptToin interfaceAdaptable- Type Parameters:
AdapterType- The generic type to which this object is adapted to- Parameters:
type- The Class object of the target type, such asjavax.jcr.Node.classorjava.io.File.class- Returns:
- The adapter target or
nullif the object cannot adapt to the requested type
-
getValueMap
Description copied from interface:ResourceReturns a value map for this resource. The value map allows to read the properties of the resource.- Specified by:
getValueMapin interfaceResource- Returns:
- A value map
- See Also:
-
toString
Returns a string representation of this wrapper consisting of the class' simple name, theresource typeandpathas well as the string representation of thewrapped resource.
-