• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Question for the Java Gurus
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Question for the Java Gurus


  • Subject: RE: Question for the Java Gurus
  • From: "Clark, Igor" <email@hidden>
  • Date: Thu, 22 Apr 2004 16:13:40 +0100

As far as I know, dynamic casting like this can't be done in Java due to the
language's strong typing, so you need to start messing around with
java.lang.reflect, in exactly the way Owen described in his "SOLVED" post.
Hope I'm not missing something?

Igor

-----Original Message-----
From: Jake MacMullin [mailto:email@hidden]
Sent: 22 April 2004 06:03
To: Owen McKerrow
Cc: Apple Webobjects List List
Subject: Re: Question for the Java Gurus


Is this what you're looking for?

public getOtherObjects(String entity, NSArray objects) {
	for(int i=0;i<objects.count();i++) {
		Object tempOb =
(Class.forName(entity))array.objectAtIndex(0);
	}
}

Regards,

Jake MacMullin


On 22 Apr 2004, at 1:48 PM, Owen McKerrow wrote:

> Hi All,
>
> How can I make the following code work if entity is an instance of
> String passed in as an argument to the function. i.e. Can I cast to a
> specific Class if all I have is the name of the Class as a String ? If
> not is there another way I can do this ?
>
> public getOtherObjects(String entity, NSArray objects) {
>
> 	for(int i=0;i<objects.count();i++) {
> 		Object tempOb = (entity)array.objectAtIndex(0);
> 	}
> }
>
>
> Thanks
> Owen McKerrow
>
> "As of tomorrow, employees will only be able to access the building
> using individual security cards. Pictures will be taken next Wednesday
> employees will receive their cards in two weeks."
> - "Dilbert Quotes" Winner, Fred Dales, Microsoft Corp
> _______________________________________________
> webobjects-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: SOLVED Question for the Java Gurus
  • Next by Date: Re: OpenSource replace EOModler
  • Previous by thread: RE: Question for the Java Gurus
  • Next by thread: Java Client Display Group Formatter
  • Index(es):
    • Date
    • Thread