org.apache.sling.api.resource
Class SyntheticResource

java.lang.Object
  extended by org.apache.sling.api.resource.SyntheticResource
All Implemented Interfaces:
Adaptable, Resource
Direct Known Subclasses:
MockResource, NonExistingResource

public class SyntheticResource
extends java.lang.Object
implements Resource

The SyntheticResource class is a simple implementation of the Resource interface which may be used to provide a resource object which has no actual resource data.


Field Summary
 
Fields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING
 
Constructor Summary
SyntheticResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType)
          Creates a synthetic resource with the given ResourceMetadata and resourceType.
SyntheticResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType)
          Creates a synthetic resource with the given path and resourceType.
 
Method Summary
<Type> Type
adaptTo(java.lang.Class<Type> type)
          Returns null because synthetic resources have no actual data and thus may not adapt to anything else.
 java.lang.String getPath()
          This resource's path - for now that could be a JCR path.
 ResourceMetadata getResourceMetadata()
          Returns a resource metadata object containing just the path of this resource as the ResourceMetadata.RESOLUTION_PATH property.
 ResourceResolver getResourceResolver()
          Returns the ResourceResolver with which this synthetic resource is related or null if none.
 java.lang.String getResourceSuperType()
          Synthetic resources by default do not have a resource super type.
 java.lang.String getResourceType()
          The resource type is meant to point to rendering/processing scripts, editing dialogs, etc.
protected  void setResourceType(java.lang.String resourceType)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SyntheticResource

public SyntheticResource(ResourceResolver resourceResolver,
                         java.lang.String path,
                         java.lang.String resourceType)
Creates a synthetic resource with the given path and resourceType.


SyntheticResource

public SyntheticResource(ResourceResolver resourceResolver,
                         ResourceMetadata rm,
                         java.lang.String resourceType)
Creates a synthetic resource with the given ResourceMetadata and resourceType.

Method Detail

getPath

public java.lang.String getPath()
Description copied from interface: Resource
This resource's path - for now that could be a JCR path. It's also possible to have an URI for other data sources.

Specified by:
getPath in interface Resource

getResourceType

public java.lang.String getResourceType()
Description copied from interface: Resource
The resource type is meant to point to rendering/processing scripts, editing dialogs, etc. It is usually a path in the repository, where scripts and other tools definitions are found, but the ResourceResolver is free to set this to any suitable value such as the primary node type of the JCR node from which the resource is created.

If the resource instance represents a resource which is not actually existing, this method returns the Resource.RESOURCE_TYPE_NON_EXISTING.

Specified by:
getResourceType in interface Resource

setResourceType

protected void setResourceType(java.lang.String resourceType)

getResourceSuperType

public java.lang.String getResourceSuperType()
Synthetic resources by default do not have a resource super type.

Specified by:
getResourceSuperType in interface Resource

getResourceMetadata

public ResourceMetadata getResourceMetadata()
Returns a resource metadata object containing just the path of this resource as the ResourceMetadata.RESOLUTION_PATH property.

Specified by:
getResourceMetadata in interface Resource
See Also:
ResourceMetadata

getResourceResolver

public ResourceResolver getResourceResolver()
Returns the ResourceResolver with which this synthetic resource is related or null if none.

Specified by:
getResourceResolver in interface Resource

adaptTo

public <Type> Type adaptTo(java.lang.Class<Type> type)
Returns null because synthetic resources have no actual data and thus may not adapt to anything else.

Specified by:
adaptTo in interface Adaptable
Type Parameters:
Type - 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 java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2007-2009. All Rights Reserved.