Package com.inet.report.cache.store
Class CachedOutput
- java.lang.Object
-
- com.inet.report.cache.store.CachedOutput
-
- All Implemented Interfaces:
DocumentOutput,java.lang.Comparable<CachedOutput>
public class CachedOutput extends java.lang.Object implements DocumentOutput, java.lang.Comparable<CachedOutput>
Implementation of DocumentOutput that saves in the report cache.- Since:
- 16.2
-
-
Constructor Summary
Constructors Constructor Description CachedOutput(ReportCacheKey key, ReportGenerator engine)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFontData(byte[] fontData)Add the data for an embedded font.voidaddPage(byte[] page)Add a page/chunk.voidclear()Reset this output in the initial state.intcompareTo(CachedOutput o)ReportGeneratorgetEngine()Get the Engine/EngineBundle that produce the data for this output.intgetFontCount()Get the count of added fonts.byte[]getFontData(int idx)Get the font data from the given index.byte[]getGroupTree()Get the data of the group tree.ReportCacheKeygetKey()Get the key of this DocumentOutput.intgetPageCount()Get the current count of pages.byte[]getPageData(int idx)Get the binary data of a page/chunk.booleanisPageLimitExceeded()Check if the rendering of the report ran into a page limit.voidsetErrorData(byte[] error)Set error data.voidsetFontData(byte[] fontData, int idx)Override the font data with a new version.voidsetGroupTree(byte[] data)Set the group tree.voidsetPageData(byte[] page, int idx)Override/patched an existing page/chunk.voidsetPageLimitExceeded()Set that a PageLimitException exception occur.voidsetUsingTotalPage()Set that a total page is used in the report.voidstop(java.lang.String cause)The rendering was stopped.
-
-
-
Constructor Detail
-
CachedOutput
public CachedOutput(ReportCacheKey key, ReportGenerator engine)
Create a new instance.- Parameters:
key- the report keyengine- the related Engine- Since:
- 16.2
-
-
Method Detail
-
getPageCount
public int getPageCount()
Get the current count of pages.- Specified by:
getPageCountin interfaceDocumentOutput- Returns:
- the page count
-
clear
public void clear()
Reset this output in the initial state. So getPageCount() == 0 and getFontCount() == 0.- Specified by:
clearin interfaceDocumentOutput
-
getPageData
public byte[] getPageData(int idx) throws java.lang.ArrayIndexOutOfBoundsExceptionGet the binary data of a page/chunk.- Specified by:
getPageDatain interfaceDocumentOutput- Parameters:
idx- the index, starts with 1- Returns:
- the data, never null
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if index is out of range
-
getGroupTree
public byte[] getGroupTree()
Get the data of the group tree.- Specified by:
getGroupTreein interfaceDocumentOutput- Returns:
- Can be null, if not set.
-
addPage
public void addPage(byte[] page) throws java.lang.IllegalStateExceptionAdd a page/chunk. IncrementDocumentOutput.getPageCount()- Specified by:
addPagein interfaceDocumentOutput- Parameters:
page- the binary data, never null- Throws:
java.lang.IllegalStateException- if this output is finish or stopped.
-
setPageData
public void setPageData(byte[] page, int idx) throws java.lang.IllegalStateExceptionOverride/patched an existing page/chunk.- Specified by:
setPageDatain interfaceDocumentOutput- Parameters:
page- die binary data, never nullidx- the index, starts with 1- Throws:
java.lang.IllegalStateException- if this output is finish or stopped.
-
setGroupTree
public void setGroupTree(byte[] data) throws java.lang.IllegalStateExceptionSet the group tree. After this call this output is finish and any try to change this object should throw an exception. This call does not changeDocumentOutput.getPageCount().- Specified by:
setGroupTreein interfaceDocumentOutput- Parameters:
data- the binary data, never null, but can be an empty array- Throws:
java.lang.IllegalStateException- if this output is finish or stopped.
-
setErrorData
public void setErrorData(byte[] error) throws java.lang.IllegalStateExceptionSet error data. After this call this output is finish and any try to change this object should throw an exception.- Specified by:
setErrorDatain interfaceDocumentOutput- Parameters:
error- serialized Exception- Throws:
java.lang.IllegalStateException- if this output is finish or stopped.
-
stop
public void stop(java.lang.String cause)
The rendering was stopped. This is called from Engine.stop(). After this call any try to change this object should throw an exception.- Specified by:
stopin interfaceDocumentOutput- Parameters:
cause- an optional message
-
addFontData
public void addFontData(byte[] fontData) throws java.lang.IllegalStateExceptionAdd the data for an embedded font. IncrementDocumentOutput.getFontCount(). This method is only used from the Java/C# output format.- Specified by:
addFontDatain interfaceDocumentOutput- Parameters:
fontData- binary data in the current protocol format.- Throws:
java.lang.IllegalStateException- if this output is finish or stopped.
-
setFontData
public void setFontData(byte[] fontData, int idx) throws java.lang.IllegalStateExceptionOverride the font data with a new version.- Specified by:
setFontDatain interfaceDocumentOutput- Parameters:
fontData- binary data in the current protocol format.idx- the index, starts with 0- Throws:
java.lang.IllegalStateException- if this output is finish or stopped.
-
getFontData
public byte[] getFontData(int idx) throws java.lang.ArrayIndexOutOfBoundsExceptionGet the font data from the given index.- Specified by:
getFontDatain interfaceDocumentOutput- Parameters:
idx- the index, starts with 0- Returns:
- the font data, never null
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if index is out of range
-
getFontCount
public int getFontCount()
Get the count of added fonts.- Specified by:
getFontCountin interfaceDocumentOutput- Returns:
- the font count
-
setPageLimitExceeded
public void setPageLimitExceeded()
Set that a PageLimitException exception occur.- Specified by:
setPageLimitExceededin interfaceDocumentOutput
-
isPageLimitExceeded
public boolean isPageLimitExceeded()
Check if the rendering of the report ran into a page limit. This means does not all possible pages exist.- Specified by:
isPageLimitExceededin interfaceDocumentOutput- Returns:
- true, if PageLimitException was occur
-
setUsingTotalPage
public void setUsingTotalPage()
Set that a total page is used in the report.- Specified by:
setUsingTotalPagein interfaceDocumentOutput
-
getKey
public ReportCacheKey getKey()
Get the key of this DocumentOutput.- Returns:
- the key
- Since:
- 16.3
-
getEngine
public ReportGenerator getEngine()
Get the Engine/EngineBundle that produce the data for this output.- Returns:
- the engine
- Since:
- 16.2
-
compareTo
public int compareTo(CachedOutput o)
- Specified by:
compareToin interfacejava.lang.Comparable<CachedOutput>
-
-