an alternative to properties files?

Hello!

I want to store and retrieve in/from a file some parameters. The problem is that I have multiple values for the same key

for example

key name=db

values for this key: db1,db2,db3

More, at some point

I need some kind of association of the following type

[key1,key2] -> value1

[key1,key3] -> value 2

.....

etc

Is some way to model this using a properties file or some kind of similar built-in mechanism (without having to parse a text file)?

Thanks

Sorin

[550 byte] By [Sorin_Ciolofana] at [2007-11-27 10:55:44]
# 1

Maybe Preferences, storing an array as a serialized byte[].

CeciNEstPasUnProgrammeura at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...
# 2

Could have those multiple values on the one line, and delimited by something. Nasty but it works. Or you could use XML

Hang on, you say you have multiple values for one key, but your example is the other way round - multiple keys for one value. Which is it?

georgemca at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...
# 3

I have both cases, as written:

1 key and multiple values

multiple keys and 1 value

Sorin_Ciolofana at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...
# 4

Multiple keys to one value is easy. Properties don't insist on values being unique

georgemca at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...
# 5

Yeah go to XML and just DOM parse it...

it'll handle the 1-to-many; and many-to-1 relationships ok.

properties presumes there is a unique key.

corlettka at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...
# 6

Or even simpler, perhaps. Use something like Apache Digester or Spring's IoC container to configure a bean. Might be a bit heavyweight for your needs, though

georgemca at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...
# 7

Thanks

Sorin_Ciolofana at 2007-7-29 11:58:28 > top of Java-index,Java Essentials,Java Programming...