• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One to many mapping of properties in java

 
brams mun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a mapping of files and devies, as of now its one-to-one mapping.

Now I need to implement one-to-many mapping(single file to multiple devices)

my logic for one-to-one mapping is



I have tried different ways which are not supporting my one-to-many mapping

1. I tried to loop through devices to map filess
2. tried to cut the string value of devices to map files

current output
--------------

devices :[1.2:SonyEricsson X10i, 1:Samsung I9000 Galaxy, 0.3:Motorola Droid Milestone, 0:Acer C6, 0.1:HTC Magic]
params files from screen :[0:TheSims3.apk, 1:Tetris.apk]
device mapping :[Acer C6:TheSims3.apk, Samsung I9000 Galaxy:Tetris.apk]

what I want is :
[Acer C6:TheSims3.apk, Samsung I9000 Galaxy:Tetris.apk, SonyEricsson X10i:Tetris.apk, HTC Magic:TheSims3.apk]


Thanks in advance for any help.
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
brams mun wrote:Now I need to implement one-to-many mapping(single file to multiple devices)

my logic for one-to-one mapping isI have tried different ways which are not supporting my one-to-many mapping

1. I tried to loop through devices to map filess
2. tried to cut the string value of devices to map files...

I'm still not quite sure exactly what your problem is, and
devices["${file.key}"]
is NOT valid Java; although it looks like it could be a Dictionary entry for something like Perl.

Could you please restate the question and provide the relevant piece of Java code that you've tried.

Also: in Java, the java.util.Properties class does not use the format you describe. It uses name=value pairs, and there's nothing to stop you making 'value' a comma-delimited list.

Winston
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that's Groovy (or one of the other JVM-based script-like languages).

Brams - if you can confirm what language you're using, I'll move this to the appropriate forum.
 
brams mun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes mathew, its groovy along with java, sorry for any confusion caused...I thought I could get an answer here...please feel free to move to groovy forum
 
brams mun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could resolve the issue by using



if you are using a version of Groovy before 1.7.9, you can use inject in place of collectEntries:



Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic