Package com.scroogexhtml.converter
Class OutputBudget
java.lang.Object
com.scroogexhtml.converter.OutputBudget
Counts what a conversion produces and stops it when it exceeds
SecurityConfiguration.getMaxElementCount() or
SecurityConfiguration.getMaxOutputChars(), so a small input cannot
expand into a huge document.
One instance is used per conversion; it is not thread-safe. Each check is a counter increment and a comparison.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidelement()Counts one element created from the RTF content.static OutputBudgetorUnlimited(OutputBudget budget) voidresult(int length) Checks the length of the finished result, markup included.voidtext(int length) Counts text taken from the RTF content.
-
Constructor Details
-
OutputBudget
- Parameters:
config- the limits
-
-
Method Details
-
orUnlimited
- Parameters:
budget- a budget, or null- Returns:
- the budget, or a new one without limits if it is null
-
element
public void element()Counts one element created from the RTF content.- Throws:
ConversionException- if the element limit is exceeded
-
text
public void text(int length) Counts text taken from the RTF content. The result is at least as long as its text, so exceeding the limit here stops the conversion early.- Parameters:
length- number of characters added- Throws:
ConversionException- if the output size limit is exceeded
-
result
public void result(int length) Checks the length of the finished result, markup included.- Parameters:
length- the result length in characters- Throws:
ConversionException- if the output size limit is exceeded
-