Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » dynamic instanceof
dynamic instanceof [message #325832] Thu, 28 February 2008 08:29 Go to next message
Eclipse UserFriend
Hello,

i want to use dynamically instanceof in java. I have a string with the
classname to compare. It is possible to get the instance of the class
over this string dynamically?

Greetings
Re: dynamic instanceof [message #325833 is a reply to message #325832] Thu, 28 February 2008 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Class.forName().newIntance() but this is a general java beginner
question whereas this forum is about Eclipse Technology

Jörg schrieb:
> Hello,
>
> i want to use dynamically instanceof in java. I have a string with the
> classname to compare. It is possible to get the instance of the class
> over this string dynamically?
>
> Greetings


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: dynamic instanceof [message #325835 is a reply to message #325833] Thu, 28 February 2008 09:07 Go to previous messageGo to next message
Eclipse UserFriend
ah sorry, i thought it wasn't that easy, cause i searched a little bit
longer. But Class.forName().newIntance() give me a syntax error with
instance of. i had to do this:

if ( Class.forName ( classNameString ).isInstance ( myObject ) )

Thanks for the trouble

Tom Schindl schrieb:
> Class.forName().newIntance() but this is a general java beginner
> question whereas this forum is about Eclipse Technology
>
> Jörg schrieb:
>> Hello,
>>
>> i want to use dynamically instanceof in java. I have a string with the
>> classname to compare. It is possible to get the instance of the class
>> over this string dynamically?
>>
>> Greetings
>
>
Re: dynamic instanceof [message #325836 is a reply to message #325835] Thu, 28 February 2008 09:16 Go to previous messageGo to next message
Eclipse UserFriend
ah I thought you wanted to create a new instance from a string. The
below is correct of course.

Tom

Jörg schrieb:
> ah sorry, i thought it wasn't that easy, cause i searched a little bit
> longer. But Class.forName().newIntance() give me a syntax error with
> instance of. i had to do this:
>
> if ( Class.forName ( classNameString ).isInstance ( myObject ) )
>
> Thanks for the trouble
>
> Tom Schindl schrieb:
>> Class.forName().newIntance() but this is a general java beginner
>> question whereas this forum is about Eclipse Technology
>>
>> Jörg schrieb:
>>> Hello,
>>>
>>> i want to use dynamically instanceof in java. I have a string with
>>> the classname to compare. It is possible to get the instance of the
>>> class over this string dynamically?
>>>
>>> Greetings
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: dynamic instanceof [message #325838 is a reply to message #325835] Thu, 28 February 2008 10:13 Go to previous message
Eclipse UserFriend
It would be good if you know which bundle provides this class and use
Bundle.loadClass() instead. If the class in question will always be
available in the same bundle it doesn't matter:)

Jörg wrote:
> ah sorry, i thought it wasn't that easy, cause i searched a little bit
> longer. But Class.forName().newIntance() give me a syntax error with
> instance of. i had to do this:
>
> if ( Class.forName ( classNameString ).isInstance ( myObject ) )
>
> Thanks for the trouble
>
> Tom Schindl schrieb:
>> Class.forName().newIntance() but this is a general java beginner
>> question whereas this forum is about Eclipse Technology
>>
>> Jörg schrieb:
>>> Hello,
>>>
>>> i want to use dynamically instanceof in java. I have a string with
>>> the classname to compare. It is possible to get the instance of the
>>> class over this string dynamically?
>>>
>>> Greetings
>>
>>
Previous Topic:compare: switch used comparer
Next Topic:Command in context menu???
Goto Forum:
  


Current Time: Fri May 02 05:22:36 EDT 2025

Powered by FUDForum. Page generated in 0.05581 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top