Package org.scijava.convert
Class ArrayToStringConverter
- java.lang.Object
-
- org.scijava.AbstractContextual
-
- org.scijava.plugin.AbstractRichPlugin
-
- org.scijava.plugin.AbstractTypedPlugin<D>
-
- org.scijava.plugin.AbstractHandlerPlugin<ConversionRequest>
-
- org.scijava.convert.AbstractConverter<Object,String>
-
- org.scijava.convert.ArrayToStringConverter
-
- All Implemented Interfaces:
Comparable<Prioritized>,Contextual,Converter<Object,String>,Identifiable,Locatable,Logged,HandlerPlugin<ConversionRequest>,HasPluginInfo,RichPlugin,SciJavaPlugin,SingletonPlugin,TypedPlugin<ConversionRequest>,Prioritized,Typed<ConversionRequest>,Versioned
public class ArrayToStringConverter extends AbstractConverter<Object,String>
AConverterthat specializes in converting n-dimensional arrays intoStrings. ThisConvertercan convert any array whose component types can be converted intoStrings. By default, thisConverterdelimits the array elements with commas.- Author:
- Gabriel Selzer
-
-
Constructor Summary
Constructors Constructor Description ArrayToStringConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanConvert(Class<?> src, Class<?> dest)Checks whether objects of the given class can be converted to the specified type.booleancanConvert(Object src, Class<?> dest)Checks whether the given object's type can be converted to the specified type.<T> Tconvert(Object src, Class<T> dest)Converts the given object to an object of the specified type.Objectconvert(Object src, Type dest)AsConverter.convert(Object, Class)but capable of creating and populating multi-element objects (Collections and array types).Class<Object>getInputType()Class<String>getOutputType()-
Methods inherited from class org.scijava.convert.AbstractConverter
populateInputCandidates, supports
-
Methods inherited from class org.scijava.plugin.AbstractRichPlugin
getInfo, getPriority, setInfo, setPriority, toString
-
Methods inherited from class org.scijava.AbstractContextual
context, getContext
-
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.convert.Converter
canConvert, canConvert, canConvert, convert, getType
-
Methods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfo
-
Methods inherited from interface org.scijava.Locatable
getLocation
-
Methods inherited from interface org.scijava.Prioritized
compareTo, getPriority, setPriority
-
Methods inherited from interface org.scijava.plugin.RichPlugin
getIdentifier, log
-
Methods inherited from interface org.scijava.Versioned
getVersion
-
-
-
-
Method Detail
-
canConvert
public boolean canConvert(Class<?> src, Class<?> dest)
Description copied from interface:ConverterChecks whether objects of the given class can be converted to the specified type.Note that this does not necessarily entail that
Converter.convert(Object, Class)on a specific object of the given source class will succeed. For example:canConvert(String.class, int.class)will returntruebecause aStringcan in general be converted to anint, but callingconvert("5.1", int.class)will throw aNumberFormatExceptionwhen the conversion is actually attempted via theInteger(String)constructor.- See Also:
Converter.convert(Object, Class)
-
canConvert
public boolean canConvert(Object src, Class<?> dest)
Description copied from interface:ConverterChecks whether the given object's type can be converted to the specified type.- See Also:
Converter.convert(Object, Class)
-
convert
public Object convert(Object src, Type dest)
Description copied from interface:ConverterAsConverter.convert(Object, Class)but capable of creating and populating multi-element objects (Collections and array types). If a single element type is provided, it will be converted the same asConverter.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
Collectioninterface or abstract class is provided we can only make a best guess as to what container type to instantiate; defaults are provided forSet,Queue, andList.- Parameters:
src- The object to convert.dest- Type to which the object should be converted.
-
convert
public <T> T convert(Object src, Class<T> dest)
Description copied from interface:ConverterConverts the given object to an object of the specified type. The object is casted directly if possible, or else a new object is created using the destination type's public constructor that takes the original object as input (except when converting toString, which uses theObject.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.- Type Parameters:
T- Type to which the object should be converted.- Parameters:
src- The object to convert.dest- Type to which the object should be converted.
-
getOutputType
public Class<String> getOutputType()
- Returns:
- The base
ClassthisConverterproduces as output.
-
-