Messages of subject
Opening Jeks sheet which contains different objects |
sumit
Location : Pune/India
Member since : May 30, 2008
Messages : 2
|
May 30, 2008 at 8:57 AM
Hi,
The Jeks sheet displays message "Not a Jeks stream" if it can't open a Jeks Sheet. The Sheet we are using has various other objects set other than default one's.
Can you tell me where do I need to make change in Jeks code if I need to display Object's representation as object.toString() value? I hope this forum is still alive. :) --- ~Sumit
|
Manu
Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
|
May 31, 2008 at 9:23 AM
Hi,
This forum is still alive. ;-)
> Can you tell me where do I need to make change in Jeks code
> if I need to display Object's representation as object.toString() value?
If you take a look at the method encode of com.eteks.jeks.JeksCodec class, you'll see from the code:
buffer.append (valueClass.getName ());
buffer.append (" ");
buffer.append (String.valueOf (value));
that your objects will be saved with their class name and their toString representation.
Then, your objects will be read in decode method and in the case of an object class different of the default ones, this code is used:
valueClass = Class.forName (value.substring (0, spaceIndex));
Object cellValue = valueClass.getConstructor (new Class [] {String.class})
.newInstance (new String [] {value.substring (spaceIndex + 1)});
meaning that your additional classes should simply have a constructor with a string as parameter.
If this doesn't match your requirements, you may add all the special cases just before this code with a classical if test.
I hope this will help... --- Manu (moderator/modérateur)
|
sumit
Location : Pune/India
Member since : May 30, 2008
Messages : 2
|
Jun 19, 2008 at 12:50 PM
Thank you. I got a way to handle this. I was not able to view Jeks Sheet earlier as it would throw exception and didn't proceed on dealing with these types of classes. Now it works fine. --- ~Sumit
|