public class Jar
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
static class |
Jar.Compression |
Modifier and Type | Field and Description |
---|---|
static java.lang.Object[] |
EMPTY_ARRAY |
Constructor and Description |
---|
Jar(java.io.File f) |
Jar(java.lang.String name) |
Jar(java.lang.String string,
java.io.File file) |
Jar(java.lang.String name,
java.io.File dirOrFile,
java.util.regex.Pattern doNotCopy) |
Jar(java.lang.String string,
java.io.InputStream resourceAsStream) |
Jar(java.lang.String name,
java.io.InputStream in,
long lastModified) |
Jar(java.lang.String name,
java.lang.String path) |
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(Jar src) |
boolean |
addAll(Jar sub,
Instruction filter)
Add all the resources in the given jar that match the given filter.
|
boolean |
addAll(Jar sub,
Instruction filter,
java.lang.String destination)
Add all the resources in the given jar that match the given filter.
|
boolean |
addDirectory(java.util.Map<java.lang.String,Resource> directory,
boolean overwrite) |
void |
calcChecksums(java.lang.String[] algorithms)
Calculate the checksums and set them in the manifest.
|
void |
close() |
void |
copy(Jar srce,
java.lang.String path,
boolean overwrite) |
void |
ensureManifest()
Make sure we have a manifest
|
boolean |
exists(java.lang.String path) |
void |
expand(java.io.File dir)
Expand the JAR file to a directory.
|
java.lang.String |
getBsn()
Get the jar bsn from the
Constants.BUNDLE_SYMBOLICNAME manifest
header. |
java.net.URI |
getDataURI(java.lang.String path,
java.lang.String mime,
int max)
Return a data uri from the JAR.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,Resource>> |
getDirectories() |
java.util.jar.Manifest |
getManifest() |
java.lang.String |
getName() |
java.util.List<java.lang.String> |
getPackages() |
Resource |
getResource(java.lang.String path) |
java.util.Map<java.lang.String,Resource> |
getResources() |
java.io.File |
getSource() |
byte[] |
getTimelessDigest() |
java.lang.String |
getVersion()
Get the jar version from the
Constants.BUNDLE_VERSION manifest
header. |
Jar.Compression |
hasCompression() |
boolean |
hasDirectory(java.lang.String path) |
boolean |
isManifestFirst()
Answer if the manifest was the first entry
|
long |
lastModified() |
static void |
outputManifest(java.util.jar.Manifest manifest,
java.io.OutputStream out)
Main function to output a manifest properly in UTF-8.
|
boolean |
putResource(java.lang.String path,
Resource resource) |
boolean |
putResource(java.lang.String path,
Resource resource,
boolean overwrite) |
Resource |
remove(java.lang.String path) |
boolean |
rename(java.lang.String oldPath,
java.lang.String newPath) |
void |
setCompression(Jar.Compression compression) |
void |
setDigestAlgorithms(java.lang.String[] algorithms) |
void |
setDoNotTouchManifest()
Make sure nobody touches the manifest! If the bundle is signed, we do not
want anybody to touch the manifest after the digests have been
calculated.
|
void |
setManifest(java.io.File file) |
void |
setManifest(java.util.jar.Manifest manifest) |
void |
setManifestName(java.lang.String manifestName) |
void |
setName(java.lang.String name) |
void |
setReporter(aQute.service.reporter.Reporter reporter) |
java.lang.String |
toString() |
void |
updateModified(long time,
java.lang.String reason) |
void |
write(java.io.File file) |
void |
write(java.io.OutputStream out) |
void |
write(java.lang.String file) |
static void |
writeManifest(java.util.jar.Manifest manifest,
java.io.OutputStream out) |
void |
writeManifest(java.io.OutputStream out)
Cleanup the manifest for writing.
|
public Jar(java.lang.String name)
public Jar(java.lang.String name, java.io.File dirOrFile, java.util.regex.Pattern doNotCopy) throws java.util.zip.ZipException, java.io.IOException
java.util.zip.ZipException
java.io.IOException
public Jar(java.lang.String name, java.io.InputStream in, long lastModified) throws java.io.IOException
java.io.IOException
public Jar(java.lang.String name, java.lang.String path) throws java.io.IOException
java.io.IOException
public Jar(java.io.File f) throws java.io.IOException
java.io.IOException
public Jar(java.lang.String string, java.io.InputStream resourceAsStream) throws java.io.IOException
java.io.IOException
public Jar(java.lang.String string, java.io.File file) throws java.util.zip.ZipException, java.io.IOException
java.util.zip.ZipException
java.io.IOException
public void setName(java.lang.String name)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean putResource(java.lang.String path, Resource resource)
public boolean putResource(java.lang.String path, Resource resource, boolean overwrite)
public Resource getResource(java.lang.String path)
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,Resource>> getDirectories()
public java.util.Map<java.lang.String,Resource> getResources()
public boolean addDirectory(java.util.Map<java.lang.String,Resource> directory, boolean overwrite)
public java.util.jar.Manifest getManifest() throws java.lang.Exception
java.lang.Exception
public boolean exists(java.lang.String path)
public void setManifest(java.util.jar.Manifest manifest)
public void setManifest(java.io.File file) throws java.io.IOException
java.io.IOException
public void setManifestName(java.lang.String manifestName)
public void write(java.io.File file) throws java.lang.Exception
java.lang.Exception
public void write(java.lang.String file) throws java.lang.Exception
java.lang.Exception
public void write(java.io.OutputStream out) throws java.lang.Exception
java.lang.Exception
public void writeManifest(java.io.OutputStream out) throws java.lang.Exception
out
- Outputjava.io.IOException
java.lang.Exception
public static void writeManifest(java.util.jar.Manifest manifest, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static void outputManifest(java.util.jar.Manifest manifest, java.io.OutputStream out) throws java.io.IOException
manifest
- The manifest to outputout
- The output streamjava.io.IOException
- when something failspublic java.lang.String getName()
public boolean addAll(Jar sub, Instruction filter)
sub
- the jarfilter
- a pattern that should match the resoures in sub to be addedpublic boolean addAll(Jar sub, Instruction filter, java.lang.String destination)
sub
- the jarfilter
- a pattern that should match the resoures in sub to be addedpublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public long lastModified()
public void updateModified(long time, java.lang.String reason)
public void setReporter(aQute.service.reporter.Reporter reporter)
public boolean hasDirectory(java.lang.String path)
public java.util.List<java.lang.String> getPackages()
public java.io.File getSource()
public boolean addAll(Jar src)
public boolean rename(java.lang.String oldPath, java.lang.String newPath)
public Resource remove(java.lang.String path)
public void setDoNotTouchManifest()
public void calcChecksums(java.lang.String[] algorithms) throws java.lang.Exception
java.lang.Exception
public java.lang.String getBsn() throws java.lang.Exception
Constants.BUNDLE_SYMBOLICNAME
manifest
header.Constants.BUNDLE_SYMBOLICNAME
header, or when the value
of the header is not a valid bsn according to BSN
.java.lang.Exception
- when the jar is closed or when the manifest could not be
retrieved.public java.lang.String getVersion() throws java.lang.Exception
Constants.BUNDLE_VERSION
manifest
header.Constants.BUNDLE_VERSION
headerjava.lang.Exception
- when the jar is closed or when the manifest could not be
retrieved.public void expand(java.io.File dir) throws java.lang.Exception
dir
- the dst directory, is not required to existjava.lang.Exception
- if anything does not work as expected.public void ensureManifest() throws java.lang.Exception
java.lang.Exception
public boolean isManifestFirst()
public void copy(Jar srce, java.lang.String path, boolean overwrite)
public void setCompression(Jar.Compression compression)
public Jar.Compression hasCompression()
public java.net.URI getDataURI(java.lang.String path, java.lang.String mime, int max) throws java.lang.Exception
jar
- The jar to load the data frompath
- the path in the jarmime
- the mime typejava.lang.Exception
public void setDigestAlgorithms(java.lang.String[] algorithms)
public byte[] getTimelessDigest() throws java.lang.Exception
java.lang.Exception