Package aQute.bnd.osgi
Interface Resource
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
AbstractResource
,CalltreeResource
,CombinedResource
,CommandResource
,CoverageResource
,EmbeddedResource
,FileResource
,JarResource
,ManifestResource
,MetaTypeReader
,PomFromManifest
,PomPropertiesResource
,PomResource
,PreprocessResource
,PropertiesResource
,TagResource
,WriteResource
,ZipResource
public interface Resource extends java.io.Closeable
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.nio.ByteBuffer
buffer()
static byte[]
decodeExtra(java.lang.String encoded)
Decode a String to a ZIP extra field.static java.lang.String
encodeExtra(byte[] extra)
Encode the ZIP extra field as a String.static Resource
fromURL(java.net.URL url)
static Resource
fromURL(java.net.URL url, HttpClient client)
java.lang.String
getExtra()
UsedecodeExtra(String)
to properly decode the ZIP extra field structured binary data from the returned String.long
lastModified()
java.io.InputStream
openInputStream()
void
setExtra(java.lang.String extra)
UseencodeExtra(byte[])
to properly encode the ZIP extra field structured binary data into the specified String.long
size()
default void
write(java.io.File file)
void
write(java.io.OutputStream out)
default void
write(java.nio.file.Path path)
-
-
-
Method Detail
-
openInputStream
java.io.InputStream openInputStream() throws java.lang.Exception
- Throws:
java.lang.Exception
-
write
void write(java.io.OutputStream out) throws java.lang.Exception
- Throws:
java.lang.Exception
-
write
default void write(java.io.File file) throws java.lang.Exception
- Throws:
java.lang.Exception
-
write
default void write(java.nio.file.Path path) throws java.lang.Exception
- Throws:
java.lang.Exception
-
lastModified
long lastModified()
-
setExtra
void setExtra(java.lang.String extra)
UseencodeExtra(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
java.lang.String getExtra()
UsedecodeExtra(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 java.lang.Exception
- Throws:
java.lang.Exception
-
buffer
java.nio.ByteBuffer buffer() throws java.lang.Exception
- Throws:
java.lang.Exception
-
fromURL
static Resource fromURL(java.net.URL url) throws java.io.IOException
- Throws:
java.io.IOException
-
fromURL
static Resource fromURL(java.net.URL url, HttpClient client) throws java.io.IOException
- Throws:
java.io.IOException
-
encodeExtra
static java.lang.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:
- Section 4.5 - Extensible data fields
-
decodeExtra
static byte[] decodeExtra(java.lang.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:
- Section 4.5 - Extensible data fields
-
-