• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

One to many mapping of properties in java

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic