aspose file tools*
The moose likes Groovy and the fly likes One to many mapping of properties in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "One to many mapping of properties in java" Watch "One to many mapping of properties in java" New topic
Author

One to many mapping of properties in java

brams mun
Greenhorn

Joined: Nov 27, 2003
Posts: 25
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

Joined: Mar 17, 2011
Posts: 8008
    
  22

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

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

Joined: Nov 27, 2003
Posts: 25
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

Joined: Nov 27, 2003
Posts: 25
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: One to many mapping of properties in java