Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

common java-function to create Maps from strings

Tags:

java

string

map

Is there any common function (in apache commons or similar) to make maps from query-parameter-like strings?

To specific:

Variant a (Querystring)

s="a=1&b=3"   
=> Utils.mapFunction(s, '&', '=') 
=>  (Hash)Map { a:1; b:3 }

Variant b (Cachecontrol-Header)

s="max-age=3600;must-revalidate"
=> Utils.mapFunction(s, ';', '=') 
=>  (Hash)Map { max-age:3600; must-revalidate:true }

I don't want to reinvent the wheel.

Thanks

like image 373
boecko Avatar asked Oct 25 '10 15:10

boecko


1 Answers

stringtomap

Try it out or browse the source code to see how it has been implemented.

like image 132
dogbane Avatar answered Sep 30 '22 08:09

dogbane