Class SyntheticResource

All Implemented Interfaces:
Adaptable, Resource
Direct Known Subclasses:
NonExistingResource

public class SyntheticResource extends AbstractResource
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 (except for the mandatory property "sling:resourceType").
  • Constructor Details

    • SyntheticResource

      public SyntheticResource(@NotNull @NotNull ResourceResolver resourceResolver, @NotNull @NotNull String path, @NotNull @NotNull String resourceType)
      Creates a synthetic resource with the given path and resourceType.
      Parameters:
      resourceResolver - The resource resolver
      path - The absolute resource path including the name. Make sure that each segment of the path only contains valid characters in Sling API resource names.
      resourceType - The type of the resource
      See Also:
    • SyntheticResource

      public SyntheticResource(@NotNull @NotNull ResourceResolver resourceResolver, @NotNull @NotNull ResourceMetadata rm, @NotNull @NotNull String resourceType)
      Creates a synthetic resource with the given ResourceMetadata and resourceType.
      Parameters:
      resourceResolver - The resource resolver
      rm - The resource meta data
      resourceType - The type of the resource
  • Method Details

    • getPath

      @NotNull public @NotNull String getPath()
      Description copied from interface: Resource
      Returns the absolute path of this resource in the resource tree.
      Returns:
      The resource path
      See Also:
    • getResourceType

      @NotNull public @NotNull 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 Resource.RESOURCE_TYPE_NON_EXISTING.

      Returns:
      The resource type
      See Also:
    • getResourceSuperType

      public String getResourceSuperType()
      Synthetic resources by default do not have a resource super type.
      Returns:
      The super type of the resource or null.
    • getResourceMetadata

      @NotNull public @NotNull ResourceMetadata getResourceMetadata()
      Returns a resource metadata object containing just the path of this resource as the ResourceMetadata.RESOLUTION_PATH property.
      Returns:
      The resource meta data
      See Also:
    • getResourceResolver

      @NotNull public @NotNull ResourceResolver getResourceResolver()
      Returns the ResourceResolver with which this synthetic resource is related or null if none.
      Returns:
      The resource resolver
    • adaptTo

      public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
      Merges the original value map with one containing the single property "sling:resourceType".
      Specified by:
      adaptTo in interface Adaptable
      Overrides:
      adaptTo in class SlingAdaptable
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object