need to set a Map<String, List<String>> using property file

3,175 views
Skip to first unread message

ATG Developer

unread,
Nov 24, 2008, 11:45:44 AM11/24/08
to ATG_Tech
Hi all,

Can anyone suggest me with the syntax how i can set a map with key as
a string and its value as a List or a Map object.

If it is not possible through properties file then is there any way it
can be achieved without hardcoding it in Java file?

Please suggest.

Thanks

ATG Developer

unread,
Nov 24, 2008, 11:45:44 AM11/24/08
to ATG_Tech

David Herman

unread,
Nov 24, 2008, 12:14:52 PM11/24/08
to atg_...@googlegroups.com
Why not have your properties file like this
map=\
key=value1,value2,value3,\
key2=value4,value5,value6,\

you then have 2 maps

private Map<String,String> pubMap

getPubMap()
setPubMap(Map<String,String> pubMap)

private Map<String,List> privateMap

and in doStartService

you iterator over pubMap's keys

then call pubMap.get(key).split(",");

then you can iterator over that and build privateMap the way you want it. 

Since it's in dostart service it will only happen once (assuming it's global)

Dave

David Herman

unread,
Nov 24, 2008, 12:15:31 PM11/24/08
to atg_...@googlegroups.com
sorry that's going to be

pubMap=\
key=value1,value2,value3,\
key2=value4,value5,value6,\

ATG Developer

unread,
Nov 24, 2008, 12:31:42 PM11/24/08
to ATG_Tech
Thanks David.

I will try this.

On Nov 24, 10:15 pm, "David Herman" <dst...@purpleasphalt.com> wrote:
> sorry that's going to be
>
> pubMap=\
> key=value1,value2,value3,\
> key2=value4,value5,value6,\
>
> On Mon, Nov 24, 2008 at 12:14 PM, David Herman <dst...@purpleasphalt.com>wrote:
>
>
>
> > Why not have your properties file like this
> > map=\
> > key=value1,value2,value3,\
> > key2=value4,value5,value6,\
>
> > you then have 2 maps
>
> > private Map<String,String> pubMap
>
> > getPubMap()
> > setPubMap(Map<String,String> pubMap)
>
> > private Map<String,List> privateMap
>
> > and in doStartService
>
> > you iterator over pubMap's keys
>
> > then call pubMap.get(key).split(",");
>
> > then you can iterator over that and build privateMap the way you want it.
>
> > Since it's in dostart service it will only happen once (assuming it's
> > global)
>
> > Dave
>
> > On Mon, Nov 24, 2008 at 11:45 AM, ATG Developer <vibhorjai...@gmail.com>wrote:
>
> >> Hi all,
>
> >> Can anyone suggest me with the syntax how i can set a map with key as
> >> a string and its value as a List or a Map object.
>
> >> If it is not possible through properties file then is there any way it
> >> can be achieved without hardcoding it in Java file?
>
> >> Please suggest.
>
> >> Thanks- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages