|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Converter
Extensible conversion Plugin
for converting between classes and
types.
ConversionRequest
Method Summary | ||
---|---|---|
boolean |
canConvert(Class<?> src,
Class<?> dest)
Checks whether objects of the given class can be converted to the specified type. |
|
boolean |
canConvert(Class<?> src,
Type dest)
Checks whether objects of the given class can be converted to the specified type. |
|
boolean |
canConvert(ConversionRequest request)
Checks whether a given can be processed, by converting the desired ConversionRequest.sourceClass() to its
ConversionRequest.destClass() or
ConversionRequest.destType() . |
|
boolean |
canConvert(Object src,
Class<?> dest)
Checks whether the given object's type can be converted to the specified type. |
|
boolean |
canConvert(Object src,
Type dest)
Checks whether the given object's type can be converted to the specified type. |
|
Object |
convert(ConversionRequest request)
Converts the given ConversionRequest.sourceObject() to the
specified ConversionRequest.destClass() or
ConversionRequest.destType() . |
|
|
convert(Object src,
Class<T> dest)
Converts the given object to an object of the specified type. |
|
Object |
convert(Object src,
Type dest)
As convert(Object, Class) but capable of creating and populating
multi-element objects (Collection s and array types). |
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 |
Methods inherited from interface org.scijava.Typed |
---|
getType, supports |
Method Detail |
---|
boolean canConvert(ConversionRequest request)
ConversionRequest.sourceClass()
to its
ConversionRequest.destClass()
or
ConversionRequest.destType()
.
convert(ConversionRequest)
boolean canConvert(Class<?> src, Type dest)
convert(Object, Type)
boolean canConvert(Class<?> src, Class<?> dest)
convert(Object, Class)
boolean canConvert(Object src, Type dest)
Note that this does not necessarily entail that
convert(Object, Type)
on that specific object will succeed. For
example: canConvert("5.1", int.class)
will return true
because a String
can in general be converted to an int
, but
calling convert("5.1", int.class)
will throw a
NumberFormatException
when the conversion is actually attempted via
the Integer.Integer(String)
constructor.
convert(Object, Type)
boolean canConvert(Object src, Class<?> dest)
Note that this does not necessarily entail that
convert(Object, Class)
on that specific object will succeed. For
example: canConvert("5.1", int.class)
will return true
because a String
can in general be converted to an int
, but
calling convert("5.1", int.class)
will throw a
NumberFormatException
when the conversion is actually attempted via
the Integer.Integer(String)
constructor.
convert(Object, Class)
Object convert(Object src, Type dest)
convert(Object, Class)
but capable of creating and populating
multi-element objects (Collection
s and array types). If a single
element type is provided, it will be converted the same as
convert(Object, Class)
. If a multi-element type is detected, then
the value parameter will be interpreted as potential collection of values.
An appropriate container will be created, and the full set of values will
be type converted and added.
NB: This method should be capable of creating any array type, but if a
Collection
interface or abstract class is provided we can only make
a best guess as to what container type to instantiate. Defaults are
provided for Set
and List
subclasses.
src
- The object to convert.dest
- Type to which the object should be converted.<T> T convert(Object src, Class<T> dest)
String
, which uses the
Object.toString()
method instead). In the case of primitive types,
returns an object of the corresponding wrapped type. If the destination
type does not have an appropriate constructor, returns null.
T
- Type to which the object should be converted.src
- The object to convert.dest
- Type to which the object should be converted.Object convert(ConversionRequest request)
ConversionRequest.sourceObject()
to the
specified ConversionRequest.destClass()
or
ConversionRequest.destType()
.
request
- ConversionRequest
to process.
convert(Object, Class)
,
convert(Object, Type)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |