I guess he wants something like, "I have an object obj which is of type
ArrayList<String>. From this obj, I want to arrive at "String" which is the
type of the objects the array list holds.
Vamsi
On 10/1/07, Gareth Evans <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I use this code in a generic dao implementation
>
> public abstract class GenericDaoImpl<T> implements GenericDao<T> {
>
> private Class<T> parameterizedClass;
>
> @SuppressWarnings( "unchecked" )
> public GenericDaoImpl() {
> this.parameterizedClass = (Class<T>) ( (ParameterizedType)
> getClass().getGenericSuperclass() ).getActualTypeArguments()[0];
> }
>
> Not sure if this is the sort of thing your after?
>
> Gareth
>
> Vamsavardhana Reddy wrote:
> >
> >
> > On 10/1/07, *Jason Dillon* <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Alright... thanks, that is what I figured :-( So lame... I can
> > figure out that a class as T and E bound, but I can't figure out the
> > type of those buggers...
> >
> >
> > The underlying object does not impose any restrictions as such (and so
> > there is nothing special about these objects). It is only for the
> > compiler that will help you prevent using some undesired type
> > unknowingly (for e.g, adding String to a Integer list). I guess it is
> > evident from the example in my last post.
> >
> >
> > so stupid :-(
> >
> > --jason
> >
> >
> > On Sep 30, 2007, at 11:08 PM, David Jencks wrote:
> >
> > >
> > > On Sep 30, 2007, at 10:48 PM, Jason Dillon wrote:
> > >
> > >> Any of you generics experts out there know if there is any way to
> > >> get the generic type from a generic class... like, say you have:
> > >>
> > >> Class type = new ArrayList<String>().getClass();
> > >>
> > >> Is there any way to determine that this is an ArrayList
> containing
> > >> String objects? I can't seem to figure out how to get this
> > >> information out of the Class instance. I can figure out what the
> > >> type variable name was, er like T, but that is well, completely
> > >> useless IMO.
> > >>
> > >> Does anyone know if its possible and how to do it?
> > >
> > > I spent a couple days reading up on generics and trying stuff and
> > > concluded it was not possible. There are some statements in the
> > > book on generics that confirm this. Hopefully you will find a way
> > > to prove I'm wrong 'cause it sure would be handy :-)
> > >
> > > sorry
> > > david jencks
> > >
> > >>
> > >> --jason
> > >
> >
> >
>
>
> --
> Gareth Evans
>
> Senior Developer
>
> MSoft eSolutions Limited
> Technology Centre
> Inward Way
> Rossmore Business Park
> Ellesmere Port
> Cheshire
> CH65 3EN
>
> --
> Tel: +44 (0)870 0100 704
> Fax: +44 (0)870 9010 705
> E-Mail: [EMAIL PROTECTED]
> Web: www.msoft.co.uk
>
> ----------------------------------------------
> Terms:
> Please note that any prices quoted within this e-mail are subject to VAT.
> All program details and code described in this e-mail are subject to
> copyright (c) of MSoft eSolutions Limited and remain the intellectual
> property of MSoft eSolutions Limited.
> Any proposal or pricing information contained within this e-mail are
> subject to MSoft eSolutions' Terms and Conditions
> ----------------------------------------------
> Disclaimer:
> This message is intended only for use of the addressee. If this message
> was sent to you in error, please notify the sender and delete this
> message. MSoft eSolutions Limited cannot accept responsibility for
> viruses,
> so please scan attachments. Views expressed in this message do not
> necessarily reflect those of MSoft eSolutions Limited who will not
> necessarily be bound by its contents.
>
>
>