jyeary
Joined: 21 Oct 2008 Posts: 608 Location: Simpsonville, SC
|
Posted: Tue Jun 08, 2010 2:04 pm Post subject: Re: Map<String, ?> |
|
|
The implication is that you want to use generics. If you use Map() it is expecting Map(Object x, Object y) by default. In your case you are using Map<String ,y>(), you need to tell the compiler what y is. If you use one generic (String), you must tell the compiler what the second element is going to be, even if it is an Object. Try Map<String, Object>().
On Tue, Jun 8, 2010 at 6:29 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
|
| Back to top |
|
 |
pepelara
Joined: 29 Nov 2008 Posts: 115
|
Posted: Tue Jun 08, 2010 4:51 pm Post subject: Re: Map<String, ?> |
|
|
Thanks for your help John.
You say I try Map<String, Object>, but I can't. In this case Map<String, ?> is a parameter of the initialize() method of the JASS LoginModule.
I am trying to assign a value to this Map for a String key but I do not find the solution. The only explanation I guess is that this parameter is an input parameter and
it is not possible to change it. The reference of LoginModule says this argument is used to pass another LoginModule.
This is taking me a week to do login but I do not find the solution. I am trying a jdbcRealm against GF v3 and MySQL
Any suggestion?
Thanks again,
Jose
From: John Yeary ([email]address-removed[/email])
Sent: Tuesday, June 08, 2010 4:03 PM
To: nbj2ee ([email]address-removed[/email])
Subject: [nbj2ee] Re: Map<String, ?>
The implication is that you want to use generics. If you use Map() it is expecting Map(Object x, Object y) by default. In your case you are using Map<String ,y>(), you need to tell the compiler what y is. If you use one generic (String), you must tell the compiler what the second element is going to be, even if it is an Object. Try Map<String, Object>().
On Tue, Jun 8, 2010 at 6:29 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi,
What does Map<String, ?> mean?
I need to do,
Map<String, ?> options; // for an already instantiated Map
options.put("someString", someObject)
but the compiler does not let me.
Any suggestion about how does it work will be appreciated!!!
Regards,
Jose
|
--
John Yeary
--
http://javaevangelist.blogspot.com
"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the grey twilight that knows not victory nor defeat."
-- Theodore Roosevelt |
|
| Back to top |
|
 |
jyeary
Joined: 21 Oct 2008 Posts: 608 Location: Simpsonville, SC
|
Posted: Tue Jun 08, 2010 7:47 pm Post subject: Re: Map<String, ?> |
|
|
Take a look at this
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
You may be encountering something like Map<String, ?> map = new HashMap<String, String>(); This creates a map which does not allow you to add elements.
map.add("Hello", "World"); // Compile time error.
On Tue, Jun 8, 2010 at 12:51 PM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Thanks for your help John.
|
|
| Back to top |
|
 |
pepelara
Joined: 29 Nov 2008 Posts: 115
|
Posted: Thu Jun 10, 2010 12:25 am Post subject: Re: Map<String, ?> |
|
|
Thanks John for your kind help.
You are right.
This map is an input parameter of a method. You can set your private field to this parameter to read it later.
I think that is the reason it is defined this way.
Best Regards,
Jose
From: John Yeary ([email]address-removed[/email])
Sent: Tuesday, June 08, 2010 9:47 PM
To: nbj2ee ([email]address-removed[/email])
Subject: [nbj2ee] Re: Map<String, ?>
Take a look at this
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
You may be encountering something like Map<String, ?> map = new HashMap<String, String>(); This creates a map which does not allow you to add elements.
map.add("Hello", "World"); // Compile time error.
On Tue, Jun 8, 2010 at 12:51 PM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Thanks for your help John.
You say I try Map<String, Object>, but I can't. In this case Map<String, ?> is a parameter of the initialize() method of the JASS LoginModule.
I am trying to assign a value to this Map for a String key but I do not find the solution. The only explanation I guess is that this parameter is an input parameter and
it is not possible to change it. The reference of LoginModule says this argument is used to pass another LoginModule.
This is taking me a week to do login but I do not find the solution. I am trying a jdbcRealm against GF v3 and MySQL
Any suggestion?
Thanks again,
Jose
From: John Yeary ([email]address-removed[/email])
Sent: Tuesday, June 08, 2010 4:03 PM
To: nbj2ee ([email]address-removed[/email])
Subject: [nbj2ee] Re: Map<String, ?>
The implication is that you want to use generics. If you use Map() it is expecting Map(Object x, Object y) by default. In your case you are using Map<String ,y>(), you need to tell the compiler what y is. If you use one generic (String), you must tell the compiler what the second element is going to be, even if it is an Object. Try Map<String, Object>().
On Tue, Jun 8, 2010 at 6:29 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi,
What does Map<String, ?> mean?
I need to do,
Map<String, ?> options; // for an already instantiated Map
options.put("someString", someObject)
but the compiler does not let me.
Any suggestion about how does it work will be appreciated!!!
Regards,
Jose
|
--
John Yeary
--
http://javaevangelist.blogspot.com
"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the grey twilight that knows not victory nor defeat."
-- Theodore Roosevelt
|
--
John Yeary
--
http://javaevangelist.blogspot.com
"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the grey twilight that knows not victory nor defeat."
-- Theodore Roosevelt |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|