-
1. Re: SHRINKWRAP-97: Verbose toString format
alrubinger Dec 5, 2009 10:58 PM (in response to alrubinger)Or perhaps this is another one for user choice:
archive.toString(Verbosity.ALL); // Jesper's proposal; parent dirs listed archive.toString(Verbosity.CONTENTS); // Current impl archive.toString(Verbosity.MINIMAL); // Same as archive.toString() archive.toString(true); // We deprecate this, defaulting to Verbosity.CONTENTS
S,
ALR -
2. Re: SHRINKWRAP-97: Verbose toString format
aslak Dec 6, 2009 4:36 AM (in response to alrubinger)Having all these different versions of toString seems a bit odd to me.
Is there a usecase for the string representation outside of 'debug/log' ?
Maybe we should move it to a Visitor of the Content instead?public interface Printer { void write(Asset, Path, PrintStream) } archive.print(Printers.minimal(), System.out) archive.print(Printers.content())
And the toString could be a simplearchive.toString() { return name + content.toString() }
-
3. Re: SHRINKWRAP-97: Verbose toString format
alrubinger Dec 6, 2009 10:02 AM (in response to alrubinger)"aslak" wrote:
Having all these different versions of toString seems a bit odd to me.
My example still has one overloaded toString; only instead of accepting a boolean is takes in an enum.
I think the Visitor approach just moves the problem and makes it more complex.
But I'd still like to understand the requirements/desire behind the request. Why the empty dirs? :)
S,
ALR -
4. Re: SHRINKWRAP-97: Verbose toString format
jaikiran Dec 6, 2009 12:05 PM (in response to alrubinger)"ALRubinger" wrote:
But I'd still like to understand the requirements/desire behind the request. Why the empty dirs? :)
S,
ALR
Just to be sure - we aren't talking about "empty" dirs, are we? From the example posted earlier in this thread, we are talking about "parent" dirs. Although i don't see an advantage as such, i do think it would be good to print the parents too (as Jesper suggests) since it would then match the output of the standard:jar -tf somejar.jar
-
5. Re: SHRINKWRAP-97: Verbose toString format
alrubinger Dec 6, 2009 12:17 PM (in response to alrubinger)"jaikiran" wrote:
Just to be sure - we aren't talking about "empty" dirs, are we?
Right; they're not "empty", just parents of directories which contain resources. Actually ShrinkWrap doesn't even support empty directories ATM. So:
https://jira.jboss.org/jira/browse/SHRINKWRAP-104"jaikiran" wrote:
i do think it would be good to print the parents too (as Jesper suggests) since it would then match the output of the standard (jar utility)
Thanks for the input. The more I think on this the more I think we need user options. I personally find the extra parent dirs a bit unnecessary/noisy in most cases.
S,
ALR -
6. Re: SHRINKWRAP-97: Verbose toString format
jesper.pedersen Dec 7, 2009 9:35 AM (in response to alrubinger)The enum would work, as it gives the developer greater control.
-
7. Re: SHRINKWRAP-97: Verbose toString format
aslak Dec 7, 2009 9:53 AM (in response to alrubinger)A Enum gives the ShrinkWrap developer control, but the user is stuck with the preset options.
public interface Formater { String format(Map<Path, Asset> content); } Archie.toString(Formater formater) archie.toString(Formaters.full()) archie.toString(new MyFormater()) archie.toString() { return toStirng(Formaters.simple()) }
If the user could choose between some 'predefined' impls or could specify his own, that would give him control. -
8. Re: SHRINKWRAP-97: Verbose toString format
alrubinger Dec 15, 2009 1:34 PM (in response to aslak)https://jira.jboss.org/jira/browse/SHRINKWRAP-107
I like Aslak's extension formatters example, so I've added them.
archive.toString(); // Same as toString(false) and toString(Formatters.SIMPLE) archive.toString(false); archive.toString(true); // Same as toString(Formatters.VERBOSE) archive.toString(Formatters.SIMPLE); archive.toString(Formatters.VERBOSE); archive.toString(new Formatter() { @Override public String format(final Archive<?> archive) throws IllegalArgumentException { return "my custom thing here"; } });
We haven't yet done SHRINKWRAP-97, to show all dirs. That can easily become a new Formatter implementation; do we like "Formatters.FULL" ?
S,
ALR
-
9. Re: SHRINKWRAP-97: Verbose toString format
jesper.pedersen Dec 15, 2009 1:51 PM (in response to alrubinger)Formatters.FULL or Formatters.ALL - up to you -
10. Re: SHRINKWRAP-97: Verbose toString format
alrubinger Dec 16, 2009 12:20 PM (in response to jesper.pedersen)jesper.pedersen wrote:
I'm leaving this one as an open issue for the time being for community contributors; it's a good entry point.
S,
ALR