Examples of MemoryByteArrayOutputStream


Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

public class ReportWritingUtil
{
  public static MasterReport saveAndLoad(MasterReport report)
      throws Exception
  {
    final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream();
    BundleWriter.writeReportToZipStream(report, bout);
    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();

    final Resource resource = mgr.createDirectly(bout.toByteArray(), MasterReport.class);
    return (MasterReport) resource.getResource();
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  private byte[] serializeReportObject(final MasterReport report) throws IOException
  {
    // we don't test whether our demo models are serializable :)
    // clear all report properties, which may cause trouble ...
    final MemoryByteArrayOutputStream bo = new MemoryByteArrayOutputStream();
    final ObjectOutputStream oout = new ObjectOutputStream(bo);
    oout.writeObject(report);
    oout.close();
    return bo.toByteArray();
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  private byte[] serializeReportObject(final MasterReport report) throws IOException
  {
    // we don't test whether our demo models are serializable :)
    // clear all report properties, which may cause trouble ...
    final MemoryByteArrayOutputStream bo = new MemoryByteArrayOutputStream();
    final ObjectOutputStream oout = new ObjectOutputStream(bo);
    oout.writeObject(report);
    oout.close();
    return bo.toByteArray();
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  {
  }

  protected MasterReport postProcess(final MasterReport originalReport) throws Exception
  {
    final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream();
    BundleWriter.writeReportToZipStream(originalReport, bout);
    assertTrue(bout.getLength() > 0);
/*
    final File f = File.createTempFile("test-output-", ".prpt", new File ("test-output"));
    final FileOutputStream outputStream = new FileOutputStream(f);
    outputStream.write(bout.toByteArray());
    outputStream.close();
*/
    final ResourceManager mgr = new ResourceManager();
    final Resource reportRes = mgr.createDirectly(bout.toByteArray(), MasterReport.class);
    return (MasterReport) reportRes.getResource();
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  }

  public static byte[] createXmlTablePageable(final MasterReport report)
      throws IOException, ReportProcessingException
  {
    final MemoryByteArrayOutputStream outputStream = new MemoryByteArrayOutputStream();
    try
    {
      final LocalFontRegistry localFontRegistry = new LocalFontRegistry();
      localFontRegistry.initialize();
      final XmlTableOutputProcessor outputProcessor =
          new XmlTableOutputProcessor(outputStream, new XmlTableOutputProcessorMetaData(
              XmlTableOutputProcessorMetaData.PAGINATION_FULL, localFontRegistry));
      final ReportProcessor streamReportProcessor = new PageableReportProcessor(report, outputProcessor);
      try
      {
        streamReportProcessor.processReport();
      }
      finally
      {
        streamReportProcessor.close();
      }
    }
    finally
    {
      outputStream.close();
    }
    return (outputStream.toByteArray());
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  public static byte[] encodeImage(final Image image,
                                   final String mimeType,
                                   final float quality,
                                   final boolean alpha) throws UnsupportedEncoderException, IOException
  {
    final MemoryByteArrayOutputStream byteOut = new MemoryByteArrayOutputStream(65536, 65536 * 2);
    encodeImage(byteOut, image, mimeType, quality, alpha);
    return byteOut.toByteArray();
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  protected void handleXmlContent(final byte[] reportOutput, final File goldSample) throws Exception
  {
    final byte[] goldData;
    final InputStream goldInput = new BufferedInputStream(new FileInputStream(goldSample));
    final MemoryByteArrayOutputStream goldByteStream =
        new MemoryByteArrayOutputStream(Math.min(1024 * 1024, (int) goldSample.length()), 1024 * 1024);

    try
    {
      IOUtils.getInstance().copyStreams(goldInput, goldByteStream);
      goldData = goldByteStream.toByteArray();
      if (Arrays.equals(goldData, reportOutput))
      {
        return;
      }
    }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  }

  protected byte[] executeTablePage(final MasterReport report)
      throws IOException, ReportProcessingException
  {
    final MemoryByteArrayOutputStream outputStream = new MemoryByteArrayOutputStream();
    try
    {
      final XmlTableOutputProcessor outputProcessor =
          new XmlTableOutputProcessor(outputStream, new XmlTableOutputProcessorMetaData(
              XmlTableOutputProcessorMetaData.PAGINATION_FULL, localFontRegistry));
      final ReportProcessor streamReportProcessor = new PageableReportProcessor(report, outputProcessor);
      try
      {
        streamReportProcessor.processReport();
      }
      finally
      {
        streamReportProcessor.close();
      }
    }
    finally
    {
      outputStream.close();
    }
    return (outputStream.toByteArray());
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  }

  protected byte[] executeTableFlow(final MasterReport report)
      throws IOException, ReportProcessingException
  {
    final MemoryByteArrayOutputStream outputStream = new MemoryByteArrayOutputStream();
    try
    {
      final XmlTableOutputProcessor outputProcessor =
          new XmlTableOutputProcessor(outputStream, new XmlTableOutputProcessorMetaData(
              XmlTableOutputProcessorMetaData.PAGINATION_MANUAL, localFontRegistry));
      final ReportProcessor streamReportProcessor = new FlowReportProcessor(report, outputProcessor);
      try
      {
        streamReportProcessor.processReport();
      }
      finally
      {
        streamReportProcessor.close();
      }
    }
    finally
    {
      outputStream.close();
    }
    return (outputStream.toByteArray());
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.MemoryByteArrayOutputStream

  }


  protected MasterReport postProcess(final MasterReport originalReport) throws Exception
  {
    final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream();
    BundleWriter.writeReportToZipStream(originalReport, bout);
    assertTrue(bout.getLength() > 0);

    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource reportRes = mgr.createDirectly(bout.toByteArray(), MasterReport.class);
    return (MasterReport) reportRes.getResource();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.