On Apr 16, 2009, at 11:42 PM, Vincent Massol wrote:
On Apr 16, 2009, at 11:38 PM, Sergiu Dumitriu wrote:
> Vincent Massol wrote:
>> Hi,
>>
>> In the rendering code we have several places where we've had to
>> create
>> generic string manipulation classes/methods (for example a method to
>> remove a single NL at start and end of string).
>> I think it would be better to create one or several components for
>> these string manipulation methods (same as we have xwiki-xml for xml
>> manipulation).
>>
>> The idea is that we should use existing framework as much as
>> possible
>> (StringUtils from commons lang for ex) but when we cannot find an
>> existing framework to manipulate text then we would put it in xwiki-
>> text.
>>
>> WDYT?
>>
>
> I don't know if this is really needed. StringUtils is supposed to
> be the
> library for string manipulation.
I'd love that too and I'd be much happier without any extra module.
Check CleanUtil.java in the converter module; you'll see it contains
lots of utility methods.
Isn't
StringUtils.removeStart(content,
"\n") + StringUtils.chomp(content) enough?
removeStart removes all NL not only the first one. BTW it's not only
"\n" but "\n", "\r" or "\r\n".
> If we just need a couple of methods on top of StringUtils, then I'd
> rather not introduce a new component. Especially one that's as
> simple as
> this one.
I think I prefer to have components rather than statics (same for
XMLUtils btw which I started I know... :)) but that's a detail
compared to the larger question of whether we want a xwiki-text module
for containing all our generic text manipulation code. BTW it wouldn't
be a single class. For example I envision one called WhitespaceUtil
for all NL/WS manipulations.
I have thought about merging xwiki-xml and xwiki-text into something
like xwiki-utils but I don't think it flies (especially since we have
the HTML cleaner in xwiki-xml). Of course we could have xwiki-utils
and another xwiki-html or xwiki-htmlcleaner module.
-Vincent
Where would you put them then? Copy paste them?
Right now for ex we have duplication in the 1.0 converter and in the
MacroTransformation.
-Vincent