java.lang.Object
io.inverno.mod.base.resource.AbstractResource
- All Implemented Interfaces:
Resource
,AutoCloseable
- Direct Known Subclasses:
AbstractAsyncResource
Base implementation for Resource
.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final boolean
Flag indicating whether paths are Windows path (i.e. using\
as path separator). -
Constructor Summary
ModifierConstructorDescriptionCreates a resource.protected
AbstractResource
(MediaTypeService mediaTypeService) Creates a resource with the specified media type service. -
Method Summary
Modifier and TypeMethodDescriptionReturns the resource media type.protected MediaTypeService
Returns the media type service.protected static String
pathToSanitizedString
(Path path) Returns a sanitized path representation of the specified path by normalizing it and replacing\
path separator by standard/
path separator.final void
setMediaTypeService
(MediaTypeService mediaTypeService) Sets the media type service.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.base.resource.Resource
close, delete, exists, getFilename, getURI, isFile, lastModified, openReadableByteChannel, openWritableByteChannel, openWritableByteChannel, openWritableByteChannel, read, resolve, resolve, size, write, write, write
-
Field Details
-
IS_WINDOWS_PATH
protected static final boolean IS_WINDOWS_PATHFlag indicating whether paths are Windows path (i.e. using\
as path separator).
-
-
Constructor Details
-
AbstractResource
public AbstractResource()Creates a resource.
-
AbstractResource
Creates a resource with the specified media type service.
- Parameters:
mediaTypeService
- a media type service
-
-
Method Details
-
pathToSanitizedString
Returns a sanitized path representation of the specified path by normalizing it and replacing
\
path separator by standard/
path separator.- Parameters:
path
- the path to sanitize- Returns:
- a sanitized representation of the path
-
setMediaTypeService
Sets the media type service.
- Parameters:
mediaTypeService
- the media type service to set
-
getMediaTypeService
Returns the media type service.
- Returns:
- a media type service or the default media type service if not set
-
getMediaType
Description copied from interface:Resource
Returns the resource media type.
- Specified by:
getMediaType
in interfaceResource
- Returns:
- the resource media type or null if it couldn't be determined
- Throws:
ResourceException
- if there was an error resolving the resource media type
-