DefaultReportOutputHandlerFactory implements ReportOutputHandlerFactory { public ReportOutputHandler createOutputHandlerForOutputType( final ReportOutputHandlerSelector selector ) throws IOException { String t = selector.getOutputType(); if ( HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE.equals( t ) ) { return createHtmlPageOutput( selector ); } if ( HtmlTableModule.TABLE_HTML_STREAM_EXPORT_TYPE.equals( t ) ) { return createHtmlStreamOutput( selector ); } if ( SimpleReportingAction.PNG_EXPORT_TYPE.equals( t ) ) { return createPngOutput(); } if ( XmlPageableModule.PAGEABLE_XML_EXPORT_TYPE.equals( t ) ) { return createXmlPageableOutput(); } if ( XmlTableModule.TABLE_XML_EXPORT_TYPE.equals( t ) ) { return createXmlTableOutput(); } if ( PdfPageableModule.PDF_EXPORT_TYPE.equals( t ) ) { return createPdfOutput(); } if ( ExcelTableModule.EXCEL_FLOW_EXPORT_TYPE.equals( t ) ) { return createXlsOutput( selector ); } if ( ExcelTableModule.XLSX_FLOW_EXPORT_TYPE.equals( t ) ) { return createXlsxOutput( selector ); } if ( CSVTableModule.TABLE_CSV_STREAM_EXPORT_TYPE.equals( t ) ) { return createCsvOutput(); } if ( RTFTableModule.TABLE_RTF_FLOW_EXPORT_TYPE.equals( t ) ) { return createRtfOutput(); } if ( SimpleReportingAction.MIME_TYPE_EMAIL.equals( t ) ) { return createMailOutput(); } if ( PlainTextPageableModule.PLAINTEXT_EXPORT_TYPE.equals( t ) ) { return createTextOutput(); } else { return null; } } DefaultReportOutputHandlerFactory(); boolean isHtmlStreamVisible(); void setHtmlStreamVisible( final boolean htmlStreamVisible ); boolean isHtmlPageVisible(); void setHtmlPageVisible( final boolean htmlPageVisible ); boolean isXlsVisible(); void setXlsVisible( final boolean xlsVisible ); boolean isXlsxVisible(); void setXlsxVisible( final boolean xlsxVisible ); boolean isCsvVisible(); void setCsvVisible( final boolean csvVisible ); boolean isRtfVisible(); void setRtfVisible( final boolean rtfVisible ); boolean isPdfVisible(); void setPdfVisible( final boolean pdfVisible ); boolean isTextVisible(); void setTextVisible( final boolean textVisible ); boolean isMailVisible(); void setMailVisible( final boolean mailVisible ); boolean isXmlTableVisible(); void setXmlTableVisible( final boolean xmlTableVisible ); boolean isXmlPageVisible(); void setXmlPageVisible( final boolean xmlPageVisible ); boolean isPngVisible(); void setPngVisible( final boolean pngVisible ); boolean isHtmlStreamAvailable(); void setHtmlStreamAvailable( final boolean htmlStreamAvailable ); boolean isHtmlPageAvailable(); void setHtmlPageAvailable( final boolean htmlPageAvailable ); boolean isXlsAvailable(); void setXlsAvailable( final boolean xlsAvailable ); boolean isXlsxAvailable(); void setXlsxAvailable( final boolean xlsxAvailable ); boolean isCsvAvailable(); void setCsvAvailable( final boolean csvAvailable ); boolean isRtfAvailable(); void setRtfAvailable( final boolean rtfAvailable ); boolean isPdfAvailable(); void setPdfAvailable( final boolean pdfAvailable ); boolean isTextAvailable(); void setTextAvailable( final boolean textAvailable ); boolean isMailAvailable(); void setMailAvailable( final boolean mailAvailable ); boolean isXmlTableAvailable(); void setXmlTableAvailable( final boolean xmlTableAvailable ); boolean isXmlPageAvailable(); void setXmlPageAvailable( final boolean xmlPageAvailable ); boolean isPngAvailable(); void setPngAvailable( final boolean pngAvailable ); String getMimeType( final ReportOutputHandlerSelector selector ); Set<Map.Entry<String, String>> getSupportedOutputTypes(); ReportOutputHandler createOutputHandlerForOutputType( final ReportOutputHandlerSelector selector );  }
@Test public void testCreateOutputHandlerForOutputType() throws Exception { MockOutputHandlerSelector selector = new MockOutputHandlerSelector(); selector.setOutputType( "pageable/X-AWT-Graphics;image-type=png" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof PNGOutput ); roh.setPngAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "pageable/xml" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof XmlPageableOutput ); roh.setXmlPageAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "table/xml" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof XmlTableOutput ); roh.setXmlTableAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "pageable/pdf" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof PDFOutput ); roh.setPdfAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "table/excel;page-mode=flow" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof XLSOutput ); roh.setXlsAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;page-mode=flow" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof XLSXOutput ); roh.setXlsxAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "table/csv;page-mode=stream" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof CSVOutput ); roh.setCsvAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "table/rtf;page-mode=flow" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof RTFOutput ); roh.setRtfAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "mime-message/text/html" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof EmailOutput ); roh.setMailAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "pageable/text" ); assertTrue( roh.createOutputHandlerForOutputType( selector ) instanceof PlainTextOutput ); roh.setTextAvailable( false ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); selector.setOutputType( "" ); assertNull( roh.createOutputHandlerForOutputType( selector ) ); }