org.apache.sling.api.resource
Class ResourceWrapper

java.lang.Object
  extended by org.apache.sling.api.resource.ResourceWrapper
All Implemented Interfaces:
Adaptable, Resource

public class ResourceWrapper
extends Object
implements Resource

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
ResourceWrapper(Resource resource)
          Creates a new wrapper instance delegating all method calls to the given resource.
 
Method Summary
<AdapterType>
AdapterType
adaptTo(Class<AdapterType> type)
          Returns the value of calling adaptTo on the wrapped resource.
 Resource getChild(String relPath)
          Returns the value of calling getChild on the wrapped resource.
 String getName()
          Returns the value of calling getName on the wrapped resource.
 Resource getParent()
          Returns the value of calling getParent on the wrapped resource.
 String getPath()
          Returns the value of calling getPath on the wrapped resource.
 Resource getResource()
          Returns the Resource wrapped by this instance.
 ResourceMetadata getResourceMetadata()
          Returns the value of calling getResourceMetadata on the wrapped resource.
 ResourceResolver getResourceResolver()
          Returns the value of calling getResourceResolver on the wrapped resource.
 String getResourceSuperType()
          Returns the value of calling getResourceSuperType on the wrapped resource.
 String getResourceType()
          Returns the value of calling getResourceType on the wrapped resource.
 boolean isResourceType(String resourceType)
          Returns the value of calling isResourceType on the wrapped resource.
 Iterator<Resource> listChildren()
          Returns the value of calling listChildren on the wrapped resource.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceWrapper

public ResourceWrapper(Resource resource)
Creates a new wrapper instance delegating all method calls to the given resource.

Method Detail

getResource

public Resource getResource()
Returns the 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.


getPath

public String getPath()
Returns the value of calling getPath on the wrapped resource.

Specified by:
getPath in interface Resource

getName

public String getName()
Returns the value of calling getName on the wrapped resource.

Specified by:
getName in interface Resource
Since:
2.1.0

getParent

public Resource getParent()
Returns the value of calling getParent on the wrapped resource.

Specified by:
getParent in interface Resource
Since:
2.1.0

getChild

public Resource getChild(String relPath)
Returns the value of calling getChild on the wrapped resource.

Specified by:
getChild in interface Resource
Since:
2.1.0
See Also:
ResourceResolver.getResource(Resource, String)

listChildren

public Iterator<Resource> listChildren()
Returns the value of calling listChildren on the wrapped resource.

Specified by:
listChildren in interface Resource
Since:
2.1.0
See Also:
ResourceResolver.listChildren(Resource)

getResourceMetadata

public ResourceMetadata getResourceMetadata()
Returns the value of calling getResourceMetadata on the wrapped resource.

Specified by:
getResourceMetadata in interface Resource
See Also:
ResourceMetadata

getResourceResolver

public ResourceResolver getResourceResolver()
Returns the value of calling getResourceResolver on the wrapped resource.

Specified by:
getResourceResolver in interface Resource

getResourceType

public String getResourceType()
Returns the value of calling getResourceType on the wrapped resource.

Specified by:
getResourceType in interface Resource

getResourceSuperType

public String getResourceSuperType()
Returns the value of calling getResourceSuperType on the wrapped resource.

Specified by:
getResourceSuperType in interface Resource

isResourceType

public boolean isResourceType(String resourceType)
Returns the value of calling isResourceType on the wrapped resource.

Specified by:
isResourceType in interface Resource
Parameters:
resourceType - The resource type to check this resource against.
Returns:
true if the resource type or any of the resource's super type(s) equals the given resource type. false is also returned if resourceType is null.
Since:
2.1.0

adaptTo

public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
Returns the value of calling adaptTo on the wrapped resource.

Specified by:
adaptTo in interface Adaptable
Type Parameters:
AdapterType - The generic type to which this resource is adapted to
Parameters:
type - The Class object of the target type, such as Node.class
Returns:
The adapter target or null if the resource cannot adapt to the requested type

toString

public 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.

Overrides:
toString in class Object


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.