Is there a good reason to have FileResourceStream final? I may be missing a better way to use it, but I feel I'm jumping through some serious hoops because I want to override one method of this class. What I'd like to do is this:

    add(new ResourceLink("downloadLink", new Resource() {
        public IResourceStream getResourceStream() {
            return new FileResourceStream(
                            new wicket.util.file.File(filename)) {
                public String getContentType() {
                    if (filename.toLowerCase().endsWith(".doc")) {
                        return "application/msword";
                    }
                    return super.getContentType();
                }
            };
        }
    }));

But because FileResourceStream is final, I need to do something like this instead:

    add(new ResourceLink("downloadLink", new Resource() {
        public IResourceStream getResourceStream() {
            return new IResourceStream() {
                FileResourceStream frs = new FileResourceStream(
                            new wicket.util.file.File(filename));

                public String getContentType() {
                    if (filename.toLowerCase().endsWith(".doc")) {
                        return "application/msword";
                    }
                    return frs.getContentType();
                }
                public void close() throws IOException {
                    frs.close();
                }
                public InputStream getInputStream()
                            throws ResourceStreamNotFoundException {
                    return frs.getInputStream();
                }
                public Locale getLocale() {
                    return frs.getLocale();
                }
                public long length() {
                    return frs.length();
                }
                public void setLocale(Locale locale) {
                    frs.setLocale(locale);
                }
                public Time lastModifiedTime() {
                    return frs.lastModifiedTime();
                }
            };
        }
    }));

Of course I should probably move this to a separate class, but, regardless, if it weren't final, this would be easier.

Of course any suggestions for how to do this more easily would also be welcome! :-)

Thanks,

  -- Scott Sauyet

P.S. This class has the following Javadoc comment for its one (public) constructor: "Private constructor to force use of static factory methods." I don't think there is any static factory for this. There certainly isn't one in the class itself.



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to