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

Re: [x3d-public] Checking node type



George Birbilis wrote:
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)
getNodeType will eventually be the fastest route for checking types. But its not implemented in Xj3D yet. I've been using getNodeName and .equals right now. instanceof checks will not work as they the objects are wrapped by a class that's the same for each type.
--
Alan Hudson


President Yumetech, Inc.                               www.yumetech.com
President Web3D Consortium                             www.web3d.org
206 340 8900
-------------------------------------------------------------------------
for list subscription/unsubscription,
go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html