Bug 58563

Summary: XSSFRichTextString does not implement equals, but HSSFRichTextString does
Product: POI Reporter: Adrodoc55 <adrodoc55>
Component: XSSFAssignee: POI Developers List <dev>
Status: NEEDINFO ---    
Severity: normal    
Priority: P2    
Version: 3.13-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Adrodoc55 2015-10-29 12:18:12 UTC
XSSFRichTextString does not implement equals, but HSSFRichTextString does.
This makes it inconsistent to work with the shared Interface RichTextString.
Comment 1 David North 2015-10-29 12:27:20 UTC
What sort of equality did you have in mind?

* XSSFRichTextString comparable to other XSSFRichTextString (only)
* XSSFRichTextString comparable to HSSFRichTextString

It looks like the HSSF equality is in terms of the string characters themselves, and not the fonts. i.e. it's roughly equivalent to comparing getString() values.

Potentially we could make both sorts comparable on the basis of getString().
Comment 2 Adrodoc55 2015-10-29 12:54:45 UTC
(In reply to David North from comment #1)
> What sort of equality did you have in mind?
> 
> * XSSFRichTextString comparable to other XSSFRichTextString (only)
> * XSSFRichTextString comparable to HSSFRichTextString
> 
> It looks like the HSSF equality is in terms of the string characters
> themselves, and not the fonts. i.e. it's roughly equivalent to comparing
> getString() values.
> 
> Potentially we could make both sorts comparable on the basis of getString().

I had XSSFRichTextString comparable to other XSSFRichTextString (only) in mind.
I am not sure if XSSFRichTextString comparable to HSSFRichTextString would be usefull.

In my concrete case the problem is, that the following assertion works for HSSF but not XSSF:
Cell cell = ...
RichTextString richTextString = ...
cell.setCellValue(richTextString)
assert cell.getRichStringCellValue().equals(richTextString)
Comment 3 Javen O'Neal 2016-04-06 02:05:15 UTC
Shouldn't H/XSSFRichTextString equals method be a rich text compare? If the user wants plain text compare, they can always do H/XSSFRichTextString.getString().equals.