[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [x3d-public] Checking node type



wonder why they are all SAINode. They should have separate nodes, all descending from SAINode. Then you could use instanceof or isAssignableFrom/isAssignableTo or similar
 
----------------
George Birbilis (birbilis@kagi.com)
Microsoft MVP J# for 2004-2006
* QuickTime, QTVR, ActiveX, VCL, .NET
http://www.kagi.com/birbilis
* Robotics PhD student
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup

 


From: owner-x3d-public@web3d.org [mailto:owner-x3d-public@web3d.org] On Behalf Of George Anastassakis
Sent: Thursday, March 02, 2006 4:23 PM
To: x3d-public@web3d.org
Subject: Re: [x3d-public] Checking node type

I don't think instanceof is any good, as all X3DNode implementations are SAINode objects. I guess my question should be, with what should the values returned by getNodeType be compared to?
 
George
----- Original Message -----
Sent: Thursday, March 02, 2006 10:23 AM
Subject: RE: [x3d-public] Checking node type

>What would be an efficient way to check the type of a node in an X3D scenegraph consisting of X3DNode objects? getNodeName returns a String which seems to  
> me a bit unsuitable towards this end as it requires string comparisons, also I'm not sure I understand what getNodeType returns.
 
see "instanceof"
have to do some testing though to see if
   s.equals(SOME_STRING_CONSTANT)
is faster
 
note: never use == for string comparisons in Java, unless you have access to X3D's java class [it's some interface usually] where the string constants are defined (supposing the same constants are reused everywhere). That is cause == compares for object equality, not for content equality in this case (one of the peculiarities of Java)
 
----------------
George Birbilis (birbilis@kagi.com)
Microsoft MVP J# for 2004-2006
* QuickTime, QTVR, ActiveX, VCL, .NET
http://www.kagi.com/birbilis
* Robotics PhD student
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup




avast! Antivirus: Outbound message clean.

Virus Database (VPS): 0609-1, 01/03/2006
Tested on: 2/3/2006 10:23:26 ðì
avast! - copyright (c) 1988-2005 ALWIL Software.





avast! Antivirus: Outbound message clean.

Virus Database (VPS): 0609-3, 03/03/2006
Tested on: 3/3/2006 3:27:38 ìì
avast! - copyright (c) 1988-2005 ALWIL Software.