Jump to content
  • ReportFormat Enumerated Type


    thangalin
    Assigned User teodord
    CategoryEnhancement request
    PriorityLow
    ReproducibilityAlways
    ResolutionWon't Fix
    SeverityTrivial
    StatusResolved
    Versionv6.4

    Please include a "ReportFormat" enumerated data type with the JasperReports library that encapsulates the Media Type and filename extensions for report formats. Something like:

     

     

    public enum ReportFormat {

     

    /**

    * Adobe Acrobat Portable Document Format.

    *

    * @see https://tools.ietf.org/html/rfc3778

    */

    PDF("application/pdf", "pdf"),

     

    /**

    * Hypertext Mark-up Language.

    *

    * @see https://www.ietf.org/rfc/rfc2854.txt

    */

    HTML("text/html", "html"),

     

    /**

    * Comma-separated Values.

    *

    * @see https://tools.ietf.org/html/rfc4180

    */

    CSV("text/csv", "csv"),

     

    /**

    * Proprietary Microsoft Excel Format (see also: CSV).

    *

    * @see http://www.iana.org/assignments/media-types/application/vnd.ms-excel

    */

    XLS("application/vnd.ms-excel", "xls"),

     

    /**

    * The media type as defined by IANA and IETF.

    *

    * @see http://www.iana.org/assignments/media-types/media-types.xhtml

    */

    private final String mediaType;

     

    /**

    * The filename extension typically used for this format's media type.

    */

    private final String extension;

     

    private ReportFormat(

    final String mediaType,

    final String extension) {

    this.mediaType = mediaType;

    this.extension = extension;

    }

     

    public String getFilenameExtension() {

    return this.extension;

    }

     

    /**

    * Returns the media type (formerly MIME type) for this report format

    * suitable for inclusion in the content-header of an HTTP response.

    *

    * @return The report format media type.

    * @see http://www.iana.org/assignments/media-types/media-types.xhtml

    */

    public String getMediaType() {

    return this.mediaType;

    }

    }

     

    There's really no need for developers to reinvent this wheel time and time and time again.

     



    User Feedback

    Recommended Comments

    Changed Status from New to Feedback Requested

    Changed Assigned User from - to @teodord


    Hi,Can you tell us when do you need this enumeration, in combination to using JasperReports library?Thank you,Teodor
    Link to comment
    Share on other sites

    The enumeration comes in handy when writing web applications that need to export in many different formats. Most developers need to write this functionality or end up hard-coding strings to handle the content-disposition header values for attachments. It's not a big issue, but would be nice to see with a well-rounded example of how to use it (when exporting over HTTP).
    Link to comment
    Share on other sites

    Changed Resolution from Open to Won't Fix

    Changed Status from Feedback Requested to Resolved


    Hi, DaveI think this falls just a little bit outside our domain and since it is not something we use ourselves in the library, I'll think we'll leave it up to other libraries specialised in web streaming to list content type formats.Thanks,Teodor
    Link to comment
    Share on other sites


×
×
  • Create New...