Class FileResource
java.lang.Object
org.apache.sling.api.adapter.SlingAdaptable
org.apache.sling.api.resource.AbstractResource
org.apache.sling.fsprovider.internal.mapper.FileResource
@Adaptable(adaptableClass=Resource.class,adapters={@Adapter({java.io.File.class,java.net.URL.class}),@Adapter(condition="If the resource is an FsResource and is a readable file.",value=java.io.InputStream.class)})
public final class FileResource
extends AbstractResource
The
FsResource
represents a file system file or folder as
a Sling Resource.-
Field Summary
Fields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING
-
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypeReturns an adapter for this resource.@NotNull String
getPath()
Returns the path of this resource@NotNull ResourceMetadata
Returns the resource meta data for this resource containing the file length, last modification time and the resource path (same asgetPath()
).@NotNull ResourceResolver
Returns the resource resolver which cause this resource object to be created.Returns the super type of the resource if the resource defines its own super type.@NotNull String
The resource type is meant to point to rendering/processing scripts, editing dialogs, etc.This method callsAdaptable.adaptTo(Class)
with theValueMap
class as an argument.toString()
Methods inherited from class org.apache.sling.api.resource.AbstractResource
getChild, getChildren, getName, getParent, hasChildren, isResourceType, listChildren
Methods inherited from class org.apache.sling.api.adapter.SlingAdaptable
setAdapterManager, unsetAdapterManager
-
Method Details
-
getPath
Returns the path of this resource- Returns:
- The resource path
-
getResourceMetadata
Returns the resource meta data for this resource containing the file length, last modification time and the resource path (same asgetPath()
).- Returns:
- The resource meta data
- See Also:
-
getResourceResolver
Returns the resource resolver which cause this resource object to be created.- Returns:
- The resource resolver
-
getResourceSuperType
Description copied from interface:Resource
Returns the super type of the resource if the resource defines its own super type. Otherwisenull
is returned. A resource might return a resource super type to overwrite the resource type hierarchy. If a client is interested in the effective resource super type of a resource, it should callResourceResolver.getParentResourceType(Resource)
.- Returns:
- The super type of the resource or
null
.
-
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 theResourceResolver
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
-
adaptTo
Returns an adapter for this resource. This implementation supportsFile
,InputStream
andURL
plus those supported by the adapter manager.- Specified by:
adaptTo
in interfaceAdaptable
- Overrides:
adaptTo
in classSlingAdaptable
- Type Parameters:
AdapterType
- The generic type to which this resource is adapted to- Parameters:
type
- The Class object of the target type, such asjavax.jcr.Node.class
orjava.io.File.class
- Returns:
- The adapter target or
null
if the resource cannot adapt to the requested type
-
toString
-
getValueMap
Description copied from class:AbstractResource
This method callsAdaptable.adaptTo(Class)
with theValueMap
class as an argument. If theadaptTo
method returns a map, this map is returned. If the resource is not adaptable to a value map, next an adaption toMap
is tried and if this is successful the map is wrapped as a value map. If the adaptions are not successful an empty value map is returned.- Specified by:
getValueMap
in interfaceResource
- Overrides:
getValueMap
in classAbstractResource
- Returns:
- A value map
- See Also:
-