public class Chunk<W> extends Object implements Iterable<W>
iterator()
method, and if there is a
failure call Chunk.ChunkIterator.remove()
on the iterator.
The skipped items are then available through the chunk.Modifier and Type | Class and Description |
---|---|
class |
Chunk.ChunkIterator
Special iterator for a chunk providing the
Chunk.ChunkIterator.remove(Throwable)
method for dynamically removing an item and adding it to the skips. |
Constructor and Description |
---|
Chunk() |
Chunk(Collection<? extends W> items) |
Chunk(Collection<? extends W> items,
List<SkipWrapper<W>> skips) |
Modifier and Type | Method and Description |
---|---|
void |
add(W item)
Add the item to the chunk.
|
void |
clear()
Clear the items down to signal that we are done.
|
void |
clearSkips()
Clear only the skips list.
|
List<Exception> |
getErrors() |
List<W> |
getItems() |
List<SkipWrapper<W>> |
getSkips() |
Object |
getUserData() |
boolean |
isBusy()
Query the chunk to see if anyone has registered an interest in keeping a
reference to it.
|
boolean |
isEmpty() |
boolean |
isEnd()
Flag to indicate if the source data is exhausted.
|
Chunk.ChunkIterator |
iterator()
Get an unmodifiable iterator for the underlying items.
|
void |
setBusy(boolean busy)
Register an interest in the chunk to prevent it from being cleaned up
before the flag is reset to false.
|
void |
setEnd()
Set the flag to say that this chunk represents an end of stream (there is
no more data to process).
|
void |
setUserData(Object userData) |
int |
size() |
void |
skip(Exception e)
Register an anonymous skip.
|
String |
toString() |
public Chunk()
public Chunk(Collection<? extends W> items)
public Chunk(Collection<? extends W> items, List<SkipWrapper<W>> skips)
public void add(W item)
item
- public void clear()
public List<W> getItems()
public List<SkipWrapper<W>> getSkips()
public List<Exception> getErrors()
public void skip(Exception e)
Chunk.ChunkIterator.remove()
.e
- the exception that caused the skippublic boolean isEmpty()
public Chunk.ChunkIterator iterator()
iterator
in interface Iterable<W>
Iterable.iterator()
public int size()
public boolean isEnd()
public void setEnd()
public boolean isBusy()
public void setBusy(boolean busy)
busy
- the flag to setpublic void clearSkips()
public Object getUserData()
public void setUserData(Object userData)
Copyright © 2014 Pivotal. All rights reserved.