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. Advertisements

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. sunil_varma
    Replies:
    1
    Views:
    1,595
  2. cyberco
    Replies:
    4
    Views:
    4,205
    Roedy Green
    Feb 14, 2006
  3. Suganya
    Replies:
    0
    Views:
    590
    Suganya
    Apr 29, 2008
  4. Replies:
    3
    Views:
    2,210
  5. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    667
    Fredrik Lundh
    Aug 13, 2008
  6. Replies:
    0
    Views:
    316
  7. m.niinimaki
    Replies:
    9
    Views:
    1,303
    steph
    Aug 29, 2010
  8. David Karr
    Replies:
    2
    Views:
    613
    J. Gleixner
    Jun 1, 2012
Loading...