Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26472 > unrolled thread

[Preferences]What is the use of .nodeExists?

Started byDaniel Moyne <daniel.moyne@free.fr>
First post2013-11-03 12:51 +0100
Last post2013-11-03 14:16 +0100
Articles 3 — 2 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  [Preferences]What is the use of .nodeExists? Daniel Moyne <daniel.moyne@free.fr> - 2013-11-03 12:51 +0100
    Re: [Preferences]What is the use of .nodeExists? Joerg Meier <joergmmeier@arcor.de> - 2013-11-03 13:18 +0100
      Re: [Preferences]What is the use of .nodeExists? Daniel Moyne <daniel.moyne@free.fr> - 2013-11-03 14:16 +0100

#26472 — [Preferences]What is the use of .nodeExists?

FromDaniel Moyne <daniel.moyne@free.fr>
Date2013-11-03 12:51 +0100
Subject[Preferences]What is the use of .nodeExists?
Message-ID<527638d5$0$3642$426a74cc@news.free.fr>
I am developing a module called "NamesPartitionsPlugin" with NetBeans. I get 
module Preferences with :

myModulePreferences = NbPreferences.forModule(NamesPartitionsPlugin.class);

Each time I open a file I want to save and retrieve some data in preferences 
associated with this file.

I do this to create a specific node.
myModulePreferences.node(myGedcomFile);
This will either create the node if it does not exists yet or initialize it 
with existing data if it already exists.

I want to know in some cases if a particular node already exists. If I do :
Boolean flag=myModulePreferences.nodeExists(myGedcomName);
It returns always false until I do :
myModulePreferences.node(myGedcomFile);

Then here is ma question :
What is the use of nodeExists(myGedcomName) if you have to use it after node 
creation and more generally how can I test whether I have already data 
stored in Preferences associated with a particular file.
Thanks.

-- 
Daniel Moyne (Nulix)   Linux        \\|||//  Machine : x86_64
Distribution : Kubuntu 13.04 Raring / --- \ Ringtail ATI Radeon 4850
kernel : 3.8.0-13-generic-23       (' o-o ') KDE 4.10.1
----------------------------------oOO-(_)-OOo-------------------------------

[toc] | [next] | [standalone]


#26473

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-11-03 13:18 +0100
Message-ID<tozhemry7dj0.1ikhc8lu9em95.dlg@40tude.net>
In reply to#26472
On Sun, 03 Nov 2013 12:51:46 +0100, Daniel Moyne wrote:

> I do this to create a specific node.
> myModulePreferences.node(myGedcomFile);
> This will either create the node if it does not exists yet or initialize it 
> with existing data if it already exists.

> I want to know in some cases if a particular node already exists. If I do :
> Boolean flag=myModulePreferences.nodeExists(myGedcomName);
> It returns always false until I do :
> myModulePreferences.node(myGedcomFile);

> Then here is ma question :
> What is the use of nodeExists(myGedcomName) if you have to use it after node 
> creation and more generally how can I test whether I have already data 
> stored in Preferences associated with a particular file.

You seem to randomly mix "myGedcomName" and "myGedcomFile". I'm not sure if
that is intentional, but if it is, you of course can't check if you have a
nome myGedcomFile by using nodeExists(myGedcomName) - that doesn't even
make any sense. The use of nodeExists is to check if a node exists.
Obviously, nodeExists will return false if the node does not exist, and
obviously, if you want it to return true, you have to call if after you add
the node.

Your question is confusing and seems to lack some detail that you consider
obvious and didn't include. You describe the normal and expected behaviour,
and then ask "what the use of that" is, which makes no sense to me. The use
of nodeExists is exactly the use you have described in the lines above. You
can use it the way you do and the answer to your question "how can I test
whether I have already data" is "with the code you provided above".

More details seem to be needed, as that is likely not what you wanted to
hear.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#26474

FromDaniel Moyne <daniel.moyne@free.fr>
Date2013-11-03 14:16 +0100
Message-ID<52764caf$0$2050$426a74cc@news.free.fr>
In reply to#26473
Joerg Meier wrote:

> On Sun, 03 Nov 2013 12:51:46 +0100, Daniel Moyne wrote:
> 
>> I do this to create a specific node.
>> myModulePreferences.node(myGedcomFile);
>> This will either create the node if it does not exists yet or initialize
>> it with existing data if it already exists.
> 
>> I want to know in some cases if a particular node already exists. If I do
>> : Boolean flag=myModulePreferences.nodeExists(myGedcomName);
>> It returns always false until I do :
>> myModulePreferences.node(myGedcomFile);
> 
>> Then here is ma question :
>> What is the use of nodeExists(myGedcomName) if you have to use it after
>> node creation and more generally how can I test whether I have already
>> data stored in Preferences associated with a particular file.
> 
> You seem to randomly mix "myGedcomName" and "myGedcomFile". I'm not sure
> if that is intentional, but if it is, you of course can't check if you
> have a nome myGedcomFile by using nodeExists(myGedcomName) - that doesn't
> even make any sense.
Sorry, it was unintentional. It is the same because as a matter of fact 
myGedcomName is the name of a gedcom file. Let us keep it myGedcomName.
> The use of nodeExists is to check if a node exists.
> Obviously, nodeExists will return false if the node does not exist, and
> obviously, if you want it to return true, you have to call if after you
> add the node.
> 
> Your question is confusing and seems to lack some detail that you consider
> obvious and didn't include. You describe the normal and expected
> behaviour, and then ask "what the use of that" is, which makes no sense to
> me. The use of nodeExists is exactly the use you have described in the
> lines above. You can use it the way you do and the answer to your question
> "how can I test whether I have already data" is "with the code you
> provided above".
> 
> More details seem to be needed, as that is likely not what you wanted to
> hear.
> 
> Liebe Gruesse,
> Joerg
Joerg, once I have done:
myGedcomPreferences = myModulePreferences.node(myGedcomName);
I have either created a node or reinitialized it if it already exists, but I 
thought that before I could check whether this node containing my data (if 
already used to store data) already existed. Maybe I have not understood the 
use of :
myModulePreferences.nodeExists(myGedcomName);

Basically what I am interested in is once I open my gedcom file is there 
already some data stored in preferences to discriminate in my code between 
both cases:
(1) I have no data stored yet,
(2) I have some data stored.

Is there a simple way to know? Otherwise I have to check for the presence of 
a particular key in myGedcomPreferences to know in which case I am standing.
Daniel.
-- 
Daniel Moyne (Nulix)   Linux        \\|||//  Machine : x86_64
Distribution : Kubuntu 13.04 Raring / --- \ Ringtail ATI Radeon 4850
kernel : 3.8.0-13-generic-23       (' o-o ') KDE 4.10.1
----------------------------------oOO-(_)-OOo-------------------------------

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web