public class StringToNumberConverter extends AbstractConverter<String,Number>
String
to a Number
. Currently handles all boxed
and unboxed primitives, along with the Numbers. In particular,
String
s converted Number
s are just Double
s, as this
features the broadest range of integers.Constructor and Description |
---|
StringToNumberConverter() |
Modifier and Type | Method and Description |
---|---|
boolean |
canConvert(Object src,
Class<?> dest)
Checks whether the given object's type can be converted to the specified
type.
|
<T> T |
convert(Object src,
Class<T> dest)
Converts the given object to an object of the specified type.
|
Class<String> |
getInputType() |
Class<Number> |
getOutputType() |
populateInputCandidates, supports
getInfo, getPriority, setInfo, setPriority, toString
context, getContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canConvert, canConvert, canConvert, canConvert, convert, convert, getType
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
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<Number> getOutputType()
Class
this Converter
produces as output.public Class<String> getInputType()
Class
this Converter
accepts as input.public boolean canConvert(Object src, Class<?> dest)
Converter
Converter.convert(Object, Class)
Copyright © 2009–2023 SciJava. All rights reserved.