1
14
15 package com.liferay.portal.kernel.bi.reporting;
16
17 import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayOutputStream;
18
19 import java.io.OutputStream;
20 import java.io.Serializable;
21
22
28 public class ByteArrayReportResultContainer
29 implements ReportResultContainer, Serializable {
30
31 public static final int DEFAULT_INITIAL_CAPCITY = 15360;
32
33 public ByteArrayReportResultContainer() {
34 this(null, DEFAULT_INITIAL_CAPCITY);
35 }
36
37 public ByteArrayReportResultContainer(String reportName) {
38 this(reportName, DEFAULT_INITIAL_CAPCITY);
39 }
40
41 public ByteArrayReportResultContainer(
42 String reportName, int initialCapacity) {
43
44 _reportName = reportName;
45 _initialCapacity = initialCapacity;
46 }
47
48 public ReportResultContainer clone(String reportName) {
49 return new ByteArrayReportResultContainer(reportName, _initialCapacity);
50 }
51
52 public OutputStream getOutputStream() {
53 if (_unsyncByteArrayOutputStream == null) {
54 _unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream(
55 _initialCapacity);
56 }
57
58 return _unsyncByteArrayOutputStream;
59 }
60
61 public ReportGenerationException getReportGenerationException() {
62 return _reportGenerationException;
63 }
64
65 public String getReportName() {
66 return _reportName;
67 }
68
69 public byte[] getResults() {
70 return _unsyncByteArrayOutputStream.toByteArray();
71 }
72
73 public boolean hasError() {
74 if (_reportGenerationException != null) {
75 return true;
76 }
77 else {
78 return false;
79 }
80 }
81
82 public void setReportGenerationException(
83 ReportGenerationException reportGenerationException) {
84
85 _reportGenerationException = reportGenerationException;
86 }
87
88 private int _initialCapacity;
89 private ReportGenerationException _reportGenerationException;
90 private String _reportName;
91 private UnsyncByteArrayOutputStream _unsyncByteArrayOutputStream;
92
93 }