|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.equinox.p2.query.Collector<T>
T
- The type of object accepted by this collectorpublic class Collector<T>
A collector is a generic visitor that collects objects passed to it,
and can then express the result of the visit in various forms. The collector
can also short-circuit a traversal by returning false
from
its accept(Object)
method.
This default collector just accepts all objects passed to it. Clients may subclass to perform different processing on the objects passed to it.
Field Summary | |
---|---|
static Collector<?> |
EMPTY_COLLECTOR
|
Constructor Summary | |
---|---|
Collector()
Creates a new collector. |
Method Summary | ||
---|---|---|
boolean |
accept(T object)
Accepts an object. |
|
void |
addAll(IQueryResult<T> queryResult)
Adds the elements from one collector to this collector |
|
static
|
emptyCollector()
|
|
protected Collection<T> |
getCollection()
Returns the collection that is being used to collect results. |
|
boolean |
isEmpty()
Returns whether this collector is empty. |
|
Iterator<T> |
iterator()
Returns an iterator on the collected objects. |
|
IQueryResult<T> |
query(IQuery<T> query,
IProgressMonitor monitor)
Performs a query on this results of this collector. |
|
int |
size()
Returns the number of collected objects. |
|
T[] |
toArray(Class<T> clazz)
Returns the collected objects as an array |
|
Set<T> |
toSet()
Returns a copy of the collected objects. |
|
Set<T> |
toUnmodifiableSet()
Returns the collected objects as an immutable collection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Collector<?> EMPTY_COLLECTOR
Constructor Detail |
---|
public Collector()
Method Detail |
---|
public static final <T> Collector<T> emptyCollector()
public boolean accept(T object)
This default implementation adds the objects to a list. Clients may override this method to perform additional filtering, add different objects to the list, short-circuit the traversal, or process the objects directly without collecting them.
object
- the object to collect or visit
true
if the traversal should continue,
or false
to indicate the traversal should stop.public void addAll(IQueryResult<T> queryResult)
queryResult
- The collector from which the elements should be retrievedprotected Collection<T> getCollection()
public boolean isEmpty()
isEmpty
in interface IQueryResult<T>
true
if this collector has accepted any results,
and false
otherwise.public Iterator<T> iterator()
iterator
in interface IQueryResult<T>
public int size()
public T[] toArray(Class<T> clazz)
toArray
in interface IQueryResult<T>
clazz
- The type of array to return
ArrayStoreException
- the runtime type of the specified array is
not a super-type of the runtime type of every collected objectpublic Set<T> toSet()
toSet
in interface IQueryResult<T>
public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor)
query
in interface IQueryable<T>
query
- The query to performmonitor
- a progress monitor, or null
if progress
reporting is not desired
public Set<T> toUnmodifiableSet()
toUnmodifiableSet
in interface IQueryResult<T>
|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.