public class ResourceWrapper extends java.lang.Object implements Resource
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.RESOURCE_TYPE_NON_EXISTING
Constructor and Description |
---|
ResourceWrapper(@NotNull Resource resource)
Creates a new wrapper instance delegating all method calls to the given
resource . |
Modifier and Type | Method and Description |
---|---|
<AdapterType> |
adaptTo(@NotNull java.lang.Class<AdapterType> type)
Returns the value of calling
adaptTo on the
wrapped resource . |
Resource |
getChild(@NotNull java.lang.String relPath)
Returns the value of calling
getChild on the
wrapped resource . |
@NotNull java.lang.Iterable<Resource> |
getChildren()
Returns an iterable of the direct children of this resource.
|
@NotNull java.lang.String |
getName()
Returns the value of calling
getName on the
wrapped resource . |
Resource |
getParent()
Returns the value of calling
getParent on the
wrapped resource . |
@NotNull java.lang.String |
getPath()
Returns the value of calling
getPath on the
wrapped resource . |
@NotNull Resource |
getResource()
Returns the
Resource wrapped by this instance. |
@NotNull ResourceMetadata |
getResourceMetadata()
Returns the value of calling
getResourceMetadata on the
wrapped resource . |
@NotNull ResourceResolver |
getResourceResolver()
Returns the value of calling
getResourceResolver on the
wrapped resource . |
java.lang.String |
getResourceSuperType()
Returns the value of calling
getResourceSuperType on the
wrapped resource . |
@NotNull java.lang.String |
getResourceType()
Returns the value of calling
getResourceType on the
wrapped resource . |
@NotNull ValueMap |
getValueMap()
Returns a value map for this resource.
|
boolean |
hasChildren()
Returns the value of calling
hasChildren on the
wrapped resource . |
boolean |
isResourceType(java.lang.String resourceType)
Returns the value of calling
isResourceType on the
wrapped resource . |
@NotNull java.util.Iterator<Resource> |
listChildren()
Returns the value of calling
listChildren on the
wrapped resource . |
java.lang.String |
toString()
Returns a string representation of this wrapper consisting of the class'
simple name, the
resource type and
path as well as the string representation of the
wrapped resource . |
public ResourceWrapper(@NotNull @NotNull Resource resource)
resource
.resource
- The resource to wrap@NotNull public @NotNull Resource getResource()
Resource
wrapped 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.@NotNull public @NotNull java.lang.String getPath()
getPath
on the
wrapped resource
.@NotNull public @NotNull java.lang.String getName()
getName
on the
wrapped resource
.public Resource getParent()
getParent
on the
wrapped resource
.getParent
in interface Resource
null
.ResourceResolver.getParent(Resource)
public Resource getChild(@NotNull @NotNull java.lang.String relPath)
getChild
on the
wrapped resource
.getChild
in interface Resource
relPath
- relative path to the child resourcenull
ResourceResolver.getResource(Resource, String)
@NotNull public @NotNull java.util.Iterator<Resource> listChildren()
listChildren
on the
wrapped resource
.listChildren
in interface Resource
ResourceResolver.listChildren(Resource)
@NotNull public @NotNull java.lang.Iterable<Resource> getChildren()
Resource
This method is a convenience and returns exactly the same resources as
calling getResourceResolver().getChildren(resource)
.
getChildren
in interface Resource
Resource.getChildren()
@NotNull public @NotNull ResourceMetadata getResourceMetadata()
getResourceMetadata
on the
wrapped resource
.getResourceMetadata
in interface Resource
ResourceMetadata
@NotNull public @NotNull ResourceResolver getResourceResolver()
getResourceResolver
on the
wrapped resource
.getResourceResolver
in interface Resource
@NotNull public @NotNull java.lang.String getResourceType()
getResourceType
on the
wrapped resource
.getResourceType
in interface Resource
public java.lang.String getResourceSuperType()
getResourceSuperType
on the
wrapped resource
.getResourceSuperType
in interface Resource
null
.public boolean hasChildren()
hasChildren
on the
wrapped resource
.hasChildren
in interface Resource
true
if the resource has any child resourcespublic boolean isResourceType(java.lang.String resourceType)
isResourceType
on the
wrapped resource
.isResourceType
in interface Resource
resourceType
- the resource type to check this resource againsttrue
if the resource type or any of the resource's
super type(s) equals the given resource type, false
otherwise;
false
can also be returned if resourceType
is nullResourceResolver.isResourceType(Resource, String)
public <AdapterType> AdapterType adaptTo(@NotNull @NotNull java.lang.Class<AdapterType> type)
adaptTo
on the
wrapped resource
.adaptTo
in interface Adaptable
AdapterType
- The generic type to which this object is adapted
totype
- The Class object of the target type, such as
javax.jcr.Node.class
or
java.io.File.class
null
if the object cannot
adapt to the requested type@NotNull public @NotNull ValueMap getValueMap()
Resource
getValueMap
in interface Resource
Resource.getValueMap()
public java.lang.String toString()
resource type
and
path
as well as the string representation of the
wrapped resource
.toString
in class java.lang.Object
Copyright © 2022 The Apache Software Foundation. All rights reserved.