commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandy McArthur" <sandy...@apache.org>
Subject Re: [compress] Interface is ready
Date Sun, 02 Apr 2006 18:26:36 GMT
On 4/2/06, C. Grobmeier <grobmeier@possessed.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Stephen Colebourne wrote:
> > I haven't been following this thread closely. However I just took a
> > quick look at the zip.
>
> Thanks for that.
>
> > The ArchiverType/CompressorType interfaces will be a problem. They
> > indicate that they must be changed when a new type is added to
> > [compress]. But commons has pretty strict rules about not changing
> > interfaces.
>
> I will change this and use constants instead.
> Is there a website regarding the mentioned rules?

This is where a type safe enum makes sense. Since it seems you would
want to make it extendable it would take a little extra effort:

public abstract class ArchiverType {
  private final String name;
  protected ArchiverType(String name) { this.name = name; }

  public static ArchiverType ZIP = new ArchiverType("ZIP") {
    public Archiver getInstance() { return new ZipArchiver(); }
  };

  public static ArchiverType TAR = new ArchiverType("TAR") {
    public Archiver getInstance() { return new TarArchiver(); }
  };

  public abstract Archive getInstance();

  public String toString() { return name; }
}

This form also elimates the need for Archive class as it's only method
is a static  getInstance(ArchiverType) which isn't extendable anyways.

> > Personally, I was also unclear as to the reason why there is a split
> > between archiver and compressor, but then I don't know the low level of
> > these APIs that well.
>
> Archiving and compressing are two different things; while you can add
> more files to a tar-archive, you can't do that to bzip2/gunzip etc.
> I didn't want methods in one single interface which work for this format
> but not sometimes not for other operations.
>
> I think it's more easy to recognize that you have to use Archiver for
> archiving and Compressor for compressing instead to know what the
> methods do exactly.
>
> Cheers + Thanks,
> Chris
>
>
> > Stephen
> >
> >
> > C. Grobmeier wrote:
> > Hey all,
> >
> > i have just uploaded this:
> > http://www.grobmeier.de/commons-compress-draft-4.zip
> >
> > Tar, Zip and BZip2 is now implemented by the 2 new interfaces.
> > Please check it out, and tell me, if something more i have to do
> > before it can be comitted to the compress-code.
> >
> > If this looks ok, i will create a bug in bugzilla and add this zip
> > as attachment.
> >
> > Looking forward to read your comments-
> > Cheers
> > Chris.
> >>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >>
> >>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.1 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFEL5Dzkv8rKBUE/T4RAiYBAJ9ZIck108krrbQihjmqjT9MNyJtigCfef9y
> s9z0WtbwF7JSarfJ8E1Jt9Q=
> =XNia
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>


--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message