|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.scijava.AbstractContextual
org.scijava.plugin.AbstractRichPlugin
org.scijava.plugin.AbstractTypedPlugin<D>
org.scijava.plugin.AbstractHandlerPlugin<ConversionRequest>
org.scijava.convert.AbstractConverter<I,O>
public abstract class AbstractConverter<I,O>
Abstract superclass for Converter plugins. Performs appropriate
dispatching of canConvert(ConversionRequest) and
convert(ConversionRequest) calls based on the actual state of the
given ConversionRequest.
Note that the supports(ConversionRequest) method is overridden as
well, to delegate to the appropriate canConvert(org.scijava.convert.ConversionRequest).
NB: by default, the populateInputCandidates(Collection) method has a
dummy implementation. Effectively, this is opt-in behavior. If a converter
implementation would like to suggest candidates for conversion, this method
can be overridden.
| Constructor Summary | |
|---|---|
AbstractConverter()
|
|
| Method Summary | |
|---|---|
boolean |
canConvert(ConversionRequest request)
Checks whether a given can be processed, by converting the desired ConversionRequest.sourceClass() to its
ConversionRequest.destClass() or
ConversionRequest.destType(). |
Object |
convert(ConversionRequest request)
Converts the given ConversionRequest.sourceObject() to the
specified ConversionRequest.destClass() or
ConversionRequest.destType(). |
Class<ConversionRequest> |
getType()
Gets the type associated with the object. |
void |
populateInputCandidates(Collection<Object> objects)
Populates the given collection with objects which are known to exist, and which are usable as inputs for this converter. |
boolean |
supports(ConversionRequest request)
Gets whether this object is compatible with the given data object. |
| Methods inherited from class org.scijava.plugin.AbstractRichPlugin |
|---|
compareTo, getInfo, getPriority, setInfo, setPriority, toString |
| Methods inherited from class org.scijava.AbstractContextual |
|---|
context, getContext, setContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.scijava.convert.Converter |
|---|
canConvert, canConvert, canConvert, canConvert, convert, convert, getInputType, getOutputType |
| Methods inherited from interface org.scijava.Contextual |
|---|
context, getContext, setContext |
| Methods inherited from interface org.scijava.Prioritized |
|---|
getPriority, setPriority |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Methods inherited from interface org.scijava.plugin.HasPluginInfo |
|---|
getInfo, setInfo |
| Constructor Detail |
|---|
public AbstractConverter()
| Method Detail |
|---|
public boolean canConvert(ConversionRequest request)
ConverterConversionRequest.sourceClass() to its
ConversionRequest.destClass() or
ConversionRequest.destType().
canConvert in interface Converter<I,O>Converter.convert(ConversionRequest)public Object convert(ConversionRequest request)
ConverterConversionRequest.sourceObject() to the
specified ConversionRequest.destClass() or
ConversionRequest.destType().
convert in interface Converter<I,O>request - ConversionRequest to process.
Converter.convert(Object, Class),
Converter.convert(Object, Type)public void populateInputCandidates(Collection<Object> objects)
Converter
That is: each such object added to the collection would return true
if queried with converter.canConvert(object), and hence would
produce an output of type Converter.getOutputType() if passed to
converter.convert(object).
The means by which "known objects" are determined is implementation
dependent, although the most typical use case is to query the
ObjectService for known objects of type Converter.getInputType(),
and return those. But other behaviors are possible, depending on the
converter implementation.
populateInputCandidates in interface Converter<I,O>objects - an initialized collection into which appropriate objects
will be inserted.public boolean supports(ConversionRequest request)
Typed
Typically, this will be the case when data.getClass() is assignable
to the type associated with the object (i.e., the one returned by
Typed.getType()). But individual implementations may have other
requirements beyond class assignability.
supports in interface Typed<ConversionRequest>supports in class AbstractTypedPlugin<ConversionRequest>public Class<ConversionRequest> getType()
Typed
getType in interface Typed<ConversionRequest>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||