Interface Transport

All Superinterfaces:
AutoCloseable, Closeable

@Experimental @Consumer public interface Transport extends Closeable
Transport for specified remote repository (using provided remote repository base URI as root). Must be treated as a resource, best in try-with-resource block.
Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    get(URI relativeSource, Path target)
    GETs the source URI content into target (does not have to exist, or will be overwritten if exist).
    Optional<byte[]>
    getBytes(URI relativeSource)
    GETs the source URI content as byte array.
    default Optional<String>
    getString(URI relativeSource)
    GETs the source URI content as string using UTF8 charset.
    getString(URI relativeSource, Charset charset)
    GETs the source URI content as string.
    void
    put(Path source, URI relativeTarget)
    PUTs the source file (must exist as file) to target URI.
    void
    putBytes(byte[] source, URI relativeTarget)
    PUTs the source byte array to target URI.
    default void
    putString(String source, URI relativeTarget)
    PUTs the source string using UTF8 charset to target URI.
    void
    putString(String source, Charset charset, URI relativeTarget)
    PUTs the source string to target URI.

    Methods inherited from interface Closeable

    close
  • Method Details

    • get

      boolean get(@Nonnull URI relativeSource, @Nonnull Path target)
      GETs the source URI content into target (does not have to exist, or will be overwritten if exist). The source MUST BE relative from the RemoteRepository.getUrl() root.
      Returns:
      true if operation succeeded, false if source does not exist.
      Throws:
      RuntimeException - If failed (and not due source not exists).
    • getBytes

      @Nonnull Optional<byte[]> getBytes(@Nonnull URI relativeSource)
      GETs the source URI content as byte array. The source MUST BE relative from the RemoteRepository.getUrl() root.
      Returns:
      the byte array if operation succeeded, null if source does not exist.
      Throws:
      RuntimeException - If failed (and not due source not exists).
    • getString

      @Nonnull Optional<String> getString(@Nonnull URI relativeSource, @Nonnull Charset charset)
      GETs the source URI content as string. The source MUST BE relative from the RemoteRepository.getUrl() root.
      Returns:
      the string if operation succeeded, null if source does not exist.
      Throws:
      RuntimeException - If failed (and not due source not exists).
    • getString

      @Nonnull default Optional<String> getString(@Nonnull URI relativeSource)
      GETs the source URI content as string using UTF8 charset. The source MUST BE relative from the RemoteRepository.getUrl() root.
      Returns:
      the string if operation succeeded, null if source does not exist.
      Throws:
      RuntimeException - If failed (and not due source not exists).
    • put

      void put(@Nonnull Path source, @Nonnull URI relativeTarget)
      PUTs the source file (must exist as file) to target URI. The target MUST BE relative from the RemoteRepository.getUrl() root.
      Throws:
      RuntimeException - If PUT fails for any reason.
    • putBytes

      void putBytes(@Nonnull byte[] source, @Nonnull URI relativeTarget)
      PUTs the source byte array to target URI. The target MUST BE relative from the RemoteRepository.getUrl() root.
      Throws:
      RuntimeException - If PUT fails for any reason.
    • putString

      void putString(@Nonnull String source, @Nonnull Charset charset, @Nonnull URI relativeTarget)
      PUTs the source string to target URI. The target MUST BE relative from the RemoteRepository.getUrl() root.
      Throws:
      RuntimeException - If PUT fails for any reason.
    • putString

      default void putString(@Nonnull String source, @Nonnull URI relativeTarget)
      PUTs the source string using UTF8 charset to target URI. The target MUST BE relative from the RemoteRepository.getUrl() root.
      Throws:
      RuntimeException - If PUT fails for any reason.