Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4FE8818544 for ; Thu, 24 Mar 2016 20:13:37 +0000 (UTC) Received: (qmail 74128 invoked by uid 500); 24 Mar 2016 20:13:27 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 73669 invoked by uid 500); 24 Mar 2016 20:13:27 -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 72976 invoked by uid 99); 24 Mar 2016 20:13:26 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Mar 2016 20:13:26 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 776532C1F71 for ; Thu, 24 Mar 2016 20:13:26 +0000 (UTC) Date: Thu, 24 Mar 2016 20:13:26 +0000 (UTC) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CONFIGURATION-480) Reading Manifest files using PropertiesConfiguration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CONFIGURATION-480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Oliver Heger updated CONFIGURATION-480: --------------------------------------- Fix Version/s: (was: 2.0) 2.x > Reading Manifest files using PropertiesConfiguration > ---------------------------------------------------- > > Key: CONFIGURATION-480 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-480 > Project: Commons Configuration > Issue Type: Bug > Affects Versions: 1.7 > Reporter: Chris Molozian > Fix For: 2.x > > > I've searched through the documentation and online with Google. The documentation for PropertiesConfiguration explains that it can parse files with '=' or ':' or ' ' as delimiters. I have a MANIFEST.MF file with the following format: > {code:title=MANIFEST.MF|borderStyle=solid} > Manifest-Version: 1.0 > Implementation-Title: webapp > Implementation-Version: 0.0.1 > Created-By: Gradle 1.0-milestone-6 > Build-Jdk: 1.6.0_26 > {code} > I've tried to use the PropertiesConfiguration to parse this file, assuming that the ' ' delimiter would be used to divide key-value pairs. Instead I get the following error: > {code} > java.lang.IllegalArgumentException: Key for add operation must be defined! > at org.apache.commons.configuration.tree.DefaultExpressionEngine.prepareAdd(DefaultExpressionEngine.java:420) > at org.apache.commons.configuration.HierarchicalConfiguration.addPropertyDirect(HierarchicalConfiguration.java:383) > at org.apache.commons.configuration.AbstractHierarchicalFileConfiguration.addPropertyDirect(AbstractHierarchicalFileConfiguration.java:147) > at org.apache.commons.configuration.AbstractConfiguration.addPropertyValues(AbstractConfiguration.java:423) > at org.apache.commons.configuration.AbstractConfiguration.append(AbstractConfiguration.java:1271) > {code} > At the moment I've created a (very rough) custom PropertiesReader as suggested by the User Guide for handling "unconventional formats". > {code} > private static class ManifestPropertiesReader > extends PropertiesConfiguration.PropertiesReader { > public ManifestPropertiesReader(final Reader in, final char delimiter) { > super(in, delimiter); > } > @Override > protected void parseProperty(final String line) { > final int pos = line.indexOf(':'); > final String key = line.substring(0, pos).trim(); > final String value = line.substring(pos + 1).trim(); > initPropertyName(key); > initPropertyValue(value); > } > } > {code} > And: > {code} > private static class ManifestIOFactory > extends PropertiesConfiguration.DefaultIOFactory { > /** Use a custom {@code PropertiesReader} for Manifest files. */ > @Override > public PropertiesReader createPropertiesReader(final Reader in, > final char delimiter) { > return new ManifestPropertiesReader(in, delimiter); > } > } > {code} > Should all this be necessary to parse MANIFEST.MF files or have I missed something? -- This message was sent by Atlassian JIRA (v6.3.4#6332)