Class AbstractResource

java.lang.Object
io.inverno.mod.base.resource.AbstractResource
All Implemented Interfaces:
Resource, AutoCloseable
Direct Known Subclasses:
AbstractAsyncResource

public abstract class AbstractResource extends Object implements Resource

Base implementation for Resource.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Field Details

    • IS_WINDOWS_PATH

      protected static final boolean IS_WINDOWS_PATH
      Flag indicating whether paths are Windows path (i.e. using \ as path separator).
  • Constructor Details

    • AbstractResource

      public AbstractResource()

      Creates a resource.

    • AbstractResource

      protected AbstractResource(MediaTypeService mediaTypeService)

      Creates a resource with the specified media type service.

      Parameters:
      mediaTypeService - a media type service
  • Method Details

    • pathToSanitizedString

      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.

      Parameters:
      path - the path to sanitize
      Returns:
      a sanitized representation of the path
    • setMediaTypeService

      public final void setMediaTypeService(MediaTypeService mediaTypeService)

      Sets the media type service.

      Parameters:
      mediaTypeService - the media type service to set
    • getMediaTypeService

      protected MediaTypeService getMediaTypeService()

      Returns the media type service.

      Returns:
      a media type service or the default media type service if not set
    • getMediaType

      public String getMediaType() throws ResourceException
      Description copied from interface: Resource

      Returns the resource media type.

      Specified by:
      getMediaType in interface Resource
      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