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
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.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira