Interface Resource

All Superinterfaces:
Broadcaster, ByteSized, Listener, ModificationTimestamped, NamedObject, Readable, ReadableResource, Receiver<Transmittable>, Repeater, Resourceful, ResourcePathed, Transceiver, Transmitter<Transmittable>
All Known Subinterfaces:
FileService, NetworkResource, WritableResource
All Known Implementing Classes:
BaseHttpResource, BaseNetworkResource, BaseReadableResource, BaseWritableResource, File, FtpResource, HttpGetResource, HttpPostResource, HttpPutResource, InputResource, NullResource, OutputResource, PackageResource, ResourceSection, SecureFtpResource, SecureHttpGetResource, SecureHttpPostResource, StringResource, ZipEntry

A resource that can be read via ReadableResource. In addition, resources are ModificationTimestamped, ByteSized and are message Repeaters. A resource can be created by instantiating a concrete implementation of Resource or one can be resolved from an abstract ResourceIdentifier with resolve(ResourceIdentifier).

Examples

Some examples of resources include:

Properties

Operations

Checks

  • Field Details

    • LOGGER

      static final Logger LOGGER
  • Method Details

    • argumentListParser

      static ArgumentParser.Builder<ResourceList> argumentListParser(String description, Extension extension)
    • argumentParser

      static ArgumentParser.Builder<Resource> argumentParser(Listener listener, String description)
    • identifier

      static ResourceIdentifier identifier(String identifier)
    • resolve

      static Resource resolve(ResourceIdentifier identifier)
    • resolve

      static Resource resolve(String identifier)
    • resourceListSwitchParser

      static SwitchParser.Builder<ResourceList> resourceListSwitchParser(String name, String description, Extension extension)
    • resourceSwitchParser

      static SwitchParser.Builder<Resource> resourceSwitchParser(Listener listener, String name, String description)
    • codec

      Codec codec()
      Returns:
      Any codec for compression / decompression
    • dematerialize

      default void dematerialize()
      Remove any materialized local copy if this is a remote resource that's been cached
    • ensureExists

      default void ensureExists()
      Ensures that this file exists or throws a runtime exception
    • exists

      boolean exists()
      Returns:
      True if the resource exists
    • isEmpty

      default boolean isEmpty()
    • isLocal

      default boolean isLocal()
    • isMaterializable

      default boolean isMaterializable()
    • isPackaged

      default boolean isPackaged()
      Returns:
      True if this resource is in a JAR file
    • isRemote

      default boolean isRemote()
      Returns:
      True if this resource is on a remote filesystem
    • isSame

      default boolean isSame(Resource that)
      Returns:
      True if the given resource has the same last modified time and the same size
    • materialized

      Resource materialized(ProgressReporter reporter)
      Returns:
      A local cached copy of this resource if it is remote.
    • path

      ResourcePath path()
      StringPath to this resource
      Specified by:
      path in interface ResourcePathed
      Returns:
      The path to this object
    • resource

      default Resource resource()
      Specified by:
      resource in interface ReadableResource
      Specified by:
      resource in interface Resourceful
      Returns:
      The resource being read
    • safeCopyTo

      default void safeCopyTo(Folder destination, CopyMode mode)
      Copies this readable resource to the given folder safely
      Parameters:
      destination - The file to copy to
      mode - Copying semantics
    • safeCopyTo

      default void safeCopyTo(Folder destination, CopyMode mode, ProgressReporter reporter)
      Copies this readable resource to the given folder safely
      Parameters:
      destination - The file to copy to
      mode - Copying semantics
    • safeCopyTo

      default void safeCopyTo(File destination, CopyMode mode)
      Copies this resource to the given file safely (ensuring that a corrupted copy of the file never exists). This is done by first copying to a temporary file in the same folder. If the copy operation is successful, the destination file is then removed and the temporary file is renamed to the destination file's name.
      Parameters:
      destination - The file to copy to
      mode - Copying semantics
    • safeCopyTo

      default void safeCopyTo(File destination, CopyMode mode, ProgressReporter reporter)
      Copies this resource to the given file safely (ensuring that a corrupted copy of the file never exists). This is done by first copying to a temporary file in the same folder. If the copy operation is successful, the destination file is then removed and the temporary file is renamed to the destination file's name.
      Parameters:
      destination - The file to copy to
      mode - Copying semantics
      reporter - Progress reporter to call as copy proceeds