From issues-return-67083-archive-asf-public=cust-asf.ponee.io@commons.apache.org Fri Mar 23 14:28:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1167218067E for ; Fri, 23 Mar 2018 14:28:03 +0100 (CET) Received: (qmail 25409 invoked by uid 500); 23 Mar 2018 13:28:02 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 25383 invoked by uid 99); 23 Mar 2018 13:28:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Mar 2018 13:28:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 7AF081A0291 for ; Fri, 23 Mar 2018 13:28:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -101.511 X-Spam-Level: X-Spam-Status: No, score=-101.511 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id nTH9QimukbXH for ; Fri, 23 Mar 2018 13:28:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 339635F126 for ; Fri, 23 Mar 2018 13:28:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 86694E010F for ; Fri, 23 Mar 2018 13:28:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 3DF35214E1 for ; Fri, 23 Mar 2018 13:28:00 +0000 (UTC) Date: Fri, 23 Mar 2018 13:28:00 +0000 (UTC) From: "Lars W (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CONFIGURATION-693) Conversion to File is missing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CONFIGURATION-693?page=3Dcom.a= tlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Lars W updated CONFIGURATION-693: --------------------------------- Description: PropertyConverter.java misses type conversion to File alth= ough a string could be easily converted to a File. (was: PropertyConverter= .java misses type conversion to File although a string could be easily conv= erted to a File. Attaching the patch as a file does not work - I don't know why. So I'll pas= te it here: =C2=A0 Index: src/main/java/org/apache/commons/configuration/PropertyConverter.jav= a =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/main/java/org/apache/commons/configuration/PropertyConverter.java +++ src/main/java/org/apache/commons/configuration/PropertyConverter.java @@ -19,6 +19,7 @@ =C2=A0package org.apache.commons.configuration2.convert; =C2=A0 =C2=A0import java.awt.Color; +import java.io.File; =C2=A0import java.lang.reflect.Constructor; =C2=A0import java.lang.reflect.InvocationTargetException; =C2=A0import java.math.BigDecimal; @@ -29,6 +30,7 @@ =C2=A0import java.net.URISyntaxException; =C2=A0import java.net.URL; =C2=A0import java.net.UnknownHostException; +import java.nio.file.Path; =C2=A0import java.text.ParseException; =C2=A0import java.text.SimpleDateFormat; =C2=A0import java.util.Calendar; @@ -153,6 +155,10 @@ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= turn toCalendar(value, convHandler.getDateFormat()); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (File.class.equals(cls)= ) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return = toFile(value); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (URI.class.equals(= cls)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= turn toURI(value); @@ -477,6 +483,33 @@ =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 /** +=C2=A0=C2=A0=C2=A0=C2=A0 * Convert the specified object into a File. +=C2=A0=C2=A0=C2=A0=C2=A0 * +=C2=A0=C2=A0=C2=A0=C2=A0 * @param value the value to convert +=C2=A0=C2=A0=C2=A0=C2=A0 * @return the converted value +=C2=A0=C2=A0=C2=A0=C2=A0 * @throws ConversionException thrown if the value= cannot be converted to a File +=C2=A0=C2=A0=C2=A0=C2=A0 */ +=C2=A0=C2=A0=C2=A0 public static File toFile(Object value) throws Conversi= onException +=C2=A0=C2=A0=C2=A0 { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (value instanceof File) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return = (File) value; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (value instanceof Path) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return = ((Path) value).toFile(); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (value instanceof Strin= g) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return = new File((String) value); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 throw n= ew ConversionException("The value " + value + " can't be converted to a Fil= e"); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 } + +=C2=A0=C2=A0=C2=A0 /** =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Convert the specified object into an URI. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * @param value the value to convert) > Conversion to File is missing > ----------------------------- > > Key: CONFIGURATION-693 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-= 693 > Project: Commons Configuration > Issue Type: Improvement > Components: Type conversion > Affects Versions: 2.2 > Reporter: Lars W > Priority: Major > Attachments: Converter.patch.txt > > > PropertyConverter.java misses type conversion to File although a string c= ould be easily converted to a File. -- This message was sent by Atlassian JIRA (v7.6.3#76005)