At 03:41 PM 12/30/01 +0200, you wrote:
>Hi all,
>
>Forgive what may be a stupid question:
>
>I am trying to retrieve all the locales from the Accept-Language header
>in a request. To do this I use the following call:
>
>Enumeration locales = pageContext.getRequest().getLocales();
>
>My problem is that once I have enumerated through this variable locales,
>there is no way I can see to "reset" it so I can enumerate through it
>again.
>
>I also cannot seems to find a way to clone this object, as Enumeration
>is not a child of java.lang.Object, but an interface.
>
>Can anyone shed some light on the "correct" way to enumerate through an
>Enumeration more than once?
>
>Regards,
>Graham

By the way, Graham, I have no idea whether you can or cannot clone the 
object you get, but the object you get is not an instance of Enumeration 
(even though it has the type of Enumeration) but is an instance of an 
anonymous inner-subclass of Enumeration.  So, your reason for not cloning 
it are not valid.  Maybe it is cloneable.  Have you tried?  Cannot see 
right off why it would not be cloneable.  Maybe you cannot because it 
cannot be casted.  However, did I not read something about there being a 
way around casting in j2sdk1.4.0-beta3?

Why don't you wrap the class and stick in your own inner class with a 
method giving an Enumeration that allows you to reset the cursor on the 
array so that you can reuse the Enumeration object?

Micael


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to