Re: XMLEncoder problem



On Sun, 21 Dec 2008 20:41:58 +0000, Arved Sandstrom wrote:

On Sun, 21 Dec 2008 06:27:37 +0000, Ken T. wrote:

On Sat, 20 Dec 2008 20:35:44 -0800, Mark Space wrote:

Ken T. wrote:

Thus the XMLEncode will notice that the property "words" (defined by
set/getWords) is actually different compared to the state after the
default constructor and writes the List to the output.

It is actually the variable, words, that doesn't seem to be being
saved.

Have I gone blind again? I don't see any setters or getters for words
at all, just word list. Even the add() method adds a world to
wordList, not words. Nothing that I see even touches "words".

If the method setWords() is called it initializes both wordList and
words. The only time words is really used is when a word is added to
the list. If it already exists, it is in words, then it isn't added
and an exception is thrown.

So when I use XMLDecoder I get all the words in wordList, but I'm still
able to add a word that already exists in wordList since words is not
updated. Somehow XMLDecoder is initializing wordList without calling
the setter. At least that is the best guess I have.

Based on the XML I saw, and printouts, I believe that the decoder is
creating an empty wordList, then calling add(Word word) on it for each
word. That's why you never see the setter called.

AHS

It doesn't hit a breakpoint there either. It must be accessing the
private member variables. I'll put together an sample program that shows
exactly what I'm talking about.



--
Ken T.

The question of whether computers can think is just like the question
of whether submarines can swim.
-- Edsger W. Dijkstra
.



Relevant Pages

  • Re: XMLEncoder problem
    ... If the method setWords() is called it initializes both wordList and ... Somehow XMLDecoder is initializing wordList without calling ... That's why you never see the setter called. ...
    (comp.lang.java.programmer)
  • Re: XMLEncoder problem
    ... Somehow XMLDecoder is initializing wordList without calling ... That's why you never see the setter called. ... I'll put together an sample program that shows ...
    (comp.lang.java.programmer)
  • Re: Accessors in Python (getters and setters)
    ... something else (user interaction, physical events); ... intermediation of setter methods that do nothing else but set the state. ... calling a setter function that does nothing else but directly setting the ... The conceptual difference is that a function call is more like an "event", ...
    (comp.lang.python)
  • Re: question from C# novice
    ... Generally the get/set just updates a private variable. ... the name of the property that is you are calling again the "set" that calls ... >> Your problem is that inside your setter, ...
    (microsoft.public.dotnet.general)
  • Re: Conditional Breaks
    ... its value, set the breakpoint in the setter or method, and use the Call ... Stack window to locate the calling line. ...
    (microsoft.public.dotnet.framework.clr)