|
|||||||||
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<Object,Object>
org.scijava.convert.NullConverter
public class NullConverter
Converter
implementation for handling null
values. Performs
basic casting when given a null
source and returns null
directly when given a
null destination.
By running at Priority.FIRST_PRIORITY
, other converters should
not need to worry about null
source or destination parameters.
NB: if a Class
source is queried for the canConvert(org.scijava.convert.ConversionRequest)
,
this converter will always return false (as there is no way of knowing
if the source object will be null or not).
Constructor Summary | |
---|---|
NullConverter()
|
Method Summary | ||
---|---|---|
boolean |
canConvert(Class<?> src,
Class<?> 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. |
|
|
convert(Object src,
Class<T> dest)
Converts the given object to an object of the specified type. |
|
Class<Object> |
getInputType()
|
|
Class<Object> |
getOutputType()
|
Methods inherited from class org.scijava.convert.AbstractConverter |
---|
canConvert, convert, convert, getType, populateInputCandidates, supports |
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.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 NullConverter()
Method Detail |
---|
public boolean canConvert(ConversionRequest request)
Converter
ConversionRequest.sourceClass()
to its
ConversionRequest.destClass()
or
ConversionRequest.destType()
.
canConvert
in interface Converter<Object,Object>
canConvert
in class AbstractConverter<Object,Object>
Converter.convert(ConversionRequest)
public boolean canConvert(Object src, Type dest)
Converter
Note that this does not necessarily entail that
Converter.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.
canConvert
in interface Converter<Object,Object>
canConvert
in class AbstractConverter<Object,Object>
Converter.convert(Object, Type)
public boolean canConvert(Object src, Class<?> dest)
Converter
Note that this does not necessarily entail that
Converter.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.
canConvert
in interface Converter<Object,Object>
canConvert
in class AbstractConverter<Object,Object>
Converter.convert(Object, Class)
public boolean canConvert(Class<?> src, Class<?> dest)
Converter
canConvert
in interface Converter<Object,Object>
canConvert
in class AbstractConverter<Object,Object>
Converter.convert(Object, Class)
public <T> T convert(Object src, Class<T> dest)
Converter
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.public Class<Object> getOutputType()
Class
this Converter
produces as output.public Class<Object> getInputType()
Class
this Converter
accepts as input.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |