Interface Resource
-
- All Known Subinterfaces:
RangeAwareResource
- All Known Implementing Classes:
CachedResource,FileResource,PathResource,URLResource
public interface ResourceRepresentation of a static resource.- Author:
- Stuart Douglas
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetCacheKey()java.lang.LonggetContentLength()java.lang.StringgetContentType(MimeMappings mimeMappings)Return the resources content type.ETaggetETag()java.io.FilegetFile()java.nio.file.PathgetFilePath()java.util.DategetLastModified()java.lang.StringgetLastModifiedString()java.lang.StringgetName()java.lang.StringgetPath()java.io.FilegetResourceManagerRoot()Returns the resource manager root.java.nio.file.PathgetResourceManagerRootPath()Returns the resource manager root.java.net.URLgetUrl()booleanisDirectory()java.util.List<Resource>list()voidserve(Sender sender, HttpServerExchange exchange, IoCallback completionCallback)Serve the resource, and call the provided callback when complete.
-
-
-
Method Detail
-
getPath
java.lang.String getPath()
- Returns:
- The path from the resource manager root
-
getLastModified
java.util.Date getLastModified()
- Returns:
- The last modified date of this resource, or null if this cannot be determined
-
getLastModifiedString
java.lang.String getLastModifiedString()
- Returns:
- A string representation of the last modified date, or null if this cannot be determined
-
getETag
ETag getETag()
- Returns:
- The resources etags
-
getName
java.lang.String getName()
- Returns:
- The name of the resource
-
isDirectory
boolean isDirectory()
- Returns:
trueif this resource represents a directory
-
list
java.util.List<Resource> list()
- Returns:
- a list of resources in this directory
-
getContentType
java.lang.String getContentType(MimeMappings mimeMappings)
Return the resources content type. In most cases this will simply use the provided mime mappings, however in some cases the resource may have additional information as to the actual content type.
-
serve
void serve(Sender sender, HttpServerExchange exchange, IoCallback completionCallback)
Serve the resource, and call the provided callback when complete.- Parameters:
sender- The sender to use.exchange- The exchange
-
getContentLength
java.lang.Long getContentLength()
- Returns:
- The content length, or null if it is unknown
-
getCacheKey
java.lang.String getCacheKey()
- Returns:
- A string that uniquely identifies this resource
-
getFile
java.io.File getFile()
- Returns:
- The underlying file that matches the resource. This may return null if the resource does not map to a file
-
getFilePath
java.nio.file.Path getFilePath()
- Returns:
- The underlying file that matches the resource. This may return null if the resource does not map to a file
-
getResourceManagerRoot
java.io.File getResourceManagerRoot()
Returns the resource manager root. If the resource manager has multiple roots then this returns the one that is the parent of this resource.- Returns:
- a file representing the resource manager root. This may return null if the resource does not map to a file
-
getResourceManagerRootPath
java.nio.file.Path getResourceManagerRootPath()
Returns the resource manager root. If the resource manager has multiple roots then this returns the one that is the parent of this resource.- Returns:
- a path representing the resource manager root. This may return null if the resource does not map to a file
-
getUrl
java.net.URL getUrl()
- Returns:
- The URL of the resource
-
-