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

Discussion in 'Java' started by christian.bongiorno@gmail.com, Mar 9, 2006.

  1. Guest

    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
     
    , Mar 9, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Suganya
    Replies:
    0
    Views:
    475
    Suganya
    Apr 29, 2008
  2. Replies:
    3
    Views:
    1,593
  3. Replies:
    0
    Views:
    264
  4. m.niinimaki
    Replies:
    9
    Views:
    1,107
    steph
    Aug 29, 2010
  5. David Karr
    Replies:
    2
    Views:
    524
    J. Gleixner
    Jun 1, 2012
Loading...

Share This Page