• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getValueAt method

 
Manoj Dixit
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using AbstractTableModel. The getValueAt() method simply returns the string. Everything is working fine ( JTable displays the data properly).The problem is when I tried to get length(String), its printing out Byte value ( same value as per my database schema ) and not actually a string length.
For E.g.
The owner field is blank, but when I prints the length it's giving me 8.
Regard's
Manoj,
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible that the "blank" owner field consists of 8 spaces? In this case the string length really is 8. Your main options are (a) use trim() to get rid of the extra spaces, or (b) just ignore them if they're not actually causing a problem. Beware that whatever you decide, you may have to rememeber what you did later. E.g. if the user searches for an "exact match" you may need to trim strings to ignore any trailing spaces.
 
Manoj Dixit
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim,
You are right those are extra spaces. As I am just using it for validating whether contractor is booked or not. So the triming does not affect any operation.

Thanks a lot.

Regard's
Manoj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic