Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Storing objects as preferences
Storing objects as preferences [message #323502] Sun, 23 December 2007 05:15 Go to next message
Eclipse UserFriend
Hi.

What is the best way to store data structures and custom object as plugin
preferences? The PreferenceStore provided by Eclipse can handle only
primitive types plus strings: even arrays are not supported.
Thanks.

--
Lorenzo Dalla Vecchia
Re: Storing objects as preferences [message #323503 is a reply to message #323502] Sun, 23 December 2007 08:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dmsubs.NOSPAM.consertum.com

Use a serializer and store them as strings.

--
Derek


Lorenzo Dalla Vecchia wrote:
> Hi.
>
> What is the best way to store data structures and custom object as
> plugin preferences? The PreferenceStore provided by Eclipse can handle
> only primitive types plus strings: even arrays are not supported.
> Thanks.
>
> --
> Lorenzo Dalla Vecchia
>
Re: Storing objects as preferences [message #323534 is a reply to message #323503] Wed, 26 December 2007 16:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Derek Morris" <dmsubs@NOSPAM.consertum.com> wrote in message
news:fklni8$qvj$1@build.eclipse.org...
> Use a serializer and store them as strings.

That's one approach. If the strings would be of unwieldy length, another
approach is to serialize the preferences into separate files. You can get
the appropriate file locations for per-plugin (workspace) settings from
Platform.getStateLocation(), or for per-project settings from
ProjectScope.getLocation().

There is some discussion of this at
http://wiki.eclipse.org/FAQ_How_do_I_store_extra_properties_ on_a_resource%3F
..
Re: Storing objects as preferences [message #323535 is a reply to message #323534] Wed, 26 December 2007 16:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Walter Harley" <wharley@bea.com> wrote in message
news:fkuhc2$esd$1@build.eclipse.org...
> "Derek Morris" <dmsubs@NOSPAM.consertum.com> wrote in message
> news:fklni8$qvj$1@build.eclipse.org...
>> Use a serializer and store them as strings.
>
> That's one approach. If the strings would be of unwieldy length, another
> approach is to serialize the preferences into separate files. You can get
> the appropriate file locations for per-plugin (workspace) settings from
> Platform.getStateLocation(), or for per-project settings from
> ProjectScope.getLocation().
>
> There is some discussion of this at
> http://wiki.eclipse.org/FAQ_How_do_I_store_extra_properties_ on_a_resource%3F .

I should also mention that another alternative is to use hierarchical
preferences. Preference nodes in Eclipse can contain nested nodes, so if
for instance you have a setting whose "value" is actually a map of strings,
you can make the setting be a node and nest the individual strings inside
it.

You can look at the code in org.eclipse.jdt.apt.core.AptConfig for an
example of how to do this.
Re: Storing objects as preferences [message #323551 is a reply to message #323503] Thu, 27 December 2007 19:45 Go to previous message
Eclipse UserFriend
Originally posted by: games.insight.com

Another approach would be to use Base64. I've used this approach to store
encrypted passwords, which are byte arrays.


"Derek Morris" <dmsubs@NOSPAM.consertum.com> wrote in message
news:fklni8$qvj$1@build.eclipse.org...
> Use a serializer and store them as strings.
>
> --
> Derek
>
>
> Lorenzo Dalla Vecchia wrote:
>> Hi.
>>
>> What is the best way to store data structures and custom object as plugin
>> preferences? The PreferenceStore provided by Eclipse can handle only
>> primitive types plus strings: even arrays are not supported.
>> Thanks.
>>
>> --
>> Lorenzo Dalla Vecchia
>>
Previous Topic:Java Debug Problem
Next Topic:Error has occured while closing workbench....
Goto Forum:
  


Current Time: Fri May 09 10:59:02 EDT 2025

Powered by FUDForum. Page generated in 0.03328 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top