public class ActionIterator<A extends Action>
extends java.lang.Object
implements java.util.Iterator<A>
Registry.useExtensions(ClientContext, ExtensionsFilter, String...)
.
That method returns an ExtensionsInvoker
object which
in it's turn uses this iterator.
Note the phrase "will be created" above. The actions
are created on demand as this iterator moves on the
next item. This happens in the hasNext()
method, which,
for each extension, calls Extension.getActionFactory()
and then ActionFactory.getActions(InvokationContext)
.
The actions returned from the extensions are piled up in an
internal buffer that the next()
method pick items from.
When the buffer is empty the iterator moves on to the actions from
next extension until there are no more extensions and the action
buffer is empty.
Modifier and Type | Field and Description |
---|---|
private A[] |
actions |
private boolean |
checkNext |
private A |
currentAction |
private ExtensionContext<A> |
currentContext |
private boolean |
hasNext |
private java.util.Iterator<ExtensionContext<A>> |
iterator |
private int |
offset |
Constructor and Description |
---|
ActionIterator(java.util.Iterator<ExtensionContext<A>> iterator) |
Modifier and Type | Method and Description |
---|---|
void |
clearError()
Clear any error that has been registered for the current
action.
|
Extension<? extends A> |
getExtension()
Get the extension that created the current action.
|
ExtensionPoint<? super A> |
getExtensionPoint()
Get the extension point that the current action
belongs to.
|
Renderer<? super A> |
getRenderer()
Gets the renderer for the current action.
|
boolean |
hasNext() |
A |
next() |
void |
remove()
Not supported.
|
void |
setError(java.lang.String message,
java.lang.Throwable t)
Register an error with a message for the current action.
|
void |
setError(java.lang.Throwable t)
Register an error for the current action.
|
private boolean |
validActions(A[] actions)
Check that the actions array is a not-null, non-empty array
and contains actions of a type that is compatible with the
ExtensionPoint.getActionClass() class. |
private ExtensionContext<A extends Action> currentContext
private final java.util.Iterator<ExtensionContext<A extends Action>> iterator
private int offset
private boolean checkNext
private boolean hasNext
ActionIterator(java.util.Iterator<ExtensionContext<A>> iterator)
public boolean hasNext()
public void remove()
public ExtensionPoint<? super A> getExtensionPoint()
public Extension<? extends A> getExtension()
public Renderer<? super A> getRenderer()
public void clearError()
setError(Throwable)
public void setError(java.lang.Throwable t)
t
- The error to registerpublic void setError(java.lang.String message, java.lang.Throwable t)
t
- The error to registermessage
- An optional messageprivate boolean validActions(A[] actions)
ExtensionPoint.getActionClass()
class.
NOTE! If the array contains at least one invalid action, all actions, including the valid ones, will be ignored. No exception will be thrown. An error-level log message is written to the log file.
actions
- The actions to check