org.apache.sling.api.adapter
Interface Adaptable

All Known Subinterfaces:
Resource, ResourceResolver, SlingHttpServletRequest, SlingHttpServletResponse
All Known Implementing Classes:
AbstractResource, NonExistingResource, ResourceWrapper, SlingAdaptable, SlingHttpServletRequestWrapper, SlingHttpServletResponseWrapper, SyntheticResource

public interface Adaptable

The Adaptable interface identifies objects which can be adapted to other types or representations of the same object. For example a JCR Node based Resource can adapt to the underlying JCR Node or a file based resource could adapt to the underlying java.io.File.


Method Summary
<AdapterType>
AdapterType
adaptTo(java.lang.Class<AdapterType> type)
          Adapts the adaptable to another type.
 

Method Detail

adaptTo

<AdapterType> AdapterType adaptTo(java.lang.Class<AdapterType> type)
Adapts the adaptable to another type.

Please not that it is explicitly left as an implementation detail whether each call to this method with the same type yields the same object or a new object on each call.

Implementations of this method should document their adapted types as well as their behaviour with respect to returning newly created or not instance on each call.

Type Parameters:
AdapterType - The generic type to which this resource is adapted to
Parameters:
type - The Class object of the target type, such as javax.jcr.Node.class or java.io.File.class
Returns:
The adapter target or null if the resource cannot adapt to the requested type


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