Class DataDrivenTemplateIterator
- java.lang.Object
-
- org.thymeleaf.engine.DataDrivenTemplateIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.Object>
public final class DataDrivenTemplateIterator extends java.lang.Object implements java.util.Iterator<java.lang.Object>Throttled implementation of
Iterator, meant to be queried in scenarios when an iterated context variable is allowed to be in control of the engine's throttling (i.e. the engine's execution is data-driven).A common scenario for this would be reactive systems executing the template engine as a part of a flow obtaining data from a data source, so that as the data is obtained, a part of the template is output containing that part of the data.
This class is meant for internal use only from the diverse integrations of Thymeleaf in reactive architectures. There is normally no reason why a user would have to use this class directly.
- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description private booleanfeedingCompleteprivate booleaninStepprivate booleanqueriedprivate static char[]SSE_HEAD_EVENT_NAMEprivate static char[]SSE_MESSAGE_EVENT_NAMEprivate static char[]SSE_TAIL_EVENT_NAMEprivate ISSEThrottledTemplateWriterControlsseControlprivate char[]sseEventsComposedMessageEventNameprivate longsseEventsIDprivate char[]sseEventsPrefixprivate java.util.List<java.lang.Object>valuesprivate IThrottledTemplateWriterControlwriterControl
-
Constructor Summary
Constructors Constructor Description DataDrivenTemplateIterator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private char[]composeToken(char[] token)booleancontinueBufferExecution()voidfeedBuffer(java.util.List<java.lang.Object> newElements)voidfeedingComplete()voidfinishIteration()voidfinishStep()booleanhasBeenQueried()booleanhasNext()(package private) booleanisPaused()booleanisStepOutputFinished()java.lang.Objectnext()voidremove()voidsetSseEventsFirstID(long sseEventsFirstID)voidsetSseEventsPrefix(java.lang.String sseEventsPrefix)voidsetWriterControl(IThrottledTemplateWriterControl writerControl)voidstartHead()voidstartIteration()voidstartTail()voidtakeBackLastEventID()
-
-
-
Field Detail
-
SSE_HEAD_EVENT_NAME
private static final char[] SSE_HEAD_EVENT_NAME
-
SSE_MESSAGE_EVENT_NAME
private static final char[] SSE_MESSAGE_EVENT_NAME
-
SSE_TAIL_EVENT_NAME
private static final char[] SSE_TAIL_EVENT_NAME
-
values
private final java.util.List<java.lang.Object> values
-
writerControl
private IThrottledTemplateWriterControl writerControl
-
sseControl
private ISSEThrottledTemplateWriterControl sseControl
-
sseEventsPrefix
private char[] sseEventsPrefix
-
sseEventsComposedMessageEventName
private char[] sseEventsComposedMessageEventName
-
sseEventsID
private long sseEventsID
-
inStep
private boolean inStep
-
feedingComplete
private boolean feedingComplete
-
queried
private boolean queried
-
-
Method Detail
-
setWriterControl
public void setWriterControl(IThrottledTemplateWriterControl writerControl)
-
setSseEventsPrefix
public void setSseEventsPrefix(java.lang.String sseEventsPrefix)
-
setSseEventsFirstID
public void setSseEventsFirstID(long sseEventsFirstID)
-
takeBackLastEventID
public void takeBackLastEventID()
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<java.lang.Object>
-
next
public java.lang.Object next()
- Specified by:
nextin interfacejava.util.Iterator<java.lang.Object>
-
startIteration
public void startIteration()
-
finishIteration
public void finishIteration()
-
hasBeenQueried
public boolean hasBeenQueried()
Returns whether this data driven iterator has been actually queried, i.e., whether its
hasNext()ornext()methods have been called at least once.This indicates if the template has actually reached a point at which this iterator has been already needed or not. The typical use of this is to be able to switch between the "head" and the "data/buffer" phase.
- Returns:
trueif this iterator has been queried,falseif not.- Since:
- 3.0.3
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<java.lang.Object>
-
isPaused
boolean isPaused()
-
continueBufferExecution
public boolean continueBufferExecution()
-
feedBuffer
public void feedBuffer(java.util.List<java.lang.Object> newElements)
-
startHead
public void startHead()
-
feedingComplete
public void feedingComplete()
-
startTail
public void startTail()
-
finishStep
public void finishStep()
-
isStepOutputFinished
public boolean isStepOutputFinished()
-
composeToken
private char[] composeToken(char[] token)
-
-