What is wrong with Arrays.toString(...) ? Been there since 1.2?

Kind regards,

        Peter Kriens


On 4 jun 2010, at 10:53, Felix Meschberger (JIRA) wrote:

> 
>    [ 
> https://issues.apache.org/jira/browse/FELIX-2284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875531#action_12875531
>  ] 
> 
> Felix Meschberger commented on FELIX-2284:
> ------------------------------------------
> 
> Good thing. Thanks.
> 
> And, yes I agree, the printing the brackets on arrays is a good thing, we 
> don't need the "addBracesIfArray" flag.
> 
>> Add common utility method for converting object (array) to string
>> -----------------------------------------------------------------
>> 
>>                Key: FELIX-2284
>>                URL: https://issues.apache.org/jira/browse/FELIX-2284
>>            Project: Felix
>>         Issue Type: Improvement
>>         Components: Web Console
>>   Affects Versions: webconsole-3.0.0
>>           Reporter: Valentin Valchev
>>           Assignee: Valentin Valchev
>>            Fix For: webconsole-3.0.2
>> 
>> 
>> Currently few plugins are making their own methods to convert an object 
>> (array) to string. And usually uses different approaches for converting the 
>> arrays:
>> #1 The following methods will convert array to string like "1, 2, 3". They 
>> use StringBuffer and append elements one by one.
>> ServicesServlet.propertyAsString()
>> ConfigurationRendere.asString()
>> #2 Another approach that is used, converts the array to List, and then 
>> toString() which returns "[1, 2, 3]"
>> ComponentConfigurationPrinter.listProperties()
>> ComponentServlet.listProperties()
>> #3 in event plugin the code from the method below prints "[1, 2, 3]" but 
>> uses approach similar to #1
>> PluginServlet.eventJson
>> The smaller problem is that we have duplicate code. The bigger problem is 
>> that the code ... will not work correctly, if the array is from primitive 
>> types (see https://issues.apache.org/jira/browse/FELIX-2142).
>> ----
>> So my proposal is to add a new utility method, 
>> WebConsoleUtil.toString(Object val, boolean addBracesIfArray);
>> The other option is to remove addBracesIfArray and always assume, that if it 
>> is array, the value is wrapped with [] braces.
>> --
>> WDYT?
> 
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 

Reply via email to