Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » dynamic instanceof
dynamic instanceof [message #325832] Thu, 28 February 2008 13:29 Go to next message
Oelerink is currently offline OelerinkFriend
Messages: 129
Registered: July 2009
Senior Member
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 13:36 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 14:07 Go to previous messageGo to next message
Oelerink is currently offline OelerinkFriend
Messages: 129
Registered: July 2009
Senior Member
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 14:16 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 15:13 Go to previous message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
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: Wed Jul 17 11:20:03 GMT 2024

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

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

Back to the top