Skip to content

Improve ConvertService to properly convert lists and arrays to String values #281

Open
@imagejan

Description

@imagejan

Currently, DefaultConvertService supports conversion from File[] to String and vice versa, but the result is wrong (i.e. a String representation of the File[] array, such as [Ljava.io.File;@31c3cff5).

The following Groovy script illustrates the issue:

#@ ConvertService cs

import java.io.File

file1 = new File("test1.csv")
file2 = new File("test2.csv")

File[] fileList = [file1, file2].toArray()

println fileList.getClass() // class [Ljava.io.File;

println cs.supports(fileList, String.class) // true
println cs.convert(fileList, String.class) // [Ljava.io.File;@31c3cff5

(The expected re-convertible output in this case should be something like test1.csv\ntest2.csv, ideally with the absolute paths of the files)

See also some related discussion in scijava/scijava-ui-swing#27.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions