Interface Resource

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractResource, CalltreeResource, CombinedResource, CommandResource, CoverageResource, EmbeddedResource, FileResource, JarResource, ManifestResource, MetaTypeReader, PomFromManifest, PomPropertiesResource, PomResource, PreprocessResource, PropertiesResource, TagResource, URLResource, WriteResource, ZipResource

public interface Resource extends Closeable
  • Method Details

    • openInputStream

      InputStream openInputStream() throws Exception
      Throws:
      Exception
    • write

      void write(OutputStream out) throws Exception
      Throws:
      Exception
    • write

      default void write(File file) throws Exception
      Throws:
      Exception
    • write

      default void write(Path path) throws Exception
      Throws:
      Exception
    • lastModified

      long lastModified()
    • setExtra

      void setExtra(String extra)
      Use encodeExtra(byte[]) to properly encode the ZIP extra field structured binary data into the specified String.
      Parameters:
      extra - A String encoding the ZIP extra field.
    • getExtra

      String getExtra()
      Use decodeExtra(String) to properly decode the ZIP extra field structured binary data from the returned String.
      Returns:
      A String encoding the ZIP extra field.
    • size

      long size() throws Exception
      Throws:
      Exception
    • buffer

      ByteBuffer buffer() throws Exception
      Throws:
      Exception
    • fromURL

      static Resource fromURL(URL url) throws IOException
      Throws:
      IOException
    • fromURL

      static Resource fromURL(URL url, HttpClient client) throws IOException
      Throws:
      IOException
    • encodeExtra

      static String encodeExtra(byte[] extra)
      Encode the ZIP extra field as a String.

      Since the Resource API uses a String as the storage format for the extra field and the extra field is structured binary data, we encode the byte array as a char array in a String. Since the byte array can have an odd length, we must also encode the array length so that we can decode into the correct byte array length.

      Parameters:
      extra - A ZIP extra field.
      Returns:
      A String encoding of the specified ZIP extra field.
      See Also:
    • decodeExtra

      static byte[] decodeExtra(String encoded)
      Decode a String to a ZIP extra field.

      Since the Resource API uses a String as the storage format for the extra field and the extra field is structured binary data, we encode the byte array as a char array in a String. Since the byte array can have an odd length, we must also encode the array length so that we can decode into the correct byte array length.

      Parameters:
      encoded - A String encoding of the ZIP extra field.
      Returns:
      The ZIP extra field encoded in the specified string.
      See Also: