Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Your thoughts on Java API and Archives (zip,jar etc..)

Reply
Thread Tools

Your thoughts on Java API and Archives (zip,jar etc..)

 
 
christian.bongiorno@gmail.com
Guest
Posts: n/a
 
      03-09-2006
So, I have been working extensively with jar files of late and now we
need to migrate to tar files, and the nagging problem continues to be

LACK OF INTERFACE!

I mean, the use of a jar and a manifest using the API's is really
whacked -- you can't create a Manifest and add entries to it, you have
to create a properly formatted UTF-8 byte sequence. But of course, you
can READ manifest entries all day.

Now we have the issue of the Streams and files. The streams have a
handfull of methods in common, but do things like:

ZipEntry getNextEntry()

JarEntry getNextJarEntry()

Now, the implementation I have found for tar (which the API's do not
have) is that they too have similar method names (close(),
putNextEntry()) etc, but because there isn't a common interface for
archives, I cannot seemlessly process the above mentioned types.

What I have done, to facilitate thise generic behavior is to implement
a combination of adapter interfaces and delegation -- and then I only
have to switch my current code to the new interface.

basically, I have done is

public interface ArchiveInputStream {

public ArchiveEntry nextEntry() throws IOException;

public int read(byte[] outBucket,int start, int amount) throws
IOException;

public void close() throws IOException;
}

public class MyJarInputStream extends JarInputStream implements
ArchiveInputStream {
private static final Log logger =
LogFactory.getLog(DaveJarInputStream.class);

public MyJarInputStream (InputStream in) throws IOException {
super(in);
}

public ArchiveEntry nextEntry() throws IOException {
return new JarArchiveEntry(getNextJarEntry());
}

}

I have done the same trick with the entry types for the archives and
OutputStreams

This seems to me to be exceptionally poor design in the Java libraries
-- a rarity.
Thoughts? Am I just spiking my java with peyote or what?

Christian

http://christian.bongiorno.org

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to properly recursively navigate into archives stored in archives David Karr Perl Misc 2 06-01-2012 05:54 PM
creating identical zip archives with java and zip tools m.niinimaki Java 9 08-29-2010 10:13 AM
"Change your language and you change your thoughts." Suganya C Programming 0 04-29-2008 01:35 PM
Python 3000: Standard API for archives? samwyse Python 3 06-05-2007 06:48 PM
RMI and Java-Archives! nullstring Java 1 11-15-2006 04:12 PM



Advertisments