RE: [Configuration] Bug with XMLConfiguration and getString() ...?!
Hi Oliver, nice feature, but there are problems ... a) if you have both, list-entries and simple entries with decollator-signs I think you have to disable/enable this feature each time ... ok, better than nothing. If there are compatibility reasons, I agree but... b) for me it doesn't work as described f.e. I've got this code ... private static XMLConfiguration xml_config; /** * inits the configuration */ private static void initConfiguration() { try { xml_config = new XMLConfiguration(ApplicationContext.class.getResource(APPLICATION_CONFIG)); } catch (ConfigurationException ex) { ex.printStackTrace(); } } /** * static inner class for SFTP-params */ static class SFTPParamObj { public String host = xml_config.getString(sftp.host); public String port = xml_config.getString(sftp.port); public String user = xml_config.getString(sftp.user); public String pass = getPasswd(); /** * @return */ private String getPasswd() { xml_config.setDelimiterParsingDisabled(true); String pass = xml_config.getString(sftp.pass); xml_config.setDelimiterParsingDisabled(false); return pass; } } and the result of pass: 08 !!! What's wrong ??? Thanks, Markus -Ursprüngliche Nachricht- Von: Oliver Heger [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 29. Oktober 2008 21:55 An: Commons Users List Betreff: Re: [Configuration] Bug with XMLConfiguration and getString() ...?! Jörg Schaible schrieb: Grimm, Markus wrote: Hi guys, I've got the following problem: I've got a xml-config-file with that content: ?xml version=1.0 encoding=UTF-8? config ... sftp hostmyhost/host port22/port usertestuser/user pass08,15/pass /sftp ... /config In my application I get the info about pass f.e. like this String pass = xml_config.getString(sftp.pass); value of pass: '08' and not '08,15' I know, that ',' is the default-decollator für list-entries, but I think it shouldn't affect the getString()-Method ?! So it might be a bug?! Actually, it works as designed. getString() delivers the first list entry. And I am sure, that quite everyone will consider this as a bug ... it makes no sense to me either :-/ - Jörg You can disable this behavior by calling xml_config.setDelimiterParsingDisabled(true); That said, I fully agree that the default behavior is confusing - I fell into this trap more than once myself. For reasons of backwards compatibility we cannot change this in the 1.x series. But in a 2.0 version I am happy to disable delimiter parsing per default. Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Configuration] Bug with XMLConfiguration and getString() ...?!
Grimm, Markus schrieb: Hi Oliver, nice feature, but there are problems ... a) if you have both, list-entries and simple entries with decollator-signs I think you have to disable/enable this feature each time ... ok, better than nothing. If there are compatibility reasons, I agree but... There are two workarounds: - You can change the character used as list delimiter using the setListDelimiter() method (or even globally using AbstractConfiguration.setDefaultListDelimiter()). - List delimiters in strings can be escaped with a backslash. Your property value could be changed to 08\,15. b) for me it doesn't work as described f.e. I've got this code ... private static XMLConfiguration xml_config; /** * inits the configuration */ private static void initConfiguration() { try { xml_config = new XMLConfiguration(ApplicationContext.class.getResource(APPLICATION_CONFIG)); } catch (ConfigurationException ex) { ex.printStackTrace(); } } You have to call setDelimiterParsingDisabled(true) before you load the configuration. The processing of list elements is done during parsing of the configuration file. This is also mentioned in the Javadocs of the setDelimiterParsingDisabled() method. Oliver /** * static inner class for SFTP-params */ static class SFTPParamObj { public String host = xml_config.getString(sftp.host); public String port = xml_config.getString(sftp.port); public String user = xml_config.getString(sftp.user); public String pass = getPasswd(); /** * @return */ private String getPasswd() { xml_config.setDelimiterParsingDisabled(true); String pass = xml_config.getString(sftp.pass); xml_config.setDelimiterParsingDisabled(false); return pass; } } and the result of pass: 08 !!! What's wrong ??? Thanks, Markus -Ursprüngliche Nachricht- Von: Oliver Heger [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 29. Oktober 2008 21:55 An: Commons Users List Betreff: Re: [Configuration] Bug with XMLConfiguration and getString() ...?! Jörg Schaible schrieb: Grimm, Markus wrote: Hi guys, I've got the following problem: I've got a xml-config-file with that content: ?xml version=1.0 encoding=UTF-8? config ... sftp hostmyhost/host port22/port usertestuser/user pass08,15/pass /sftp ... /config In my application I get the info about pass f.e. like this String pass = xml_config.getString(sftp.pass); value of pass: '08' and not '08,15' I know, that ',' is the default-decollator für list-entries, but I think it shouldn't affect the getString()-Method ?! So it might be a bug?! Actually, it works as designed. getString() delivers the first list entry. And I am sure, that quite everyone will consider this as a bug ... it makes no sense to me either :-/ - Jörg You can disable this behavior by calling xml_config.setDelimiterParsingDisabled(true); That said, I fully agree that the default behavior is confusing - I fell into this trap more than once myself. For reasons of backwards compatibility we cannot change this in the 1.x series. But in a 2.0 version I am happy to disable delimiter parsing per default. Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [Configuration] Bug with XMLConfiguration and getString() ...?!
Oliver Heger wrote: Jörg Schaible schrieb: [snip] Actually, it works as designed. getString() delivers the first list entry. And I am sure, that quite everyone will consider this as a bug ... it makes no sense to me either :-/ - Jörg You can disable this behavior by calling xml_config.setDelimiterParsingDisabled(true); That said, I fully agree that the default behavior is confusing - I fell into this trap more than once myself. For reasons of backwards compatibility we cannot change this in the 1.x series. But in a 2.0 version I am happy to disable delimiter parsing per default. +1000, really looking forward to 2.0 - Jörg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [Configuration] Bug with XMLConfiguration and getString() ...?!
Hi, You have to call setDelimiterParsingDisabled(true) before you load the configuration. The processing of list elements is done during parsing of the configuration file. This is also mentioned in the Javadocs of the setDelimiterParsingDisabled() method. ok. you're right ... rtfm ... but there are some other solutions, too ... (if I would look at the api-docs ...) a) you can set the listDelimiter to another sign b) you can escape the delimiter sign f.e. pass08\,15pass so anyway... it works and thanks for your help. Markus Oliver /** * static inner class for SFTP-params */ static class SFTPParamObj { public String host = xml_config.getString(sftp.host); public String port = xml_config.getString(sftp.port); public String user = xml_config.getString(sftp.user); public String pass = getPasswd(); /** * @return */ private String getPasswd() { xml_config.setDelimiterParsingDisabled(true); String pass = xml_config.getString(sftp.pass); xml_config.setDelimiterParsingDisabled(false); return pass; } } and the result of pass: 08 !!! What's wrong ??? Thanks, Markus -Ursprüngliche Nachricht- Von: Oliver Heger [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 29. Oktober 2008 21:55 An: Commons Users List Betreff: Re: [Configuration] Bug with XMLConfiguration and getString() ...?! Jörg Schaible schrieb: Grimm, Markus wrote: Hi guys, I've got the following problem: I've got a xml-config-file with that content: ?xml version=1.0 encoding=UTF-8? config ... sftp hostmyhost/host port22/port usertestuser/user pass08,15/pass /sftp ... /config In my application I get the info about pass f.e. like this String pass = xml_config.getString(sftp.pass); value of pass: '08' and not '08,15' I know, that ',' is the default-decollator für list-entries, but I think it shouldn't affect the getString()-Method ?! So it might be a bug?! Actually, it works as designed. getString() delivers the first list entry. And I am sure, that quite everyone will consider this as a bug ... it makes no sense to me either :-/ - Jörg You can disable this behavior by calling xml_config.setDelimiterParsingDisabled(true); That said, I fully agree that the default behavior is confusing - I fell into this trap more than once myself. For reasons of backwards compatibility we cannot change this in the 1.x series. But in a 2.0 version I am happy to disable delimiter parsing per default. Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Configuration] Bug with XMLConfiguration and getString() ...?!
Jörg Schaible schrieb: Grimm, Markus wrote: Hi guys, I've got the following problem: I've got a xml-config-file with that content: ?xml version=1.0 encoding=UTF-8? config ... sftp hostmyhost/host port22/port usertestuser/user pass08,15/pass /sftp ... /config In my application I get the info about pass f.e. like this String pass = xml_config.getString(sftp.pass); value of pass: '08' and not '08,15' I know, that ',' is the default-decollator für list-entries, but I think it shouldn't affect the getString()-Method ?! So it might be a bug?! Actually, it works as designed. getString() delivers the first list entry. And I am sure, that quite everyone will consider this as a bug ... it makes no sense to me either :-/ - Jörg You can disable this behavior by calling xml_config.setDelimiterParsingDisabled(true); That said, I fully agree that the default behavior is confusing - I fell into this trap more than once myself. For reasons of backwards compatibility we cannot change this in the 1.x series. But in a 2.0 version I am happy to disable delimiter parsing per default. Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]