This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Apache POI

 
Johannes Uhlmann
Greenhorn
Posts: 5
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

i got a question regarding to the class hierarchy of Cell and the possibility to implement Comparable.

There are HSSFCell implements Cell and XSSFCell implements Cell. I wanted the compareTo functionality for both, hence my idea was to design a class like abstract class MyCell implements Cell, Comparable<Cell>. So i could implement compareTo but omit the Cell functions. The problem is that MyCell is not a Cell. Available options: 1.) always cast if a Cell is needed 2.) extend HSSFCell as well as XSSFCell and implement Comparable for both. Are there more options?

regards
Johannes

edit: ;-)
 
Paul Clapham
Sheriff
Posts: 21136
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps something like

Another option would be to forget about making a Cell comparable; you can compare a MyCell object to an XSSFCell object, because you wrote the code for MyCell, but you can't compare an XSSFCell object to a MyCell object because you didn't write the code for XSSFCell. A Comparator might be a better idea.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic