Java Code Examples for java.util.jar.JarEntry#setExtra()

The following examples show how to use java.util.jar.JarEntry#setExtra() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jar.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
private static JarEntry newJarEntry(Entry entry) {
    final JarEntry result = new JarEntry(entry.getName());
    if (result.getCreationTime() != null) {
        result.setCreationTime(entry.getCreationTime());
    }
    if (result.getLastModifiedTime() != null) {
        result.setLastModifiedTime(entry.getLastModifiedTime());
    }
    if (entry.getExtra() != null) {
        result.setExtra(entry.getExtra());
    }
    if (result.getComment() != null) {
        result.setComment(entry.getComment());
    }
    if (!entry.isDirectory()) {
        final int method = entry.getMethod();
        if (method == JarEntry.STORED || method == ZipEntry.DEFLATED) {
            result.setMethod(method);
        }
    }
    return result;
}
 
Example 2
Source File: Repackager.java    From sofa-ark with Apache License 2.0 6 votes vote down vote up
@Override
public JarEntry transform(JarEntry entry) {
    JarEntry renamedEntry = new JarEntry(this.namePrefix + entry.getName());
    renamedEntry.setTime(entry.getTime());
    renamedEntry.setSize(entry.getSize());
    renamedEntry.setMethod(entry.getMethod());
    if (entry.getComment() != null) {
        renamedEntry.setComment(entry.getComment());
    }
    renamedEntry.setCompressedSize(entry.getCompressedSize());
    renamedEntry.setCrc(entry.getCrc());
    //setCreationTimeIfPossible(entry, renamedEntry);
    if (entry.getExtra() != null) {
        renamedEntry.setExtra(entry.getExtra());
    }
    return renamedEntry;
}
 
Example 3
Source File: Saver.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
public static void packFile(JarOutputStream out, JarEntry oldEntry, String path, byte[] data) throws IOException {
	JarEntry newEntry = new JarEntry(path);
	newEntry.setTime(oldEntry.getTime());
	// newEntry.setMethod(oldEntry.getMethod());
	newEntry.setComment(oldEntry.getComment());
	newEntry.setExtra(oldEntry.getExtra());

	out.putNextEntry(newEntry);
	out.write(data, 0, data.length);
	out.closeEntry();
}
 
Example 4
Source File: ZipEntryTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testClone() {
  byte[] extra = { 5, 7, 9 };
  JarEntry jarEntry = new JarEntry("foo");
  jarEntry.setExtra(extra);
  assertSame("Expected no defensive copy of extra", extra, jarEntry.getExtra());

  ZipEntry clone = (ZipEntry) jarEntry.clone();
  assertEquals(JarEntry.class, clone.getClass());
  assertNotSame(extra, clone.getExtra());
}
 
Example 5
Source File: JarStreamingAssembly.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
private static JarEntry smartClone(JarEntry originalJarEntry) {
    final JarEntry newJarEntry = new JarEntry(originalJarEntry.getName());
    newJarEntry.setComment(originalJarEntry.getComment());
    newJarEntry.setExtra(originalJarEntry.getExtra());
    newJarEntry.setMethod(originalJarEntry.getMethod());
    newJarEntry.setTime(originalJarEntry.getTime());

    //Must set size and CRC for STORED entries
    if (newJarEntry.getMethod() == ZipEntry.STORED) {
        newJarEntry.setSize(originalJarEntry.getSize());
        newJarEntry.setCrc(originalJarEntry.getCrc());
    }

    return newJarEntry;
}