tags:

views:

1667

answers:

2

For instance, how would you declare a triple map like-

Map<String, Map<String, Map<Boolean, String>>>, with the keys being someKey1, someKey2, and someKey3 (true/false)?

I know until this-

<util:map
     id="someMap"
    map-class="java.util.HashMap"
    key-type="java.lang.String"
    value-type="java.lang.String">
     <entry key="someKey1" value="someValue" />
</util:map>

EDIT:

Ok, this is what I want to do to reduce tons of if statements.

123: //some key 1

  abc: //some key 2

     true:  //some key 3

        a  //some value

     false: //some key 3

        b  //some value


 456: 

  def: 

     true:  

        c

     false: 

        d

Thanks a bunch.

+5  A: 

Perhaps this would work:

<util:map id="someMap">
    <entry key="123">
        <value>
            <map>
                <entry key="abc">
                    <value>
                        <map key-type="java.lang.Boolean">
                            <entry key="true" value="a"/>
                            <entry key="false" value="b"/>
                        </map>
                    </value>
                </entry>
            </map>
        </value>
    </entry>
    <entry key="456">
        <value>
            <map>
                <entry key="def">
                    <value>
                        <map key-type="java.lang.Boolean">
                            <entry key="true" value="c"/>
                            <entry key="false" value="d"/>
                        </map>
                    </value>
                </entry>
            </map>
        </value>
    </entry>
</util:map>
Adam Paynter
Map<String, Map<String, Map<Boolean, String> But isn't it from this structure, the value for the first key is also a map and same goes for the second one where in your code snippet, the value is a String for the first map?
Whoops, I forgot to remove that "value-type" attribute off the first map. Is this a little more like what you're looking for?
Adam Paynter
I added what I need. Really thanks for the response.
A: 

Did you really get Adam's code to compile? I had to remove the outer value-tags to make it work.

<util:map id="someMap">
    <entry key="123">        
        <map>
            <entry key="abc">
                <map key-type="java.lang.Boolean">
                    <entry key="true" value="a"/>
                    <entry key="false" value="b"/>
                </map>        
            </entry>
        </map>        
    </entry>
    <entry key="456">
        <map>
            <entry key="def">
                 <map key-type="java.lang.Boolean">
                     <entry key="true" value="c"/>
                     <entry key="false" value="d"/>
                 </map>
            </entry>
        </map>
    </entry>
</util:map>

Or am I missing something? =)

mikek