private static Object convert()

in activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/IntrospectionSupport.java [181:207]


    private static Object convert(Object value, Class type) throws URISyntaxException {
        PropertyEditor editor = PropertyEditorManager.findEditor(type);
        if (editor != null) {
            editor.setAsText(value.toString());
            return editor.getValue();
        }
        if (type == URI.class) {
            return new URI(value.toString());
        }
        if (type == File.class) {
            return new File(value.toString());
        }
        if (type == File[].class) {
            ArrayList<File> files = new ArrayList<File>();
            StringTokenizer st = new StringTokenizer(value.toString(), ":");
            while(st.hasMoreTokens()) {
                String t = st.nextToken();
                if( t!=null && t.trim().length()>0 ) {
                    files.add(new File(t.trim()));
                }
            }
            File rc[] = new File[files.size()];
            files.toArray(rc);
            return rc;
        }
        return null;
    }