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
FieldsModifier and TypeFieldDescriptionprotected static final booleanFlag indicating whether paths are Windows path (i.e. using\as path separator). -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a resource.protectedAbstractResource(MediaTypeService mediaTypeService) Creates a resource with the specified media type service. -
Method Summary
Modifier and TypeMethodDescriptionReturns the resource media type.protected MediaTypeServiceReturns the media type service.protected static StringpathToSanitizedString(Path path) Returns a sanitized path representation of the specified path by normalizing it and replacing\path separator by standard/path separator.final voidsetMediaTypeService(MediaTypeService mediaTypeService) Sets the media type service.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ResourceReturns the resource media type.
- Specified by:
getMediaTypein 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
-