Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsStoring multidimensional String arrays in preferences
https://www.eclipse.org/forums/index.php/mv/msg/83958/260763/#msg_260763
i want to store a multidimensional string array in the preferences. so far
i read through this article http://www.eclipse.org/articles/Article-Preferences/preferen ces.htm which
explains how to store an one dimensional array.
but i want to store values in a table kind of structure. i think it can be
done since the usual java preferences use a table layout as well sometimes.
anyone who can hint me to the right path? :)
thx in advance
moritz post]]>Moritz Post2004-07-12T15:44:59-00:00Re: Storing multidimensional String arrays in preferences
https://www.eclipse.org/forums/index.php/mv/msg/83958/260798/#msg_260798
Preferences are always stored as strings - regardless of what object
they represent. To handle objects other than strings, you need a way of
converting them into strings for storage, and then a way of turning
those strings back into objects.
(NB - this is conceptually similar to pickling; has anyone tried using
pickle to do this job?)
In the preferences article, an array {"a","b","c"} is changed into the
string "a;b;c" (where PREFERENCE_DELIMITER=";") by setBadWordsPreference
Conversely, "a;b;c" is converted into an array {"a","b","c"} by the
convert method.
You could extend this approach to handle 2-dimensional arrays by having
an end of row delimiter.
eg. store a b c as "a;b;c|d;e;f"
d e f
where the column delimiter is ";" and the row delimiter is "|"
So to handle multi-dimensional arrays, you need to:
a) create a widget on your preference page that will allow the user to
edit the array
b) define a method to convert your arrays into strings, and another
method to reverse the process, converting your strings into arrays.
Hope that helps,
- Dan
Moritz Post wrote:
> hi there
>
> i want to store a multidimensional string array in the preferences. so far
> i read through this article
> http://www.eclipse.org/articles/Article-Preferences/preferen ces.htm which
> explains how to store an one dimensional array.
>
> but i want to store values in a table kind of structure. i think it can be
> done since the usual java preferences use a table layout as well sometimes.
>
> anyone who can hint me to the right path? :)
>
> thx in advance
> moritz post
>]]>Dan Winterstein2004-07-12T16:36:40-00:00Re: Storing multidimensional String arrays in preferences
https://www.eclipse.org/forums/index.php/mv/msg/83958/260803/#msg_260803
thx for the swift answer...
after reading through some sources of the jdt and examining the exported
preferences i realized, that the jdt converts the data into an xml tree
and stores that tree. i will go for that apropach.
btw... thx for your explanaition :)
moritz
> Preferences are always stored as strings - regardless of what object
> they represent. To handle objects other than strings, you need a way of
> converting them into strings for storage, and then a way of turning
> those strings back into objects.
> (NB - this is conceptually similar to pickling; has anyone tried using
> pickle to do this job?)
> In the preferences article, an array {"a","b","c"} is changed into the
> string "a;b;c" (where PREFERENCE_DELIMITER=";") by setBadWordsPreference
> Conversely, "a;b;c" is converted into an array {"a","b","c"} by the
> convert method.
> You could extend this approach to handle 2-dimensional arrays by having
> an end of row delimiter.
> eg. store a b c as "a;b;c|d;e;f"
> d e f
> where the column delimiter is ";" and the row delimiter is "|"
> So to handle multi-dimensional arrays, you need to:
> a) create a widget on your preference page that will allow the user to
> edit the array
> b) define a method to convert your arrays into strings, and another
> method to reverse the process, converting your strings into arrays.
> Hope that helps,
> - Dan
> Moritz Post wrote:
> > hi there
> >
> > i want to store a multidimensional string array in the preferences. so far
> > i read through this article
> > http://www.eclipse.org/articles/Article-Preferences/preferen ces.htm which
> > explains how to store an one dimensional array.
> >
> > but i want to store values in a table kind of structure. i think it can be
> > done since the usual java preferences use a table layout as well sometimes.
> >
> > anyone who can hint me to the right path? :)
> >
> > thx in advance
> > moritz post
> >]]>Moritz Post2004-07-12T16:40:29-00:00