Fix issue 1946: make it easier to read multi-valued DN properties. The get-xxx-prop sub-commands separate multi-valued properties using comma separators. This makes the display quite hard to read when the values are DNs because the DNs themselves contain commas. This change modifies the property value printing for dsconfig so that any values containing a comma or that entirely comprise of white-space are double-quoted. Thus, the DN dc=com stays as dc=com and the value dc=example,dc=com becomes "dc=example,dc=com".
Note that the get-xxx-prop sub-commands also support a one value per line mode (-E) which makes multi-valued properties easier to read. The sub-commands also support a script-friendly mode where no quoting is performed.
| | |
| | | public <T> String visitUnknown(PropertyDefinition<T> d, T v, Void p) { |
| | | // For all other property definition types the default encoding |
| | | // will do. |
| | | return d.encodeValue(v); |
| | | String s = d.encodeValue(v); |
| | | if (isScriptFriendly) { |
| | | return s; |
| | | } else if (s.trim().length() == 0 || s.contains(",")) { |
| | | // Quote empty strings or strings containing commas |
| | | // non-scripting mode. |
| | | return "\"" + s + "\""; |
| | | } else { |
| | | return s; |
| | | } |
| | | } |
| | | |
| | | } |