Interface ReportArtifact
- All Superinterfaces:
AutoCloseable, PdfArtifact
render 完成的報表產物(REP-05);以 renderer 的暫存檔承載,關閉後刪除
產物不是 Entity:要保存就交給 StoredReports.save(FileStorage, String, ReportArtifact),要直接下載就交給 ReportResponses(兩者都會接手並關閉)。
- 關閉後
openStream()、transferTo(OutputStream)丟出IllegalStateException; 已開啟的串流仍可讀完,暫存檔在最後一個串流關閉時刪除 - 刪除暫存檔失敗不丟出例外,以 WARN 記錄(
report.resource.cleanup-failed) - 未關閉而被回收時刪除暫存檔並記錄 WARN;這是保險,不能取代關閉
try (var artifact = renderer.render(document, RenderOptions.defaults())) {
artifact.transferTo(out);
}
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()關閉並刪除暫存檔;可重複呼叫,不丟出例外文件時間:PDF metadata 的建立時間filename()metadata()開啟讀取串流;可多次開啟,每個串流由呼叫者關閉intlongsize()longtransferTo(OutputStream out) 寫出全部內容到out(不關閉out)Methods inherited from interface PdfArtifact
layoutDiagnostics
-
Method Details
-
contentType
String contentType()- Specified by:
contentTypein interfacePdfArtifact- Returns:
- MIME 類型,例如
application/pdf
-
filename
String filename()- Specified by:
filenamein interfacePdfArtifact- Returns:
- 建議檔名(已移除路徑分隔與控制字元,含副檔名)
-
size
long size()- Specified by:
sizein interfacePdfArtifact- Returns:
- 位元組數
-
pageCount
int pageCount()- Specified by:
pageCountin interfacePdfArtifact- Returns:
- 頁數
-
createdAt
Instant createdAt()文件時間:PDF metadata 的建立時間
可能是
ReportMetadata.createdAt()指定的歷史日期,或固定時鐘產生的時間;不可用於計算保存期限。- Specified by:
createdAtin interfacePdfArtifact- Returns:
- 建立時間
-
metadata
ReportMetadata metadata()- Returns:
- 文件 metadata
-
diagnostics
List<ReportDiagnostic> diagnostics()- Returns:
- render 產生的 INFO 與 WARNING diagnostic
-
openStream
InputStream openStream()開啟讀取串流;可多次開啟,每個串流由呼叫者關閉- Specified by:
openStreamin interfacePdfArtifact- Returns:
- 串流
- Throws:
IllegalStateException- 已關閉
-
transferTo
寫出全部內容到out(不關閉out)- Specified by:
transferToin interfacePdfArtifact- Parameters:
out- 目的地- Returns:
- 寫出的位元組數
- Throws:
IllegalStateException- 已關閉UncheckedIOException- 讀寫失敗
-
close
void close()關閉並刪除暫存檔;可重複呼叫,不丟出例外- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacePdfArtifact
-