Interface Resource
-
- All Known Subinterfaces:
RangeAwareResource
- All Known Implementing Classes:
CachedResource
,FileResource
,PathResource
,URLResource
public interface Resource
Representation of a static resource.- Author:
- Stuart Douglas
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getCacheKey()
java.lang.Long
getContentLength()
java.lang.String
getContentType(MimeMappings mimeMappings)
Return the resources content type.ETag
getETag()
java.io.File
getFile()
java.nio.file.Path
getFilePath()
java.util.Date
getLastModified()
java.lang.String
getLastModifiedString()
java.lang.String
getName()
java.lang.String
getPath()
java.io.File
getResourceManagerRoot()
Returns the resource manager root.java.nio.file.Path
getResourceManagerRootPath()
Returns the resource manager root.java.net.URL
getUrl()
boolean
isDirectory()
java.util.List<Resource>
list()
void
serve(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:
true
if 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
-
-